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
920
153k
wat
stringlengths
321
66.1k
number_of_lines
int64
2
37
number_of_chars
int64
18
1.4k
wat_number_of_chars
int64
321
66.1k
wat_number_of_lines
int64
11
2.51k
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_test/code_0.cpp' source_filename = "c_code_test/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::__...
(module (type (;0;) (func)) (type (;1;) (func (param i32 f32) (result i32))) (import "env" "memory" (memory (;0;) 0)) (func (;0;) (type 0)) (func (;1;) (type 1) (param i32 f32) (result i32) (local i32 i32 i32 i32 i32 i32) local.get 0 i32.load offset=4 local.get 0 i32.load local.tee 4 ...
10
175
1,651
75
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_test/code_1.cpp' source_filename = "c_code_test/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::__...
(module (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_9allocatorIcE...
25
519
10,984
482
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_test/code_2.cpp' source_filename = "c_code_test/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) ...
(module (type (;0;) (func)) (type (;1;) (func (param f32) (result f32))) (func (;0;) (type 0)) (func (;1;) (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;) f32.lt if ;; label = @2 ...
2
33
589
23
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_test/code_3.cpp' source_filename = "c_code_test/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::__...
(module (type (;0;) (func)) (type (;1;) (func (param i32) (result i32))) (import "env" "memory" (memory (;0;) 0)) (func (;0;) (type 0)) (func (;1;) (type 1) (param i32) (result i32) (local i32 i32 i32 i32) local.get 0 i32.load offset=4 local.get 0 i32.load local.tee 4 i32.sub i...
8
149
1,116
51
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_test/code_4.cpp' source_filename = "c_code_test/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::__...
(module (type (;0;) (func)) (type (;1;) (func (param i32) (result f32))) (import "env" "memory" (memory (;0;) 0)) (func (;0;) (type 0)) (func (;1;) (type 1) (param i32) (result f32) (local f32 f32 f32 i32 i32) local.get 0 i32.load offset=4 local.get 0 i32.load local.tee 5 i32.sub ...
11
259
1,621
81
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_test/code_5.cpp' source_filename = "c_code_test/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::__...
(module (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_back_slow_pathIR...
10
216
7,066
345
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_test/code_6.cpp' source_filename = "c_code_test/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::__...
(module (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_9allocatorIcE...
27
599
8,933
400
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_test/code_7.cpp'\nsource_filename = \"c_code_test/code_7.cpp\"\ntarget datalay(...TRUNCATED)
"(module\n (type (;0;) (func (param i32 i32 i32) (result i32)))\n (type (;1;) (func (param i32 i32(...TRUNCATED)
8
185
13,614
588
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_test/code_8.cpp'\nsource_filename = \"c_code_test/code_8.cpp\"\ntarget datalay(...TRUNCATED)
"(module\n (type (;0;) (func (param i32) (result i32)))\n (type (;1;) (func (param i32 i32 i32) (r(...TRUNCATED)
8
158
5,237
207
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_test/code_9.cpp'\nsource_filename = \"c_code_test/code_9.cpp\"\ntarget datalay(...TRUNCATED)
"(module\n (type (;0;) (func (param i32 i32)))\n (type (;1;) (func (param i32) (result i32)))\n ((...TRUNCATED)
9
177
7,132
338
End of preview. Expand in Data Studio

Dataset Card for "humaneval_x_with_stats"

More Information needed

Downloads last month
7