id stringlengths 44 73 | content stringlengths 361 6.18k |
|---|---|
multipl-e_humaneval-cpp_data_HumanEval_0_has_close_elements | #include<assert.h>
#include<bits/stdc++.h>
// Check if in given vector of numbers, are any two numbers closer to each other than
// given threshold.
// >>> has_close_elements((std::vector<float>({(float)1.0f, (float)2.0f, (float)3.0f})), (0.5f))
// (false)
// >>> has_close_elements((std::vector<float>({(float)1.0f, (fl... |
multipl-e_humaneval-cpp_data_HumanEval_1_separate_paren_groups | #include<assert.h>
#include<bits/stdc++.h>
// Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
// separate those group into separate strings and return the vector of those.
// Separate groups are balanced (each open brace is properly closed) and not nested within each... |
multipl-e_humaneval-cpp_data_HumanEval_2_truncate_number | #include<assert.h>
#include<bits/stdc++.h>
// Given a positive floating point number, it can be decomposed into
// and integer part (largest integer smaller than given number) and decimals
// (leftover part always smaller than 1).
// Return the decimal part of the number.
// >>> truncate_number((3.5f))
// (0.5f)
float ... |
multipl-e_humaneval-cpp_data_HumanEval_3_below_zero | #include<assert.h>
#include<bits/stdc++.h>
// You're given a vector of deposit and withdrawal operations on a bank account that starts with
// zero balance. Your task is to detect if at any point the balance of account fallls below zero, and
// at that point function should return true. Otherwise it should return false... |
multipl-e_humaneval-cpp_data_HumanEval_4_mean_absolute_deviation | #include<assert.h>
#include<bits/stdc++.h>
// For a given vector of input numbers, calculate Mean Absolute Deviation
// around the mean of this dataset.
// Mean Absolute Deviation is the average absolute difference between each
// element and a centerpoint (mean in this case):
// MAD = average | x - x_mean |
// >>> mea... |
multipl-e_humaneval-cpp_data_HumanEval_5_intersperse | #include<assert.h>
#include<bits/stdc++.h>
// Insert a number 'delimeter' between every two consecutive elements of input vector `numbers'
// >>> intersperse((std::vector<long>()), (4))
// (std::vector<long>())
// >>> intersperse((std::vector<long>({(long)1, (long)2, (long)3})), (4))
// (std::vector<long>({(long)1, (lo... |
multipl-e_humaneval-cpp_data_HumanEval_6_parse_nested_parens | #include<assert.h>
#include<bits/stdc++.h>
// Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
// For each of the group, output the deepest level of nesting of parentheses.
// E.g. (()()) has maximum two levels of nesting while ((())) has three.
// >>> parse_nes... |
multipl-e_humaneval-cpp_data_HumanEval_7_filter_by_substring | #include<assert.h>
#include<bits/stdc++.h>
// Filter an input vector of strings only for ones that contain given substring
// >>> filter_by_substring((std::vector<std::string>()), ("a"))
// (std::vector<std::string>())
// >>> filter_by_substring((std::vector<std::string>({(std::string)"abc", (std::string)"bacd", (std::... |
multipl-e_humaneval-cpp_data_HumanEval_8_sum_product | #include<assert.h>
#include<bits/stdc++.h>
// For a given vector of integers, return a tuple consisting of a sum and a product of all the integers in a vector.
// Empty sum should be equal to 0 and empty product should be equal to 1.
// >>> sum_product((std::vector<long>()))
// (std::make_tuple(0, 1))
// >>> sum_produc... |
multipl-e_humaneval-cpp_data_HumanEval_9_rolling_max | #include<assert.h>
#include<bits/stdc++.h>
// From a given vector of integers, generate a vector of rolling maximum element found until given moment
// in the sequence.
// >>> rolling_max((std::vector<long>({(long)1, (long)2, (long)3, (long)2, (long)3, (long)4, (long)2})))
// (std::vector<long>({(long)1, (long)2, (long... |
multipl-e_humaneval-cpp_data_HumanEval_10_make_palindrome | #include<assert.h>
#include<bits/stdc++.h>
// Find the shortest palindrome that begins with a supplied string.
// Algorithm idea is simple:
// - Find the longest postfix of supplied string that is a palindrome.
// - Append to the end of the string reverse of a string prefix that comes before the palindromic suffix.
// ... |
multipl-e_humaneval-cpp_data_HumanEval_11_string_xor | #include<assert.h>
#include<bits/stdc++.h>
// Input are two strings a and b consisting only of 1s and 0s.
// Perform binary XOR on these inputs and return result also as a string.
// >>> string_xor(("010"), ("110"))
// ("100")
std::string string_xor(std::string a, std::string b) {
}
int main() {
auto candidate = ... |
multipl-e_humaneval-cpp_data_HumanEval_12_longest | #include<assert.h>
#include<bits/stdc++.h>
// Out of vector of strings, return the longest one. Return the first one in case of multiple
// strings of the same length. Return None in case the input vector is empty.
// >>> longest((std::vector<std::string>()))
// std::nullopt
// >>> longest((std::vector<std::string>({(s... |
multipl-e_humaneval-cpp_data_HumanEval_13_greatest_common_divisor | #include<assert.h>
#include<bits/stdc++.h>
// Return a greatest common divisor of two integers a and b
// >>> greatest_common_divisor((3), (5))
// (1)
// >>> greatest_common_divisor((25), (15))
// (5)
long greatest_common_divisor(long a, long b) {
}
int main() {
auto candidate = greatest_common_divisor;
asser... |
multipl-e_humaneval-cpp_data_HumanEval_14_all_prefixes | #include<assert.h>
#include<bits/stdc++.h>
// Return vector of all prefixes from shortest to longest of the input string
// >>> all_prefixes(("abc"))
// (std::vector<std::string>({(std::string)"a", (std::string)"ab", (std::string)"abc"}))
std::vector<std::string> all_prefixes(std::string string) {
}
int main() {
... |
multipl-e_humaneval-cpp_data_HumanEval_15_string_sequence | #include<assert.h>
#include<bits/stdc++.h>
// Return a string containing space-delimited numbers starting from 0 upto n inclusive.
// >>> string_sequence((0))
// ("0")
// >>> string_sequence((5))
// ("0 1 2 3 4 5")
std::string string_sequence(long n) {
}
int main() {
auto candidate = string_sequence;
assert(c... |
multipl-e_humaneval-cpp_data_HumanEval_16_count_distinct_characters | #include<assert.h>
#include<bits/stdc++.h>
// Given a string, find out how many distinct characters (regardless of case) does it consist of
// >>> count_distinct_characters(("xyzXYZ"))
// (3)
// >>> count_distinct_characters(("Jerry"))
// (4)
long count_distinct_characters(std::string string) {
}
int main() {
aut... |
multipl-e_humaneval-cpp_data_HumanEval_17_parse_music | #include<assert.h>
#include<bits/stdc++.h>
// Input to this function is a string representing musical notes in a special ASCII format.
// Your task is to parse this string and return vector of integers corresponding to how many beats does each
// not last.
// Here is a legend:
// 'o' - whole note, lasts four beats
// '... |
multipl-e_humaneval-cpp_data_HumanEval_18_how_many_times | #include<assert.h>
#include<bits/stdc++.h>
// Find how many times a given substring can be found in the original string. Count overlaping cases.
// >>> how_many_times((""), ("a"))
// (0)
// >>> how_many_times(("aaa"), ("a"))
// (3)
// >>> how_many_times(("aaaa"), ("aa"))
// (3)
long how_many_times(std::string string, s... |
multipl-e_humaneval-cpp_data_HumanEval_19_sort_numbers | #include<assert.h>
#include<bits/stdc++.h>
// Input is a space-delimited string of numberals from 'zero' to 'nine'.
// Valid choices are 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight' and 'nine'.
// Return the string with numbers sorted from smallest to largest
// >>> sort_numbers(("three one fi... |
multipl-e_humaneval-cpp_data_HumanEval_20_find_closest_elements | #include<assert.h>
#include<bits/stdc++.h>
// From a supplied vector of numbers (of length at least two) select and return two that are the closest to each
// other and return them in order (smaller number, larger number).
// >>> find_closest_elements((std::vector<float>({(float)1.0f, (float)2.0f, (float)3.0f, (float)4... |
multipl-e_humaneval-cpp_data_HumanEval_21_rescale_to_unit | #include<assert.h>
#include<bits/stdc++.h>
// Given vector of numbers (of at least two elements), apply a linear transform to that vector,
// such that the smallest number will become 0 and the largest will become 1
// >>> rescale_to_unit((std::vector<float>({(float)1.0f, (float)2.0f, (float)3.0f, (float)4.0f, (float)5... |
multipl-e_humaneval-cpp_data_HumanEval_22_filter_integers | #include<assert.h>
#include<bits/stdc++.h>
// Filter given vector of any cppthon values only for integers
// >>> filter_integers((std::vector<std::any>({(std::string)"a", (std::string)3.14f, (std::string)5})))
// (std::vector<long>({(long)5}))
// >>> filter_integers((std::vector<std::any>({1, 2, 3, "abc", std::map<long... |
multipl-e_humaneval-cpp_data_HumanEval_23_strlen | #include<assert.h>
#include<bits/stdc++.h>
// Return length of given string
// >>> string_length((""))
// (0)
// >>> string_length(("abc"))
// (3)
long string_length(std::string string) {
}
int main() {
auto candidate = string_length;
assert(candidate(("")) == (0));
assert(candidate(("x")) == (1));
as... |
multipl-e_humaneval-cpp_data_HumanEval_24_largest_divisor | #include<assert.h>
#include<bits/stdc++.h>
// For a given number n, find the largest number that divides n evenly, smaller than n
// >>> largest_divisor((15))
// (5)
long largest_divisor(long n) {
}
int main() {
auto candidate = largest_divisor;
assert(candidate((3)) == (1));
assert(candidate((7)) == (1))... |
multipl-e_humaneval-cpp_data_HumanEval_25_factorize | #include<assert.h>
#include<bits/stdc++.h>
// Return vector of prime factors of given integer in the order from smallest to largest.
// Each of the factors should be vectored number of times corresponding to how many times it appeares in factorization.
// Input number should be equal to the product of all factors
// >>... |
multipl-e_humaneval-cpp_data_HumanEval_26_remove_duplicates | #include<assert.h>
#include<bits/stdc++.h>
// From a vector of integers, remove all elements that occur more than once.
// Keep order of elements left the same as in the input.
// >>> remove_duplicates((std::vector<long>({(long)1, (long)2, (long)3, (long)2, (long)4})))
// (std::vector<long>({(long)1, (long)3, (long)4})... |
multipl-e_humaneval-cpp_data_HumanEval_27_flip_case | #include<assert.h>
#include<bits/stdc++.h>
// For a given string, flip lowercase characters to uppercase and uppercase to lowercase.
// >>> flip_case(("Hello"))
// ("hELLO")
std::string flip_case(std::string string) {
}
int main() {
auto candidate = flip_case;
assert(candidate(("")) == (""));
assert(candi... |
multipl-e_humaneval-cpp_data_HumanEval_28_concatenate | #include<assert.h>
#include<bits/stdc++.h>
// Concatenate vector of strings into a single string
// >>> concatenate((std::vector<std::string>()))
// ("")
// >>> concatenate((std::vector<std::string>({(std::string)"a", (std::string)"b", (std::string)"c"})))
// ("abc")
std::string concatenate(std::vector<std::string> str... |
multipl-e_humaneval-cpp_data_HumanEval_29_filter_by_prefix | #include<assert.h>
#include<bits/stdc++.h>
// Filter an input vector of strings only for ones that start with a given prefix.
// >>> filter_by_prefix((std::vector<std::string>()), ("a"))
// (std::vector<std::string>())
// >>> filter_by_prefix((std::vector<std::string>({(std::string)"abc", (std::string)"bcd", (std::stri... |
multipl-e_humaneval-cpp_data_HumanEval_30_get_positive | #include<assert.h>
#include<bits/stdc++.h>
// Return only positive numbers in the vector.
// >>> get_positive((std::vector<long>({(long)-1, (long)2, (long)-4, (long)5, (long)6})))
// (std::vector<long>({(long)2, (long)5, (long)6}))
// >>> get_positive((std::vector<long>({(long)5, (long)3, (long)-5, (long)2, (long)-3, (... |
multipl-e_humaneval-cpp_data_HumanEval_31_is_prime | #include<assert.h>
#include<bits/stdc++.h>
// Return true if a given number is prime, and false otherwise.
// >>> is_prime((6))
// (false)
// >>> is_prime((101))
// (true)
// >>> is_prime((11))
// (true)
// >>> is_prime((13441))
// (true)
// >>> is_prime((61))
// (true)
// >>> is_prime((4))
// (false)
// >>> is_prime((... |
multipl-e_humaneval-cpp_data_HumanEval_33_sort_third | #include<assert.h>
#include<bits/stdc++.h>
// This function takes a vector l and returns a vector l' such that
// l' is identical to l in the indicies that are not divisible by three, while its values at the indicies that are divisible by three are equal
// to the values of the corresponding indicies of l, but sorted.
... |
multipl-e_humaneval-cpp_data_HumanEval_34_unique | #include<assert.h>
#include<bits/stdc++.h>
// Return sorted unique elements in a vector
// >>> unique((std::vector<long>({(long)5, (long)3, (long)5, (long)2, (long)3, (long)3, (long)9, (long)0, (long)123})))
// (std::vector<long>({(long)0, (long)2, (long)3, (long)5, (long)9, (long)123}))
std::vector<long> unique(std::v... |
multipl-e_humaneval-cpp_data_HumanEval_35_max_element | #include<assert.h>
#include<bits/stdc++.h>
// Return maximum element in the vector.
// >>> max_element((std::vector<long>({(long)1, (long)2, (long)3})))
// (3)
// >>> max_element((std::vector<long>({(long)5, (long)3, (long)-5, (long)2, (long)-3, (long)3, (long)9, (long)0, (long)123, (long)1, (long)-10})))
// (123)
long... |
multipl-e_humaneval-cpp_data_HumanEval_36_fizz_buzz | #include<assert.h>
#include<bits/stdc++.h>
// Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13.
// >>> fizz_buzz((50))
// (0)
// >>> fizz_buzz((78))
// (2)
// >>> fizz_buzz((79))
// (3)
long fizz_buzz(long n) {
}
int main() {
auto candidate = fizz_buzz;
as... |
multipl-e_humaneval-cpp_data_HumanEval_37_sort_even | #include<assert.h>
#include<bits/stdc++.h>
// This function takes a vector l and returns a vector l' such that
// l' is identical to l in the odd indicies, while its values at the even indicies are equal
// to the values of the even indicies of l, but sorted.
// >>> sort_even((std::vector<long>({(long)1, (long)2, (long... |
multipl-e_humaneval-cpp_data_HumanEval_39_prime_fib | #include<assert.h>
#include<bits/stdc++.h>
// prime_fib returns n-th number that is a Fibonacci number and it's also prime.
// >>> prime_fib((1))
// (2)
// >>> prime_fib((2))
// (3)
// >>> prime_fib((3))
// (5)
// >>> prime_fib((4))
// (13)
// >>> prime_fib((5))
// (89)
long prime_fib(long n) {
}
int main() {
aut... |
multipl-e_humaneval-cpp_data_HumanEval_40_triples_sum_to_zero | #include<assert.h>
#include<bits/stdc++.h>
// triples_sum_to_zero takes a vector of integers as an input.
// it returns true if there are three distinct elements in the vector that
// sum to zero, and false otherwise.
// >>> triples_sum_to_zero((std::vector<long>({(long)1, (long)3, (long)5, (long)0})))
// (false)
// >>... |
multipl-e_humaneval-cpp_data_HumanEval_41_car_race_collision | #include<assert.h>
#include<bits/stdc++.h>
// Imagine a road that's a perfectly straight infinitely long line.
// n cars are driving left to right; simultaneously, a different set of n cars
// are driving right to left. The two sets of cars start out being very far from
// each other. All cars move in the same spee... |
multipl-e_humaneval-cpp_data_HumanEval_42_incr_list | #include<assert.h>
#include<bits/stdc++.h>
// Return vector with elements incremented by 1.
// >>> incr_list((std::vector<long>({(long)1, (long)2, (long)3})))
// (std::vector<long>({(long)2, (long)3, (long)4}))
// >>> incr_list((std::vector<long>({(long)5, (long)3, (long)5, (long)2, (long)3, (long)3, (long)9, (long)0, ... |
multipl-e_humaneval-cpp_data_HumanEval_43_pairs_sum_to_zero | #include<assert.h>
#include<bits/stdc++.h>
// pairs_sum_to_zero takes a vector of integers as an input.
// it returns true if there are two distinct elements in the vector that
// sum to zero, and false otherwise.
// >>> pairs_sum_to_zero((std::vector<long>({(long)1, (long)3, (long)5, (long)0})))
// (false)
// >>> pair... |
multipl-e_humaneval-cpp_data_HumanEval_44_change_base | #include<assert.h>
#include<bits/stdc++.h>
// Change numerical base of input number x to base.
// return string representation after the conversion.
// base numbers are less than 10.
// >>> change_base((8), (3))
// ("22")
// >>> change_base((8), (2))
// ("1000")
// >>> change_base((7), (2))
// ("111")
std::string chang... |
multipl-e_humaneval-cpp_data_HumanEval_45_triangle_area | #include<assert.h>
#include<bits/stdc++.h>
// Given length of a side and high return area for a triangle.
// >>> triangle_area((5), (3))
// (7.5f)
float triangle_area(long a, long h) {
}
int main() {
auto candidate = triangle_area;
assert(candidate((5), (3)) == (7.5f));
assert(candidate((2), (2)) == (2.0f... |
multipl-e_humaneval-cpp_data_HumanEval_46_fib4 | #include<assert.h>
#include<bits/stdc++.h>
// The Fib4 number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
// fib4(0) -> 0
// fib4(1) -> 0
// fib4(2) -> 2
// fib4(3) -> 0
// fib4(n) -> fib4(n-1) + fib4(n-2) + fib4(n-3) + fib4(n-4).
// Please write a function to efficiently comput... |
multipl-e_humaneval-cpp_data_HumanEval_47_median | #include<assert.h>
#include<bits/stdc++.h>
// Return median of elements in the vector l.
// >>> median((std::vector<long>({(long)3, (long)1, (long)2, (long)4, (long)5})))
// (float(3))
// >>> median((std::vector<long>({(long)-10, (long)4, (long)6, (long)1000, (long)10, (long)20})))
// (15.0f)
float median(std::vector<l... |
multipl-e_humaneval-cpp_data_HumanEval_48_is_palindrome | #include<assert.h>
#include<bits/stdc++.h>
// Checks if given string is a palindrome
// >>> is_palindrome((""))
// (true)
// >>> is_palindrome(("aba"))
// (true)
// >>> is_palindrome(("aaaaa"))
// (true)
// >>> is_palindrome(("zbcd"))
// (false)
bool is_palindrome(std::string text) {
}
int main() {
auto candidate... |
multipl-e_humaneval-cpp_data_HumanEval_49_modp | #include<assert.h>
#include<bits/stdc++.h>
// Return 2^n modulo p (be aware of numerics).
// >>> modp((3), (5))
// (3)
// >>> modp((1101), (101))
// (2)
// >>> modp((0), (101))
// (1)
// >>> modp((3), (11))
// (8)
// >>> modp((100), (101))
// (1)
long modp(long n, long p) {
}
int main() {
auto candidate = modp;
... |
multipl-e_humaneval-cpp_data_HumanEval_51_remove_vowels | #include<assert.h>
#include<bits/stdc++.h>
// remove_vowels is a function that takes string and returns string without vowels.
// >>> remove_vowels((""))
// ("")
// >>> remove_vowels(("abcdef"))
// ("bcdf")
// >>> remove_vowels(("aaaaa"))
// ("")
// >>> remove_vowels(("aaBAA"))
// ("B")
// >>> remove_vowels(("zbcd"))
/... |
multipl-e_humaneval-cpp_data_HumanEval_52_below_threshold | #include<assert.h>
#include<bits/stdc++.h>
// Return true if all numbers in the vector l are below threshold t.
// >>> below_threshold((std::vector<long>({(long)1, (long)2, (long)4, (long)10})), (100))
// (true)
// >>> below_threshold((std::vector<long>({(long)1, (long)20, (long)4, (long)10})), (5))
// (false)
bool bel... |
multipl-e_humaneval-cpp_data_HumanEval_53_add | #include<assert.h>
#include<bits/stdc++.h>
// Add two numbers x and y
// >>> add((2), (3))
// (5)
// >>> add((5), (7))
// (12)
long add(long x, long y) {
}
int main() {
auto candidate = add;
assert(candidate((0), (1)) == (1));
assert(candidate((1), (0)) == (1));
assert(candidate((2), (3)) == (5));
... |
multipl-e_humaneval-cpp_data_HumanEval_54_same_chars | #include<assert.h>
#include<bits/stdc++.h>
// Check if two words have the same characters.
// >>> same_chars(("eabcdzzzz"), ("dddzzzzzzzddeddabc"))
// (true)
// >>> same_chars(("abcd"), ("dddddddabc"))
// (true)
// >>> same_chars(("dddddddabc"), ("abcd"))
// (true)
// >>> same_chars(("eabcd"), ("dddddddabc"))
// (false... |
multipl-e_humaneval-cpp_data_HumanEval_55_fib | #include<assert.h>
#include<bits/stdc++.h>
// Return n-th Fibonacci number.
// >>> fib((10))
// (55)
// >>> fib((1))
// (1)
// >>> fib((8))
// (21)
long fib(long n) {
}
int main() {
auto candidate = fib;
assert(candidate((10)) == (55));
assert(candidate((1)) == (1));
assert(candidate((8)) == (21));
... |
multipl-e_humaneval-cpp_data_HumanEval_56_correct_bracketing | #include<assert.h>
#include<bits/stdc++.h>
// brackets is a string of "<" and ">".
// return true if every opening bracket has a corresponding closing bracket.
// >>> correct_bracketing(("<"))
// (false)
// >>> correct_bracketing(("<>"))
// (true)
// >>> correct_bracketing(("<<><>>"))
// (true)
// >>> correct_bracketin... |
multipl-e_humaneval-cpp_data_HumanEval_57_monotonic | #include<assert.h>
#include<bits/stdc++.h>
// Return true is vector elements are monotonically increasing or decreasing.
// >>> monotonic((std::vector<long>({(long)1, (long)2, (long)4, (long)20})))
// (true)
// >>> monotonic((std::vector<long>({(long)1, (long)20, (long)4, (long)10})))
// (false)
// >>> monotonic((std::... |
multipl-e_humaneval-cpp_data_HumanEval_58_common | #include<assert.h>
#include<bits/stdc++.h>
// Return sorted unique common elements for two vectors.
// >>> common((std::vector<long>({(long)1, (long)4, (long)3, (long)34, (long)653, (long)2, (long)5})), (std::vector<long>({(long)5, (long)7, (long)1, (long)5, (long)9, (long)653, (long)121})))
// (std::vector<long>({(lon... |
multipl-e_humaneval-cpp_data_HumanEval_59_largest_prime_factor | #include<assert.h>
#include<bits/stdc++.h>
// Return the largest prime factor of n. Assume n > 1 and is not a prime.
// >>> largest_prime_factor((13195))
// (29)
// >>> largest_prime_factor((2048))
// (2)
long largest_prime_factor(long n) {
}
int main() {
auto candidate = largest_prime_factor;
assert(candidat... |
multipl-e_humaneval-cpp_data_HumanEval_60_sum_to_n | #include<assert.h>
#include<bits/stdc++.h>
// sum_to_n is a function that sums numbers from 1 to n.
// >>> sum_to_n((30))
// (465)
// >>> sum_to_n((100))
// (5050)
// >>> sum_to_n((5))
// (15)
// >>> sum_to_n((10))
// (55)
// >>> sum_to_n((1))
// (1)
long sum_to_n(long n) {
}
int main() {
auto candidate = sum_to_... |
multipl-e_humaneval-cpp_data_HumanEval_61_correct_bracketing | #include<assert.h>
#include<bits/stdc++.h>
// brackets is a string of "(" and ")".
// return true if every opening bracket has a corresponding closing bracket.
// >>> correct_bracketing(("("))
// (false)
// >>> correct_bracketing(("()"))
// (true)
// >>> correct_bracketing(("(()())"))
// (true)
// >>> correct_bracketin... |
multipl-e_humaneval-cpp_data_HumanEval_62_derivative | #include<assert.h>
#include<bits/stdc++.h>
// xs represent coefficients of a polynomial.
// xs[0] + xs[1] * x + xs[2] * x^2 + ....
// Return derivative of this polynomial in the same form.
// >>> derivative((std::vector<long>({(long)3, (long)1, (long)2, (long)4, (long)5})))
// (std::vector<long>({(long)1, (long)4, (lon... |
multipl-e_humaneval-cpp_data_HumanEval_63_fibfib | #include<assert.h>
#include<bits/stdc++.h>
// The FibFib number sequence is a sequence similar to the Fibbonacci sequnece that's defined as follows:
// fibfib(0) == 0
// fibfib(1) == 0
// fibfib(2) == 1
// fibfib(n) == fibfib(n-1) + fibfib(n-2) + fibfib(n-3).
// Please write a function to efficiently compute the n-th e... |
multipl-e_humaneval-cpp_data_HumanEval_64_vowels_count | #include<assert.h>
#include<bits/stdc++.h>
// Write a function vowels_count which takes a string representing
// a word as input and returns the number of vowels in the string.
// Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a
// vowel, but only when it is at the end of the given word.
// Example:... |
multipl-e_humaneval-cpp_data_HumanEval_65_circular_shift | #include<assert.h>
#include<bits/stdc++.h>
// Circular shift the digits of the integer x, shift the digits right by shift
// and return the result as a string.
// If shift > number of digits, return digits reversed.
// >>> circular_shift((12), (1))
// ("21")
// >>> circular_shift((12), (2))
// ("12")
std::string circul... |
multipl-e_humaneval-cpp_data_HumanEval_66_digitSum | #include<assert.h>
#include<bits/stdc++.h>
// Task
// Write a function that takes a string as input and returns the sum of the upper characters only'
// ASCII codes.
// Examples:
// >>> digitSum((""))
// (0)
// >>> digitSum(("abAB"))
// (131)
// >>> digitSum(("abcCd"))
// (67)
// >>> digitSum(("helloE"))
// (69)
// >>>... |
multipl-e_humaneval-cpp_data_HumanEval_67_fruit_distribution | #include<assert.h>
#include<bits/stdc++.h>
// In this task, you will be given a string that represents a number of apples and oranges
// that are distributed in a basket of fruit this basket contains
// apples, oranges, and mango fruits. Given the string that represents the total number of
// the oranges and apples ... |
multipl-e_humaneval-cpp_data_HumanEval_68_pluck | #include<assert.h>
#include<bits/stdc++.h>
// "Given a vector representing a branch of a tree that has non-negative integer nodes
// your task is to pluck one of the nodes and return it.
// The plucked node should be the node with the smallest even value.
// If multiple nodes with the same smallest even value are found... |
multipl-e_humaneval-cpp_data_HumanEval_69_search | #include<assert.h>
#include<bits/stdc++.h>
// You are given a non-empty vector of positive integers. Return the greatest integer that is greater than
// zero, and has a frequency greater than or equal to the value of the integer itself.
// The frequency of an integer is the number of times it appears in the vector.
/... |
multipl-e_humaneval-cpp_data_HumanEval_70_strange_sort_list | #include<assert.h>
#include<bits/stdc++.h>
// Given vector of integers, return vector in strange order.
// Strange sorting, is when you start with the minimum value,
// then maximum of the remaining integers, then minimum and so on.
// Examples:
// >>> strange_sort_list((std::vector<long>({(long)1, (long)2, (long)3, (l... |
multipl-e_humaneval-cpp_data_HumanEval_71_triangle_area | #include<assert.h>
#include<bits/stdc++.h>
// Given the lengths of the three sides of a triangle. Return the area of
// the triangle rounded to 2 decimal points if the three sides form a valid triangle.
// Otherwise return -1
// Three sides make a valid triangle when the sum of any two sides is greater
// than the th... |
multipl-e_humaneval-cpp_data_HumanEval_72_will_it_fly | #include<assert.h>
#include<bits/stdc++.h>
// Write a function that returns true if the object q will fly, and false otherwise.
// The object q will fly if it's balanced (it is a palindromic vector) and the sum of its elements is less than or equal the maximum possible weight w.
// Example:
// >>> will_it_fly((std::vec... |
multipl-e_humaneval-cpp_data_HumanEval_73_smallest_change | #include<assert.h>
#include<bits/stdc++.h>
// Given a vector arr of integers, find the minimum number of elements that
// need to be changed to make the vector palindromic. A palindromic vector is a vector that
// is read the same backwards and forwards. In one change, you can change one element to any other element.
/... |
multipl-e_humaneval-cpp_data_HumanEval_74_total_match | #include<assert.h>
#include<bits/stdc++.h>
// Write a function that accepts two vectors of strings and returns the vector that has
// total number of chars in the all strings of the vector less than the other vector.
// if the two vectors have the same number of chars, return the first vector.
// Examples
// >>> total... |
multipl-e_humaneval-cpp_data_HumanEval_75_is_multiply_prime | #include<assert.h>
#include<bits/stdc++.h>
// Write a function that returns true if the given number is the multiplication of 3 prime numbers
// and false otherwise.
// Knowing that (a) is less then 100.
// Example:
// >>> is_multiply_prime((30))
// (true)
// 30 = 2 * 3 * 5
bool is_multiply_prime(long a) {
}
int mai... |
multipl-e_humaneval-cpp_data_HumanEval_76_is_simple_power | #include<assert.h>
#include<bits/stdc++.h>
// Your task is to write a function that returns true if a number x is a simple
// power of n and false in other cases.
// x is a simple power of n if n**int=x
// For example:
// >>> is_simple_power((1), (4))
// (true)
// >>> is_simple_power((2), (2))
// (true)
// >>> is_simpl... |
multipl-e_humaneval-cpp_data_HumanEval_77_iscube | #include<assert.h>
#include<bits/stdc++.h>
// Write a function that takes an integer a and returns true
// if this ingeger is a cube of some integer number.
// Note: you may assume the input is always valid.
// Examples:
// >>> iscube((1))
// (true)
// >>> iscube((2))
// (false)
// >>> iscube((-1))
// (true)
// >>> is... |
multipl-e_humaneval-cpp_data_HumanEval_78_hex_key | #include<assert.h>
#include<bits/stdc++.h>
// You have been tasked to write a function that receives
// a hexadecimal number as a string and counts the number of hexadecimal
// digits that are primes (prime number, or a prime, is a natural number
// greater than 1 that is not a product of two smaller natural numbers... |
multipl-e_humaneval-cpp_data_HumanEval_79_decimal_to_binary | #include<assert.h>
#include<bits/stdc++.h>
// You will be given a number in decimal form and your task is to convert it to
// binary format. The function should return a string, with each character representing a binary
// number. Each character in the string will be '0' or '1'.
// There will be an extra couple of char... |
multipl-e_humaneval-cpp_data_HumanEval_80_is_happy | #include<assert.h>
#include<bits/stdc++.h>
// You are given a string s.
// Your task is to check if the string is hapcpp or not.
// A string is hapcpp if its length is at least 3 and every 3 consecutive letters are distinct
// For example:
// >>> is_happy(("a"))
// (false)
// >>> is_happy(("aa"))
// (false)
// >>> is_h... |
multipl-e_humaneval-cpp_data_HumanEval_81_numerical_letter_grade | #include<assert.h>
#include<bits/stdc++.h>
// It is the last week of the semester and the teacher has to give the grades
// to students. The teacher has been making her own algorithm for grading.
// The only problem is, she has lost the code she used for grading.
// She has given you a vector of GPAs for some students ... |
multipl-e_humaneval-cpp_data_HumanEval_82_prime_length | #include<assert.h>
#include<bits/stdc++.h>
// Write a function that takes a string and returns true if the string
// length is a prime number or false otherwise
// Examples
// >>> prime_length(("Hello"))
// (true)
// >>> prime_length(("abcdcba"))
// (true)
// >>> prime_length(("kittens"))
// (true)
// >>> prime_length(... |
multipl-e_humaneval-cpp_data_HumanEval_83_starts_one_ends | #include<assert.h>
#include<bits/stdc++.h>
// Given a positive integer n, return the count of the numbers of n-digit
// positive integers that start or end with 1.
long starts_one_ends(long n) {
}
int main() {
auto candidate = starts_one_ends;
assert(candidate((1)) == (1));
assert(candidate((2)) == (18));... |
multipl-e_humaneval-cpp_data_HumanEval_84_solve | #include<assert.h>
#include<bits/stdc++.h>
// Given a positive integer N, return the total sum of its digits in binary.
// Example
// >>> solve((1000))
// ("1")
// >>> solve((150))
// ("110")
// >>> solve((147))
// ("1100")
// Variables:
// @N integer
// Constraints: 0 ≤ N ≤ 10000.
// Output:
// a string of binary numb... |
multipl-e_humaneval-cpp_data_HumanEval_85_add | #include<assert.h>
#include<bits/stdc++.h>
// Given a non-empty vector of integers lst. add the even elements that are at odd indices..
// Examples:
// >>> add((std::vector<long>({(long)4, (long)2, (long)6, (long)7})))
// (2)
long add(std::vector<long> lst) {
}
int main() {
auto candidate = add;
assert(candid... |
multipl-e_humaneval-cpp_data_HumanEval_86_anti_shuffle | #include<assert.h>
#include<bits/stdc++.h>
// Write a function that takes a string and returns an ordered version of it.
// Ordered version of string, is a string where all words (separated by space)
// are replaced by a new word where all the characters arranged in
// ascending order based on ascii value.
// Note: You... |
multipl-e_humaneval-cpp_data_HumanEval_87_get_row | #include<assert.h>
#include<bits/stdc++.h>
// You are given a 2 dimensional data, as a nested vectors,
// which is similar to matrix, however, unlike matrices,
// each row may contain a different number of columns.
// Given lst, and integer x, find integers x in the vector,
// and return vector of tuples, [(x1, y1), (x... |
multipl-e_humaneval-cpp_data_HumanEval_88_sort_array | #include<assert.h>
#include<bits/stdc++.h>
// Given a vector of non-negative integers, return a cocpp of the given vector after sorting,
// you will sort the given vector in ascending order if the sum( first index value, last index value) is odd,
// or sort it in descending order if the sum( first index value, last ind... |
multipl-e_humaneval-cpp_data_HumanEval_89_encrypt | #include<assert.h>
#include<bits/stdc++.h>
// Create a function encrypt that takes a string as an argument and
// returns a string encrypted with the alphabet being rotated.
// The alphabet should be rotated in a manner such that the letters
// shift down by two multiplied to two places.
// For example:
// >>> encryp... |
multipl-e_humaneval-cpp_data_HumanEval_90_next_smallest | #include<assert.h>
#include<bits/stdc++.h>
// You are given a vector of integers.
// Write a function next_smallest() that returns the 2nd smallest element of the vector.
// Return None if there is no such element.
// >>> next_smallest((std::vector<long>({(long)1, (long)2, (long)3, (long)4, (long)5})))
// 2
// >>> next... |
multipl-e_humaneval-cpp_data_HumanEval_91_is_bored | #include<assert.h>
#include<bits/stdc++.h>
// You'll be given a string of words, and your task is to count the number
// of boredoms. A boredom is a sentence that starts with the word "I".
// Sentences are delimited by '.', '?' or '!'.
// For example:
// >>> is_bored(("Hello world"))
// (0)
// >>> is_bored(("The sky is... |
multipl-e_humaneval-cpp_data_HumanEval_92_any_int | #include<assert.h>
#include<bits/stdc++.h>
// Create a function that takes 3 numbers.
// Returns true if one of the numbers is equal to the sum of the other two, and all numbers are integers.
// Returns false in any other cases.
// Examples
// >>> any_int((float(5)), (float(2)), (float(7)))
// (true)
// >>> any_int((fl... |
multipl-e_humaneval-cpp_data_HumanEval_93_encode | #include<assert.h>
#include<bits/stdc++.h>
// Write a function that takes a message, and encodes in such a
// way that it swaps case of all letters, replaces all vowels in
// the message with the letter that appears 2 places ahead of that
// vowel in the english alphabet.
// Assume only letters.
// Examples:
// >>... |
multipl-e_humaneval-cpp_data_HumanEval_94_skjkasdkd | #include<assert.h>
#include<bits/stdc++.h>
// You are given a vector of integers.
// You need to find the largest prime value and return the sum of its digits.
// Examples:
// >>> skjkasdkd((std::vector<long>({(long)0, (long)3, (long)2, (long)1, (long)3, (long)5, (long)7, (long)4, (long)5, (long)5, (long)5, (long)2, (l... |
multipl-e_humaneval-cpp_data_HumanEval_95_check_dict_case | #include<assert.h>
#include<bits/stdc++.h>
// Given a map, return true if all keys are strings in lower
// case or all keys are strings in upper case, else return false.
// The function should return false is the given map is empty.
// Examples:
// >>> check_dict_case((std::map<std::string,std::string>({{"a", "apple"}... |
multipl-e_humaneval-cpp_data_HumanEval_96_count_up_to | #include<assert.h>
#include<bits/stdc++.h>
// Implement a function that takes an non-negative integer and returns a vector of the first n
// integers that are prime numbers and less than n.
// for example:
// >>> count_up_to((5))
// (std::vector<long>({(long)2, (long)3}))
// >>> count_up_to((11))
// (std::vector<long>(... |
multipl-e_humaneval-cpp_data_HumanEval_97_multiply | #include<assert.h>
#include<bits/stdc++.h>
// Complete the function that takes two integers and returns
// the product of their unit digits.
// Assume the input is always valid.
// Examples:
// >>> multiply((148), (412))
// (16)
// >>> multiply((19), (28))
// (72)
// >>> multiply((2020), (1851))
// (0)
// >>> multiply... |
multipl-e_humaneval-cpp_data_HumanEval_98_count_upper | #include<assert.h>
#include<bits/stdc++.h>
// Given a string s, count the number of uppercase vowels in even indices.
// For example:
// >>> count_upper(("aBCdEf"))
// (1)
// >>> count_upper(("abcdefg"))
// (0)
// >>> count_upper(("dBBE"))
// (0)
long count_upper(std::string s) {
}
int main() {
auto candidate = c... |
multipl-e_humaneval-cpp_data_HumanEval_99_closest_integer | #include<assert.h>
#include<bits/stdc++.h>
// Create a function that takes a value (string) representing a number
// and returns the closest integer to it. If the number is equidistant
// from two integers, round it away from zero.
// Examples
// >>> closest_integer(("10"))
// (10)
// >>> closest_integer(("15.3"))
// (... |
multipl-e_humaneval-cpp_data_HumanEval_100_make_a_pile | #include<assert.h>
#include<bits/stdc++.h>
// Given a positive integer n, you have to make a pile of n levels of stones.
// The first level has n stones.
// The number of stones in the next level is:
// - the next odd number if n is odd.
// - the next even number if n is even.
// Return the number of stones in each lev... |
multipl-e_humaneval-cpp_data_HumanEval_101_words_string | #include<assert.h>
#include<bits/stdc++.h>
// You will be given a string of words separated by commas or spaces. Your task is
// to split the string into words and return a vector of the words.
// For example:
// >>> words_string(("Hi, my name is John"))
// (std::vector<std::string>({(std::string)"Hi", (std::string)"my... |
multipl-e_humaneval-cpp_data_HumanEval_102_choose_num | #include<assert.h>
#include<bits/stdc++.h>
// This function takes two positive numbers x and y and returns the
// biggest even integer number that is in the range [x, y] inclusive. If
// there's no such number, then the function should return -1.
// For example:
// >>> choose_num((12), (15))
// (14)
// >>> choose_num(... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.