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.99k |
|---|---|---|---|---|---|---|
[
{
"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": ""
} | Below is the Python function that implements the logic described in your prompt. It reads from standard input and prints the result for each test case.
```python
def can_become_abc():
import sys
input = sys.stdin.read
data = input().splitlines()
t = int(data[0]) # the number of test cases
res... |
[
{
"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 that meets the requirements from your prompt. This function reads input for multiple test cases, processes each test case to find the maximum product that can be achieved by adding 1 to one of the digits, and finally prints the results for each test case.
```python
def maximum_product_with_inc... |
[
{
"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 the Python function that implements the described problem solution. This function reads from standard input, processes each test case, and prints the required output for each case.
```python
def min_operations_to_remove_black_cells():
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.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": ""
} | To solve the problem of determining if we can remove exactly `k` characters from a string `s` to form a palindrome from the remaining characters, we can implement a Python function based on the following logic:
1. **Character Frequency Count**: Count the frequency of each character in the string.
2. **Character Parity... |
[
{
"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": ""
} | Here's an executable Python function that solves the problem described in your prompt:
```python
def min_operations_for_divisibility():
import sys
input = sys.stdin.read
data = input().splitlines()
t = int(data[0])
results = []
index = 1
for _ in range(t):
n, k = map(int, ... |
[
{
"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’s a Python function that implements the game between Vanya and Vova, based on the rules provided in your prompt. The function reads multiple test cases, evaluates them, and prints the results accordingly.
```python
def determine_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": ""
} | Here's a Python function that implements the solution for the problem statement given. The function reads its input from standard input, computes the required maximum absolute difference between the total weights of any two trucks for each test case, and prints the results.
```python
def maximum_difference_between_tru... |
[
{
"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's a Python function that solves the problem as described in your prompt. This function reads the input from the standard input, processes each test case, and prints the maximum sum of a subarray with alternating parity.
```python
def max_alternating_subarray_sum():
import sys
input = sys.stdin.read
da... |
[
{
"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": ""
} | The problem involves calculating the number of pairs `(i, j)` such that `b_i^b_j = b_j^b_i`, where `b_i` and `b_j` are derived from powers of two based on values in the input array `a`.
The condition `b_i^b_j = b_j^b_i` holds true when:
1. The bases (which are powers of 2) are the same, or
2. The exponents of the bas... |
[
{
"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_str = detail[10:12] # Extracting the age part
age = int(age_str) # Converting age to integer
if age > 60: # Checking if age is greater than 60
count += 1 # In... |
[
{
"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 matrixScore(nums):
score = 0
while nums:
max_numbers = [max(row) for row in nums]
max_value = max(max_numbers)
score += max_value
# Remove the max numbers from each row
for i in range(len(nums)):
nums[i].remove(max_numbers[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 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
# To compute the OR value of the array
for i in range(n):
max_or_value |= nums[i]
# Test each number and apply the operation
for i in range(n):
current_product = nums[i]
for j in range(k):
curr... |
[
{
"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 maxStrength(nums):
positive_nums = [x for x in nums if x > 0]
negative_nums = [x for x in nums if x < 0]
if len(negative_nums) % 2 == 1:
negative_nums.sort()
negative_nums.pop(0) # Remove the largest negative to maximize product
if not positive_nums and not negat... |
[
{
"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):
n = len(s)
dp = [0] * (n + 1)
dictionary_set = set(dictionary)
for i in range(n + 1):
dp[i] = i # maximum extra characters if we take no substrings
for j in range(i):
if s[j:i] in dictionary_set:
dp[i] = min(dp[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):
min_sum = float('inf')
# Iterate through each pair of chocolates
for i in range(len(prices)):
for j in range(i + 1, len(prices)):
current_sum = prices[i] + prices[j]
# Check if the sum of the two prices is less than or equal 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 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
def digit_sum(n: int) -> int:
return sum(int(d) for d in str(n))
def count_within_bounds(start: int, end: int) -> int:
count = 0
for x in range(start, end + 1):
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 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 distinctDifferenceArray(nums):
n = len(nums)
diff = [0] * n
for i in range(n):
prefix_distinct = len(set(nums[:i + 1]))
suffix_distinct = len(set(nums[i + 1:]))
diff[i] = prefix_distinct - suffix_distinct
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 = []
def count_adjacent_same_color():
count = 0
for j in range(n - 1):
if nums[j] == nums[j + 1] and nums[j] != 0:
count += 1
return count
for index_i, color_i 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
# Create a list of tuples (strength, count of how many times it can be the max)
strengths = sorted([(num, i + 1) for i, num in enumerate(nums)])
for j in range(n):
max_strength = strengths[j][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 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 the first element (1) and the last element (n)
index_of_one = nums.index(1)
index_of_n = nums.index(n)
# Count operations needed to bring 1 to the front and n to the back
operations = 0
# Bri... |
[
{
"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:
n = len(s)
max_length = 0
left = 0
count_pairs = 0
for right in range(n):
# When we find a pair of the same digits
if right > 0 and s[right] == s[right - 1]:
count_pairs += 1
# If we hav... |
[
{
"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):
position = 0 # Start at the 1st friend (0-index)
seen = set() # To keep track of who has received the ball
losers = list(range(1, n + 1)) # All friends are potential losers
for i in range(1, n + 1):
position = (position + i * k) % n # Calculate the new posit... |
[
{
"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 valid if derived is [0]
# Use derived[0] and derived[1] to determine the original array's first two elements
original = [0, 0]
original[0] = derived[0] ^ derived[1]
# Now we can buil... |
[
{
"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 the last two characters in the stack for "AB" or "CD"
if len(stack) >= 2:
if stack[-1] == 'B' and stack[-2] == 'A':
stack.pop() # Remove 'B'
... |
[
{
"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(number, target):
str_number = str(number)
length = len(str_number)
# Helper function for backtracking.
def backtrack(start, current_sum):
if current_sum == target:
return True
if cu... |
[
{
"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 minCostToPaintWalls(cost, time):
n = len(cost)
dp = [float('inf')] * (n + 1)
dp[0] = 0
for i in range(n):
current_time = 0
for j in range(i, n):
current_time += time[j]
if j == i: # If we're painting the first wall
dp[j + 1] = min(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 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_chocolates(nums, x):
n = len(nums)
total_cost = sum(nums)
min_cost = total_cost
for i in range(n):
cost = total_cost
rotations = i
operation_cost = rotations * x
# Collect chocolates after `rotations` operations
for j in range(... |
[
{
"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 = []
used = set()
current = 1
while len(result) < n:
if current not in used and (k - current) not in used:
result.append(current)
used.add(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:
s_list = list(s)
left, right = 0, len(s) - 1
while left < right:
if s_list[left] != s_list[right]:
# Replace the larger character with the smaller one
s_list[left] = s_list[right] = min(s_list[left], s_list[right])
... |
[
{
"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_chars(s: str) -> int:
n = len(s)
# Cost to make all characters 0 or all characters 1
cost_to_all_0 = 0
cost_to_all_1 = 0
# Count the number of changes needed to make the string all '0's
for i in range(n):
if s[i] == '1':
# If we encounter ... |
[
{
"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 number as a string
concatenated = str(n) + str(2 * n) + str(3 * n)
# Check if the concatenated number is of length 9 and contains all digits from 1 to 9 exactly once
return len(concatenated) == 9 and set(concatenated) == set("123456789")
... |
[
{
"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 minimize_string_length(s: str) -> int:
last_seen = {}
to_delete = set()
for i, char in enumerate(s):
if char in last_seen:
to_delete.add(last_seen[char])
to_delete.add(i)
last_seen[char] = i
minimized_length = len(s) - len(to_delete)
... |
[
{
"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 can_traverse_all_pairs(nums):
n = len(nums)
if n < 2:
return True
# Create a graph where edges exist if gcd > 1
graph = defaultdict(list)
# Build the graph
for i in range(n):
for j in range(i + 1, 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 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)
# Start with the case where we might consider converting to 'z'
min_string = ''.join(chr((ord(c) - 97 - 1) % 26 + 97) for c in s)
# Try finding the best possible substring to convert
for i in range(n):
# Check th... |
[
{
"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
max_length = 0
count = {}
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_servers_without_requests(n, logs, x, queries):
from collections import defaultdict
# Create a dictionary to store the set of active requests for each server
server_requests = defaultdict(set)
# Populate server_requests with request times for each server
for server_id, time in 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 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):
# Use a set to keep track of occupied positions
occupied_positions = set(nums)
# Perform each move operation
for from_pos, to_pos in zip(moveFrom, moveTo):
if from_pos in occupied_positions:
occupied_positions.discard(from_pos)
... |
[
{
"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(num1: int, num2: int) -> int:
# Calculate the effective decrement value for each i in the range [0, 60]
max_operation_value = [(1 << i) + num2 for i in range(61)]
# Create a list that will store how many operations we can perform with each effective value
from collectio... |
[
{
"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_values(nums1, nums2, queries):
n = len(nums1)
# Create a combined list of tuples
combined = [(nums1[i] + nums2[i], nums1[i], nums2[i]) for i in range(n)]
# Sort based on the sum values in descending order
combined.sort(reverse=True, key=lambda x: x[0])
results = []
... |
[
{
"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_special_squares(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 findMinPartitionValue(nums):
nums.sort()
min_partition_value = float('inf')
for i in range(len(nums) - 1):
max_nums1 = nums[i]
min_nums2 = nums[i + 1]
partition_value = abs(max_nums1 - min_nums2)
min_partition_value = min(min_partition_value, partition_valu... |
[
{
"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):
seen = set()
pair_count = 0
for word in words:
reversed_word = word[::-1] # Reverse the current word
if reversed_word in seen: # Check if the reversed word has been seen
pair_count += 1 # Found a pair
seen.remove(rever... |
[
{
"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 factorial
MOD = 10**9 + 7
n = len(nums)
# Precompute adjacency list based on the special condition
adj = [[] for _ in range(n)]
for i in range(n):
for j in range(n):
if i != j and (nums[i] % nums[j] == 0 o... |
[
{
"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_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 range(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 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:
# Start by calculating the initial maximum possible length without any restrictions
total_length = (x * 2) + (y * 2) + (z * 2)
# Calculate pairs of "AA" and "BB"
pairs = min(x, y)
total_length -= pairs # Each pair of "AA" and "BB" can ca... |
[
{
"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 minimizeStringLength(words):
n = len(words)
dp = [[float('inf')] * 2 for _ in range(n)]
# Initialize the first word
dp[0][0] = len(words[0]) # str_0
dp[0][1] = len(words[0]) # str_0
for i in range(1, n):
word = words[i]
# Joining str_(i-1) + wor... |
[
{
"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):
distinct_count = len(set(nums)) # Get the number of distinct elements in the entire array
n = len(nums)
complete_subarray_count = 0
# Check all possible subarrays
for start in range(n):
seen = set()
for end in range(start, n):
... |
[
{
"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: int, additionalTank: int) -> int:
distance = 0
mileage = 10
transfer_rate = 5
# Calculate the number of times fuel can be consumed in the main tank
while mainTank > 0:
# If there's enough fuel for another 5 liters consumption
if mainTank >= tr... |
[
{
"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):
n = len(nums)
max_length = 0
for l in range(n):
if nums[l] % 2 == 0 and nums[l] <= threshold: # Check the starting condition
current_length = 1
last_mod = nums[l] % 2
for r in range(l + 1, 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 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
count = 0
last_one_index = -1
zeros_between = []
for i in range(len(nums)):
if nums[i] == 1:
if last_one_index != -1:
zeros_between.append(i - last_one_index - 1)
last_one_index = 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)
count = 0
left = 0
for right in range(n):
while nums[right] - nums[left] > 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 longest_non_decreasing_subarray(nums1, nums2):
n = len(nums1)
if n == 0:
return 0
# Start the maximum length at least 1 (as a single element is a non-decreasing subarray)
max_length = 1
current_length = 1
# Choose the first element for nums3
last_value = min(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. 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: # Check if the sequence is increasing
current_length = 2 # Start counting the length of the alternating subarray
for 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 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 max_possible_value(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 = []
prime_se... |
[
{
"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, b, c):
def merge_strings(s1, s2):
max_overlap = 0
for i in range(1, min(len(s1), len(s2)) + 1):
if s1[-i:] == s2[:i]:
max_overlap = i
return s1 + s2[max_overlap:]
candidates = []
for x in [a, b, c]:
for y in [a, b, ... |
[
{
"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_zeroes(nums, k):
max_num = max(nums)
n = len(nums)
total_ops = 0
for i in range(n):
if nums[i] < total_ops:
return False
total_ops += (nums[i] - total_ops) // k
return True
``` |
[
{
"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:
n = len(s)
# Function to calculate the number of changes required to make a substring semi-palindrome
def changes_to_semi_palindrome(sub: str) -> int:
length = len(sub)
change_count = 0
for d in... |
[
{
"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)
# Filter out empty strings and extend the result list
result.extend([s for s in split_words if s])
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": ""
} | Here is the executable Python function based on the provided requirements:
```python
def count_ways(n, x):
MOD = 10**9 + 7
# Precompute the powers of integers up to n
power = [i**x for i in range(1, n + 1) if i**x <= n]
# DP array where dp[i] means the number of ways to express i
dp = [0] * (n + ... |
[
{
"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:
beautiful_powers_of_five = set()
power = 1
# Create a set of binary representations of powers of 5
while True:
binary_representation = bin(power)[2:] # Get binary representation without '0b' prefix
if len(binary_representation)... |
[
{
"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)
n = len(word)
max_length = 0
left = 0
for right in range(n):
while any(word[left:right + 1].find(f) != -1 for f in forbidden_set):
left += 1
max_length = max(max_length, right - le... |
[
{
"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 type_with_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 vowels and their indices
for i, char in enumerate(s):
if char in vowels:
vowel_indices.append(i)
vowel_chars.append(char)
# Sort the vowels
vowel_ch... |
[
{
"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_minimum_split(nums):
from collections import Counter
n = len(nums)
freq = Counter(nums)
dominant_element = max(freq.items(), key=lambda x: x[1])[0]
dominant_freq = freq[dominant_element]
# Check the whole array for the dominant frequency condition
if dominant_freq * 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 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 max_beauty(nums, k):
from collections import Counter
# Create a counter for the occurrences of each element in nums
num_count = Counter(nums)
# Find the maximum value in nums for the range after modification
max_value = max(nums)
# Create a variable to hold the maximum possi... |
[
{
"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)
length_of_base_n = n + 1
if len(nums) != length_of_base_n:
return False
count = [0] * (n + 1)
for num in nums:
if num > n or num <= 0:
return False
count[num] += 1
if count[n] != 2:
return Fals... |
[
{
"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]
for j in range(i):
score = dp[j] + nums[i]
if (nums[j] % 2) != (nums[i] % 2):
score -= x
dp[i] = max(dp[i], 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. 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_equal_digit_sum(nums):
from collections import defaultdict
max_digit_map = defaultdict(list)
# Helper function to find the maximum digit in a number
def max_digit(n):
return max(int(d) for d in str(n))
# Populate the dictionary with max digits and correspondi... |
[
{
"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):
count = 0
num_of_interesting_subarrays = 0
prefix_count = {0: 1}
for num in nums:
if num % modulo == k:
count += 1
mod_count = count % modulo
if mod_count in prefix_count:
n... |
End of preview. Expand in Data Studio
Dataset card for REASONING_evalchemy_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": "Below is the Python function that implements the logic described in your prompt. It reads from standard input and prints the result for each test case.\n\n```python\ndef can_become_abc():\n import sys\n input = sys.stdin.read\n data = input().splitlines()\n \n t = int(data[0]) # the number of test cases\n results = []\n \n for i in range(1, t + 1):\n cards = data[i]\n \n if cards == 'abc':\n results.append(\"YES\")\n elif cards in ['acb', 'bac', 'cba']:\n results.append(\"YES\")\n else:\n results.append(\"NO\")\n \n print(\"\\n\".join(results))\n\ncan_become_abc()\n```\n\n### Explanation:\n1. The function `can_become_abc` starts by reading all input at once to avoid multiple calls to input.\n2. The first line of input is the number of test cases `t`.\n3. For each test case, it checks the current arrangement of cards:\n - If it's already `abc`, we append \"YES\".\n - It checks for all arrangements that can become `abc` with a single swap (`acb`, `bac`, `cba`) and appends \"YES\" for those as well.\n - If the arrangement doesn't match any of these cases, \"NO\" is appended to collect results.\n4. Finally, all results are printed at once, separated by new lines.\n\n### Usage:\nTo use the function, provide the input in the specified format (using stdin). The function will output whether each arrangement can become `abc` with at most one swap."
}
Loading the dataset
You can load this dataset using the following code:
from datasets import load_dataset
dataset = load_dataset("mlfoundations-dev/REASONING_evalchemy_gpt-4o-mini", split="default")
Evaluation Results
Summary
| Metric | AIME24 | AIME25 | AMC23 | GPQADiamond | MATH500 |
|---|---|---|---|---|---|
| Accuracy | 10.7 | 10.7 | 54.5 | 31.0 | 73.6 |
AIME24
- Average Accuracy: 10.67% ± 1.12%
- Number of Runs: 5
| Run | Accuracy | Questions Solved | Total Questions |
|---|---|---|---|
| 1 | 13.33% | 4 | 30 |
| 2 | 10.00% | 3 | 30 |
| 3 | 10.00% | 3 | 30 |
| 4 | 13.33% | 4 | 30 |
| 5 | 6.67% | 2 | 30 |
AIME25
- Average Accuracy: 10.67% ± 0.60%
- Number of Runs: 5
| Run | Accuracy | Questions Solved | Total Questions |
|---|---|---|---|
| 1 | 10.00% | 3 | 30 |
| 2 | 10.00% | 3 | 30 |
| 3 | 13.33% | 4 | 30 |
| 4 | 10.00% | 3 | 30 |
| 5 | 10.00% | 3 | 30 |
AMC23
- Average Accuracy: 54.50% ± 2.39%
- Number of Runs: 5
| Run | Accuracy | Questions Solved | Total Questions |
|---|---|---|---|
| 1 | 57.50% | 23 | 40 |
| 2 | 60.00% | 24 | 40 |
| 3 | 57.50% | 23 | 40 |
| 4 | 45.00% | 18 | 40 |
| 5 | 52.50% | 21 | 40 |
GPQADiamond
- Average Accuracy: 30.98% ± 4.07%
- Number of Runs: 3
| Run | Accuracy | Questions Solved | Total Questions |
|---|---|---|---|
| 1 | 26.77% | 53 | 198 |
| 2 | 25.25% | 50 | 198 |
| 3 | 40.91% | 81 | 198 |
MATH500
- Accuracy: 73.60%
Accuracy Questions Solved Total Questions 73.60% 368 500
- Downloads last month
- 17