id stringlengths 44 73 | content stringlengths 361 6.18k |
|---|---|
multipl-e_humaneval-cpp_data_HumanEval_103_rounded_avg | #include<assert.h>
#include<bits/stdc++.h>
union Union_std_string_long{
std::string f0;
long f1; Union_std_string_long(std::string _f0) : f0(_f0) {}
Union_std_string_long(long _f1) : f1(_f1) {}
~Union_std_string_long() {}
bool operator==(std::string f) {
return f0 == f ;
} bool ope... |
multipl-e_humaneval-cpp_data_HumanEval_104_unique_digits | #include<assert.h>
#include<bits/stdc++.h>
// Given a vector of positive integers x. return a sorted vector of all
// elements that hasn't any even digit.
// Note: Returned vector should be sorted in increasing order.
// For example:
// >>> unique_digits((std::vector<long>({(long)15, (long)33, (long)1422, (long)1})))
... |
multipl-e_humaneval-cpp_data_HumanEval_105_by_length | #include<assert.h>
#include<bits/stdc++.h>
// Given a vector of integers, sort the integers that are between 1 and 9 inclusive,
// reverse the resulting vector, and then replace each digit by its corresponding name from
// "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine".
// For example:
// >>> by... |
multipl-e_humaneval-cpp_data_HumanEval_106_f | #include<assert.h>
#include<bits/stdc++.h>
// Implement the function f that takes n as a parameter,
// and returns a vector of size n, such that the value of the element at index i is the factorial of i if i is even
// or the sum of numbers from 1 to i otherwise.
// i starts from 1.
// the factorial of i is the multipl... |
multipl-e_humaneval-cpp_data_HumanEval_107_even_odd_palindrome | #include<assert.h>
#include<bits/stdc++.h>
// Given a positive integer n, return a tuple that has the number of even and odd
// integer palindromes that fall within the range(1, n), inclusive.
// Example 1:
// >>> even_odd_palindrome((3))
// (std::make_tuple(1, 2))
// Explanation:
// Integer palindrome are 1, 2, 3. one... |
multipl-e_humaneval-cpp_data_HumanEval_108_count_nums | #include<assert.h>
#include<bits/stdc++.h>
// Write a function count_nums which takes a vector of integers and returns
// the number of elements which has a sum of digits > 0.
// If a number is negative, then its first signed digit will be negative:
// e.g. -123 has signed digits -1, 2, and 3.
// >>> count_nums((std::v... |
multipl-e_humaneval-cpp_data_HumanEval_109_move_one_ball | #include<assert.h>
#include<bits/stdc++.h>
// We have a vector 'arr' of N integers arr[1], arr[2], ..., arr[N].The
// numbers in the vector will be randomly ordered. Your task is to determine if
// it is possible to get a vector sorted in non-decreasing order by performing
// the following operation on the given vecto... |
multipl-e_humaneval-cpp_data_HumanEval_110_exchange | #include<assert.h>
#include<bits/stdc++.h>
// In this problem, you will implement a function that takes two vectors of numbers,
// and determines whether it is possible to perform an exchange of elements
// between them to make lst1 a vector of only even numbers.
// There is no limit on the number of exchanged elements... |
multipl-e_humaneval-cpp_data_HumanEval_111_histogram | #include<assert.h>
#include<bits/stdc++.h>
// Given a string representing a space separated lowercase letters, return a map
// of the letter with the most repetition and containing the corresponding count.
// If several letters have the same occurrence, return all of them.
// Example:
// >>> histogram(("a b c"))
// (st... |
multipl-e_humaneval-cpp_data_HumanEval_112_reverse_delete | #include<assert.h>
#include<bits/stdc++.h>
// Task
// We are given two strings s and c, you have to deleted all the characters in s that are equal to any character in c
// then check if the result string is palindrome.
// A string is called palindrome if it reads the same backward as forward.
// You should return a tup... |
multipl-e_humaneval-cpp_data_HumanEval_113_odd_count | #include<assert.h>
#include<bits/stdc++.h>
// Given a vector of strings, where each string consists of only digits, return a vector.
// Each element i of the output should be "the number of odd elements in the
// string i of the input." where all the i's should be replaced by the number
// of odd digits in the i'th str... |
multipl-e_humaneval-cpp_data_HumanEval_114_minSubArraySum | #include<assert.h>
#include<bits/stdc++.h>
// Given a vector of integers nums, find the minimum sum of any non-empty sub-vector
// of nums.
// Example
// >>> minSubArraySum((std::vector<long>({(long)2, (long)3, (long)4, (long)1, (long)2, (long)4})))
// (1)
// >>> minSubArraySum((std::vector<long>({(long)-1, (long)-2, (... |
multipl-e_humaneval-cpp_data_HumanEval_115_max_fill | #include<assert.h>
#include<bits/stdc++.h>
// You are given a rectangular grid of wells. Each row represents a single well,
// and each 1 in a row represents a single unit of water.
// Each well has a corresponding bucket that can be used to extract water from it,
// and all buckets have the same capacity.
// Your tas... |
multipl-e_humaneval-cpp_data_HumanEval_116_sort_array | #include<assert.h>
#include<bits/stdc++.h>
// In this Kata, you have to sort a vector of non-negative integers according to
// number of ones in their binary representation in ascending order.
// For similar number of ones, sort based on decimal value.
// It must be implemented like this:
// >>> sort_array((std::vector... |
multipl-e_humaneval-cpp_data_HumanEval_117_select_words | #include<assert.h>
#include<bits/stdc++.h>
// Given a string s and a natural number n, you have been tasked to implement
// a function that returns a vector of all words from string s that contain exactly
// n consonants, in order these words appear in the string s.
// If the string s is empty then the function shoul... |
multipl-e_humaneval-cpp_data_HumanEval_118_get_closest_vowel | #include<assert.h>
#include<bits/stdc++.h>
// You are given a word. Your task is to find the closest vowel that stands between
// two consonants from the right side of the word (case sensitive).
// Vowels in the beginning and ending doesn't count. Return empty string if you didn't
// find any vowel met the above condi... |
multipl-e_humaneval-cpp_data_HumanEval_119_match_parens | #include<assert.h>
#include<bits/stdc++.h>
// You are given a vector of two strings, both strings consist of open
// parentheses '(' or close parentheses ')' only.
// Your job is to check if it is possible to concatenate the two strings in
// some order, that the resulting string will be good.
// A string S is consider... |
multipl-e_humaneval-cpp_data_HumanEval_120_maximum | #include<assert.h>
#include<bits/stdc++.h>
// Given a vector arr of integers and a positive integer k, return a sorted vector
// of length k with the maximum k numbers in arr.
// Example 1:
// >>> maximum((std::vector<long>({(long)-3, (long)-4, (long)5})), (3))
// (std::vector<long>({(long)-4, (long)-3, (long)5}))
// ... |
multipl-e_humaneval-cpp_data_HumanEval_121_solution | #include<assert.h>
#include<bits/stdc++.h>
// Given a non-empty vector of integers, return the sum of all of the odd elements that are in even positions.
// Examples
// >>> solution((std::vector<long>({(long)5, (long)8, (long)7, (long)1})))
// (12)
// >>> solution((std::vector<long>({(long)3, (long)3, (long)3, (long)3,... |
multipl-e_humaneval-cpp_data_HumanEval_122_add_elements | #include<assert.h>
#include<bits/stdc++.h>
// Given a non-empty vector of integers arr and an integer k, return
// the sum of the elements with at most two digits from the first k elements of arr.
// Example:
// >>> add_elements((std::vector<long>({(long)111, (long)21, (long)3, (long)4000, (long)5, (long)6, (long)7, (l... |
multipl-e_humaneval-cpp_data_HumanEval_123_get_odd_collatz | #include<assert.h>
#include<bits/stdc++.h>
// Given a positive integer n, return a sorted vector that has the odd numbers in collatz sequence.
// The Collatz conjecture is a conjecture in mathematics that concerns a sequence defined
// as follows: start with any positive integer n. Then each term is obtained from the
... |
multipl-e_humaneval-cpp_data_HumanEval_124_valid_date | #include<assert.h>
#include<bits/stdc++.h>
// You have to write a function which validates a given date string and
// returns true if the date is valid otherwise false.
// The date is valid if all of the following rules are satisfied:
// 1. The date string is not empty.
// 2. The number of days is not less than 1 or hi... |
multipl-e_humaneval-cpp_data_HumanEval_125_split_words | #include<assert.h>
#include<bits/stdc++.h>
union Union_std_vector_std_string__long{
std::vector<std::string> f0;
long f1; Union_std_vector_std_string__long(std::vector<std::string> _f0) : f0(_f0) {}
Union_std_vector_std_string__long(long _f1) : f1(_f1) {}
~Union_std_vector_std_string__long() {}
b... |
multipl-e_humaneval-cpp_data_HumanEval_126_is_sorted | #include<assert.h>
#include<bits/stdc++.h>
// Given a vector of numbers, return whether or not they are sorted
// in ascending order. If vector has more than 1 duplicate of the same
// number, return false. Assume no negative numbers and only integers.
// Examples
// >>> is_sorted((std::vector<long>({(long)5})))
// (tr... |
multipl-e_humaneval-cpp_data_HumanEval_127_intersection | #include<assert.h>
#include<bits/stdc++.h>
// You are given two intervals,
// where each interval is a pair of integers. For example, interval = (start, end) = (1, 2).
// The given intervals are closed which means that the interval (start, end)
// includes both start and end.
// For each given interval, it is assumed t... |
multipl-e_humaneval-cpp_data_HumanEval_128_prod_signs | #include<assert.h>
#include<bits/stdc++.h>
// You are given a vector arr of integers and you need to return
// sum of magnitudes of integers multiplied by product of all signs
// of each number in the vector, represented by 1, -1 or 0.
// Note: return None for empty arr.
// Example:
// >>> prod_signs((std::vector<long>... |
multipl-e_humaneval-cpp_data_HumanEval_129_minPath | #include<assert.h>
#include<bits/stdc++.h>
// Given a grid with N rows and N columns (N >= 2) and a positive integer k,
// each cell of the grid contains a value. Every integer in the range [1, N * N]
// inclusive appears exactly once on the cells of the grid.
// You have to find the minimum path of length k in the gr... |
multipl-e_humaneval-cpp_data_HumanEval_130_tri | #include<assert.h>
#include<bits/stdc++.h>
// Everyone knows Fibonacci sequence, it was studied deeply by mathematicians in
// the last couple centuries. However, what people don't know is Tribonacci sequence.
// Tribonacci sequence is defined by the recurrence:
// tri(1) = 3
// tri(n) = 1 + n / 2, if n is even.
// tr... |
multipl-e_humaneval-cpp_data_HumanEval_131_digits | #include<assert.h>
#include<bits/stdc++.h>
// Given a positive integer n, return the product of the odd digits.
// Return 0 if all digits are even.
// For example:
// >>> digits((1))
// (1)
// >>> digits((4))
// (0)
// >>> digits((235))
// (15)
long digits(long n) {
}
int main() {
auto candidate = digits;
ass... |
multipl-e_humaneval-cpp_data_HumanEval_132_is_nested | #include<assert.h>
#include<bits/stdc++.h>
// Create a function that takes a string as input which contains only square brackets.
// The function should return true if and only if there is a valid subsequence of brackets
// where at least one bracket in the subsequence is nested.
// >>> is_nested(("[[]]"))
// (true)
/... |
multipl-e_humaneval-cpp_data_HumanEval_133_sum_squares | #include<assert.h>
#include<bits/stdc++.h>
// You are given a vector of numbers.
// You need to return the sum of squared numbers in the given vector,
// round each element in the vector to the upper int(Ceiling) first.
// Examples:
// >>> lst((std::vector<float>({(float)1.0f, (float)2.0f, (float)3.0f})))
// (14)
// >>... |
multipl-e_humaneval-cpp_data_HumanEval_134_check_if_last_char_is_a_letter | #include<assert.h>
#include<bits/stdc++.h>
// Create a function that returns true if the last character
// of a given string is an alphabetical character and is not
// a part of a word, and false otherwise.
// Note: "word" is a group of characters separated by space.
// Examples:
// >>> check_if_last_char_is_a_letter((... |
multipl-e_humaneval-cpp_data_HumanEval_135_can_arrange | #include<assert.h>
#include<bits/stdc++.h>
// Create a function which returns the largest index of an element which
// is not greater than or equal to the element immediately preceding it. If
// no such element exists then return -1. The given vector will not contain
// duplicate values.
// Examples:
// >>> can_arrange... |
multipl-e_humaneval-cpp_data_HumanEval_136_largest_smallest_integers | #include<assert.h>
#include<bits/stdc++.h>
// Create a function that returns a tuple (a, b), where 'a' is
// the largest of negative integers, and 'b' is the smallest
// of positive integers in a vector.
// If there is no negative or positive integers, return them as None.
// Examples:
// >>> largest_smallest_integers(... |
multipl-e_humaneval-cpp_data_HumanEval_137_compare_one | #include<assert.h>
#include<bits/stdc++.h>
union Union_long_float_std_string{
long f0;
float f1;
std::string f2; Union_long_float_std_string(long _f0) : f0(_f0) {}
Union_long_float_std_string(float _f1) : f1(_f1) {}
Union_long_float_std_string(std::string _f2) : f2(_f2) {}
~Union_long_float_s... |
multipl-e_humaneval-cpp_data_HumanEval_138_is_equal_to_sum_even | #include<assert.h>
#include<bits/stdc++.h>
// Evaluate whether the given number n can be written as the sum of exactly 4 positive even numbers
// Example
// >>> is_equal_to_sum_even((4))
// (false)
// >>> is_equal_to_sum_even((6))
// (false)
// >>> is_equal_to_sum_even((8))
// (true)
bool is_equal_to_sum_even(long n) {... |
multipl-e_humaneval-cpp_data_HumanEval_139_special_factorial | #include<assert.h>
#include<bits/stdc++.h>
// The Brazilian factorial is defined as:
// brazilian_factorial(n) = n! * (n-1)! * (n-2)! * ... * 1!
// where n > 0
// For example:
// >>> special_factorial((4))
// (288)
// The function will receive an integer as input and should return the special
// factorial of this integ... |
multipl-e_humaneval-cpp_data_HumanEval_140_fix_spaces | #include<assert.h>
#include<bits/stdc++.h>
// Given a string text, replace all spaces in it with underscores,
// and if a string has more than 2 consecutive spaces,
// then replace all consecutive spaces with -
// >>> fix_spaces((" Example"))
// ("Example")
// >>> fix_spaces((" Example 1"))
// ("Example_1")
// >>> f... |
multipl-e_humaneval-cpp_data_HumanEval_141_file_name_check | #include<assert.h>
#include<bits/stdc++.h>
// Create a function which takes a string representing a file's name, and returns
// 'Yes' if the the file's name is valid, and returns 'No' otherwise.
// A file's name is considered to be valid if and only if all the following conditions
// are met:
// - There should not be ... |
multipl-e_humaneval-cpp_data_HumanEval_142_sum_squares | #include<assert.h>
#include<bits/stdc++.h>
// "
// This function will take a vector of integers. For all entries in the vector, the function shall square the integer entry if its index is a
// multiple of 3 and will cube the integer entry if its index is a multiple of 4 and not a multiple of 3. The function will not
... |
multipl-e_humaneval-cpp_data_HumanEval_143_words_in_sentence | #include<assert.h>
#include<bits/stdc++.h>
// You are given a string representing a sentence,
// the sentence contains some words separated by a space,
// and you have to return a string that contains the words from the original sentence,
// whose lengths are prime numbers,
// the order of the words in the new string s... |
multipl-e_humaneval-cpp_data_HumanEval_144_simplify | #include<assert.h>
#include<bits/stdc++.h>
// Your task is to implement a function that will simplify the expression
// x * n. The function returns true if x * n evaluates to a whole number and false
// otherwise. Both x and n, are string representation of a fraction, and have the following format,
// <numerator>/<deno... |
multipl-e_humaneval-cpp_data_HumanEval_145_order_by_points | #include<assert.h>
#include<bits/stdc++.h>
// Write a function which sorts the given vector of integers
// in ascending order according to the sum of their digits.
// Note: if there are several items with similar sum of their digits,
// order them based on their index in original vector.
// For example:
// >>> order_by... |
multipl-e_humaneval-cpp_data_HumanEval_146_specialFilter | #include<assert.h>
#include<bits/stdc++.h>
// Write a function that takes a vector of numbers as input and returns
// the number of elements in the vector that are greater than 10 and both
// first and last digits of a number are odd (1, 3, 5, 7, 9).
// For example:
// >>> specialFilter((std::vector<long>({(long)15, ... |
multipl-e_humaneval-cpp_data_HumanEval_147_get_max_triples | #include<assert.h>
#include<bits/stdc++.h>
// You are given a positive integer n. You have to create an integer vector a of length n.
// For each i (1 ≤ i ≤ n), the value of a[i] = i * i - i + 1.
// Return the number of triples (a[i], a[j], a[k]) of a where i < j < k,
// and a[i] + a[j] + a[k] is a multiple of 3.
// E... |
multipl-e_humaneval-cpp_data_HumanEval_148_bf | #include<assert.h>
#include<bits/stdc++.h>
// There are eight planets in our solar system: the closerst to the Sun
// is Mercury, the next one is Venus, then Earth, Mars, Jupiter, Saturn,
// Uranus, Neptune.
// Write a function that takes two planet names as strings planet1 and planet2.
// The function should return... |
multipl-e_humaneval-cpp_data_HumanEval_149_sorted_list_sum | #include<assert.h>
#include<bits/stdc++.h>
// Write a function that accepts a vector of strings as a parameter,
// deletes the strings that have odd lengths from it,
// and returns the resulted vector with a sorted order,
// The vector is always a vector of strings and never a vector of numbers,
// and it may contain d... |
multipl-e_humaneval-cpp_data_HumanEval_150_x_or_y | #include<assert.h>
#include<bits/stdc++.h>
// A simple program which should return the value of x if n is
// a prime number and should return the value of y otherwise.
// Examples:
// >>> x_or_y((7), (34), (12))
// (34)
// >>> x_or_y((15), (8), (5))
// (5)
long x_or_y(long n, long x, long y) {
}
int main() {
aut... |
multipl-e_humaneval-cpp_data_HumanEval_151_double_the_difference | #include<assert.h>
#include<bits/stdc++.h>
// Given a vector of numbers, return the sum of squares of the numbers
// in the vector that are odd. Ignore numbers that are negative or not integers.
// >>> double_the_difference((std::vector<float>({(long)1, (long)3, (long)2, (long)0})))
// (10)
// >>> double_the_difference... |
multipl-e_humaneval-cpp_data_HumanEval_152_compare | #include<assert.h>
#include<bits/stdc++.h>
// I think we all remember that feeling when the result of some long-awaited
// event is finally known. The feelings and thoughts you have at that moment are
// definitely worth noting down and comparing.
// Your task is to determine if a person correctly guessed the results o... |
multipl-e_humaneval-cpp_data_HumanEval_153_Strongest_Extension | #include<assert.h>
#include<bits/stdc++.h>
// You will be given the name of a class (a string) and a vector of extensions.
// The extensions are to be used to load additional classes to the class. The
// strength of the extension is as follows: Let CAP be the number of the uppercase
// letters in the extension's name, ... |
multipl-e_humaneval-cpp_data_HumanEval_154_cycpattern_check | #include<assert.h>
#include<bits/stdc++.h>
// You are given 2 words. You need to return true if the second word or any of its rotations is a substring in the first word
// >>> cycpattern_check(("abcd"), ("abd"))
// (false)
// >>> cycpattern_check(("hello"), ("ell"))
// (true)
// >>> cycpattern_check(("whassup"), ("psus... |
multipl-e_humaneval-cpp_data_HumanEval_155_even_odd_count | #include<assert.h>
#include<bits/stdc++.h>
// Given an integer. return a tuple that has the number of even and odd digits respectively.
// Example:
// >>> even_odd_count((-12))
// (std::make_tuple(1, 1))
// >>> even_odd_count((123))
// (std::make_tuple(1, 2))
std::tuple<long, long> even_odd_count(long num) {
}
int ma... |
multipl-e_humaneval-cpp_data_HumanEval_156_int_to_mini_roman | #include<assert.h>
#include<bits/stdc++.h>
// Given a positive integer, obtain its roman numeral equivalent as a string,
// and return it in lowercase.
// Restrictions: 1 <= num <= 1000
// Examples:
// >>> int_to_mini_roman((19))
// ("xix")
// >>> int_to_mini_roman((152))
// ("clii")
// >>> int_to_mini_roman((426))
// ... |
multipl-e_humaneval-cpp_data_HumanEval_157_right_angle_triangle | #include<assert.h>
#include<bits/stdc++.h>
// Given the lengths of the three sides of a triangle. Return true if the three
// sides form a right-angled triangle, false otherwise.
// A right-angled triangle is a triangle in which one angle is right angle or
// 90 degree.
// Example:
// >>> right_angle_triangle((3), (4)... |
multipl-e_humaneval-cpp_data_HumanEval_158_find_max | #include<assert.h>
#include<bits/stdc++.h>
// Write a function that accepts a vector of strings.
// The vector contains different words. Return the word with maximum number
// of unique characters. If multiple strings have maximum number of unique
// characters, return the one which comes first in lexicographical order... |
multipl-e_humaneval-cpp_data_HumanEval_159_eat | #include<assert.h>
#include<bits/stdc++.h>
// You're a hungry rabbit, and you already have eaten a certain number of carrots,
// but now you need to eat more carrots to complete the day's meals.
// you should return a vector of [ total number of eaten carrots after your meals,
// the number of carrots left after your m... |
multipl-e_humaneval-cpp_data_HumanEval_160_do_algebra | #include<assert.h>
#include<bits/stdc++.h>
// Given two vectors operator, and operand. The first vector has basic algebra operations, and
// the second vector is a vector of integers. Use the two given vectors to build the algebric
// expression and return the evaluation of this expression.
// The basic algebra opera... |
multipl-e_humaneval-cpp_data_HumanEval_161_solve | #include<assert.h>
#include<bits/stdc++.h>
// You are given a string s.
// if s[i] is a letter, reverse its case from lower to upper or vise versa,
// otherwise keep it as it is.
// If the string contains no letters, reverse the string.
// The function should return the resulted string.
// Examples
// >>> solve(("1234... |
multipl-e_humaneval-cpp_data_HumanEval_162_string_to_md5 | #include<assert.h>
#include<bits/stdc++.h>
// Given a string 'text', return its md5 hash equivalent string.
// If 'text' is an empty string, return None.
// >>> string_to_md5(("Hello world"))
// "3e25960a79dbc69b674cd4ec67a72c62"
std::optional<std::string> string_to_md5(std::string text) {
}
int main() {
auto can... |
multipl-e_humaneval-cpp_data_HumanEval_163_generate_integers | #include<assert.h>
#include<bits/stdc++.h>
// Given two positive integers a and b, return the even digits between a
// and b, in ascending order.
// For example:
// >>> generate_integers((2), (8))
// (std::vector<long>({(long)2, (long)4, (long)6, (long)8}))
// >>> generate_integers((8), (2))
// (std::vector<long>({(lon... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.