Dataset Viewer
Auto-converted to Parquet Duplicate
id
stringlengths
26
28
content
stringlengths
332
3.27k
humaneval-x-cpp_data_CPP_0
#undef NDEBUG #include<assert.h> int main(){ vector<float> a={1.0, 2.0, 3.9, 4.0, 5.0, 2.2}; assert (has_close_elements(a, 0.3)==true); assert (has_close_elements(a, 0.05) == false); assert (has_close_elements({1.0, 2.0, 5.9, 4.0, 5.0}, 0.95) == true); assert (has_close_elements({1.0, 2.0, 5.9, 4.0...
humaneval-x-cpp_data_CPP_1
#undef NDEBUG #include<assert.h> bool issame(vector<string> a,vector<string>b){ if (a.size()!=b.size()) return false; for (int i=0;i<a.size();i++) { if (a[i]!=b[i]) return false; } return true; } int main(){ assert (issame(separate_paren_groups("(()()) ((())) () ((())()())"),{"(()())", "((...
humaneval-x-cpp_data_CPP_2
#undef NDEBUG #include<assert.h> int main(){ assert (truncate_number(3.5) == 0.5); assert (abs(truncate_number(1.33) - 0.33) < 1e-4); assert (abs(truncate_number(123.456) - 0.456) < 1e-4); } /* Given a positive floating point number, it can be decomposed into and integer part (largest integer smaller than given n...
humaneval-x-cpp_data_CPP_3
#undef NDEBUG #include<assert.h> int main(){ assert (below_zero({}) == false); assert (below_zero({1, 2, -3, 1, 2, -3}) == false); assert (below_zero({1, 2, -4, 5, 6}) == true); assert (below_zero({1, -1, 2, -2, 5, -5, 4, -4}) == false); assert (below_zero({1, -1, 2, -2, 5, -5, 4, -5}) == true); ...
humaneval-x-cpp_data_CPP_4
#undef NDEBUG #include<assert.h> int main(){ assert (abs(mean_absolute_deviation({1.0, 2.0, 3.0}) - 2.0/3.0) < 1e-4); assert (abs(mean_absolute_deviation({1.0, 2.0, 3.0, 4.0}) - 1.0) < 1e-4); assert (abs(mean_absolute_deviation({1.0, 2.0, 3.0, 4.0, 5.0}) - 6.0/5.0) < 1e-4); } /* For a given vector of input...
humaneval-x-cpp_data_CPP_5
#undef NDEBUG #include<assert.h> bool issame(vector<int> a,vector<int>b){ if (a.size()!=b.size()) return false; for (int i=0;i<a.size();i++) { if (a[i]!=b[i]) return false; } return true; } int main(){ assert (issame(intersperse({}, 7), {})); assert (issame(intersperse({5, 6, 3,...
humaneval-x-cpp_data_CPP_6
#undef NDEBUG #include<assert.h> bool issame(vector<int> a,vector<int>b){ if (a.size()!=b.size()) return false; for (int i=0;i<a.size();i++) { if (a[i]!=b[i]) return false; } return true; } int main(){ assert (issame(parse_nested_parens("(()()) ((())) () ((())()())"),{2, 3, 1, 3})); ...
humaneval-x-cpp_data_CPP_7
#undef NDEBUG #include<assert.h> bool issame(vector<string> a,vector<string>b){ if (a.size()!=b.size()) return false; for (int i=0;i<a.size();i++) { if (a[i]!=b[i]) return false; } return true; } int main(){ assert (issame(filter_by_substring({}, "john"),{})); assert (issame(filter_by_s...
humaneval-x-cpp_data_CPP_8
#undef NDEBUG #include<assert.h> bool issame(vector<int> a,vector<int>b){ if (a.size()!=b.size()) return false; for (int i=0;i<a.size();i++) { if (a[i]!=b[i]) return false; } return true; } int main(){ assert (issame(sum_product({}) ,{0, 1})); assert (issame(sum_product({1, 1, 1}), {...
humaneval-x-cpp_data_CPP_9
#undef NDEBUG #include<assert.h> bool issame(vector<int> a,vector<int>b){ if (a.size()!=b.size()) return false; for (int i=0;i<a.size();i++) { if (a[i]!=b[i]) return false; } return true; } int main(){ assert (issame(rolling_max({}),{})); assert (issame(rolling_max({1, 2, 3, 4}) , {...
humaneval-x-cpp_data_CPP_10
#undef NDEBUG #include<assert.h> int main(){ assert (make_palindrome("") == ""); assert (make_palindrome("x") == "x"); assert (make_palindrome("xyz") == "xyzyx"); assert (make_palindrome("xyx") == "xyx") ; assert (make_palindrome("jerry") == "jerryrrej"); } #include<stdio.h> #include<string> ...
humaneval-x-cpp_data_CPP_11
#undef NDEBUG #include<assert.h> int main(){ assert (string_xor("111000", "101010") == "010010"); assert (string_xor("1", "1") == "0"); assert (string_xor("0101", "0000") == "0101"); } /* Input are two strings a and b consisting only of 1s and 0s. Perform binary XOR on these inputs and return result als...
humaneval-x-cpp_data_CPP_12
#undef NDEBUG #include<assert.h> int main(){ assert (longest({}) == ""); assert (longest({"x", "y", "z"}) == "x"); assert (longest({"x", "yyy", "zzzz", "www", "kkkk", "abc"}) == "zzzz"); } /* Out of vector of strings, return the longest one. Return the first one in case of multiple strings of the same len...
humaneval-x-cpp_data_CPP_13
#undef NDEBUG #include<assert.h> int main(){ assert (greatest_common_divisor(3, 7) == 1); assert (greatest_common_divisor(10, 15) == 5); assert (greatest_common_divisor(49, 14) == 7); assert (greatest_common_divisor(144, 60) == 12); } /* Return a greatest common divisor of two integers a and b >>>...
humaneval-x-cpp_data_CPP_14
#undef NDEBUG #include<assert.h> bool issame(vector<string> a,vector<string>b){ if (a.size()!=b.size()) return false; for (int i=0;i<a.size();i++) { if (a[i]!=b[i]) return false; } return true; } int main(){ assert (issame(all_prefixes(""),{})); assert (issame(all_prefixes("asdfgh") ,{"a...
humaneval-x-cpp_data_CPP_15
#undef NDEBUG #include<assert.h> int main(){ assert (string_sequence(0) == "0"); assert (string_sequence(3) == "0 1 2 3"); assert (string_sequence(10) == "0 1 2 3 4 5 6 7 8 9 10"); } /* Return a string containing space-delimited numbers starting from 0 upto n inclusive. >>> string_sequence(0) "0" >>> str...
humaneval-x-cpp_data_CPP_16
#undef NDEBUG #include<assert.h> int main(){ assert (count_distinct_characters("") == 0); assert (count_distinct_characters("abcde") == 5); assert (count_distinct_characters("abcdecadeCADE") == 5); assert (count_distinct_characters("aaaaAAAAaaaa") == 1); assert (count_distinct_characters("Jerry jERR...
humaneval-x-cpp_data_CPP_17
#undef NDEBUG #include<assert.h> bool issame(vector<int> a,vector<int>b){ if (a.size()!=b.size()) return false; for (int i=0;i<a.size();i++) { if (a[i]!=b[i]) return false; } return true; } int main(){ assert (issame(parse_music("") , {})); assert (issame(parse_music("o o o o") ,{4,...
humaneval-x-cpp_data_CPP_18
#undef NDEBUG #include<assert.h> int main(){ assert (how_many_times("", "x") == 0); assert (how_many_times("xyxyxyx", "x") == 4); assert (how_many_times("cacacacac", "cac") == 4); assert (how_many_times("john doe", "john") == 1); } /* Find how many times a given substring can be found in the original...
humaneval-x-cpp_data_CPP_19
#undef NDEBUG #include<assert.h> int main(){ assert (sort_numbers("") == ""); assert (sort_numbers("three") == "three"); assert (sort_numbers("three five nine") == "three five nine"); assert (sort_numbers("five zero four seven nine eight") == "zero four five seven eight nine"); assert (sort_numbe...
humaneval-x-cpp_data_CPP_20
#undef NDEBUG #include<assert.h> bool issame(vector<float> a,vector<float>b){ if (a.size()!=b.size()) return false; for (int i=0;i<a.size();i++) { if (abs(a[i]-b[i])>1e-4) return false; } return true; } int main(){ assert (issame(find_closest_elements({1.0, 2.0, 3.9, 4.0, 5.0, 2.2}) , {3...
humaneval-x-cpp_data_CPP_21
#undef NDEBUG #include<assert.h> bool issame(vector<float> a,vector<float>b){ if (a.size()!=b.size()) return false; for (int i=0;i<a.size();i++) { if (abs(a[i]-b[i])>1e-4) return false; } return true; } int main(){ assert (issame(rescale_to_unit({2.0, 49.9}) , {0.0, 1.0})); assert (...
humaneval-x-cpp_data_CPP_22
#undef NDEBUG #include<assert.h> bool issame(vector<int> a,vector<int>b){ if (a.size()!=b.size()) return false; for (int i=0;i<a.size();i++) { if (a[i]!=b[i]) return false; } return true; } int main(){ assert (issame(filter_integers({}),{})); assert (issame(filter_integers({4, {},2...
humaneval-x-cpp_data_CPP_23
#undef NDEBUG #include<assert.h> int main(){ assert (strlen("") == 0); assert (strlen("x") == 1); assert (strlen("asdasnakj") == 9); } /* Return length of given string >>> strlen("") 0 >>> strlen("abc") 3 */ #include<stdio.h> #include<string> using namespace std; int strlen(string str){ return str....
humaneval-x-cpp_data_CPP_24
#undef NDEBUG #include<assert.h> int main(){ assert (largest_divisor(3) == 1); assert (largest_divisor(7) == 1); assert (largest_divisor(10) == 5); assert (largest_divisor(100) == 50); assert (largest_divisor(49) == 7); } /* For a given number n, find the largest number that divides n evenly, smal...
humaneval-x-cpp_data_CPP_25
#undef NDEBUG #include<assert.h> bool issame(vector<int> a,vector<int>b){ if (a.size()!=b.size()) return false; for (int i=0;i<a.size();i++) { if (a[i]!=b[i]) return false; } return true; } int main(){ assert (issame(factorize(2) , {2})); assert (issame(factorize(4) , {2, 2})); a...
humaneval-x-cpp_data_CPP_26
#undef NDEBUG #include<assert.h> bool issame(vector<int> a,vector<int>b){ if (a.size()!=b.size()) return false; for (int i=0;i<a.size();i++) { if (a[i]!=b[i]) return false; } return true; } int main(){ assert (issame(remove_duplicates({}) , {})); assert (issame(remove_duplicates({1,...
humaneval-x-cpp_data_CPP_27
#undef NDEBUG #include<assert.h> int main(){ assert (filp_case("") == ""); assert (filp_case("Hello!") == "hELLO!"); assert (filp_case("These violent delights have violent ends") == "tHESE VIOLENT DELIGHTS HAVE VIOLENT ENDS"); } /* For a given string, flip lowercase characters to uppercase and uppercase t...
humaneval-x-cpp_data_CPP_28
#undef NDEBUG #include<assert.h> int main(){ assert (concatenate({}) == ""); assert (concatenate({"x", "y", "z"}) == "xyz"); assert (concatenate({"x", "y", "z", "w", "k"}) == "xyzwk"); } /* Concatenate vector of strings into a single string >>> concatenate({}) "" >>> concatenate({"a", "b", "c"}) "abc" */...
humaneval-x-cpp_data_CPP_29
#undef NDEBUG #include<assert.h> bool issame(vector<string> a,vector<string>b){ if (a.size()!=b.size()) return false; for (int i=0;i<a.size();i++) { if (a[i]!=b[i]) return false; } return true; } int main(){ assert (issame(filter_by_prefix({}, "john") , {})); assert (issame(filter_by_pre...
humaneval-x-cpp_data_CPP_30
#undef NDEBUG #include<assert.h> bool issame(vector<float> a,vector<float>b){ if (a.size()!=b.size()) return false; for (int i=0;i<a.size();i++) { if (abs(a[i]-b[i])>1e-4) return false; } return true; } int main(){ assert (issame(get_positive({-1, -2, 4, 5, 6}) , {4, 5, 6} )); assert...
humaneval-x-cpp_data_CPP_31
#undef NDEBUG #include<assert.h> int main(){ assert (is_prime(6) == false); assert (is_prime(101) == true); assert (is_prime(11) == true); assert (is_prime(13441) == true); assert (is_prime(61) == true); assert (is_prime(4) == false); assert (is_prime(1) == false); assert (is_prime(5) ==...
humaneval-x-cpp_data_CPP_32
#undef NDEBUG #include<assert.h> int main(){ double solution; int ncoeff; for (int i=0;i<100;i++) { ncoeff = 2 * (1+rand()%4); vector<double> coeffs = {}; for (int j=0;j<ncoeff;j++) { double coeff = -10+rand()%21; if (coeff == 0) coeff = 1; ...
humaneval-x-cpp_data_CPP_33
#undef NDEBUG #include<assert.h> bool issame(vector<int> a,vector<int>b){ if (a.size()!=b.size()) return false; for (int i=0;i<a.size();i++) { if (a[i]!=b[i]) return false; } return true; } int main(){ assert (issame(sort_third({1, 2, 3}) , sort_third({1, 2, 3}))); assert (issame(sor...
humaneval-x-cpp_data_CPP_34
#undef NDEBUG #include<assert.h> bool issame(vector<int> a,vector<int>b){ if (a.size()!=b.size()) return false; for (int i=0;i<a.size();i++) { if (a[i]!=b[i]) return false; } return true; } int main(){ assert (issame(unique({5, 3, 5, 2, 3, 3, 9, 0, 123}) , {0, 2, 3, 5, 9, 123})); } /* ...
humaneval-x-cpp_data_CPP_35
#undef NDEBUG #include<assert.h> int main(){ assert (abs(max_element({1, 2, 3})- 3)<1e-4); assert (abs(max_element({5, 3, -5, 2, -3, 3, 9, 0, 124, 1, -10})- 124)<1e-4); } /* Return maximum element in the vector. >>> max_element({1, 2, 3}) 3 >>> max_element({5, 3, -5, 2, -3, 3, 9, 0, 123, 1, -10}) 123 */ #incl...
humaneval-x-cpp_data_CPP_36
#undef NDEBUG #include<assert.h> int main(){ assert (fizz_buzz(50) == 0); assert (fizz_buzz(78) == 2); assert (fizz_buzz(79) == 3); assert (fizz_buzz(100) == 3); assert (fizz_buzz(200) == 6); assert (fizz_buzz(4000) == 192); assert (fizz_buzz(10000) == 639); assert (fizz_buzz(100000) == ...
humaneval-x-cpp_data_CPP_37
#undef NDEBUG #include<assert.h> bool issame(vector<float> a,vector<float>b){ if (a.size()!=b.size()) return false; for (int i=0;i<a.size();i++) { if (abs(a[i]-b[i])>1e-4) return false; } return true; } int main(){ assert (issame(sort_even({1, 2, 3}), {1, 2, 3})); assert (issame(sort...
humaneval-x-cpp_data_CPP_38
#undef NDEBUG #include<assert.h> int main(){ for (int i=0;i<100;i++) { int l=10+rand()%11; string str=""; for (int j=0;j<l;j++) { char chr=97+rand()%26; str+=chr; } string encoded_str = encode_cyclic(str); assert (decode_cycli...
humaneval-x-cpp_data_CPP_39
#undef NDEBUG #include<assert.h> int main(){ assert (prime_fib(1) == 2); assert (prime_fib(2) == 3); assert (prime_fib(3) == 5); assert (prime_fib(4) == 13); assert (prime_fib(5) == 89); assert (prime_fib(6) == 233); assert (prime_fib(7) == 1597); assert (prime_fib(8) == 28657); asse...
humaneval-x-cpp_data_CPP_40
#undef NDEBUG #include<assert.h> int main(){ assert (triples_sum_to_zero({1, 3, 5, 0}) == false); assert (triples_sum_to_zero({1, 3, 5, -1}) == false); assert (triples_sum_to_zero({1, 3, -2, 1}) == true); assert (triples_sum_to_zero({1, 2, 3, 7}) == false); assert (triples_sum_to_zero({1, 2, 5, 7}) ...
humaneval-x-cpp_data_CPP_41
#undef NDEBUG #include<assert.h> int main(){ assert (car_race_collision(2) == 4); assert (car_race_collision(3) == 9); assert (car_race_collision(4) == 16); assert (car_race_collision(8) == 64); assert (car_race_collision(10) == 100); } /* Imagine a road that's a perfectly straight infinitely long...
humaneval-x-cpp_data_CPP_42
#undef NDEBUG #include<assert.h> bool issame(vector<int> a,vector<int>b){ if (a.size()!=b.size()) return false; for (int i=0;i<a.size();i++) { if (a[i]!=b[i]) return false; } return true; } int main(){ assert (issame(incr_list({}) , {})); assert (issame(incr_list({3, 2, 1}) , {4, 3, ...
humaneval-x-cpp_data_CPP_43
#undef NDEBUG #include<assert.h> int main(){ assert (pairs_sum_to_zero({1, 3, 5, 0}) == false); assert (pairs_sum_to_zero({1, 3, -2, 1}) == false); assert (pairs_sum_to_zero({1, 2, 3, 7}) == false); assert (pairs_sum_to_zero({2, 4, -5, 3, 5, 7}) == true); assert (pairs_sum_to_zero({1}) == false); ...
humaneval-x-cpp_data_CPP_44
#undef NDEBUG #include<assert.h> int main(){ assert (change_base(8, 3) == "22"); assert (change_base(9, 3) == "100"); assert (change_base(234, 2) == "11101010"); assert (change_base(16, 2) == "10000"); assert (change_base(8, 2) == "1000"); assert (change_base(7, 2) == "111"); for (int x=2;x<...
humaneval-x-cpp_data_CPP_45
#undef NDEBUG #include<assert.h> int main(){ assert (abs(triangle_area(5, 3) - 7.5)<1e-4); assert (abs(triangle_area(2, 2) - 2.0)<1e-4); assert (abs(triangle_area(10, 8) - 40.0)<1e-4); } /* Given length of a side and high return area for a triangle. >>> triangle_area(5, 3) 7.5 */ #include<stdio.h> #includ...
humaneval-x-cpp_data_CPP_46
#undef NDEBUG #include<assert.h> int main(){ assert (fib4(5) == 4); assert (fib4(8) == 28); assert (fib4(10) == 104); assert (fib4(12) == 386); } /* 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 ...
humaneval-x-cpp_data_CPP_47
#undef NDEBUG #include<assert.h> int main(){ assert (abs(median({3, 1, 2, 4, 5}) - 3)<1e-4); assert (abs(median({-10, 4, 6, 1000, 10, 20}) -8.0)<1e-4); assert (abs(median({5}) - 5)<1e-4); assert (abs(median({6, 5}) - 5.5)<1e-4); assert (abs(median({8, 1, 3, 9, 9, 2, 7}) - 7)<1e-4 ); } /* Return me...
humaneval-x-cpp_data_CPP_48
#undef NDEBUG #include<assert.h> int main(){ assert (is_palindrome("") == true); assert (is_palindrome("aba") == true); assert (is_palindrome("aaaaa") == true); assert (is_palindrome("zbcd") == false); assert (is_palindrome("xywyx") == true); assert (is_palindrome("xywyz") == false); assert ...
humaneval-x-cpp_data_CPP_49
#undef NDEBUG #include<assert.h> int main(){ assert (modp(3, 5) == 3); assert (modp(1101, 101) == 2); assert (modp(0, 101) == 1); assert (modp(3, 11) == 8); assert (modp(100, 101) == 1); assert (modp(30, 5) == 4); assert (modp(31, 5) == 3); } /* Return 2^n modulo p (be aware of numerics). ...
humaneval-x-cpp_data_CPP_50
#undef NDEBUG #include<assert.h> int main(){ for (int i=0;i<100;i++) { int l=10+rand()%11; string str=""; for (int j=0;j<l;j++) { char chr=97+rand()%26; str+=chr; } string encoded_str = encode_shift(str); assert (decode_shift(...
humaneval-x-cpp_data_CPP_51
#undef NDEBUG #include<assert.h> int main(){ assert (remove_vowels("") == ""); assert (remove_vowels("abcdef\nghijklm") == "bcdf\nghjklm"); assert (remove_vowels("fedcba") == "fdcb"); assert (remove_vowels("eeeee") == ""); assert (remove_vowels("acBAA") == "cB"); assert (remove_vowels("EcBOO") =...
humaneval-x-cpp_data_CPP_52
#undef NDEBUG #include<assert.h> int main(){ assert (below_threshold({1, 2, 4, 10}, 100)); assert (not(below_threshold({1, 20, 4, 10}, 5))); assert (below_threshold({1, 20, 4, 10}, 21)); assert (below_threshold({1, 20, 4, 10}, 22)); assert (below_threshold({1, 8, 4, 10}, 11)); assert (not(below_...
humaneval-x-cpp_data_CPP_53
#undef NDEBUG #include<assert.h> int main(){ assert (add(0, 1) == 1); assert (add(1, 0) == 1); assert (add(2, 3) == 5); assert (add(5, 7) == 12); assert (add(7, 5) == 12); for (int i=0;i<100;i+=1) { int x=rand()%1000; int y=rand()%1000; assert (add(x, y) == x + y); ...
humaneval-x-cpp_data_CPP_54
#undef NDEBUG #include<assert.h> int main(){ assert (same_chars("eabcdzzzz", "dddzzzzzzzddeddabc") == true); assert (same_chars("abcd", "dddddddabc") == true); assert (same_chars("dddddddabc", "abcd") == true); assert (same_chars("eabcd", "dddddddabc") == false); assert (same_chars("abcd", "ddddddda...
humaneval-x-cpp_data_CPP_55
#undef NDEBUG #include<assert.h> int main(){ assert (fib(10) == 55); assert (fib(1) == 1); assert (fib(8) == 21); assert (fib(11) == 89); assert (fib(12) == 144); } /* Return n-th Fibonacci number. >>> fib(10) 55 >>> fib(1) 1 >>> fib(8) 21 */ #include<stdio.h> using namespace std; int fib(int n){ ...
humaneval-x-cpp_data_CPP_56
#undef NDEBUG #include<assert.h> int main(){ assert (correct_bracketing("<>")); assert (correct_bracketing("<<><>>")); assert (correct_bracketing("<><><<><>><>")); assert (correct_bracketing("<><><<<><><>><>><<><><<>>>")); assert (not (correct_bracketing("<<<><>>>>"))); assert (not (correct_brac...
humaneval-x-cpp_data_CPP_57
#undef NDEBUG #include<assert.h> int main(){ assert (monotonic({1, 2, 4, 10}) == true); assert (monotonic({1, 2, 4, 20}) == true); assert (monotonic({1, 20, 4, 10}) == false); assert (monotonic({4, 1, 0, -10}) == true); assert (monotonic({4, 1, 1, 0}) == true); assert (monotonic({1, 2, 3, 2, 5, ...
humaneval-x-cpp_data_CPP_58
#undef NDEBUG #include<assert.h> bool issame(vector<int> a,vector<int>b){ if (a.size()!=b.size()) return false; for (int i=0;i<a.size();i++) { if (a[i]!=b[i]) return false; } return true; } int main(){ assert (issame(common({1, 4, 3, 34, 653, 2, 5}, {5, 7, 1, 5, 9, 653, 121}) , {1, 5, 65...
humaneval-x-cpp_data_CPP_59
#undef NDEBUG #include<assert.h> int main(){ assert (largest_prime_factor(15) == 5); assert (largest_prime_factor(27) == 3); assert (largest_prime_factor(63) == 7); assert (largest_prime_factor(330) == 11); assert (largest_prime_factor(13195) == 29); } /* Return the largest prime factor of n. Assu...
humaneval-x-cpp_data_CPP_60
#undef NDEBUG #include<assert.h> int main(){ assert (sum_to_n(1) == 1); assert (sum_to_n(6) == 21); assert (sum_to_n(11) == 66); assert (sum_to_n(30) == 465); assert (sum_to_n(100) == 5050); } /* sum_to_n is a function that sums numbers from 1 to n. >>> sum_to_n(30) 465 >>> sum_to_n(100) 5050 >>> ...
humaneval-x-cpp_data_CPP_61
#undef NDEBUG #include<assert.h> int main(){ assert (correct_bracketing("()")); assert (correct_bracketing("(()())")); assert (correct_bracketing("()()(()())()")); assert (correct_bracketing("()()((()()())())(()()(()))")); assert (not (correct_bracketing("((()())))"))); assert (not (correct_brac...
humaneval-x-cpp_data_CPP_62
#undef NDEBUG #include<assert.h> bool issame(vector<float> a,vector<float>b){ if (a.size()!=b.size()) return false; for (int i=0;i<a.size();i++) { if (abs(a[i]-b[i])>1e-4) return false; } return true; } int main(){ assert (issame(derivative({3, 1, 2, 4, 5}) , {1, 4, 12, 20})); assert...
humaneval-x-cpp_data_CPP_63
#undef NDEBUG #include<assert.h> int main(){ assert (fibfib(2) == 1); assert (fibfib(1) == 0); assert (fibfib(5) == 4); assert (fibfib(8) == 24); assert (fibfib(10) == 81); assert (fibfib(12) == 274); assert (fibfib(14) == 927); } /* The FibFib number sequence is a sequence similar to the ...
humaneval-x-cpp_data_CPP_64
#undef NDEBUG #include<assert.h> int main(){ assert (vowels_count("abcde") == 2); assert (vowels_count("Alone") == 3); assert (vowels_count("key") == 2); assert (vowels_count("bye") == 1); assert (vowels_count("keY") == 2); assert (vowels_count("bYe") == 1); assert (vowels_count("ACEDY") == ...
humaneval-x-cpp_data_CPP_65
#undef NDEBUG #include<assert.h> int main(){ assert (circular_shift(100, 2) == "001"); assert (circular_shift(12, 2) == "12"); assert (circular_shift(97, 8) == "79"); assert (circular_shift(12, 1) == "21"); assert (circular_shift(11, 101) == "11"); } /* Circular shift the digits of the integer x, ...
humaneval-x-cpp_data_CPP_66
#undef NDEBUG #include<assert.h> int main(){ assert (digitSum("") == 0); assert (digitSum("abAB") == 131); assert (digitSum("abcCd") == 67); assert (digitSum("helloE") == 69); assert (digitSum("woArBld") == 131); assert (digitSum("aAaaaXa") == 153); assert (digitSum(" How are yOu?") == 151);...
humaneval-x-cpp_data_CPP_67
#undef NDEBUG #include<assert.h> int main(){ assert (fruit_distribution("5 apples and 6 oranges",19) == 8); assert (fruit_distribution("5 apples and 6 oranges",21) == 10); assert (fruit_distribution("0 apples and 1 oranges",3) == 2); assert (fruit_distribution("1 apples and 0 oranges",3) == 2); asse...
humaneval-x-cpp_data_CPP_68
#undef NDEBUG #include<assert.h> bool issame(vector<int> a,vector<int>b){ if (a.size()!=b.size()) return false; for (int i=0;i<a.size();i++) { if (a[i]!=b[i]) return false; } return true; } int main(){ assert (issame(pluck({4,2,3}) , {2, 1})); assert (issame(pluck({1,2,3}) , {2, 1}))...
humaneval-x-cpp_data_CPP_69
#undef NDEBUG #include<assert.h> int main(){ assert (search({5, 5, 5, 5, 1}) == 1); assert (search({4, 1, 4, 1, 4, 4}) == 4); assert (search({3, 3}) == -1); assert (search({8, 8, 8, 8, 8, 8, 8, 8}) == 8); assert (search({2, 3, 3, 2, 2}) == 2); assert (search({2, 7, 8, 8, 4, 8, 7, 3, 9, 6, 5, 10,...
humaneval-x-cpp_data_CPP_70
#undef NDEBUG #include<assert.h> bool issame(vector<int> a,vector<int>b){ if (a.size()!=b.size()) return false; for (int i=0;i<a.size();i++) { if (a[i]!=b[i]) return false; } return true; } int main(){ assert (issame(strange_sort_list({1, 2, 3, 4}) , {1, 4, 2, 3})); assert (issame(st...
humaneval-x-cpp_data_CPP_71
#undef NDEBUG #include<assert.h> int main(){ assert (abs(triangle_area(3, 4, 5)-6.00)<0.01); assert (abs(triangle_area(1, 2, 10) +1)<0.01); assert (abs(triangle_area(4, 8, 5) -8.18)<0.01); assert (abs(triangle_area(2, 2, 2) -1.73)<0.01); assert (abs(triangle_area(1, 2, 3) +1)<0.01); assert (abs(...
humaneval-x-cpp_data_CPP_72
#undef NDEBUG #include<assert.h> int main(){ assert (will_it_fly({3, 2, 3}, 9)==true); assert (will_it_fly({1, 2}, 5) == false); assert (will_it_fly({3}, 5) == true); assert (will_it_fly({3, 2, 3}, 1) == false); assert (will_it_fly({1, 2, 3}, 6) ==false); assert (will_it_fly({5}, 5) == true); } ...
humaneval-x-cpp_data_CPP_73
#undef NDEBUG #include<assert.h> int main(){ assert (smallest_change({1,2,3,5,4,7,9,6}) == 4); assert (smallest_change({1, 2, 3, 4, 3, 2, 2}) == 1); assert (smallest_change({1, 4, 2}) == 1); assert (smallest_change({1, 4, 4, 2}) == 1); assert (smallest_change({1, 2, 3, 2, 1}) == 0); assert (smal...
humaneval-x-cpp_data_CPP_74
#undef NDEBUG #include<assert.h> bool issame(vector<string> a,vector<string>b){ if (a.size()!=b.size()) return false; for (int i=0;i<a.size();i++) { if (a[i]!=b[i]) return false; } return true; } int main(){ assert (issame(total_match({}, {}) , {})); assert (issame(total_match({"hi", "ad...
humaneval-x-cpp_data_CPP_75
#undef NDEBUG #include<assert.h> int main(){ assert (is_multiply_prime(5) == false); assert (is_multiply_prime(30) == true); assert (is_multiply_prime(8) == true); assert (is_multiply_prime(10) == false); assert (is_multiply_prime(125) == true); assert (is_multiply_prime(3 * 5 * 7) == true); ...
humaneval-x-cpp_data_CPP_76
#undef NDEBUG #include<assert.h> int main(){ assert (is_simple_power(1, 4)== true); assert (is_simple_power(2, 2)==true); assert (is_simple_power(8, 2)==true); assert (is_simple_power(3, 2)==false); assert (is_simple_power(3, 1)==false); assert (is_simple_power(5, 3)==false); assert (is_simp...
humaneval-x-cpp_data_CPP_77
#undef NDEBUG #include<assert.h> int main(){ assert (iscuber(1) == true); assert (iscuber(2) == false); assert (iscuber(-1) == true); assert (iscuber(64) == true); assert (iscuber(180) == false); assert (iscuber(1000) == true); assert (iscuber(0) == true); assert (iscuber(1729) == false)...
humaneval-x-cpp_data_CPP_78
#undef NDEBUG #include<assert.h> int main(){ assert (hex_key("AB") == 1 ); assert (hex_key("1077E") == 2 ); assert (hex_key("ABED1A33") == 4 ); assert (hex_key("2020") == 2 ); assert (hex_key("123456789ABCDEF0") == 6 ); assert (hex_key("112233445566778899AABBCCDDEEFF00") == 12 ); ...
humaneval-x-cpp_data_CPP_79
#undef NDEBUG #include<assert.h> int main(){ assert (decimal_to_binary(0) == "db0db"); assert (decimal_to_binary(32) == "db100000db"); assert (decimal_to_binary(103) == "db1100111db"); assert (decimal_to_binary(15) == "db1111db"); } /* You will be given a number in decimal form and your task is to co...
humaneval-x-cpp_data_CPP_80
#undef NDEBUG #include<assert.h> int main(){ assert (is_happy("a") == false ); assert (is_happy("aa") == false ); assert (is_happy("abcd") == true ); assert (is_happy("aabb") == false ); assert (is_happy("adb") == true ); assert (is_happy("xyy") == false ); assert (is_happy("iopaxpoi") == tr...
humaneval-x-cpp_data_CPP_81
#undef NDEBUG #include<assert.h> bool issame(vector<string> a,vector<string>b){ if (a.size()!=b.size()) return false; for (int i=0;i<a.size();i++) { if (a[i]!=b[i]) return false; } return true; } int main(){ assert (issame(numerical_letter_grade({4.0, 3, 1.7, 2, 3.5}) , {"A+", "B", "C-", "C"...
humaneval-x-cpp_data_CPP_82
#undef NDEBUG #include<assert.h> int main(){ assert (prime_length("Hello") == true); assert (prime_length("abcdcba") == true); assert (prime_length("kittens") == true); assert (prime_length("orange") == false); assert (prime_length("wow") == true); assert (prime_length("world") == true); ass...
humaneval-x-cpp_data_CPP_83
#undef NDEBUG #include<assert.h> int main(){ assert (starts_one_ends(1) == 1); assert (starts_one_ends(2) == 18); assert (starts_one_ends(3) == 180); assert (starts_one_ends(4) == 1800); assert (starts_one_ends(5) == 18000); } /* Given a positive integer n, return the count of the numbers of n-dig...
humaneval-x-cpp_data_CPP_84
#undef NDEBUG #include<assert.h> int main(){ assert (solve(1000) == "1"); assert (solve(150) == "110"); assert (solve(147) == "1100"); assert (solve(333) == "1001"); assert (solve(963) == "10010"); } /* Given a positive integer N, return the total sum of its digits in binary. Example For N = ...
humaneval-x-cpp_data_CPP_85
#undef NDEBUG #include<assert.h> int main(){ assert (add({4, 88}) == 88); assert (add({4, 5, 6, 7, 2, 122}) == 122); assert (add({4, 0, 6, 7}) == 0); assert (add({4, 4, 6, 8}) == 12); } /* Given a non-empty vector of integers lst. add the even elements that are at odd indices.. Examples: add({4,...
humaneval-x-cpp_data_CPP_86
#undef NDEBUG #include<assert.h> int main(){ assert (anti_shuffle("Hi") == "Hi"); assert (anti_shuffle("hello") == "ehllo"); assert (anti_shuffle("number") == "bemnru"); assert (anti_shuffle("abcd") == "abcd"); assert (anti_shuffle("Hello World!!!") == "Hello !!!Wdlor"); assert (anti_shuffle("")...
humaneval-x-cpp_data_CPP_87
#undef NDEBUG #include<assert.h> bool issame(vector<vector<int>> a,vector<vector<int>> b){ if (a.size()!=b.size()) return false; for (int i=0;i<a.size();i++) { if (a[i].size()!=b[i].size()) return false; for (int j=0;j<a[i].size();j++) if (a[i][j]!=b[i][j]) return false; } ...
humaneval-x-cpp_data_CPP_88
#undef NDEBUG #include<assert.h> bool issame(vector<int> a,vector<int>b){ if (a.size()!=b.size()) return false; for (int i=0;i<a.size();i++) { if (a[i]!=b[i]) return false; } return true; } int main(){ assert (issame(sort_array({}) , {})); assert (issame(sort_array({5}) , {5})); asse...
humaneval-x-cpp_data_CPP_89
#undef NDEBUG #include<assert.h> int main(){ assert (encrypt("hi") == "lm"); assert (encrypt("asdfghjkl") == "ewhjklnop"); assert (encrypt("gf") == "kj"); assert (encrypt("et") == "ix"); assert (encrypt("faewfawefaewg")=="jeiajeaijeiak"); assert (encrypt("hellomyfriend")=="lippsqcjvmirh"); a...
humaneval-x-cpp_data_CPP_90
#undef NDEBUG #include<assert.h> int main(){ assert (next_smallest({1, 2, 3, 4, 5}) == 2); assert (next_smallest({5, 1, 4, 3, 2}) == 2); assert (next_smallest({}) == -1); assert (next_smallest({1, 1}) == -1); assert (next_smallest({1,1,1,1,0}) == 1); assert (next_smallest({-35, 34, 12, -45}) == ...
humaneval-x-cpp_data_CPP_91
#undef NDEBUG #include<assert.h> int main(){ assert (is_bored("Hello world") == 0); assert (is_bored("Is the sky blue?") == 0); assert (is_bored("I love It !") == 1); assert (is_bored("bIt") == 0); assert (is_bored("I feel good today. I will be productive. will kill It") == 2); assert (is_bored(...
humaneval-x-cpp_data_CPP_92
#undef NDEBUG #include<assert.h> int main(){ assert (any_int(2, 3, 1)==true); assert (any_int(2.5, 2, 3)==false); assert (any_int(1.5, 5, 3.5)==false); assert (any_int(2, 6, 2)==false); assert (any_int(4, 2, 2)==true); assert (any_int(2.2, 2.2, 2.2)==false); assert (any_int(-4, 6, 2)==true);...
humaneval-x-cpp_data_CPP_93
#undef NDEBUG #include<assert.h> int main(){ assert (encode("TEST") == "tgst"); assert (encode("Mudasir") == "mWDCSKR"); assert (encode("YES") == "ygs"); assert (encode("This is a message") == "tHKS KS C MGSSCGG"); assert (encode("I DoNt KnOw WhAt tO WrItE") == "k dQnT kNqW wHcT Tq wRkTg"); } /* W...
humaneval-x-cpp_data_CPP_94
#undef NDEBUG #include<assert.h> int main(){ assert (skjkasdkd({0,3,2,1,3,5,7,4,5,5,5,2,181,32,4,32,3,2,32,324,4,3}) == 10); assert (skjkasdkd({1,0,1,8,2,4597,2,1,3,40,1,2,1,2,4,2,5,1}) == 25); assert (skjkasdkd({1,3,1,32,5107,34,83278,109,163,23,2323,32,30,1,9,3}) == 13); assert (skjkasdkd({0,724,32,71...
humaneval-x-cpp_data_CPP_95
#undef NDEBUG #include<assert.h> int main(){ assert (check_dict_case({{"p","pineapple"}, {"b","banana"}}) == true); assert (check_dict_case({{"p","pineapple"}, {"A","banana"}, {"B","banana"}}) == false); assert (check_dict_case({{"p","pineapple"}, {"5","banana"}, {"a","apple"}}) == false); assert (check...
humaneval-x-cpp_data_CPP_96
#undef NDEBUG #include<assert.h> bool issame(vector<int> a,vector<int>b){ if (a.size()!=b.size()) return false; for (int i=0;i<a.size();i++) { if (a[i]!=b[i]) return false; } return true; } int main(){ assert (issame(count_up_to(5) , {2,3})); assert (issame(count_up_to(6) , {2,3,5})); ...
humaneval-x-cpp_data_CPP_97
#undef NDEBUG #include<assert.h> int main(){ assert (multiply(148, 412) == 16 ); assert (multiply(19, 28) == 72 ); assert (multiply(2020, 1851) == 0); assert (multiply(14,-15) == 20 ); assert (multiply(76, 67) == 42 ); assert (multiply(17, 27) == 49 ); assert ...
humaneval-x-cpp_data_CPP_98
#undef NDEBUG #include<assert.h> int main(){ assert (count_upper("aBCdEf") == 1); assert (count_upper("abcdefg") == 0); assert (count_upper("dBBE") == 0); assert (count_upper("B") == 0); assert (count_upper("U") == 1); assert (count_upper("") == 0); assert (count_upper("EEEE") == 2); } ...
humaneval-x-cpp_data_CPP_99
#undef NDEBUG #include<assert.h> int main(){ assert (closest_integer("10") == 10); assert (closest_integer("14.5") == 15); assert (closest_integer("-15.5") == -16); assert (closest_integer("15.3") == 15); assert (closest_integer("0") == 0); } /* Create a function that takes a value (string) repres...
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
3