Dataset Viewer
Auto-converted to Parquet Duplicate
task_id
stringlengths
5
7
prompt
stringlengths
133
1.35k
declaration
stringlengths
111
411
canonical_solution
stringlengths
18
1.4k
test
stringlengths
148
1.76k
example_test
stringlengths
0
679
llvm_ir
stringlengths
910
153k
wat
stringlengths
404
165k
CPP/0
/* Check if in given vector of numbers, are any two numbers closer to each other than given threshold. >>> has_close_elements({1.0, 2.0, 3.0}, 0.5) false >>> has_close_elements({1.0, 2.8, 3.0, 4.0, 5.0, 2.0}, 0.3) true */ #include<stdio.h> #include<vector> #include<math.h> using namespace std; bool has_close_elements(v...
#include<stdio.h> #include<vector> #include<math.h> using namespace std; #include<algorithm> #include<stdlib.h> bool has_close_elements(vector<float> numbers, float threshold){
int i,j; for (i=0;i<numbers.size();i++) for (j=i+1;j<numbers.size();j++) if (abs(numbers[i]-numbers[j])<threshold) return true; return false; }
#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...
#undef NDEBUG #include<assert.h> int main(){ assert (has_close_elements({1.0, 2.0, 3.0}, 0.5) == false && "failure 1"); assert (has_close_elements({1.0, 2.8, 3.0, 4.0, 5.0, 2.0}, 0.3) && "failure 2") ; }
; ModuleID = 'c_code/code_0.cpp' source_filename = "c_code/code_0.cpp" target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-S128-ni:1:10:20" target triple = "wasm32-unknown-emscripten" %"class.std::__2::vector" = type { ptr, ptr, %"class.std::__2::__compressed_pair" } %"class.std::__2::__compressed...
(module $code_0.wasm (type (;0;) (func)) (type (;1;) (func (param i32 f32) (result i32))) (import "env" "memory" (memory (;0;) 0)) (func $__wasm_call_ctors (type 0)) (func $has_close_elements_std::__2::vector<float__std::__2::allocator<float>>__float_ (type 1) (param i32 f32) (result i32) (local i32 i32 i...
CPP/1
/* Input to this function is a string containing multiple groups of nested parentheses. Your goal is to separate those group into separate strings and return the vector of those. Separate groups are balanced (each open brace is properly closed) and not nested within each other Ignore any spaces in the input string. >>>...
#include<stdio.h> #include<vector> #include<string> using namespace std; #include<algorithm> #include<math.h> #include<stdlib.h> vector<string> separate_paren_groups(string paren_string){
vector<string> all_parens; string current_paren; int level=0; char chr; int i; for (i=0;i<paren_string.length();i++) { chr=paren_string[i]; if (chr=='(') { level+=1; current_paren+=chr; } if (chr==')') { level-=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("(()()) ((())) () ((())()())"),{"(()())", "((...
#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("( ) (( )) (( )( ))") ,{"()", "(())", "(()())...
; ModuleID = 'c_code/code_1.cpp' source_filename = "c_code/code_1.cpp" target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-S128-ni:1:10:20" target triple = "wasm32-unknown-emscripten" %"class.std::__2::vector" = type { ptr, ptr, %"class.std::__2::__compressed_pair" } %"class.std::__2::__compressed...
(module $code_1.wasm (type (;0;) (func (param i32 i32))) (type (;1;) (func (param i32 i32) (result i32))) (type (;2;) (func (param i32) (result i32))) (type (;3;) (func (param i32 i32 i32))) (type (;4;) (func (param i32))) (type (;5;) (func)) (import "env" "_ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_...
CPP/2
/* Given a positive floating point number, it can be decomposed into and integer part (largest integer smaller than given number) and decimals (leftover part always smaller than 1). Return the decimal part of the number. >>> truncate_number(3.5) 0.5 */ #include<stdio.h> #include<math.h> using namespace std; float trun...
#include<stdio.h> #include<math.h> using namespace std; #include<algorithm> #include<stdlib.h> float truncate_number(float number){
return number-int(number); }
#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); }
#undef NDEBUG #include<assert.h> int main(){ assert (truncate_number(3.5) == 0.5); }
; ModuleID = 'c_code/code_2.cpp' source_filename = "c_code/code_2.cpp" target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-S128-ni:1:10:20" target triple = "wasm32-unknown-emscripten" ; Function Attrs: minsize mustprogress nofree norecurse nosync nounwind optsize willreturn memory(none) define nou...
(module $code_2.wasm (type (;0;) (func)) (type (;1;) (func (param f32) (result f32))) (func $__wasm_call_ctors (type 0)) (func $truncate_number_float_ (type 1) (param f32) (result f32) local.get 0 block (result i32) ;; label = @1 local.get 0 f32.abs f32.const 0x1p+31 (;=2.14748e+09;) ...
CPP/3
/* You"re given a vector of deposit and withdrawal operations on a bank account that starts with zero balance. Your task is to detect if at any point the balance of account falls below zero, and at that point function should return true. Otherwise it should return false. >>> below_zero({1, 2, 3}) false >>> below_zero({...
#include<stdio.h> #include<vector> using namespace std; #include<algorithm> #include<math.h> #include<stdlib.h> bool below_zero(vector<int> operations){
int num=0; for (int i=0;i<operations.size();i++) { num+=operations[i]; if (num<0) return true; } return false; }
#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); ...
#undef NDEBUG #include<assert.h> int main(){ assert (below_zero({1, 2, 3}) == false); assert (below_zero({1, 2, -4, 5}) == true); }
; ModuleID = 'c_code/code_3.cpp' source_filename = "c_code/code_3.cpp" target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-S128-ni:1:10:20" target triple = "wasm32-unknown-emscripten" %"class.std::__2::vector" = type { ptr, ptr, %"class.std::__2::__compressed_pair" } %"class.std::__2::__compressed...
(module $code_3.wasm (type (;0;) (func)) (type (;1;) (func (param i32) (result i32))) (import "env" "memory" (memory (;0;) 0)) (func $__wasm_call_ctors (type 0)) (func $below_zero_std::__2::vector<int__std::__2::allocator<int>>_ (type 1) (param i32) (result i32) (local i32 i32 i32 i32) local.get 0 ...
CPP/4
/* For a given vector of input numbers, calculate Mean Absolute Deviation around the mean of this dataset. Mean Absolute Deviation is the average absolute difference between each element and a centerpoint (mean in this case): MAD = average | x - x_mean | >>> mean_absolute_deviation({1.0, 2.0, 3.0, 4.0}) 1.0 */ #include...
#include<stdio.h> #include<math.h> #include<vector> using namespace std; #include<algorithm> #include<stdlib.h> float mean_absolute_deviation(vector<float> numbers){
float sum=0; float avg,msum,mavg; int i=0; for (i=0;i<numbers.size();i++) sum+=numbers[i]; avg=sum/numbers.size(); msum=0; for (i=0;i<numbers.size();i++) msum+=abs(numbers[i]-avg); return msum/numbers.size(); }
#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); }
#undef NDEBUG #include<assert.h> int main(){ assert (abs(mean_absolute_deviation({1.0, 2.0, 3.0, 4.0}) - 1.0) < 1e-4); }
; ModuleID = 'c_code/code_4.cpp' source_filename = "c_code/code_4.cpp" target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-S128-ni:1:10:20" target triple = "wasm32-unknown-emscripten" %"class.std::__2::vector" = type { ptr, ptr, %"class.std::__2::__compressed_pair" } %"class.std::__2::__compressed...
(module $code_4.wasm (type (;0;) (func)) (type (;1;) (func (param i32) (result f32))) (import "env" "memory" (memory (;0;) 0)) (func $__wasm_call_ctors (type 0)) (func $mean_absolute_deviation_std::__2::vector<float__std::__2::allocator<float>>_ (type 1) (param i32) (result f32) (local f32 f32 f32 i32 i32...
CPP/5
/* Insert a number "delimeter" between every two consecutive elements of input vector `numbers" >>> intersperse({}, 4) {} >>> intersperse({1, 2, 3}, 4) {1, 4, 2, 4, 3} */ #include<stdio.h> #include<vector> using namespace std; vector<int> intersperse(vector<int> numbers, int delimeter){
#include<stdio.h> #include<vector> using namespace std; #include<algorithm> #include<math.h> #include<stdlib.h> vector<int> intersperse(vector<int> numbers, int delimeter){
vector<int> out={}; if (numbers.size()>0) out.push_back(numbers[0]); for (int i=1;i<numbers.size();i++) { out.push_back(delimeter); out.push_back(numbers[i]); } return out; }
#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,...
#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({}, 4), {})); assert (issame(intersperse({1, 2, 3}, 4),...
; ModuleID = 'c_code/code_5.cpp' source_filename = "c_code/code_5.cpp" target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-S128-ni:1:10:20" target triple = "wasm32-unknown-emscripten" %"class.std::__2::vector" = type { ptr, ptr, %"class.std::__2::__compressed_pair" } %"class.std::__2::__compressed...
(module $code_5.wasm (type (;0;) (func (param i32 i32))) (type (;1;) (func (param i32) (result i32))) (type (;2;) (func (param i32 i32 i32))) (type (;3;) (func (param i32))) (type (;4;) (func (param i32 i32) (result i32))) (type (;5;) (func)) (import "env" "_ZNSt3__26vectorIiNS_9allocatorIiEEE21__push_bac...
CPP/6
/* Input to this function is a string represented multiple groups for nested parentheses separated by spaces. For each of the group, output the deepest level of nesting of parentheses. E.g. (()()) has maximum two levels of nesting while ((())) has three. >>> parse_nested_parens("(()()) ((())) () ((())()())") {2, 3, 1,...
#include<stdio.h> #include<vector> #include<string> using namespace std; #include<algorithm> #include<math.h> #include<stdlib.h> vector<int> parse_nested_parens(string paren_string){
vector<int> all_levels; string current_paren; int level=0,max_level=0; char chr; int i; for (i=0;i<paren_string.length();i++) { chr=paren_string[i]; if (chr=='(') { level+=1; if (level>max_level) max_level=level; current_paren+=chr; } ...
#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})); ...
#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})); }
; ModuleID = 'c_code/code_6.cpp' source_filename = "c_code/code_6.cpp" target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-f128:64-n32:64-S128-ni:1:10:20" target triple = "wasm32-unknown-emscripten" %"class.std::__2::vector" = type { ptr, ptr, %"class.std::__2::__compressed_pair" } %"class.std::__2::__compressed...
(module $code_6.wasm (type (;0;) (func (param i32 i32))) (type (;1;) (func (param i32) (result i32))) (type (;2;) (func (param i32 i32) (result i32))) (type (;3;) (func (param i32))) (type (;4;) (func (param i32 i32 i32))) (type (;5;) (func)) (import "env" "_ZNSt3__212basic_stringIcNS_11char_traitsIcEENS_...
CPP/7
"/*\nFilter an input vector of strings only for ones that contain given substring\n>>> filter_by_sub(...TRUNCATED)
"#include<stdio.h>\n#include<vector>\n#include<string>\nusing namespace std;\n#include<algorithm>\n#(...TRUNCATED)
" vector<string> out;\n for (int i=0;i<strings.size();i++)\n {\n if (strings[i].find(...TRUNCATED)
"#undef NDEBUG\n#include<assert.h>\nbool issame(vector<string> a,vector<string>b){\n if (a.size()(...TRUNCATED)
"#undef NDEBUG\n#include<assert.h>\nbool issame(vector<string> a,vector<string>b){\n if (a.size()(...TRUNCATED)
"; ModuleID = 'c_code/code_7.cpp'\nsource_filename = \"c_code/code_7.cpp\"\ntarget datalayout = \"e-(...TRUNCATED)
"(module $code_7.wasm\n (type (;0;) (func (param i32 i32 i32) (result i32)))\n (type (;1;) (func ((...TRUNCATED)
CPP/8
"/*\nFor a given vector of integers, return a vector consisting of a sum and a product of all the in(...TRUNCATED)
"#include<stdio.h>\n#include<vector>\nusing namespace std;\n#include<algorithm>\n#include<math.h>\n#(...TRUNCATED)
" int sum=0,product=1;\n for (int i=0;i<numbers.size();i++)\n {\n sum+=numbers[i];\n(...TRUNCATED)
"#undef NDEBUG\n#include<assert.h>\nbool issame(vector<int> a,vector<int>b){\n if (a.size()!=b.si(...TRUNCATED)
"#undef NDEBUG\n#include<assert.h>\nbool issame(vector<int> a,vector<int>b){\n if (a.size()!=b.si(...TRUNCATED)
"; ModuleID = 'c_code/code_8.cpp'\nsource_filename = \"c_code/code_8.cpp\"\ntarget datalayout = \"e-(...TRUNCATED)
"(module $code_8.wasm\n (type (;0;) (func (param i32) (result i32)))\n (type (;1;) (func (param i3(...TRUNCATED)
CPP/9
"/*\nFrom a given vector of integers, generate a vector of rolling maximum element found until given(...TRUNCATED)
"#include<stdio.h>\n#include<vector>\nusing namespace std;\n#include<algorithm>\n#include<math.h>\n#(...TRUNCATED)
" vector<int> out;\n int max=0;\n for (int i=0;i<numbers.size();i++)\n {\n if (nu(...TRUNCATED)
"#undef NDEBUG\n#include<assert.h>\nbool issame(vector<int> a,vector<int>b){\n if (a.size()!=b.si(...TRUNCATED)
"#undef NDEBUG\n#include<assert.h>\nbool issame(vector<int> a,vector<int>b){\n if (a.size()!=b.si(...TRUNCATED)
"; ModuleID = 'c_code/code_9.cpp'\nsource_filename = \"c_code/code_9.cpp\"\ntarget datalayout = \"e-(...TRUNCATED)
"(module $code_9.wasm\n (type (;0;) (func (param i32 i32)))\n (type (;1;) (func (param i32) (resul(...TRUNCATED)
End of preview. Expand in Data Studio

Dataset Card for "humaneval_x_llvm_wasm"

More Information needed

Downloads last month
6