id stringlengths 36 64 | content stringlengths 278 9.76k |
|---|---|
multipl-e_mbpp-cpp_data_mbpp_237_check_occurences | #include<assert.h>
#include<bits/stdc++.h>
// Write a function that takes in a vector of tuples and returns a map mapping each unique tuple to the number of times it occurs in the vector.
std::map<std::tuple<long, long>,long> check_occurences(std::vector<std::tuple<long, long>> test_list) {
}
int main() {
auto ca... |
multipl-e_mbpp-cpp_data_mbpp_238_number_of_substrings | #include<assert.h>
#include<bits/stdc++.h>
// Write a cppthon function to count the number of non-empty substrings of a given string.
long number_of_substrings(std::string str) {
}
int main() {
auto candidate = number_of_substrings;
assert(candidate(("abc")) == (6));
assert(candidate(("abcd")) == (10));
... |
multipl-e_mbpp-cpp_data_mbpp_239_get_total_number_of_sequences | #include<assert.h>
#include<bits/stdc++.h>
// Write a function that takes in positive integers m and n and finds the number of possible sequences of length n, such that each element is a positive integer and is greater than or equal to twice the previous element but less than or equal to m.
long get_total_number_of_seq... |
multipl-e_mbpp-cpp_data_mbpp_240_replace_list | #include<assert.h>
#include<bits/stdc++.h>
// Write a function that takes in two vectors and replaces the last element of the first vector with the elements of the second vector.
std::vector<std::any> replace_list(std::vector<std::any> list1, std::vector<std::any> list2) {
}
int main() {
auto candidate = replace_... |
multipl-e_mbpp-cpp_data_mbpp_242_count_charac | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to count the total number of characters in a string.
long count_charac(std::string str1) {
}
int main() {
auto candidate = count_charac;
assert(candidate(("python programming")) == (18));
assert(candidate(("language")) == (8));
assert(cand... |
multipl-e_mbpp-cpp_data_mbpp_244_next_Perfect_Square | #include<assert.h>
#include<bits/stdc++.h>
// Write a cppthon function to find the next perfect square greater than a given number.
long next_Perfect_Square(long N) {
}
int main() {
auto candidate = next_Perfect_Square;
assert(candidate((35)) == (36));
assert(candidate((6)) == (9));
assert(candidate((... |
multipl-e_mbpp-cpp_data_mbpp_245_max_sum | #include<assert.h>
#include<bits/stdc++.h>
// Write a function that takes a vector and finds the maximum sum of a bitonic subsequence for the given vector, where a sequence is bitonic if it is first increasing and then decreasing.
long max_sum(std::vector<long> arr) {
}
int main() {
auto candidate = max_sum;
... |
multipl-e_mbpp-cpp_data_mbpp_247_lps | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to find the length of the longest palindromic subsequence in the given string.
long lps(std::string str) {
}
int main() {
auto candidate = lps;
assert(candidate(("TENS FOR TENS")) == (5));
assert(candidate(("CARDIO FOR CARDS")) == (7));
as... |
multipl-e_mbpp-cpp_data_mbpp_249_intersection_array | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to find the intersection of two vectors.
std::vector<long> intersection_array(std::vector<long> array_nums1, std::vector<long> array_nums2) {
}
int main() {
auto candidate = intersection_array;
assert(candidate((std::vector<long>({(long)1, (long)2... |
multipl-e_mbpp-cpp_data_mbpp_250_count_X | #include<assert.h>
#include<bits/stdc++.h>
// Write a cppthon function that takes in a tuple and an element and counts the occcurences of the element in the vector.
long count_X(std::vector<long> tup, long x) {
}
int main() {
auto candidate = count_X;
assert(candidate((std::vector<long>({(long)10, (long)8, (l... |
multipl-e_mbpp-cpp_data_mbpp_251_insert_element | #include<assert.h>
#include<bits/stdc++.h>
// Write a function that takes in a vector and an element and inserts the element before each element in the vector, and returns the resulting vector.
std::vector<std::string> insert_element(std::vector<std::string> list, std::string element) {
}
int main() {
auto candid... |
multipl-e_mbpp-cpp_data_mbpp_252_convert | #include<assert.h>
#include<bits/stdc++.h>
// Write a cppthon function to convert complex numbers to polar coordinates.
std::tuple<float, float> convert(long numbers) {
}
int main() {
auto candidate = convert;
assert(candidate((1)) == (std::make_tuple(1.0f, 0.0f)));
assert(candidate((4)) == (std::make_tup... |
multipl-e_mbpp-cpp_data_mbpp_253_count_integer | #include<assert.h>
#include<bits/stdc++.h>
union Union_long_std_string_float{
long f0;
std::string f1;
float f2; Union_long_std_string_float(long _f0) : f0(_f0) {}
Union_long_std_string_float(std::string _f1) : f1(_f1) {}
Union_long_std_string_float(float _f2) : f2(_f2) {}
~Union_long_std_str... |
multipl-e_mbpp-cpp_data_mbpp_255_combinations_colors | #include<assert.h>
#include<bits/stdc++.h>
// Write a function that takes in a vector and length n, and generates all combinations (with repetition) of the elements of the vector and returns a vector with a vector for each combination.
std::vector<std::vector<std::string>> combinations_colors(std::vector<std::string> l... |
multipl-e_mbpp-cpp_data_mbpp_256_count_Primes_nums | #include<assert.h>
#include<bits/stdc++.h>
// Write a cppthon function that takes in a non-negative number and returns the number of prime numbers less than the given non-negative number.
long count_Primes_nums(long n) {
}
int main() {
auto candidate = count_Primes_nums;
assert(candidate((5)) == (2));
ass... |
multipl-e_mbpp-cpp_data_mbpp_257_swap_numbers | #include<assert.h>
#include<bits/stdc++.h>
// Write a function that takes in two numbers and returns a vector with the second number and then the first number.
std::vector<long> swap_numbers(long a, long b) {
}
int main() {
auto candidate = swap_numbers;
assert(candidate((10), (20)) == (std::vector<long>({(lo... |
multipl-e_mbpp-cpp_data_mbpp_259_maximize_elements | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to maximize the given two vectors.
std::vector<std::vector<long>> maximize_elements(std::vector<std::vector<long>> test_tup1, std::vector<std::vector<long>> test_tup2) {
}
int main() {
auto candidate = maximize_elements;
assert(candidate((std::vec... |
multipl-e_mbpp-cpp_data_mbpp_260_newman_prime | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to find the nth newman–shanks–williams prime number.
long newman_prime(long n) {
}
int main() {
auto candidate = newman_prime;
assert(candidate((3)) == (7));
assert(candidate((4)) == (17));
assert(candidate((5)) == (41));
}
|
multipl-e_mbpp-cpp_data_mbpp_261_division_elements | #include<assert.h>
#include<bits/stdc++.h>
// Write a function that takes in two tuples and performs mathematical division operation element-wise across the given tuples.
std::tuple<long, long, long, long> division_elements(std::tuple<long, long, long, long> test_tup1, std::tuple<long, long, long, long> test_tup2) {
... |
multipl-e_mbpp-cpp_data_mbpp_262_split_two_parts | #include<assert.h>
#include<bits/stdc++.h>
// Write a function that takes in a vector and an integer L and splits the given vector into two parts where the length of the first part of the vector is L, and returns the resulting vectors in a tuple.
std::any split_two_parts(std::vector<std::any> list1, long L) {
}
int m... |
multipl-e_mbpp-cpp_data_mbpp_264_dog_age | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to calculate a dog's age in dog's years.
long dog_age(long h_age) {
}
int main() {
auto candidate = dog_age;
assert(candidate((12)) == (61));
assert(candidate((15)) == (73));
assert(candidate((24)) == (109));
}
|
multipl-e_mbpp-cpp_data_mbpp_265_list_split | #include<assert.h>
#include<bits/stdc++.h>
// Write a function that takes in a vector and an integer n and splits a vector for every nth element, returning a vector of the resulting vectors.
std::vector<std::vector<std::any>> list_split(std::vector<std::any> S, long step) {
}
int main() {
auto candidate = list_sp... |
multipl-e_mbpp-cpp_data_mbpp_266_lateralsurface_cube | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to find the lateral surface area of a cube given its side length.
long lateralsurface_cube(long l) {
}
int main() {
auto candidate = lateralsurface_cube;
assert(candidate((5)) == (100));
assert(candidate((9)) == (324));
assert(candidate((1... |
multipl-e_mbpp-cpp_data_mbpp_267_square_Sum | #include<assert.h>
#include<bits/stdc++.h>
// Write a cppthon function that takes in an integer n and returns the sum of the squares of the first n odd natural numbers.
long square_Sum(long n) {
}
int main() {
auto candidate = square_Sum;
assert(candidate((2)) == (10));
assert(candidate((3)) == (35));
... |
multipl-e_mbpp-cpp_data_mbpp_268_find_star_num | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to find the n'th star number.
long find_star_num(long n) {
}
int main() {
auto candidate = find_star_num;
assert(candidate((3)) == (37));
assert(candidate((4)) == (73));
assert(candidate((5)) == (121));
}
|
multipl-e_mbpp-cpp_data_mbpp_269_ascii_value | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to find the ascii value of a character.
long ascii_value(std::string k) {
}
int main() {
auto candidate = ascii_value;
assert(candidate(("A")) == (65));
assert(candidate(("R")) == (82));
assert(candidate(("S")) == (83));
}
|
multipl-e_mbpp-cpp_data_mbpp_270_sum_even_and_even_index | #include<assert.h>
#include<bits/stdc++.h>
// Write a cppthon function to find the sum of even numbers at even positions of a vector.
long sum_even_and_even_index(std::vector<long> arr) {
}
int main() {
auto candidate = sum_even_and_even_index;
assert(candidate((std::vector<long>({(long)5, (long)6, (long)12, ... |
multipl-e_mbpp-cpp_data_mbpp_271_even_Power_Sum | #include<assert.h>
#include<bits/stdc++.h>
// Write a cppthon function that takes in an integer n and finds the sum of the first n even natural numbers that are raised to the fifth power.
long even_Power_Sum(long n) {
}
int main() {
auto candidate = even_Power_Sum;
assert(candidate((2)) == (1056));
assert... |
multipl-e_mbpp-cpp_data_mbpp_272_rear_extract | #include<assert.h>
#include<bits/stdc++.h>
// Write a function that takes in a vector of tuples and returns a vector containing the rear element of each tuple.
std::vector<long> rear_extract(std::vector<std::tuple<long, std::string, long>> test_list) {
}
int main() {
auto candidate = rear_extract;
assert(cand... |
multipl-e_mbpp-cpp_data_mbpp_273_substract_elements | #include<assert.h>
#include<bits/stdc++.h>
// Write a function that takes in two tuples and subtracts the elements of the first tuple by the elements of the second tuple with the same index.
std::tuple<long, long, long> substract_elements(std::tuple<long, long, long> test_tup1, std::tuple<long, long, long> test_tup2) {... |
multipl-e_mbpp-cpp_data_mbpp_274_even_binomial_Coeff_Sum | #include<assert.h>
#include<bits/stdc++.h>
// Write a cppthon function that takes in a positive integer n and finds the sum of even index binomial coefficients.
long even_binomial_Coeff_Sum(long n) {
}
int main() {
auto candidate = even_binomial_Coeff_Sum;
assert(candidate((4)) == (8));
assert(candidate((... |
multipl-e_mbpp-cpp_data_mbpp_277_dict_filter | #include<assert.h>
#include<bits/stdc++.h>
// Write a function that takes in a map and integer n and filters the map to only include entries with values greater than or equal to n.
std::map<std::string,long> dict_filter(std::map<std::string,long> dict, long n) {
}
int main() {
auto candidate = dict_filter;
as... |
multipl-e_mbpp-cpp_data_mbpp_278_count_first_elements | #include<assert.h>
#include<bits/stdc++.h>
union Union_long_std_tuple_long, long_{
long f0;
std::tuple<long, long> f1; Union_long_std_tuple_long, long_(long _f0) : f0(_f0) {}
Union_long_std_tuple_long, long_(std::tuple<long, long> _f1) : f1(_f1) {}
~Union_long_std_tuple_long, long_() {}
bool oper... |
multipl-e_mbpp-cpp_data_mbpp_279_is_num_decagonal | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to find the nth decagonal number.
long is_num_decagonal(long n) {
}
int main() {
auto candidate = is_num_decagonal;
assert(candidate((3)) == (27));
assert(candidate((7)) == (175));
assert(candidate((10)) == (370));
}
|
multipl-e_mbpp-cpp_data_mbpp_280_sequential_search | #include<assert.h>
#include<bits/stdc++.h>
// Write a function that takes in a vector and element and returns a tuple containing a boolean that indicates if the element is in the vector and the index position of the element (or -1 if the element is not found).
std::tuple<bool, long> sequential_search(std::vector<long> ... |
multipl-e_mbpp-cpp_data_mbpp_281_all_unique | #include<assert.h>
#include<bits/stdc++.h>
// Write a cppthon function to check if the elements of a given vector are unique or not.
bool all_unique(std::vector<long> test_list) {
}
int main() {
auto candidate = all_unique;
assert(candidate((std::vector<long>({(long)1, (long)2, (long)3}))) == (true));
ass... |
multipl-e_mbpp-cpp_data_mbpp_282_sub_list | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to subtract two vectors element-wise.
std::vector<long> sub_list(std::vector<long> nums1, std::vector<long> nums2) {
}
int main() {
auto candidate = sub_list;
assert(candidate((std::vector<long>({(long)1, (long)2, (long)3})), (std::vector<long>({(... |
multipl-e_mbpp-cpp_data_mbpp_283_validate | #include<assert.h>
#include<bits/stdc++.h>
// Write a cppthon function takes in an integer and check whether the frequency of each digit in the integer is less than or equal to the digit itself.
bool validate(long n) {
}
int main() {
auto candidate = validate;
assert(candidate((1234)) == (true));
assert(c... |
multipl-e_mbpp-cpp_data_mbpp_284_check_element | #include<assert.h>
#include<bits/stdc++.h>
// Write a function that takes in a vector and element and checks whether all items in the vector are equal to the given element.
bool check_element(std::vector<std::any> list, std::any element) {
}
int main() {
auto candidate = check_element;
assert(candidate((std::... |
multipl-e_mbpp-cpp_data_mbpp_285_text_match_two_three | #include<assert.h>
#include<bits/stdc++.h>
// Write a function that checks whether a string contains the 'a' character followed by two or three 'b' characters.
bool text_match_two_three(std::string text) {
}
int main() {
auto candidate = text_match_two_three;
assert(candidate(("ac")) == (false));
assert(c... |
multipl-e_mbpp-cpp_data_mbpp_286_max_sub_array_sum_repeated | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to find the largest sum of a contiguous vector in the modified vector which is formed by repeating the given vector k times.
long max_sub_array_sum_repeated(std::vector<long> a, long n, long k) {
}
int main() {
auto candidate = max_sub_array_sum_repea... |
multipl-e_mbpp-cpp_data_mbpp_287_square_Sum | #include<assert.h>
#include<bits/stdc++.h>
// Write a cppthon function takes in an integer n and returns the sum of squares of first n even natural numbers.
long square_Sum(long n) {
}
int main() {
auto candidate = square_Sum;
assert(candidate((2)) == (20));
assert(candidate((3)) == (56));
assert(cand... |
multipl-e_mbpp-cpp_data_mbpp_290_max_length | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to find the vector of maximum length in a vector of vectors.
std::tuple<long, std::vector<long>> max_length(std::vector<std::vector<long>> list1) {
}
int main() {
auto candidate = max_length;
assert(candidate((std::vector<std::vector<long>>({(std:... |
multipl-e_mbpp-cpp_data_mbpp_291_count_no_of_ways | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to find out the number of ways of painting the fence such that at most 2 adjacent posts have the same color for the given fence with n posts and k colors.
long count_no_of_ways(long n, long k) {
}
int main() {
auto candidate = count_no_of_ways;
as... |
multipl-e_mbpp-cpp_data_mbpp_292_find | #include<assert.h>
#include<bits/stdc++.h>
// Write a cppthon function to find quotient of two numbers (rounded down to the nearest integer).
long find(long n, long m) {
}
int main() {
auto candidate = find;
assert(candidate((10), (3)) == (3));
assert(candidate((4), (2)) == (2));
assert(candidate((20)... |
multipl-e_mbpp-cpp_data_mbpp_293_otherside_rightangle | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to find the third side of a right angled triangle.
float otherside_rightangle(long w, long h) {
}
int main() {
auto candidate = otherside_rightangle;
assert(candidate((7), (8)) == (10.63014581273465f));
assert(candidate((3), (4)) == (float(5))... |
multipl-e_mbpp-cpp_data_mbpp_294_max_val | #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_mbpp-cpp_data_mbpp_295_sum_div | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to return the sum of all divisors of a number.
long sum_div(long number) {
}
int main() {
auto candidate = sum_div;
assert(candidate((8)) == (7));
assert(candidate((12)) == (16));
assert(candidate((7)) == (1));
}
|
multipl-e_mbpp-cpp_data_mbpp_296_get_Inv_Count | #include<assert.h>
#include<bits/stdc++.h>
// Write a cppthon function to count inversions in a vector.
long get_Inv_Count(std::vector<long> arr) {
}
int main() {
auto candidate = get_Inv_Count;
assert(candidate((std::vector<long>({(long)1, (long)20, (long)6, (long)4, (long)5}))) == (5));
assert(candidate... |
multipl-e_mbpp-cpp_data_mbpp_297_flatten_list | #include<assert.h>
#include<bits/stdc++.h>
union Union_long_std_vector_long_{
long f0;
std::vector<long> f1; Union_long_std_vector_long_(long _f0) : f0(_f0) {}
Union_long_std_vector_long_(std::vector<long> _f1) : f1(_f1) {}
~Union_long_std_vector_long_() {}
bool operator==(long f) {
retur... |
multipl-e_mbpp-cpp_data_mbpp_299_max_aggregate | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to calculate the maximum aggregate from the vector of tuples.
std::tuple<std::string, long> max_aggregate(std::vector<std::tuple<std::string, long>> stdata) {
}
int main() {
auto candidate = max_aggregate;
assert(candidate((std::vector<std::tuple<... |
multipl-e_mbpp-cpp_data_mbpp_304_find_Element | #include<assert.h>
#include<bits/stdc++.h>
// Write a cppthon function to find element at a given index after number of rotations.
long find_Element(std::vector<long> arr, std::vector<std::vector<long>> ranges, long rotations, long index) {
}
int main() {
auto candidate = find_Element;
assert(candidate((std::... |
multipl-e_mbpp-cpp_data_mbpp_305_start_withp | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to return two words from a vector of words starting with letter 'p'.
std::tuple<std::string, std::string> start_withp(std::vector<std::string> words) {
}
int main() {
auto candidate = start_withp;
assert(candidate((std::vector<std::string>({(std::... |
multipl-e_mbpp-cpp_data_mbpp_306_max_sum_increasing_subseq | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i .
long max_sum_increasing_subseq(std::vector<long> a, long n, long index, long k) {
}
int main() {
auto ... |
multipl-e_mbpp-cpp_data_mbpp_308_large_product | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to find the specified number of largest products from two given vectors, selecting one factor from each vector.
std::vector<long> large_product(std::vector<long> nums1, std::vector<long> nums2, long N) {
}
int main() {
auto candidate = large_product;
... |
multipl-e_mbpp-cpp_data_mbpp_309_maximum | #include<assert.h>
#include<bits/stdc++.h>
// Write a cppthon function to find the maximum of two numbers.
long maximum(long a, long b) {
}
int main() {
auto candidate = maximum;
assert(candidate((5), (10)) == (10));
assert(candidate((-1), (-2)) == (-1));
assert(candidate((9), (7)) == (9));
}
|
multipl-e_mbpp-cpp_data_mbpp_310_string_to_tuple | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to convert a given string to a vector of characters.
std::vector<std::string> string_to_tuple(std::string str1) {
}
int main() {
auto candidate = string_to_tuple;
assert(candidate(("python 3.0")) == (std::vector<std::string>({(std::string)"p", (st... |
multipl-e_mbpp-cpp_data_mbpp_388_highest_Power_of_2 | #include<assert.h>
#include<bits/stdc++.h>
// Write a cppthon function to find the highest power of 2 that is less than or equal to n.
long highest_Power_of_2(long n) {
}
int main() {
auto candidate = highest_Power_of_2;
assert(candidate((10)) == (8));
assert(candidate((19)) == (16));
assert(candidate... |
multipl-e_mbpp-cpp_data_mbpp_389_find_lucas | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to find the n'th lucas number.
long find_lucas(long n) {
}
int main() {
auto candidate = find_lucas;
assert(candidate((9)) == (76));
assert(candidate((4)) == (7));
assert(candidate((3)) == (4));
}
|
multipl-e_mbpp-cpp_data_mbpp_390_add_string | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to apply a given format string to all of the elements in a vector.
std::vector<std::string> add_string(std::vector<std::any> list_, std::string string) {
}
int main() {
auto candidate = add_string;
assert(candidate((std::vector<std::any>({(long)1,... |
multipl-e_mbpp-cpp_data_mbpp_391_convert_list_dictionary | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to convert more than one vector to nested map.
std::vector<std::map<std::string,std::map<std::string,long>>> convert_list_dictionary(std::vector<std::string> l1, std::vector<std::string> l2, std::vector<long> l3) {
}
int main() {
auto candidate = conv... |
multipl-e_mbpp-cpp_data_mbpp_392_get_max_sum | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to find the maximum sum possible by using the given equation f(n) = max( (f(n/2) + f(n/3) + f(n/4) + f(n/5)), n).
long get_max_sum(long n) {
}
int main() {
auto candidate = get_max_sum;
assert(candidate((60)) == (106));
assert(candidate((10)) ... |
multipl-e_mbpp-cpp_data_mbpp_393_max_length_list | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to find the vector with maximum length.
std::tuple<long, std::vector<long>> max_length_list(std::vector<std::vector<long>> input_list) {
}
int main() {
auto candidate = max_length_list;
assert(candidate((std::vector<std::vector<long>>({(std::vecto... |
multipl-e_mbpp-cpp_data_mbpp_394_check_distinct | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to check if given vector contains no duplicates.
bool check_distinct(std::vector<long> test_tup) {
}
int main() {
auto candidate = check_distinct;
assert(candidate((std::vector<long>({(long)1, (long)4, (long)5, (long)6, (long)1, (long)4}))) == (fa... |
multipl-e_mbpp-cpp_data_mbpp_395_first_non_repeating_character | #include<assert.h>
#include<bits/stdc++.h>
// Write a cppthon function to find the first non-repeated character in a given string.
std::optional<std::string> first_non_repeating_character(std::string str1) {
}
int main() {
auto candidate = first_non_repeating_character;
assert(candidate(("abcabc")) == std::nu... |
multipl-e_mbpp-cpp_data_mbpp_396_check_char | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to check whether the given string starts and ends with the same character or not.
std::string check_char(std::string string) {
}
int main() {
auto candidate = check_char;
assert(candidate(("abba")) == ("Valid"));
assert(candidate(("a")) == ("V... |
multipl-e_mbpp-cpp_data_mbpp_397_median_numbers | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to find the median of three numbers.
float median_numbers(long a, long b, long c) {
}
int main() {
auto candidate = median_numbers;
assert(candidate((25), (55), (65)) == (55.0f));
assert(candidate((20), (10), (30)) == (20.0f));
assert(cand... |
multipl-e_mbpp-cpp_data_mbpp_398_sum_of_digits | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to compute the sum of digits of each number of a given vector.
long sum_of_digits(std::vector<std::any> nums) {
}
int main() {
auto candidate = sum_of_digits;
assert(candidate((std::vector<std::any>({(long)10, (long)2, (long)56}))) == (14));
a... |
multipl-e_mbpp-cpp_data_mbpp_399_bitwise_xor | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to perform the mathematical bitwise xor operation across the given tuples.
std::tuple<long, long, long, long> bitwise_xor(std::tuple<long, long, long, long> test_tup1, std::tuple<long, long, long, long> test_tup2) {
}
int main() {
auto candidate = bit... |
multipl-e_mbpp-cpp_data_mbpp_400_extract_freq | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to extract the number of unique tuples in the given vector.
long extract_freq(std::vector<std::tuple<long, long>> test_list) {
}
int main() {
auto candidate = extract_freq;
assert(candidate((std::vector<std::tuple<long, long>>({(std::tuple<long, l... |
multipl-e_mbpp-cpp_data_mbpp_401_add_nested_tuples | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to perform index wise addition of vector elements in the given two nested vectors.
std::vector<std::vector<long>> add_nested_tuples(std::vector<std::vector<long>> test_tup1, std::vector<std::vector<long>> test_tup2) {
}
int main() {
auto candidate = a... |
multipl-e_mbpp-cpp_data_mbpp_404_minimum | #include<assert.h>
#include<bits/stdc++.h>
// Write a cppthon function to find the minimum of two numbers.
long minimum(long a, long b) {
}
int main() {
auto candidate = minimum;
assert(candidate((1), (2)) == (1));
assert(candidate((-5), (-4)) == (-5));
assert(candidate((0), (0)) == (0));
}
|
multipl-e_mbpp-cpp_data_mbpp_405_check_tuplex | #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_mbpp-cpp_data_mbpp_406_find_Parity | #include<assert.h>
#include<bits/stdc++.h>
// Write a cppthon function to find whether the parity of a given number is odd.
bool find_Parity(long x) {
}
int main() {
auto candidate = find_Parity;
assert(candidate((12)) == (false));
assert(candidate((7)) == (true));
assert(candidate((10)) == (false));
... |
multipl-e_mbpp-cpp_data_mbpp_407_rearrange_bigger | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to create the next bigger number by rearranging the digits of a given number.
std::any rearrange_bigger(long n) {
}
int main() {
auto candidate = rearrange_bigger;
assert(candidate((12)) == (std::any(21)));
assert(candidate((10)) == (std::any(... |
multipl-e_mbpp-cpp_data_mbpp_408_k_smallest_pairs | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to find k number of smallest pairs which consist of one element from the first vector and one element from the second vector.
std::vector<std::vector<long>> k_smallest_pairs(std::vector<long> nums1, std::vector<long> nums2, long k) {
}
int main() {
au... |
multipl-e_mbpp-cpp_data_mbpp_409_min_product_tuple | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to find the minimum product from the pairs of tuples within a given vector.
long min_product_tuple(std::vector<std::tuple<long, long>> list1) {
}
int main() {
auto candidate = min_product_tuple;
assert(candidate((std::vector<std::tuple<long, long>... |
multipl-e_mbpp-cpp_data_mbpp_410_min_val | #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_mbpp-cpp_data_mbpp_411_snake_to_camel | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to convert the given snake case string to camel case string.
std::string snake_to_camel(std::string word) {
}
int main() {
auto candidate = snake_to_camel;
assert(candidate(("android_tv")) == ("AndroidTv"));
assert(candidate(("google_pixel")) ... |
multipl-e_mbpp-cpp_data_mbpp_412_remove_odd | #include<assert.h>
#include<bits/stdc++.h>
// Write a cppthon function to remove odd numbers from a given vector.
std::vector<long> remove_odd(std::vector<long> l) {
}
int main() {
auto candidate = remove_odd;
assert(candidate((std::vector<long>({(long)1, (long)2, (long)3}))) == (std::vector<long>({(long)2}))... |
multipl-e_mbpp-cpp_data_mbpp_413_extract_nth_element | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to extract the nth element from a given vector of tuples.
std::vector<std::any> extract_nth_element(std::vector<std::tuple<std::string, long, long>> list1, long n) {
}
int main() {
auto candidate = extract_nth_element;
assert(candidate((std::vecto... |
multipl-e_mbpp-cpp_data_mbpp_414_overlapping | #include<assert.h>
#include<bits/stdc++.h>
// Write a cppthon function to check whether any value in a sequence exists in a sequence or not.
bool overlapping(std::vector<long> list1, std::vector<long> list2) {
}
int main() {
auto candidate = overlapping;
assert(candidate((std::vector<long>({(long)1, (long)2, ... |
multipl-e_mbpp-cpp_data_mbpp_415_max_Product | #include<assert.h>
#include<bits/stdc++.h>
// Write a cppthon function to find a pair with highest product from a given vector of integers.
std::tuple<long, long> max_Product(std::vector<long> arr) {
}
int main() {
auto candidate = max_Product;
assert(candidate((std::vector<long>({(long)1, (long)2, (long)3, (... |
multipl-e_mbpp-cpp_data_mbpp_417_group_tuples | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to find common first element in given vector of vectors.
std::vector<std::vector<std::string>> group_tuples(std::vector<std::vector<std::string>> Input) {
}
int main() {
auto candidate = group_tuples;
assert(candidate((std::vector<std::vector<std:... |
multipl-e_mbpp-cpp_data_mbpp_418_Find_Max | #include<assert.h>
#include<bits/stdc++.h>
// Write a cppthon function to find the element of a vector having maximum length.
std::vector<std::any> Find_Max(std::vector<std::vector<std::any>> lst) {
}
int main() {
auto candidate = Find_Max;
assert(candidate((std::vector<std::vector<std::any>>({(std::vector<st... |
multipl-e_mbpp-cpp_data_mbpp_419_round_and_sum | #include<assert.h>
#include<bits/stdc++.h>
union Union_float_long{
float f0;
long f1; Union_float_long(float _f0) : f0(_f0) {}
Union_float_long(long _f1) : f1(_f1) {}
~Union_float_long() {}
bool operator==(float f) {
return f0 == f ;
} bool operator==(long f) {
return f1 ==... |
multipl-e_mbpp-cpp_data_mbpp_420_cube_Sum | #include<assert.h>
#include<bits/stdc++.h>
// Write a cppthon function to find the cube sum of first n even natural numbers.
long cube_Sum(long n) {
}
int main() {
auto candidate = cube_Sum;
assert(candidate((2)) == (72));
assert(candidate((3)) == (288));
assert(candidate((4)) == (800));
}
|
multipl-e_mbpp-cpp_data_mbpp_421_concatenate_tuple | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to concatenate each element of tuple by the delimiter.
std::string concatenate_tuple(std::tuple<std::string, std::string, long, std::string> test_tup) {
}
int main() {
auto candidate = concatenate_tuple;
assert(candidate((std::make_tuple("ID", "is... |
multipl-e_mbpp-cpp_data_mbpp_422_find_Average_Of_Cube | #include<assert.h>
#include<bits/stdc++.h>
// Write a cppthon function to find the average of cubes of first n natural numbers.
float find_Average_Of_Cube(long n) {
}
int main() {
auto candidate = find_Average_Of_Cube;
assert(candidate((2)) == (4.5f));
assert(candidate((3)) == (float(12)));
assert(can... |
multipl-e_mbpp-cpp_data_mbpp_424_extract_rear | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to extract only the rear index element of each string in the given tuple.
std::vector<std::string> extract_rear(std::tuple<std::string, std::string, std::string> test_tuple) {
}
int main() {
auto candidate = extract_rear;
assert(candidate((std::ma... |
multipl-e_mbpp-cpp_data_mbpp_425_count_element_in_list | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to count the number of subvectors containing a particular element.
long count_element_in_list(std::vector<std::vector<std::any>> list1, std::any x) {
}
int main() {
auto candidate = count_element_in_list;
assert(candidate((std::vector<std::vector<... |
multipl-e_mbpp-cpp_data_mbpp_426_filter_oddnumbers | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to filter odd numbers.
std::vector<long> filter_oddnumbers(std::vector<long> nums) {
}
int main() {
auto candidate = filter_oddnumbers;
assert(candidate((std::vector<long>({(long)1, (long)2, (long)3, (long)4, (long)5, (long)6, (long)7, (long)8, (l... |
multipl-e_mbpp-cpp_data_mbpp_427_change_date_format | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to convert a date of yyyy-mm-dd format to dd-mm-yyyy format.
std::string change_date_format(std::string dt) {
}
int main() {
auto candidate = change_date_format;
assert(candidate(("2026-01-02")) == ("02-01-2026"));
assert(candidate(("2020-11-1... |
multipl-e_mbpp-cpp_data_mbpp_428_shell_sort | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to sort the given vector by using shell sort.
std::vector<long> shell_sort(std::vector<long> my_list) {
}
int main() {
auto candidate = shell_sort;
assert(candidate((std::vector<long>({(long)12, (long)23, (long)4, (long)5, (long)3, (long)2, (long)... |
multipl-e_mbpp-cpp_data_mbpp_429_and_tuples | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to extract the elementwise and tuples from the given two tuples.
std::tuple<long, long, long, long> and_tuples(std::tuple<long, long, long, long> test_tup1, std::tuple<long, long, long, long> test_tup2) {
}
int main() {
auto candidate = and_tuples;
... |
multipl-e_mbpp-cpp_data_mbpp_430_parabola_directrix | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to find the directrix of a parabola.
long parabola_directrix(long a, long b, long c) {
}
int main() {
auto candidate = parabola_directrix;
assert(candidate((5), (3), (2)) == (-198));
assert(candidate((9), (8), (4)) == (-2336));
assert(cand... |
multipl-e_mbpp-cpp_data_mbpp_431_common_element | #include<assert.h>
#include<bits/stdc++.h>
// Write a function that takes two vectors and returns true if they have at least one common element.
std::optional<bool> common_element(std::vector<std::any> list1, std::vector<std::any> list2) {
}
int main() {
auto candidate = common_element;
assert(candidate((std:... |
multipl-e_mbpp-cpp_data_mbpp_432_median_trapezium | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to find the median length of a trapezium.
float median_trapezium(long base1, long base2, long height) {
}
int main() {
auto candidate = median_trapezium;
assert(candidate((15), (25), (35)) == (float(20)));
assert(candidate((10), (20), (30)) ==... |
multipl-e_mbpp-cpp_data_mbpp_433_check_greater | #include<assert.h>
#include<bits/stdc++.h>
// Write a function to check whether the entered number is greater than the elements of the given vector.
bool check_greater(std::vector<long> arr, long number) {
}
int main() {
auto candidate = check_greater;
assert(candidate((std::vector<long>({(long)1, (long)2, (l... |
multipl-e_mbpp-cpp_data_mbpp_434_text_match_one | #include<assert.h>
#include<bits/stdc++.h>
// Write a function that matches a string that has an a followed by one or more b's.
bool text_match_one(std::string text) {
}
int main() {
auto candidate = text_match_one;
assert(candidate(("ac")) == (false));
assert(candidate(("dc")) == (false));
assert(can... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.