id
stringlengths
36
64
content
stringlengths
278
9.76k
multipl-e_mbpp-cpp_data_mbpp_3_is_not_prime
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to identify non-prime numbers. bool is_not_prime(long n) { } int main() { auto candidate = is_not_prime; assert(candidate((2)) == (false)); assert(candidate((10)) == (true)); assert(candidate((35)) == (true)); assert(candidate(...
multipl-e_mbpp-cpp_data_mbpp_4_heap_queue_largest
#include<assert.h> #include<bits/stdc++.h> // Write a function to find the n largest integers from a given vector of numbers, returned in descending order. std::vector<long> heap_queue_largest(std::vector<long> nums, long n) { } int main() { auto candidate = heap_queue_largest; assert(candidate((std::vector<l...
multipl-e_mbpp-cpp_data_mbpp_6_differ_At_One_Bit_Pos
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to check whether the two numbers differ at one bit position only or not. bool differ_At_One_Bit_Pos(long a, long b) { } int main() { auto candidate = differ_At_One_Bit_Pos; assert(candidate((13), (9)) == (true)); assert(candidate((15),...
multipl-e_mbpp-cpp_data_mbpp_8_square_nums
#include<assert.h> #include<bits/stdc++.h> // Write a function to find squares of individual elements in a vector. std::vector<long> square_nums(std::vector<long> nums) { } int main() { auto candidate = square_nums; assert(candidate((std::vector<long>({(long)1, (long)2, (long)3, (long)4, (long)5, (long)6, (lo...
multipl-e_mbpp-cpp_data_mbpp_9_find_Rotations
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to find the minimum number of rotations (greater than 0) required to get the same string. long find_Rotations(std::string str) { } int main() { auto candidate = find_Rotations; assert(candidate(("aaaa")) == (1)); assert(candidate(("ab"...
multipl-e_mbpp-cpp_data_mbpp_11_remove_Occ
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to remove first and last occurrence of a given character from the string. std::string remove_Occ(std::string s, std::string ch) { } int main() { auto candidate = remove_Occ; assert(candidate(("hello"), ("l")) == ("heo")); assert(candid...
multipl-e_mbpp-cpp_data_mbpp_12_sort_matrix
#include<assert.h> #include<bits/stdc++.h> // Write a function to sort a given matrix in ascending order according to the sum of its rows. std::vector<std::vector<long>> sort_matrix(std::vector<std::vector<long>> M) { } int main() { auto candidate = sort_matrix; assert(candidate((std::vector<std::vector<long>...
multipl-e_mbpp-cpp_data_mbpp_14_find_Volume
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to find the volume of a triangular prism. long find_Volume(long l, long b, long h) { } int main() { auto candidate = find_Volume; assert(candidate((10), (8), (6)) == (240)); assert(candidate((3), (2), (2)) == (6)); assert(candidate...
multipl-e_mbpp-cpp_data_mbpp_16_text_lowercase_underscore
#include<assert.h> #include<bits/stdc++.h> // Write a function to that returns true if the input string contains sequences of lowercase letters joined with an underscore and false otherwise. bool text_lowercase_underscore(std::string text) { } int main() { auto candidate = text_lowercase_underscore; assert(ca...
multipl-e_mbpp-cpp_data_mbpp_17_square_perimeter
#include<assert.h> #include<bits/stdc++.h> // Write a function that returns the perimeter of a square given its side length as input. long square_perimeter(long a) { } int main() { auto candidate = square_perimeter; assert(candidate((10)) == (40)); assert(candidate((5)) == (20)); assert(candidate((4))...
multipl-e_mbpp-cpp_data_mbpp_18_remove_dirty_chars
#include<assert.h> #include<bits/stdc++.h> // Write a function to remove characters from the first string which are present in the second string. std::string remove_dirty_chars(std::string string, std::string second_string) { } int main() { auto candidate = remove_dirty_chars; assert(candidate(("probasscurve"...
multipl-e_mbpp-cpp_data_mbpp_19_test_duplicate
#include<assert.h> #include<bits/stdc++.h> // Write a function to find whether a given vector of integers contains any duplicate element. bool test_duplicate(std::vector<long> arraynums) { } int main() { auto candidate = test_duplicate; assert(candidate((std::vector<long>({(long)1, (long)2, (long)3, (long)4, ...
multipl-e_mbpp-cpp_data_mbpp_20_is_woodall
#include<assert.h> #include<bits/stdc++.h> // Write a function to check if the given number is woodball or not. bool is_woodall(long x) { } int main() { auto candidate = is_woodall; assert(candidate((383)) == (true)); assert(candidate((254)) == (false)); assert(candidate((200)) == (false)); }
multipl-e_mbpp-cpp_data_mbpp_56_checks
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to check if a given number is one less than twice its reverse. bool checks(long n) { } int main() { auto candidate = checks; assert(candidate((70)) == (false)); assert(candidate((23)) == (false)); assert(candidate((73)) == (true));...
multipl-e_mbpp-cpp_data_mbpp_57_find_Max_Num
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to find the largest number that can be formed with the given vector of digits. long find_Max_Num(std::vector<long> arr) { } int main() { auto candidate = find_Max_Num; assert(candidate((std::vector<long>({(long)1, (long)2, (long)3}))) == (...
multipl-e_mbpp-cpp_data_mbpp_58_opposite_Signs
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to check whether the given two integers have opposite sign or not. bool opposite_Signs(long x, long y) { } int main() { auto candidate = opposite_Signs; assert(candidate((1), (-2)) == (true)); assert(candidate((3), (2)) == (false)); ...
multipl-e_mbpp-cpp_data_mbpp_59_is_octagonal
#include<assert.h> #include<bits/stdc++.h> // Write a function to find the nth octagonal number. long is_octagonal(long n) { } int main() { auto candidate = is_octagonal; assert(candidate((5)) == (65)); assert(candidate((10)) == (280)); assert(candidate((15)) == (645)); }
multipl-e_mbpp-cpp_data_mbpp_61_count_Substrings
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to count the number of substrings with the sum of digits equal to their length. long count_Substrings(std::string s) { } int main() { auto candidate = count_Substrings; assert(candidate(("112112")) == (6)); assert(candidate(("111")) ==...
multipl-e_mbpp-cpp_data_mbpp_62_smallest_num
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to find smallest number in a vector. long smallest_num(std::vector<long> xs) { } int main() { auto candidate = smallest_num; assert(candidate((std::vector<long>({(long)10, (long)20, (long)1, (long)45, (long)99}))) == (1)); assert(candi...
multipl-e_mbpp-cpp_data_mbpp_63_max_difference
#include<assert.h> #include<bits/stdc++.h> // Write a function to find the maximum difference between available pairs in the given tuple vector. long max_difference(std::vector<std::tuple<long, long>> test_list) { } int main() { auto candidate = max_difference; assert(candidate((std::vector<std::tuple<long, l...
multipl-e_mbpp-cpp_data_mbpp_64_subject_marks
#include<assert.h> #include<bits/stdc++.h> // Write a function to sort a vector of tuples using the second value of each tuple. std::vector<std::tuple<std::string, long>> subject_marks(std::vector<std::tuple<std::string, long>> subjectmarks) { } int main() { auto candidate = subject_marks; assert(candidate((s...
multipl-e_mbpp-cpp_data_mbpp_65_recursive_list_sum
#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_66_pos_count
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to count the number of positive numbers in a vector. long pos_count(std::vector<long> list) { } int main() { auto candidate = pos_count; assert(candidate((std::vector<long>({(long)1, (long)-2, (long)3, (long)-4}))) == (2)); assert(cand...
multipl-e_mbpp-cpp_data_mbpp_67_bell_number
#include<assert.h> #include<bits/stdc++.h> // Write a function to find the number of ways to partition a set of Bell numbers. long bell_number(long n) { } int main() { auto candidate = bell_number; assert(candidate((2)) == (2)); assert(candidate((10)) == (115975)); assert(candidate((56)) == (677568532...
multipl-e_mbpp-cpp_data_mbpp_68_is_Monotonic
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to check whether the given vector is monotonic or not. bool is_Monotonic(std::vector<long> A) { } int main() { auto candidate = is_Monotonic; assert(candidate((std::vector<long>({(long)6, (long)5, (long)4, (long)4}))) == (true)); asser...
multipl-e_mbpp-cpp_data_mbpp_69_is_sublist
#include<assert.h> #include<bits/stdc++.h> // Write a function to check whether a vector contains the given subvector or not. bool is_sublist(std::vector<long> l, std::vector<long> s) { } int main() { auto candidate = is_sublist; assert(candidate((std::vector<long>({(long)2, (long)4, (long)3, (long)5, (long)7...
multipl-e_mbpp-cpp_data_mbpp_70_get_equal
#include<assert.h> #include<bits/stdc++.h> // Write a function to find whether all the given vectors have equal length or not. bool get_equal(std::vector<std::vector<long>> Input) { } int main() { auto candidate = get_equal; assert(candidate((std::vector<std::vector<long>>({(std::vector<long>)std::vector<long...
multipl-e_mbpp-cpp_data_mbpp_71_comb_sort
#include<assert.h> #include<bits/stdc++.h> // Write a function to sort a vector of elements. std::vector<long> comb_sort(std::vector<long> nums) { } int main() { auto candidate = comb_sort; assert(candidate((std::vector<long>({(long)5, (long)15, (long)37, (long)25, (long)79}))) == (std::vector<long>({(long)5,...
multipl-e_mbpp-cpp_data_mbpp_72_dif_Square
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to check whether the given number can be represented as the difference of two squares or not. bool dif_Square(long n) { } int main() { auto candidate = dif_Square; assert(candidate((5)) == (true)); assert(candidate((10)) == (false)); ...
multipl-e_mbpp-cpp_data_mbpp_74_is_samepatterns
#include<assert.h> #include<bits/stdc++.h> // Write a function to check whether it follows the sequence given in the patterns vector. bool is_samepatterns(std::vector<std::string> colors, std::vector<std::string> patterns) { } int main() { auto candidate = is_samepatterns; assert(candidate((std::vector<std::s...
multipl-e_mbpp-cpp_data_mbpp_75_find_tuples
#include<assert.h> #include<bits/stdc++.h> // Write a function to find tuples which have all elements divisible by k from the given vector of tuples. std::vector<std::tuple<long, long, long>> find_tuples(std::vector<std::tuple<long, long, long>> test_list, long K) { } int main() { auto candidate = find_tuples; ...
multipl-e_mbpp-cpp_data_mbpp_77_is_Diff
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to find whether a number is divisible by 11. bool is_Diff(long n) { } int main() { auto candidate = is_Diff; assert(candidate((12345)) == (false)); assert(candidate((1212112)) == (true)); assert(candidate((1212)) == (false)); }
multipl-e_mbpp-cpp_data_mbpp_79_word_len
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to check whether the length of the word is odd or not. bool word_len(std::string s) { } int main() { auto candidate = word_len; assert(candidate(("Hadoop")) == (false)); assert(candidate(("great")) == (true)); assert(candidate(("st...
multipl-e_mbpp-cpp_data_mbpp_80_tetrahedral_number
#include<assert.h> #include<bits/stdc++.h> // Write a function to find the nth tetrahedral number. long tetrahedral_number(long n) { } int main() { auto candidate = tetrahedral_number; assert(candidate((5)) == (35)); assert(candidate((6)) == (56)); assert(candidate((7)) == (84)); }
multipl-e_mbpp-cpp_data_mbpp_83_get_Char
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to find the character made by adding the ASCII value of all the characters of the given string modulo 26. std::string get_Char(std::string strr) { } int main() { auto candidate = get_Char; assert(candidate(("abc")) == ("f")); assert(ca...
multipl-e_mbpp-cpp_data_mbpp_84_sequence
#include<assert.h> #include<bits/stdc++.h> // Write a function to find the nth number in the newman conway sequence. long sequence(long n) { } int main() { auto candidate = sequence; assert(candidate((10)) == (6)); assert(candidate((2)) == (1)); assert(candidate((3)) == (2)); }
multipl-e_mbpp-cpp_data_mbpp_86_centered_hexagonal_number
#include<assert.h> #include<bits/stdc++.h> // Write a function to find nth centered hexagonal number. long centered_hexagonal_number(long n) { } int main() { auto candidate = centered_hexagonal_number; assert(candidate((10)) == (271)); assert(candidate((2)) == (7)); assert(candidate((9)) == (217)); }
multipl-e_mbpp-cpp_data_mbpp_87_merge_dictionaries_three
#include<assert.h> #include<bits/stdc++.h> // Write a function to merge three dictionaries into a single map. std::map<std::string,std::string> merge_dictionaries_three(std::map<std::string,std::string> dict1, std::map<std::string,std::string> dict2, std::map<std::string,std::string> dict3) { } int main() { auto ...
multipl-e_mbpp-cpp_data_mbpp_88_freq_count
#include<assert.h> #include<bits/stdc++.h> // Write a function to get the frequency of all the elements in a vector, returned as a map. std::map<long,long> freq_count(std::vector<long> list1) { } int main() { auto candidate = freq_count; assert(candidate((std::vector<long>({(long)10, (long)10, (long)10, (long...
multipl-e_mbpp-cpp_data_mbpp_89_closest_num
#include<assert.h> #include<bits/stdc++.h> // Write a function to find the closest smaller number than n. long closest_num(long N) { } int main() { auto candidate = closest_num; assert(candidate((11)) == (10)); assert(candidate((7)) == (6)); assert(candidate((12)) == (11)); }
multipl-e_mbpp-cpp_data_mbpp_90_len_log
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to find the length of the longest word. long len_log(std::vector<std::string> list1) { } int main() { auto candidate = len_log; assert(candidate((std::vector<std::string>({(std::string)"python", (std::string)"PHP", (std::string)"bigdata"})...
multipl-e_mbpp-cpp_data_mbpp_91_find_substring
#include<assert.h> #include<bits/stdc++.h> // Write a function to check if a string is present as a substring in a given vector of string values. bool find_substring(std::vector<std::string> str1, std::string sub_str) { } int main() { auto candidate = find_substring; assert(candidate((std::vector<std::string>...
multipl-e_mbpp-cpp_data_mbpp_92_is_undulating
#include<assert.h> #include<bits/stdc++.h> // Write a function to check whether the given number is undulating or not. bool is_undulating(long n) { } int main() { auto candidate = is_undulating; assert(candidate((1212121)) == (true)); assert(candidate((1991)) == (false)); assert(candidate((121)) == (t...
multipl-e_mbpp-cpp_data_mbpp_93_power
#include<assert.h> #include<bits/stdc++.h> // Write a function to calculate the value of 'a' to the power 'b'. long power(long a, long b) { } int main() { auto candidate = power; assert(candidate((3), (4)) == (81)); assert(candidate((2), (3)) == (8)); assert(candidate((5), (5)) == (3125)); }
multipl-e_mbpp-cpp_data_mbpp_94_index_minimum
#include<assert.h> #include<bits/stdc++.h> // Given a vector of tuples, write a function that returns the first value of the tuple with the smallest second value. std::string index_minimum(std::vector<std::tuple<std::string, long>> test_list) { } int main() { auto candidate = index_minimum; assert(candidate((...
multipl-e_mbpp-cpp_data_mbpp_95_Find_Min_Length
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to find the length of the smallest vector in a vector of vectors. long Find_Min_Length(std::vector<std::vector<long>> lst) { } int main() { auto candidate = Find_Min_Length; assert(candidate((std::vector<std::vector<long>>({(std::vector<lo...
multipl-e_mbpp-cpp_data_mbpp_96_divisor
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to find the number of divisors of a given integer. long divisor(long n) { } int main() { auto candidate = divisor; assert(candidate((15)) == (4)); assert(candidate((12)) == (6)); assert(candidate((9)) == (3)); }
multipl-e_mbpp-cpp_data_mbpp_97_frequency_lists
#include<assert.h> #include<bits/stdc++.h> // Write a function to find frequency of each element in a flattened vector of vectors, returned in a map. std::map<long,long> frequency_lists(std::vector<std::vector<long>> list1) { } int main() { auto candidate = frequency_lists; assert(candidate((std::vector<std::...
multipl-e_mbpp-cpp_data_mbpp_99_decimal_to_binary
#include<assert.h> #include<bits/stdc++.h> // Write a function to convert the given decimal number to its binary equivalent, represented as a string with no leading zeros. std::string decimal_to_binary(long n) { } int main() { auto candidate = decimal_to_binary; assert(candidate((8)) == ("1000")); assert(...
multipl-e_mbpp-cpp_data_mbpp_100_next_smallest_palindrome
#include<assert.h> #include<bits/stdc++.h> // Write a function to find the next smallest palindrome of a specified integer, returned as an integer. long next_smallest_palindrome(long num) { } int main() { auto candidate = next_smallest_palindrome; assert(candidate((99)) == (101)); assert(candidate((1221))...
multipl-e_mbpp-cpp_data_mbpp_101_kth_element
#include<assert.h> #include<bits/stdc++.h> // Write a function to find the kth element in the given vector using 1-based indexing. long kth_element(std::vector<long> arr, long k) { } int main() { auto candidate = kth_element; assert(candidate((std::vector<long>({(long)12, (long)3, (long)5, (long)7, (long)19})...
multipl-e_mbpp-cpp_data_mbpp_102_snake_to_camel
#include<assert.h> #include<bits/stdc++.h> // Write a function to convert a snake case string to camel case string. std::string snake_to_camel(std::string word) { } int main() { auto candidate = snake_to_camel; assert(candidate(("python_program")) == ("PythonProgram")); assert(candidate(("python_language"...
multipl-e_mbpp-cpp_data_mbpp_103_eulerian_num
#include<assert.h> #include<bits/stdc++.h> // Write a function to find the Eulerian number a(n, m). long eulerian_num(long n, long m) { } int main() { auto candidate = eulerian_num; assert(candidate((3), (1)) == (4)); assert(candidate((4), (1)) == (11)); assert(candidate((5), (3)) == (26)); }
multipl-e_mbpp-cpp_data_mbpp_104_sort_sublists
#include<assert.h> #include<bits/stdc++.h> // Write a function to sort each subvector of strings in a given vector of vectors. std::vector<std::vector<std::string>> sort_sublists(std::vector<std::vector<std::string>> input_list) { } int main() { auto candidate = sort_sublists; assert(candidate((std::vector<st...
multipl-e_mbpp-cpp_data_mbpp_105_count
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to count true booleans in the given vector. long count(std::vector<bool> lst) { } int main() { auto candidate = count; assert(candidate((std::vector<bool>({(bool)true, (bool)false, (bool)true}))) == (2)); assert(candidate((std::vector<...
multipl-e_mbpp-cpp_data_mbpp_106_add_lists
#include<assert.h> #include<bits/stdc++.h> // Write a function to append the given vector to the given tuples. std::tuple<long, long, long, long, long> add_lists(std::vector<long> test_list, std::tuple<long, long> test_tup) { } int main() { auto candidate = add_lists; assert(candidate((std::vector<long>({(lon...
multipl-e_mbpp-cpp_data_mbpp_108_merge_sorted_list
#include<assert.h> #include<bits/stdc++.h> // Write a function to merge three vectors into a single sorted vector. std::vector<long> merge_sorted_list(std::vector<long> num1, std::vector<long> num2, std::vector<long> num3) { } int main() { auto candidate = merge_sorted_list; assert(candidate((std::vector<long...
multipl-e_mbpp-cpp_data_mbpp_109_odd_Equivalent
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to find the number of numbers with an odd value when rotating a binary string the given number of times. long odd_Equivalent(std::string s, long n) { } int main() { auto candidate = odd_Equivalent; assert(candidate(("011001"), (6)) == (3))...
multipl-e_mbpp-cpp_data_mbpp_113_check_integer
#include<assert.h> #include<bits/stdc++.h> // Write a function to check if a string represents an integer or not. bool check_integer(std::string text) { } int main() { auto candidate = check_integer; assert(candidate(("python")) == (false)); assert(candidate(("1")) == (true)); assert(candidate(("12345...
multipl-e_mbpp-cpp_data_mbpp_116_tuple_to_int
#include<assert.h> #include<bits/stdc++.h> // Write a function to convert a given tuple of positive integers into a single integer. long tuple_to_int(std::tuple<long, long, long> nums) { } int main() { auto candidate = tuple_to_int; assert(candidate((std::make_tuple(1, 2, 3))) == (123)); assert(candidate(...
multipl-e_mbpp-cpp_data_mbpp_117_list_to_float
#include<assert.h> #include<bits/stdc++.h> // Write a function to convert all possible convertible elements in a vector of vectors to floats. std::vector<std::tuple<float, float>> list_to_float(std::vector<std::tuple<std::string, std::string>> test_list) { } int main() { auto candidate = list_to_float; assert...
multipl-e_mbpp-cpp_data_mbpp_118_string_to_list
#include<assert.h> #include<bits/stdc++.h> // Write a function to convert a string to a vector of strings split on the space character. std::vector<std::string> string_to_list(std::string string) { } int main() { auto candidate = string_to_list; assert(candidate(("python programming")) == (std::vector<std::st...
multipl-e_mbpp-cpp_data_mbpp_119_search
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to find the element that appears only once in a sorted vector. long search(std::vector<long> arr) { } int main() { auto candidate = search; assert(candidate((std::vector<long>({(long)1, (long)1, (long)2, (long)2, (long)3}))) == (3)); a...
multipl-e_mbpp-cpp_data_mbpp_120_max_product_tuple
#include<assert.h> #include<bits/stdc++.h> // Write a function to find the maximum absolute product between numbers in pairs of tuples within a given vector. long max_product_tuple(std::vector<std::tuple<long, long>> list1) { } int main() { auto candidate = max_product_tuple; assert(candidate((std::vector<std...
multipl-e_mbpp-cpp_data_mbpp_123_amicable_numbers_sum
#include<assert.h> #include<bits/stdc++.h> // Write a function to sum all amicable numbers from 1 to a specified number. long amicable_numbers_sum(long limit) { } int main() { auto candidate = amicable_numbers_sum; assert(candidate((999)) == (504)); assert(candidate((9999)) == (31626)); assert(candida...
multipl-e_mbpp-cpp_data_mbpp_125_find_length
#include<assert.h> #include<bits/stdc++.h> // Write a function to find the maximum difference between the number of 0s and number of 1s in any sub-string of the given binary string. long find_length(std::string string) { } int main() { auto candidate = find_length; assert(candidate(("11000010001")) == (6)); ...
multipl-e_mbpp-cpp_data_mbpp_126_sum
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to find the sum of common divisors of two given numbers. long sum(long a, long b) { } int main() { auto candidate = sum; assert(candidate((10), (15)) == (6)); assert(candidate((100), (150)) == (93)); assert(candidate((4), (6)) == (...
multipl-e_mbpp-cpp_data_mbpp_127_multiply_int
#include<assert.h> #include<bits/stdc++.h> // Write a function to multiply two integers. long multiply_int(long x, long y) { } int main() { auto candidate = multiply_int; assert(candidate((10), (20)) == (200)); assert(candidate((5), (10)) == (50)); assert(candidate((4), (8)) == (32)); }
multipl-e_mbpp-cpp_data_mbpp_128_long_words
#include<assert.h> #include<bits/stdc++.h> // Write a function to find words that are longer than n characters from a given vector of words. std::vector<std::string> long_words(long n, std::string str) { } int main() { auto candidate = long_words; assert(candidate((3), ("python is a programming language")) ==...
multipl-e_mbpp-cpp_data_mbpp_129_magic_square_test
#include<assert.h> #include<bits/stdc++.h> // Write a function to calculate whether the matrix is a magic square. bool magic_square_test(std::vector<std::vector<long>> my_matrix) { } int main() { auto candidate = magic_square_test; assert(candidate((std::vector<std::vector<long>>({(std::vector<long>)std::vect...
multipl-e_mbpp-cpp_data_mbpp_130_max_occurrences
#include<assert.h> #include<bits/stdc++.h> // Write a function to find the item with maximum frequency in a given vector. long max_occurrences(std::vector<long> nums) { } int main() { auto candidate = max_occurrences; assert(candidate((std::vector<long>({(long)2, (long)3, (long)8, (long)4, (long)7, (long)9, (...
multipl-e_mbpp-cpp_data_mbpp_131_reverse_vowels
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to reverse only the vowels of a given string (where y is not a vowel). std::string reverse_vowels(std::string str1) { } int main() { auto candidate = reverse_vowels; assert(candidate(("Python")) == ("Python")); assert(candidate(("USA")...
multipl-e_mbpp-cpp_data_mbpp_132_tup_string
#include<assert.h> #include<bits/stdc++.h> // Write a function to convert a vector to a string. std::string tup_string(std::vector<std::string> tup1) { } int main() { auto candidate = tup_string; assert(candidate((std::vector<std::string>({(std::string)"e", (std::string)"x", (std::string)"e", (std::string)"r"...
multipl-e_mbpp-cpp_data_mbpp_133_sum_negativenum
#include<assert.h> #include<bits/stdc++.h> // Write a function to calculate the sum of the negative numbers of a given vector of numbers. long sum_negativenum(std::vector<long> nums) { } int main() { auto candidate = sum_negativenum; assert(candidate((std::vector<long>({(long)2, (long)4, (long)-6, (long)-9, (...
multipl-e_mbpp-cpp_data_mbpp_135_hexagonal_num
#include<assert.h> #include<bits/stdc++.h> // Write a function to find the nth hexagonal number. long hexagonal_num(long n) { } int main() { auto candidate = hexagonal_num; assert(candidate((10)) == (190)); assert(candidate((5)) == (45)); assert(candidate((7)) == (91)); }
multipl-e_mbpp-cpp_data_mbpp_138_is_Sum_Of_Powers_Of_Two
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to check whether the given number can be represented as sum of non-zero powers of 2 or not. bool is_Sum_Of_Powers_Of_Two(long n) { } int main() { auto candidate = is_Sum_Of_Powers_Of_Two; assert(candidate((10)) == (true)); assert(candi...
multipl-e_mbpp-cpp_data_mbpp_141_pancake_sort
#include<assert.h> #include<bits/stdc++.h> // Write a function to sort a vector of elements. std::vector<long> pancake_sort(std::vector<long> nums) { } int main() { auto candidate = pancake_sort; assert(candidate((std::vector<long>({(long)15, (long)79, (long)25, (long)38, (long)69}))) == (std::vector<long>({(...
multipl-e_mbpp-cpp_data_mbpp_142_count_samepair
#include<assert.h> #include<bits/stdc++.h> // Write a function to count number items that are identical in the same position of three given vectors. long count_samepair(std::vector<long> list1, std::vector<long> list2, std::vector<long> list3) { } int main() { auto candidate = count_samepair; assert(candidate...
multipl-e_mbpp-cpp_data_mbpp_143_find_lists
#include<assert.h> #include<bits/stdc++.h> // Write a function to find number of vectors present in the given vector. long find_lists(std::vector<std::any> Input) { } int main() { auto candidate = find_lists; assert(candidate((std::vector<std::any>({(std::vector<long>)std::vector<long>({(long)1, (long)2, (lon...
multipl-e_mbpp-cpp_data_mbpp_145_max_Abs_Diff
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to find the maximum difference between any two elements in a given vector. long max_Abs_Diff(std::vector<long> arr) { } int main() { auto candidate = max_Abs_Diff; assert(candidate((std::vector<long>({(long)2, (long)1, (long)5, (long)3})))...
multipl-e_mbpp-cpp_data_mbpp_160_find_solution
#include<assert.h> #include<bits/stdc++.h> // Write a function that returns integers x and y that satisfy ax + by = n as a tuple, or return None if no solution exists. std::optional<std::tuple<long, long>> find_solution(long a, long b, long n) { } int main() { auto candidate = find_solution; assert(candidate(...
multipl-e_mbpp-cpp_data_mbpp_161_remove_elements
#include<assert.h> #include<bits/stdc++.h> // Write a function to remove all elements from a given vector present in another vector. std::vector<long> remove_elements(std::vector<long> list1, std::vector<long> list2) { } int main() { auto candidate = remove_elements; assert(candidate((std::vector<long>({(long...
multipl-e_mbpp-cpp_data_mbpp_162_sum_series
#include<assert.h> #include<bits/stdc++.h> // Write a function to calculate the sum (n - 2*i) from i=0 to n // 2, for instance n + (n-2) + (n-4)... (until n-x =< 0). long sum_series(long n) { } int main() { auto candidate = sum_series; assert(candidate((6)) == (12)); assert(candidate((10)) == (30)); a...
multipl-e_mbpp-cpp_data_mbpp_164_are_equivalent
#include<assert.h> #include<bits/stdc++.h> // Write a function to determine if the sum of the divisors of two integers are the same. bool are_equivalent(long num1, long num2) { } int main() { auto candidate = are_equivalent; assert(candidate((36), (57)) == (false)); assert(candidate((2), (4)) == (false));...
multipl-e_mbpp-cpp_data_mbpp_165_count_char_position
#include<assert.h> #include<bits/stdc++.h> // Write a function to count the number of characters in a string that occur at the same position in the string as in the English alphabet (case insensitive). long count_char_position(std::string str1) { } int main() { auto candidate = count_char_position; assert(can...
multipl-e_mbpp-cpp_data_mbpp_166_find_even_pair
#include<assert.h> #include<bits/stdc++.h> // Write a function that counts the number of pairs of integers in a vector that xor to an even number. long find_even_pair(std::vector<long> A) { } int main() { auto candidate = find_even_pair; assert(candidate((std::vector<long>({(long)5, (long)4, (long)7, (long)2,...
multipl-e_mbpp-cpp_data_mbpp_167_next_power_of_2
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to find the smallest power of 2 greater than or equal to n. long next_power_of_2(long n) { } int main() { auto candidate = next_power_of_2; assert(candidate((0)) == (1)); assert(candidate((5)) == (8)); assert(candidate((17)) == (32...
multipl-e_mbpp-cpp_data_mbpp_168_frequency
#include<assert.h> #include<bits/stdc++.h> // Write a function to count the number of occurrences of a number in a given vector. long frequency(std::vector<long> a, long x) { } int main() { auto candidate = frequency; assert(candidate((std::vector<long>({(long)1, (long)2, (long)3})), (4)) == (0)); assert(...
multipl-e_mbpp-cpp_data_mbpp_170_sum_range_list
#include<assert.h> #include<bits/stdc++.h> // Write a function to find the sum of numbers in a vector within a range specified by two indices. long sum_range_list(std::vector<long> list1, long m, long n) { } int main() { auto candidate = sum_range_list; assert(candidate((std::vector<long>({(long)2, (long)1, (...
multipl-e_mbpp-cpp_data_mbpp_171_perimeter_pentagon
#include<assert.h> #include<bits/stdc++.h> // Write a function to find the perimeter of a regular pentagon from the length of its sides. long perimeter_pentagon(long a) { } int main() { auto candidate = perimeter_pentagon; assert(candidate((5)) == (25)); assert(candidate((10)) == (50)); assert(candida...
multipl-e_mbpp-cpp_data_mbpp_172_count_occurance
#include<assert.h> #include<bits/stdc++.h> // Write a function to count the number of occurence of the string 'std' in a given string. long count_occurance(std::string s) { } int main() { auto candidate = count_occurance; assert(candidate(("letstdlenstdporstd")) == (3)); assert(candidate(("truststdsolensp...
multipl-e_mbpp-cpp_data_mbpp_222_check_type
#include<assert.h> #include<bits/stdc++.h> // Write a function to check if all the elements in tuple have same data type or not. bool check_type(std::any test_tuple) { } int main() { auto candidate = check_type; assert(candidate(std::make_tuple(5, 6, 7, 3, 5, 6)) == (true)); assert(candidate(std::make_tup...
multipl-e_mbpp-cpp_data_mbpp_223_is_majority
#include<assert.h> #include<bits/stdc++.h> // Write a function that takes in a sorted vector, its length (n), and an element and returns whether the element is the majority element in the given sorted vector. (The majority element is the element that occurs more than n/2 times.) bool is_majority(std::vector<long> arr, ...
multipl-e_mbpp-cpp_data_mbpp_224_count_Set_Bits
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to count the number of set bits (binary digits with value 1) in a given number. long count_Set_Bits(long n) { } int main() { auto candidate = count_Set_Bits; assert(candidate((2)) == (1)); assert(candidate((4)) == (1)); assert(cand...
multipl-e_mbpp-cpp_data_mbpp_226_odd_values_string
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to remove the characters which have odd index values of a given string. std::string odd_values_string(std::string str) { } int main() { auto candidate = odd_values_string; assert(candidate(("abcdef")) == ("ace")); assert(candidate(("py...
multipl-e_mbpp-cpp_data_mbpp_227_min_of_three
#include<assert.h> #include<bits/stdc++.h> // Write a function to find minimum of three numbers. long min_of_three(long a, long b, long c) { } int main() { auto candidate = min_of_three; assert(candidate((10), (20), (0)) == (0)); assert(candidate((19), (15), (18)) == (15)); assert(candidate((-10), (-2...
multipl-e_mbpp-cpp_data_mbpp_228_all_Bits_Set_In_The_Given_Range
#include<assert.h> #include<bits/stdc++.h> // Write a cppthon function to check whether all the bits are unset in the given range or not. bool all_Bits_Set_In_The_Given_Range(long n, long l, long r) { } int main() { auto candidate = all_Bits_Set_In_The_Given_Range; assert(candidate((4), (1), (2)) == (true)); ...
multipl-e_mbpp-cpp_data_mbpp_229_re_arrange_array
#include<assert.h> #include<bits/stdc++.h> // Write a function that takes in a vector and an integer n, and re-arranges the first n elements of the given vector so that all negative elements appear before positive ones, and where the relative order among negative and positive elements is preserved. std::vector<long> re...
multipl-e_mbpp-cpp_data_mbpp_230_replace_blank
#include<assert.h> #include<bits/stdc++.h> // Write a function that takes in a string and character, replaces blank spaces in the string with the character, and returns the string. std::string replace_blank(std::string str1, std::string char) { } int main() { auto candidate = replace_blank; assert(candidate((...
multipl-e_mbpp-cpp_data_mbpp_234_volume_cube
#include<assert.h> #include<bits/stdc++.h> // Write a function to find the volume of a cube given its side length. long volume_cube(long l) { } int main() { auto candidate = volume_cube; assert(candidate((3)) == (27)); assert(candidate((2)) == (8)); assert(candidate((5)) == (125)); }