Datasets:

Languages:
code
ArXiv:
Tags:
code
License:
shubhamugare commited on
Commit
ac828fc
1 Parent(s): 7980d99

Upload humanevalpack.jsonl

Browse files

Fixing couple of typos in cpp humaneval.

Example 121: The entry point and the prompt calls the function `solution` but the signature calls it `solutions`
Example 156: The entry point and the prompt calls the function `int_to_mini_romank` but the signature calls it `int_to_mini_roman`

This change makes them consistent to humaneval in other langaugaes.

Files changed (1) hide show
  1. data/cpp/data/humanevalpack.jsonl +2 -2
data/cpp/data/humanevalpack.jsonl CHANGED
@@ -119,7 +119,7 @@
119
  {"task_id": "CPP/118", "prompt": "/*\nYou are given a word. Your task is to find the closest vowel that stands between \ntwo consonants from the right side of the word (case sensitive).\n\nVowels in the beginning and ending doesn't count. Return empty string if you didn't\nfind any vowel met the above condition. \n\nYou may assume that the given string contains English letter only.\n\nExample:\nget_closest_vowel(\"yogurt\") ==> \"u\"\nget_closest_vowel(\"FULL\") ==> \"U\"\nget_closest_vowel(\"quick\") ==> \"\"\nget_closest_vowel(\"ab\") ==> \"\"\n*/\n#include<stdio.h>\n#include<string>\n#include<algorithm>\nusing namespace std;\nstring get_closest_vowel(string word){\n", "canonical_solution": " string out=\"\";\n string vowels=\"AEIOUaeiou\";\n for (int i=word.length()-2;i>=1;i-=1)\n if (find(vowels.begin(),vowels.end(),word[i])!=vowels.end())\n if (find(vowels.begin(),vowels.end(),word[i+1])==vowels.end())\n if (find(vowels.begin(),vowels.end(),word[i-1])==vowels.end())\n return out+word[i];\n return out;\n}\n", "test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert (get_closest_vowel(\"yogurt\") == \"u\");\n assert (get_closest_vowel(\"full\") == \"u\");\n assert (get_closest_vowel(\"easy\") == \"\");\n assert (get_closest_vowel(\"eAsy\") == \"\");\n assert (get_closest_vowel(\"ali\") == \"\");\n assert (get_closest_vowel(\"bad\") == \"a\");\n assert (get_closest_vowel(\"most\") ==\"o\");\n assert (get_closest_vowel(\"ab\") == \"\");\n assert (get_closest_vowel(\"ba\") == \"\");\n assert (get_closest_vowel(\"quick\") == \"\");\n assert (get_closest_vowel(\"anime\") == \"i\");\n assert (get_closest_vowel(\"Asia\") == \"\");\n assert (get_closest_vowel(\"Above\") == \"o\");\n}\n", "declaration": "#include<stdio.h>\n#include<math.h>\n#include<string>\n#include<algorithm>\nusing namespace std;\n#include<stdlib.h>\nstring get_closest_vowel(string word){\n", "example_test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert (get_closest_vowel(\"yogurt\") == \"u\");\n assert (get_closest_vowel(\"FULL\") == \"U\");\n assert (get_closest_vowel(\"ab\") == \"\");\n assert (get_closest_vowel(\"quick\") == \"\");\n}\n", "buggy_solution": " string out=\" \";\n string vowels=\"AEIOUaeiou\";\n for (int i=word.length()-2;i>=1;i-=1)\n if (find(vowels.begin(),vowels.end(),word[i])!=vowels.end())\n if (find(vowels.begin(),vowels.end(),word[i+1])==vowels.end())\n if (find(vowels.begin(),vowels.end(),word[i-1])==vowels.end())\n return out+word[i];\n return out;\n}\n", "bug_type": "excess logic", "failure_symptoms": "incorrect output", "entry_point": "get_closest_vowel", "signature": "string get_closest_vowel(string word)", "docstring": "You are given a word. Your task is to find the closest vowel that stands between\ntwo consonants from the right side of the word (case sensitive).\nVowels in the beginning and ending doesn't count. Return empty string if you didn't\nfind any vowel met the above condition.\nYou may assume that the given string contains English letter only.\nExample:\nget_closest_vowel(\"yogurt\") ==> \"u\"\nget_closest_vowel(\"FULL\") ==> \"U\"\nget_closest_vowel(\"quick\") ==> \"\"\nget_closest_vowel(\"ab\") ==> \"\"", "instruction": "Write a C++ function `string get_closest_vowel(string word)` to solve the following problem:\nYou are given a word. Your task is to find the closest vowel that stands between\ntwo consonants from the right side of the word (case sensitive).\nVowels in the beginning and ending doesn't count. Return empty string if you didn't\nfind any vowel met the above condition.\nYou may assume that the given string contains English letter only.\nExample:\nget_closest_vowel(\"yogurt\") ==> \"u\"\nget_closest_vowel(\"FULL\") ==> \"U\"\nget_closest_vowel(\"quick\") ==> \"\"\nget_closest_vowel(\"ab\") ==> \"\""}
120
  {"task_id": "CPP/119", "prompt": "/*\nYou are given a vector of two strings, both strings consist of open\nparentheses '(' or close parentheses ')' only.\nYour job is to check if it is possible to concatenate the two strings in\nsome order, that the resulting string will be good.\nA string S is considered to be good if and only if all parentheses in S\nare balanced. For example: the string \"(())()\" is good, while the string\n\"())\" is not.\nReturn \"Yes\" if there's a way to make a good string, and return \"No\" otherwise.\n\nExamples:\nmatch_parens({\"()(\", \")\"}) == \"Yes\"\nmatch_parens({\")\", \")\"}) == \"No\"\n*/\n#include<stdio.h>\n#include<vector>\n#include<string>\nusing namespace std;\nstring match_parens(vector<string> lst){\n", "canonical_solution": " string l1=lst[0]+lst[1];\n int i,count=0;\n bool can=true;\n for (i=0;i<l1.length();i++)\n {\n if (l1[i]=='(') count+=1;\n if (l1[i]==')') count-=1;\n if (count<0) can=false;\n }\n if (count!=0) return \"No\";\n if (can==true) return \"Yes\";\n l1=lst[1]+lst[0];\n can=true;\n for (i=0;i<l1.length();i++)\n {\n if (l1[i]=='(') count+=1;\n if (l1[i]==')') count-=1;\n if (count<0) can=false;\n }\n if (can==true) return \"Yes\";\n return \"No\";\n}\n", "test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert (match_parens({\"()(\", \")\"}) == \"Yes\");\n assert (match_parens({\")\", \")\"}) == \"No\");\n assert (match_parens({\"(()(())\", \"())())\"}) == \"No\");\n assert (match_parens({\")())\", \"(()()(\"}) == \"Yes\");\n assert (match_parens({\"(())))\", \"(()())((\"}) == \"Yes\");\n assert (match_parens({\"()\", \"())\"}) == \"No\");\n assert (match_parens({\"(()(\", \"()))()\"}) == \"Yes\");\n assert (match_parens({\"((((\", \"((())\"}) == \"No\");\n assert (match_parens({\")(()\", \"(()(\"}) == \"No\");\n assert (match_parens({\")(\", \")(\"}) == \"No\");\n assert (match_parens({\"(\", \")\"}) == \"Yes\");\n assert (match_parens({\")\", \"(\"}) == \"Yes\" );\n}\n", "declaration": "#include<stdio.h>\n#include<math.h>\n#include<vector>\n#include<string>\nusing namespace std;\n#include<algorithm>\n#include<stdlib.h>\nstring match_parens(vector<string> lst){\n", "example_test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert (match_parens({\"()(\", \")\"}) == \"Yes\");\n assert (match_parens({\")\", \")\"}) == \"No\");\n}\n", "buggy_solution": " string l1=lst[0]+lst[1];\n int i,count=0;\n bool can=true;\n for (i=0;i<l1.length();i++)\n {\n if (l1[i]=='(') count+=1;\n if (l1[i]==')') count-=1;\n if (count<0) can=false;\n }\n if (count!=0) return \"No\";\n if (can==true) return \"Yes\";\n l1=lst[1]+lst[0];\n can=true;\n for (i=0;i<l1.length();i++)\n {\n if (l1[i]=='(') count+=1;\n if (l1[i]==')') count-=1;\n if (count<0) can=false;\n }\n if (can==true) return \"yes\";\n return \"no\";\n}\n", "bug_type": "value misuse", "failure_symptoms": "incorrect output", "entry_point": "match_parens", "signature": "string match_parens(vector<string> lst)", "docstring": "You are given a vector of two strings, both strings consist of open\nparentheses '(' or close parentheses ')' only.\nYour job is to check if it is possible to concatenate the two strings in\nsome order, that the resulting string will be good.\nA string S is considered to be good if and only if all parentheses in S\nare balanced. For example: the string \"(())()\" is good, while the string\n\"())\" is not.\nReturn \"Yes\" if there's a way to make a good string, and return \"No\" otherwise.\nExamples:\nmatch_parens({\"()(\", \")\"}) == \"Yes\"\nmatch_parens({\")\", \")\"}) == \"No\"", "instruction": "Write a C++ function `string match_parens(vector<string> lst)` to solve the following problem:\nYou are given a vector of two strings, both strings consist of open\nparentheses '(' or close parentheses ')' only.\nYour job is to check if it is possible to concatenate the two strings in\nsome order, that the resulting string will be good.\nA string S is considered to be good if and only if all parentheses in S\nare balanced. For example: the string \"(())()\" is good, while the string\n\"())\" is not.\nReturn \"Yes\" if there's a way to make a good string, and return \"No\" otherwise.\nExamples:\nmatch_parens({\"()(\", \")\"}) == \"Yes\"\nmatch_parens({\")\", \")\"}) == \"No\""}
121
  {"task_id": "CPP/120", "prompt": "/*\nGiven a vector arr of integers and a positive integer k, return a sorted vector \nof length k with the maximum k numbers in arr.\n\nExample 1:\n\n Input: arr = {-3, -4, 5}, k = 3\n Output: {-4, -3, 5}\n\nExample 2:\n\n Input: arr = {4, -4, 4}, k = 2\n Output: {4, 4}\n\nExample 3:\n\n Input: arr = {-3, 2, 1, 2, -1, -2, 1}, k = 1\n Output: {2}\n\nNote:\n 1. The length of the vector will be in the range of {1, 1000}.\n 2. The elements in the vector will be in the range of {-1000, 1000}.\n 3. 0 <= k <= len(arr)\n*/\n#include<stdio.h>\n#include<vector>\n#include<algorithm>\nusing namespace std;\nvector<int> maximum(vector<int> arr,int k){\n", "canonical_solution": " sort(arr.begin(),arr.end());\n vector<int> out(arr.end()-k,arr.end());\n return out;\n}\n", "test": "#undef NDEBUG\n#include<assert.h>\nbool issame(vector<int> a,vector<int>b){\n if (a.size()!=b.size()) return false;\n for (int i=0;i<a.size();i++)\n {\n if (a[i]!=b[i]) return false;\n }\n return true;\n}\nint main(){\n assert (issame(maximum({-3, -4, 5}, 3) , {-4, -3, 5}));\n assert (issame(maximum({4, -4, 4}, 2) , {4, 4}));\n assert (issame(maximum({-3, 2, 1, 2, -1, -2, 1}, 1) , {2}));\n assert (issame(maximum({123, -123, 20, 0 , 1, 2, -3}, 3) , {2, 20, 123}));\n assert (issame(maximum({-123, 20, 0 , 1, 2, -3}, 4) , {0, 1, 2, 20}));\n assert (issame(maximum({5, 15, 0, 3, -13, -8, 0}, 7) , {-13, -8, 0, 0, 3, 5, 15}));\n assert (issame(maximum({-1, 0, 2, 5, 3, -10}, 2) , {3, 5}));\n assert (issame(maximum({1, 0, 5, -7}, 1) , {5}));\n assert (issame(maximum({4, -4}, 2) , {-4, 4}));\n assert (issame(maximum({-10, 10}, 2) , {-10, 10}));\n assert (issame(maximum({1, 2, 3, -23, 243, -400, 0}, 0) , {}));\n}\n", "declaration": "#include<stdio.h>\n#include<math.h>\n#include<vector>\n#include<algorithm>\nusing namespace std;\n#include<stdlib.h>\nvector<int> maximum(vector<int> arr,int k){\n", "example_test": "#undef NDEBUG\n#include<assert.h>\nbool issame(vector<int> a,vector<int>b){\n if (a.size()!=b.size()) return false;\n for (int i=0;i<a.size();i++)\n {\n if (a[i]!=b[i]) return false;\n }\n return true;\n}\nint main(){\n assert (issame(maximum({-3, -4, 5}, 3) , {-4, -3, 5}));\n assert (issame(maximum({4, -4, 4}, 2) , {4, 4}));\n assert (issame(maximum({-3, 2, 1, 2, -1, -2, 1}, 1) , {2}));\n}\n", "buggy_solution": " sort(arr.begin(),arr.end());\n vector<int> out(arr.end()-k,arr.end());\n sort(out.end(),out.begin());\n return out;\n}\n", "bug_type": "excess logic", "failure_symptoms": "incorrect output", "entry_point": "maximum", "signature": "vector<int> maximum(vector<int> arr,int k)", "docstring": "Given a vector arr of integers and a positive integer k, return a sorted vector\nof length k with the maximum k numbers in arr.\nExample 1:\nInput: arr = {-3, -4, 5}, k = 3\nOutput: {-4, -3, 5}\nExample 2:\nInput: arr = {4, -4, 4}, k = 2\nOutput: {4, 4}\nExample 3:\nInput: arr = {-3, 2, 1, 2, -1, -2, 1}, k = 1\nOutput: {2}\nNote:\n1. The length of the vector will be in the range of {1, 1000}.\n2. The elements in the vector will be in the range of {-1000, 1000}.\n3. 0 <= k <= len(arr)", "instruction": "Write a C++ function `vector<int> maximum(vector<int> arr,int k)` to solve the following problem:\nGiven a vector arr of integers and a positive integer k, return a sorted vector\nof length k with the maximum k numbers in arr.\nExample 1:\nInput: arr = {-3, -4, 5}, k = 3\nOutput: {-4, -3, 5}\nExample 2:\nInput: arr = {4, -4, 4}, k = 2\nOutput: {4, 4}\nExample 3:\nInput: arr = {-3, 2, 1, 2, -1, -2, 1}, k = 1\nOutput: {2}\nNote:\n1. The length of the vector will be in the range of {1, 1000}.\n2. The elements in the vector will be in the range of {-1000, 1000}.\n3. 0 <= k <= len(arr)"}
122
- {"task_id": "CPP/121", "prompt": "/*\nGiven a non-empty vector of integers, return the sum of all of the odd elements that are in even positions.\n\n\nExamples\nsolution({5, 8, 7, 1}) ==> 12\nsolution({3, 3, 3, 3, 3}) ==> 9\nsolution({30, 13, 24, 321}) ==>0\n*/\n#include<stdio.h>\n#include<vector>\nusing namespace std;\nint solutions(vector<int> lst){\n", "canonical_solution": " int sum=0;\n for (int i=0;i*2<lst.size();i++)\n if (lst[i*2]%2==1) sum+=lst[i*2];\n return sum;\n}\n", "test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert (solutions({5, 8, 7, 1}) == 12);\n assert (solutions({3, 3, 3, 3, 3}) == 9);\n assert (solutions({30, 13, 24, 321}) == 0);\n assert (solutions({5, 9}) == 5);\n assert (solutions({2, 4, 8}) == 0);\n assert (solutions({30, 13, 23, 32}) == 23);\n assert (solutions({3, 13, 2, 9}) == 3);\n}\n", "declaration": "#include<stdio.h>\n#include<math.h>\n#include<vector>\nusing namespace std;\n#include<algorithm>\n#include<stdlib.h>\nint solutions(vector<int> lst){\n", "example_test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert (solutions({5, 8, 7, 1}) == 12);\n assert (solutions({3, 3, 3, 3, 3}) == 9);\n assert (solutions({30, 13, 24, 321}) == 0);\n}\n", "buggy_solution": " int sum=1;\n for (int i=0;i*2<lst.size();i++)\n if (lst[i*2]%2==1) sum+=lst[i*2];\n return sum;\n}\n", "bug_type": "value misuse", "failure_symptoms": "incorrect output", "entry_point": "solution", "signature": "int solutions(vector<int> lst)", "docstring": "Given a non-empty vector of integers, return the sum of all of the odd elements that are in even positions.\nExamples\nsolution({5, 8, 7, 1}) ==> 12\nsolution({3, 3, 3, 3, 3}) ==> 9\nsolution({30, 13, 24, 321}) ==>0", "instruction": "Write a C++ function `int solutions(vector<int> lst)` to solve the following problem:\nGiven a non-empty vector of integers, return the sum of all of the odd elements that are in even positions.\nExamples\nsolution({5, 8, 7, 1}) ==> 12\nsolution({3, 3, 3, 3, 3}) ==> 9\nsolution({30, 13, 24, 321}) ==>0"}
123
  {"task_id": "CPP/122", "prompt": "/*\nGiven a non-empty vector of integers arr and an integer k, return\nthe sum of the elements with at most two digits from the first k elements of arr.\n\nExample:\n\n Input: arr = {111,21,3,4000,5,6,7,8,9}, k = 4\n Output: 24 # sum of 21 + 3\n\nConstraints:\n 1. 1 <= len(arr) <= 100\n 2. 1 <= k <= len(arr)\n*/\n#include<stdio.h>\n#include<vector>\nusing namespace std;\nint add_elements(vector<int> arr,int k){\n", "canonical_solution": " int sum=0;\n for (int i=0;i<k;i++)\n if( arr[i]>=-99 and arr[i]<=99)\n sum+=arr[i];\n return sum;\n}\n", "test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert (add_elements({1,-2,-3,41,57,76,87,88,99}, 3) == -4);\n assert (add_elements({111,121,3,4000,5,6}, 2) == 0);\n assert (add_elements({11,21,3,90,5,6,7,8,9}, 4) == 125);\n assert (add_elements({111,21,3,4000,5,6,7,8,9}, 4) == 24);\n assert (add_elements({1}, 1) == 1);\n}\n", "declaration": "#include<stdio.h>\n#include<math.h>\n#include<vector>\nusing namespace std;\n#include<algorithm>\n#include<stdlib.h>\nint add_elements(vector<int> arr,int k){\n", "example_test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert (add_elements({111,21,3,4000,5,6,7,8,9}, 4) == 24);\n}\n", "buggy_solution": " int sum=0;\n for (int i=0;i<arr.size();i++)\n if( arr[i]>=-99 and arr[i]<=99)\n sum+=arr[i];\n return sum;\n}\n", "bug_type": "missing logic", "failure_symptoms": "incorrect output", "entry_point": "add_elements", "signature": "int add_elements(vector<int> arr,int k)", "docstring": "Given a non-empty vector of integers arr and an integer k, return\nthe sum of the elements with at most two digits from the first k elements of arr.\nExample:\nInput: arr = {111,21,3,4000,5,6,7,8,9}, k = 4\nOutput: 24 # sum of 21 + 3\nConstraints:\n1. 1 <= len(arr) <= 100\n2. 1 <= k <= len(arr)", "instruction": "Write a C++ function `int add_elements(vector<int> arr,int k)` to solve the following problem:\nGiven a non-empty vector of integers arr and an integer k, return\nthe sum of the elements with at most two digits from the first k elements of arr.\nExample:\nInput: arr = {111,21,3,4000,5,6,7,8,9}, k = 4\nOutput: 24 # sum of 21 + 3\nConstraints:\n1. 1 <= len(arr) <= 100\n2. 1 <= k <= len(arr)"}
124
  {"task_id": "CPP/123", "prompt": "/*\nGiven a positive integer n, return a sorted vector that has the odd numbers in collatz sequence.\n\nThe Collatz conjecture is a conjecture in mathematics that concerns a sequence defined\nas follows: start with any positive integer n. Then each term is obtained from the \nprevious term as follows: if the previous term is even, the next term is one half of \nthe previous term. If the previous term is odd, the next term is 3 times the previous\nterm plus 1. The conjecture is that no matter what value of n, the sequence will always reach 1.\n\nNote: \n 1. Collatz(1) is {1}.\n 2. returned vector sorted in increasing order.\n\nFor example:\nget_odd_collatz(5) returns {1, 5} // The collatz sequence for 5 is {5, 16, 8, 4, 2, 1}, so the odd numbers are only 1, and 5.\n*/\n#include<stdio.h>\n#include<vector>\n#include<algorithm>\nusing namespace std;\nvector<int> get_odd_collatz(int n){\n", "canonical_solution": " vector<int> out={1};\n while (n!=1)\n {\n if (n%2==1) {out.push_back(n); n=n*3+1;}\n else n=n/2;\n }\n sort(out.begin(),out.end());\n return out;\n}\n", "test": "#undef NDEBUG\n#include<assert.h>\nbool issame(vector<int> a,vector<int>b){\n if (a.size()!=b.size()) return false;\n for (int i=0;i<a.size();i++)\n {\n if (a[i]!=b[i]) return false;\n }\n return true;\n}\nint main(){\n assert (issame(get_odd_collatz(14) , {1, 5, 7, 11, 13, 17}));\n assert (issame(get_odd_collatz(5) , {1, 5}));\n assert (issame(get_odd_collatz(12) , {1, 3, 5}));\n assert (issame(get_odd_collatz(1) , {1}));\n}\n", "declaration": "#include<stdio.h>\n#include<math.h>\n#include<vector>\n#include<algorithm>\nusing namespace std;\n#include<stdlib.h>\nvector<int> get_odd_collatz(int n){\n", "example_test": "#undef NDEBUG\n#include<assert.h>\nbool issame(vector<int> a,vector<int>b){\n if (a.size()!=b.size()) return false;\n for (int i=0;i<a.size();i++)\n {\n if (a[i]!=b[i]) return false;\n }\n return true;\n}\nint main(){\n assert (issame(get_odd_collatz(5) , {1, 5}));\n}\n", "buggy_solution": " vector<int> out={1};\n while (n!=1)\n {\n if (n%2==1) {out.push_back(n); n=n*2+1;}\n else n=n/2;\n }\n sort(out.begin(),out.end());\n return out;\n}\n", "bug_type": "value misuse", "failure_symptoms": "incorrect output", "entry_point": "get_odd_collatz", "signature": "vector<int> get_odd_collatz(int n)", "docstring": "Given a positive integer n, return a sorted vector that has the odd numbers in collatz sequence.\nThe Collatz conjecture is a conjecture in mathematics that concerns a sequence defined\nas follows: start with any positive integer n. Then each term is obtained from the\nprevious term as follows: if the previous term is even, the next term is one half of\nthe previous term. If the previous term is odd, the next term is 3 times the previous\nterm plus 1. The conjecture is that no matter what value of n, the sequence will always reach 1.\nNote:\n1. Collatz(1) is {1}.\n2. returned vector sorted in increasing order.\nFor example:\nget_odd_collatz(5) returns {1, 5} // The collatz sequence for 5 is {5, 16, 8, 4, 2, 1}, so the odd numbers are only 1, and 5.", "instruction": "Write a C++ function `vector<int> get_odd_collatz(int n)` to solve the following problem:\nGiven a positive integer n, return a sorted vector that has the odd numbers in collatz sequence.\nThe Collatz conjecture is a conjecture in mathematics that concerns a sequence defined\nas follows: start with any positive integer n. Then each term is obtained from the\nprevious term as follows: if the previous term is even, the next term is one half of\nthe previous term. If the previous term is odd, the next term is 3 times the previous\nterm plus 1. The conjecture is that no matter what value of n, the sequence will always reach 1.\nNote:\n1. Collatz(1) is {1}.\n2. returned vector sorted in increasing order.\nFor example:\nget_odd_collatz(5) returns {1, 5} // The collatz sequence for 5 is {5, 16, 8, 4, 2, 1}, so the odd numbers are only 1, and 5."}
125
  {"task_id": "CPP/124", "prompt": "/*\nYou have to write a function which validates a given date string and\nreturns true if the date is valid otherwise false.\nThe date is valid if all of the following rules are satisfied:\n1. The date string is not empty.\n2. The number of days is not less than 1 or higher than 31 days for months 1,3,5,7,8,10,12. And the number of days is not less than 1 or higher than 30 days for months 4,6,9,11. And, the number of days is not less than 1 or higher than 29 for the month 2.\n3. The months should not be less than 1 or higher than 12.\n4. The date should be in the format: mm-dd-yyyy\n\nfor example: \nvalid_date(\"03-11-2000\") => true\n\nvalid_date(\"15-01-2012\") => false\n\nvalid_date(\"04-0-2040\") => false\n\nvalid_date(\"06-04-2020\") => true\n\nvalid_date(\"06/04/2020\") => false\n*/\n#include<stdio.h>\n#include<string>\nusing namespace std;\nbool valid_date(string date){\n", "canonical_solution": " int mm,dd,yy,i;\n if (date.length()!=10) return false;\n for (int i=0;i<10;i++)\n if (i==2 or i==5)\n {\n if (date[i]!='-') return false;\n }\n else\n if (date[i]<48 or date[i]>57) return false;\n\n mm=atoi(date.substr(0,2).c_str());\n dd=atoi(date.substr(3,2).c_str());\n yy=atoi(date.substr(6,4).c_str());\n if (mm<1 or mm>12) return false;\n if (dd<1 or dd>31) return false;\n if (dd==31 and (mm==4 or mm==6 or mm==9 or mm==11 or mm==2)) return false;\n if (dd==30 and mm==2) return false;\n return true;\n\n}\n", "test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert (valid_date(\"03-11-2000\") == true);\n assert (valid_date(\"15-01-2012\") == false);\n assert (valid_date(\"04-0-2040\") == false);\n assert (valid_date(\"06-04-2020\") == true);\n assert (valid_date(\"01-01-2007\") == true);\n assert (valid_date(\"03-32-2011\") == false);\n assert (valid_date(\"\") == false);\n assert (valid_date(\"04-31-3000\") == false);\n assert (valid_date(\"06-06-2005\") == true);\n assert (valid_date(\"21-31-2000\") == false);\n assert (valid_date(\"04-12-2003\") == true);\n assert (valid_date(\"04122003\") == false);\n assert (valid_date(\"20030412\") == false);\n assert (valid_date(\"2003-04\") == false);\n assert (valid_date(\"2003-04-12\") == false);\n assert (valid_date(\"04-2003\") == false);\n}\n", "declaration": "#include<stdio.h>\n#include<math.h>\n#include<string>\n#include<algorithm>\nusing namespace std;\n#include<stdlib.h>\nbool valid_date(string date){\n", "example_test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert (valid_date(\"03-11-2000\") == true);\n assert (valid_date(\"15-01-2012\") == false);\n assert (valid_date(\"04-0-2040\") == false);\n assert (valid_date(\"06-04-2020\") == true);\n assert (valid_date(\"06/04/2020\") == false);\n}\n", "buggy_solution": " int dd,mm,yy,i;\n if (date.length()!=10) return false;\n for (int i=0;i<10;i++)\n if (i==2 or i==5)\n {\n if (date[i]!='-') return false;\n }\n else\n if (date[i]<48 or date[i]>57) return false;\n\n dd=atoi(date.substr(0,2).c_str());\n mm=atoi(date.substr(3,2).c_str());\n yy=atoi(date.substr(6,4).c_str());\n if (mm<1 or mm>12) return false;\n if (dd<1 or dd>31) return false;\n if (dd==31 and (mm==4 or mm==6 or mm==9 or mm==11 or mm==2)) return false;\n if (dd==30 and mm==2) return false;\n return true;\n\n}\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output", "entry_point": "valid_date", "signature": "bool valid_date(string date)", "docstring": "You have to write a function which validates a given date string and\nreturns true if the date is valid otherwise false.\nThe date is valid if all of the following rules are satisfied:\n1. The date string is not empty.\n2. The number of days is not less than 1 or higher than 31 days for months 1,3,5,7,8,10,12. And the number of days is not less than 1 or higher than 30 days for months 4,6,9,11. And, the number of days is not less than 1 or higher than 29 for the month 2.\n3. The months should not be less than 1 or higher than 12.\n4. The date should be in the format: mm-dd-yyyy\nfor example:\nvalid_date(\"03-11-2000\") => true\nvalid_date(\"15-01-2012\") => false\nvalid_date(\"04-0-2040\") => false\nvalid_date(\"06-04-2020\") => true\nvalid_date(\"06/04/2020\") => false", "instruction": "Write a C++ function `bool valid_date(string date)` to solve the following problem:\nYou have to write a function which validates a given date string and\nreturns true if the date is valid otherwise false.\nThe date is valid if all of the following rules are satisfied:\n1. The date string is not empty.\n2. The number of days is not less than 1 or higher than 31 days for months 1,3,5,7,8,10,12. And the number of days is not less than 1 or higher than 30 days for months 4,6,9,11. And, the number of days is not less than 1 or higher than 29 for the month 2.\n3. The months should not be less than 1 or higher than 12.\n4. The date should be in the format: mm-dd-yyyy\nfor example:\nvalid_date(\"03-11-2000\") => true\nvalid_date(\"15-01-2012\") => false\nvalid_date(\"04-0-2040\") => false\nvalid_date(\"06-04-2020\") => true\nvalid_date(\"06/04/2020\") => false"}
@@ -154,7 +154,7 @@
154
  {"task_id": "CPP/153", "prompt": "/*\nYou will be given the name of a class (a string) and a vector of extensions.\nThe extensions are to be used to load additional classes to the class. The\nstrength of the extension is as follows: Let CAP be the number of the uppercase\nletters in the extension's name, and let SM be the number of lowercase letters \nin the extension's name, the strength is given by the fraction CAP - SM. \nYou should find the strongest extension and return a string in this \nformat: ClassName.StrongestExtensionName.\nIf there are two or more extensions with the same strength, you should\nchoose the one that comes first in the vector.\nFor example, if you are given \"Slices\" as the class and a vector of the\nextensions: {\"SErviNGSliCes\", \"Cheese\", \"StuFfed\"} then you should\nreturn \"Slices.SErviNGSliCes\" since \"SErviNGSliCes\" is the strongest extension \n(its strength is -1).\nExample:\nfor Strongest_Extension(\"my_class\", {\"AA\", \"Be\", \"CC\"}) == \"my_class.AA\"\n*/\n#include<stdio.h>\n#include<vector>\n#include<string>\nusing namespace std;\nstring Strongest_Extension(string class_name,vector<string> extensions){\n", "canonical_solution": " string strongest=\"\";\n int max=-1000;\n for (int i=0;i<extensions.size();i++)\n {\n int strength=0;\n for (int j=0;j<extensions[i].length();j++)\n {\n char chr=extensions[i][j];\n if (chr>=65 and chr<=90) strength+=1;\n if (chr>=97 and chr<=122) strength-=1;\n }\n if (strength>max) \n {\n max=strength;\n strongest=extensions[i];\n }\n }\n return class_name+'.'+strongest;\n}\n", "test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert (Strongest_Extension(\"Watashi\", {\"tEN\", \"niNE\", \"eIGHt8OKe\"}) == \"Watashi.eIGHt8OKe\");\n assert (Strongest_Extension(\"Boku123\", {\"nani\", \"NazeDa\", \"YEs.WeCaNe\", \"32145tggg\"}) == \"Boku123.YEs.WeCaNe\");\n assert (Strongest_Extension(\"__YESIMHERE\", {\"t\", \"eMptY\", \"(nothing\", \"zeR00\", \"NuLl__\", \"123NoooneB321\"}) == \"__YESIMHERE.NuLl__\");\n assert (Strongest_Extension(\"K\", {\"Ta\", \"TAR\", \"t234An\", \"cosSo\"}) == \"K.TAR\");\n assert (Strongest_Extension(\"__HAHA\", {\"Tab\", \"123\", \"781345\", \"-_-\"}) == \"__HAHA.123\");\n assert (Strongest_Extension(\"YameRore\", {\"HhAas\", \"okIWILL123\", \"WorkOut\", \"Fails\", \"-_-\"}) == \"YameRore.okIWILL123\");\n assert (Strongest_Extension(\"finNNalLLly\", {\"Die\", \"NowW\", \"Wow\", \"WoW\"}) == \"finNNalLLly.WoW\");\n assert (Strongest_Extension(\"_\", {\"Bb\", \"91245\"}) == \"_.Bb\");\n assert (Strongest_Extension(\"Sp\", {\"671235\", \"Bb\"}) == \"Sp.671235\");\n}\n", "declaration": "#include<stdio.h>\n#include<math.h>\n#include<vector>\n#include<string>\n#include<algorithm>\nusing namespace std;\n#include<stdlib.h>\nstring Strongest_Extension(string class_name,vector<string> extensions){\n", "example_test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert (Strongest_Extension(\"my_class\", {\"AA\", \"Be\", \"CC\"}) == \"my_class.AA\");\n}\n", "buggy_solution": " string strongest=\"\";\n int max=-1000;\n for (int i=0;i<extensions.size();i++)\n {\n int strength=0;\n for (int j=0;j<extensions[i].length();j++)\n {\n char chr=extensions[i][j];\n if (chr>=65 and chr<=90) strength+=1;\n if (chr>=97 and chr<=122) strength-=1;\n }\n if (strength>max) \n {\n max=strength;\n strongest=extensions[i];\n }\n }\n return class_name+strongest;\n}\n", "bug_type": "missing logic", "failure_symptoms": "incorrect output", "entry_point": "Strongest_Extension", "signature": "string Strongest_Extension(string class_name,vector<string> extensions)", "docstring": "You will be given the name of a class (a string) and a vector of extensions.\nThe extensions are to be used to load additional classes to the class. The\nstrength of the extension is as follows: Let CAP be the number of the uppercase\nletters in the extension's name, and let SM be the number of lowercase letters\nin the extension's name, the strength is given by the fraction CAP - SM.\nYou should find the strongest extension and return a string in this\nformat: ClassName.StrongestExtensionName.\nIf there are two or more extensions with the same strength, you should\nchoose the one that comes first in the vector.\nFor example, if you are given \"Slices\" as the class and a vector of the\nextensions: {\"SErviNGSliCes\", \"Cheese\", \"StuFfed\"} then you should\nreturn \"Slices.SErviNGSliCes\" since \"SErviNGSliCes\" is the strongest extension\n(its strength is -1).\nExample:\nfor Strongest_Extension(\"my_class\", {\"AA\", \"Be\", \"CC\"}) == \"my_class.AA\"", "instruction": "Write a C++ function `string Strongest_Extension(string class_name,vector<string> extensions)` to solve the following problem:\nYou will be given the name of a class (a string) and a vector of extensions.\nThe extensions are to be used to load additional classes to the class. The\nstrength of the extension is as follows: Let CAP be the number of the uppercase\nletters in the extension's name, and let SM be the number of lowercase letters\nin the extension's name, the strength is given by the fraction CAP - SM.\nYou should find the strongest extension and return a string in this\nformat: ClassName.StrongestExtensionName.\nIf there are two or more extensions with the same strength, you should\nchoose the one that comes first in the vector.\nFor example, if you are given \"Slices\" as the class and a vector of the\nextensions: {\"SErviNGSliCes\", \"Cheese\", \"StuFfed\"} then you should\nreturn \"Slices.SErviNGSliCes\" since \"SErviNGSliCes\" is the strongest extension\n(its strength is -1).\nExample:\nfor Strongest_Extension(\"my_class\", {\"AA\", \"Be\", \"CC\"}) == \"my_class.AA\""}
155
  {"task_id": "CPP/154", "prompt": "/*\nYou are given 2 words. You need to return true if the second word or any of its rotations is a substring in the first word\ncycpattern_check(\"abcd\",\"abd\") => false\ncycpattern_check(\"hello\",\"ell\") => true\ncycpattern_check(\"whassup\",\"psus\") => false\ncycpattern_check(\"abab\",\"baa\") => true\ncycpattern_check(\"efef\",\"eeff\") => false\ncycpattern_check(\"himenss\",'simen\") => true\n\n*/\n#include<stdio.h>\n#include<string>\nusing namespace std;\nbool cycpattern_check(string a,string b){\n", "canonical_solution": " for (int i=0;i<b.size();i++)\n {\n string rotate=b.substr(i)+b.substr(0,i);\n if (a.find(rotate)!=string::npos) return true;\n }\n return false;\n\n}\n", "test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert (cycpattern_check(\"xyzw\",\"xyw\") == false );\n assert (cycpattern_check(\"yello\",\"ell\") == true );\n assert (cycpattern_check(\"whattup\",\"ptut\") == false );\n assert (cycpattern_check(\"efef\",\"fee\") == true );\n assert (cycpattern_check(\"abab\",\"aabb\") == false );\n assert (cycpattern_check(\"winemtt\",\"tinem\") == true );\n}\n", "declaration": "#include<stdio.h>\n#include<string>\nusing namespace std;\n#include<algorithm>\n#include<math.h>\n#include<stdlib.h>\nbool cycpattern_check(string a,string b){\n", "example_test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert (cycpattern_check(\"abcd\",\"abd\") == false );\n assert (cycpattern_check(\"hello\",\"ell\") == true );\n assert (cycpattern_check(\"whassup\",\"psus\") == false );\n assert (cycpattern_check(\"abab\",\"baa\") == true );\n assert (cycpattern_check(\"efef\",\"eeff\") == false );\n assert (cycpattern_check(\"himenss\",\"simen\") == true );\n}\n", "buggy_solution": " for (int i=0;i<b.size();i++)\n {\n string rotate=b.substr(i)+b.substr(0);\n if (a.find(rotate)!=string::npos) return true;\n }\n return false;\n\n}\n", "bug_type": "value misuse", "failure_symptoms": "incorrect output", "entry_point": "cycpattern_check", "signature": "bool cycpattern_check(string a,string b)", "docstring": "You are given 2 words. You need to return true if the second word or any of its rotations is a substring in the first word\ncycpattern_check(\"abcd\",\"abd\") => false\ncycpattern_check(\"hello\",\"ell\") => true\ncycpattern_check(\"whassup\",\"psus\") => false\ncycpattern_check(\"abab\",\"baa\") => true\ncycpattern_check(\"efef\",\"eeff\") => false\ncycpattern_check(\"himenss\",'simen\") => true", "instruction": "Write a C++ function `bool cycpattern_check(string a,string b)` to solve the following problem:\nYou are given 2 words. You need to return true if the second word or any of its rotations is a substring in the first word\ncycpattern_check(\"abcd\",\"abd\") => false\ncycpattern_check(\"hello\",\"ell\") => true\ncycpattern_check(\"whassup\",\"psus\") => false\ncycpattern_check(\"abab\",\"baa\") => true\ncycpattern_check(\"efef\",\"eeff\") => false\ncycpattern_check(\"himenss\",'simen\") => true"}
156
  {"task_id": "CPP/155", "prompt": "/*\nGiven an integer. return a vector that has the number of even and odd digits respectively.\n\n Example:\n even_odd_count(-12) ==> {1, 1}\n even_odd_count(123) ==> {1, 2}\n*/\n#include<stdio.h>\n#include<math.h>\n#include<string>\n#include<vector>\nusing namespace std;\nvector<int> even_odd_count(int num){\n", "canonical_solution": " string w=to_string(abs(num));\n int n1=0,n2=0;\n for (int i=0;i<w.length();i++)\n if (w[i]%2==1) n1+=1;\n else n2+=1;\n return {n2,n1};\n}\n", "test": "#undef NDEBUG\n#include<assert.h>\nbool issame(vector<int> a,vector<int>b){\n if (a.size()!=b.size()) return false;\n for (int i=0;i<a.size();i++)\n {\n if (a[i]!=b[i]) return false;\n }\n return true;\n}\nint main(){\n assert (issame(even_odd_count(7) , {0, 1}));\n assert (issame(even_odd_count(-78) , {1, 1}));\n assert (issame(even_odd_count(3452) , {2, 2}));\n assert (issame(even_odd_count(346211) , {3, 3}));\n assert (issame(even_odd_count(-345821) , {3, 3}));\n assert (issame(even_odd_count(-2) , {1, 0}));\n assert (issame(even_odd_count(-45347) , {2, 3}));\n assert (issame(even_odd_count(0) , {1, 0}));\n}\n", "declaration": "#include<stdio.h>\n#include<math.h>\n#include<string>\n#include<vector>\nusing namespace std;\n#include<algorithm>\n#include<stdlib.h>\nvector<int> even_odd_count(int num){\n", "example_test": "#undef NDEBUG\n#include<assert.h>\nbool issame(vector<int> a,vector<int>b){\n if (a.size()!=b.size()) return false;\n for (int i=0;i<a.size();i++)\n {\n if (a[i]!=b[i]) return false;\n }\n return true;\n}\nint main(){\n assert (issame(even_odd_count(-12) , {1, 1}));\n assert (issame(even_odd_count(123) , {1, 2}));\n}\n", "buggy_solution": " string w=to_string(abs(num));\n int n1=0,n2=0;\n for (int i=0;i<w.length();i++)\n if (w[i]%2==1) n1+=1;\n return {n2,n1};\n}\n", "bug_type": "missing logic", "failure_symptoms": "incorrect output", "entry_point": "even_odd_count", "signature": "vector<int> even_odd_count(int num)", "docstring": "Given an integer. return a vector that has the number of even and odd digits respectively.\nExample:\neven_odd_count(-12) ==> {1, 1}\neven_odd_count(123) ==> {1, 2}", "instruction": "Write a C++ function `vector<int> even_odd_count(int num)` to solve the following problem:\nGiven an integer. return a vector that has the number of even and odd digits respectively.\nExample:\neven_odd_count(-12) ==> {1, 1}\neven_odd_count(123) ==> {1, 2}"}
157
- {"task_id": "CPP/156", "prompt": "/*\nGiven a positive integer, obtain its roman numeral equivalent as a string,\nand return it in lowercase.\nRestrictions: 1 <= num <= 1000\n\nExamples:\n>>> int_to_mini_roman(19) == \"xix\"\n>>> int_to_mini_roman(152) == \"clii\"\n>>> int_to_mini_roman(426) == \"cdxxvi\"\n*/\n#include<stdio.h>\n#include<vector>\n#include<string>\nusing namespace std;\nstring int_to_mini_romank(int number){\n", "canonical_solution": " string current=\"\";\n vector<string> rep={\"m\",\"cm\",\"d\",\"cd\",\"c\",\"xc\",\"l\",\"xl\",\"x\",\"ix\",\"v\",\"iv\",\"i\"};\n vector<int> num={1000,900,500,400,100,90,50,40,10,9,5,4,1};\n int pos=0;\n while(number>0)\n {\n while (number>=num[pos])\n {\n current=current+rep[pos];\n number-=num[pos];\n }\n if (number>0) pos+=1;\n }\n return current;\n}\n", "test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert (int_to_mini_romank(19) == \"xix\");\n assert (int_to_mini_romank(152) == \"clii\");\n assert (int_to_mini_romank(251) == \"ccli\");\n assert (int_to_mini_romank(426) == \"cdxxvi\");\n assert (int_to_mini_romank(500) == \"d\");\n assert (int_to_mini_romank(1) == \"i\");\n assert (int_to_mini_romank(4) == \"iv\");\n assert (int_to_mini_romank(43) == \"xliii\");\n assert (int_to_mini_romank(90) == \"xc\");\n assert (int_to_mini_romank(94) == \"xciv\");\n assert (int_to_mini_romank(532) == \"dxxxii\");\n assert (int_to_mini_romank(900) == \"cm\");\n assert (int_to_mini_romank(994) == \"cmxciv\");\n assert (int_to_mini_romank(1000) == \"m\");\n}\n", "declaration": "#include<stdio.h>\n#include<vector>\n#include<string>\nusing namespace std;\n#include<algorithm>\n#include<math.h>\n#include<stdlib.h>\nstring int_to_mini_romank(int number){\n", "example_test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert (int_to_mini_romank(19) == \"xix\");\n assert (int_to_mini_romank(152) == \"clii\");\n assert (int_to_mini_romank(426) == \"cdxxvi\");\n}\n", "buggy_solution": " string current=\"\";\n vector<string> rep={\"m\",\"cm\",\"d\",\"cd\",\"c\",\"xc\",\"l\",\"xl\",\"x\",\"ix\",\"v\",\"iv\",\"i\"};\n vector<int> num={1000,900,500,400,100,90,50,40,10,9,5,4,1};\n int pos=0;\n while(number>0)\n {\n while (number>=num[pos])\n {\n current=current+rep[pos];\n }\n if (number>0) pos+=1;\n }\n return current;\n}\n", "bug_type": "missing logic", "failure_symptoms": "infinite loop", "entry_point": "int_to_mini_roman", "signature": "string int_to_mini_romank(int number)", "docstring": "Given a positive integer, obtain its roman numeral equivalent as a string,\nand return it in lowercase.\nRestrictions: 1 <= num <= 1000\nExamples:\n>>> int_to_mini_roman(19) == \"xix\"\n>>> int_to_mini_roman(152) == \"clii\"\n>>> int_to_mini_roman(426) == \"cdxxvi\"", "instruction": "Write a C++ function `string int_to_mini_romank(int number)` to solve the following problem:\nGiven a positive integer, obtain its roman numeral equivalent as a string,\nand return it in lowercase.\nRestrictions: 1 <= num <= 1000\nExamples:\n>>> int_to_mini_roman(19) == \"xix\"\n>>> int_to_mini_roman(152) == \"clii\"\n>>> int_to_mini_roman(426) == \"cdxxvi\""}
158
  {"task_id": "CPP/157", "prompt": "/*\nGiven the lengths of the three sides of a triangle. Return true if the three\nsides form a right-angled triangle, false otherwise.\nA right-angled triangle is a triangle in which one angle is right angle or \n90 degree.\nExample:\nright_angle_triangle(3, 4, 5) == true\nright_angle_triangle(1, 2, 3) == false\n*/\n#include<stdio.h>\n#include<math.h>\nusing namespace std;\nbool right_angle_triangle(float a,float b,float c){\n", "canonical_solution": " if (abs(a*a+b*b-c*c)<1e-4 or abs(a*a+c*c-b*b)<1e-4 or abs(b*b+c*c-a*a)<1e-4) return true;\n return false;\n}\n", "test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert (right_angle_triangle(3, 4, 5) == true);\n assert (right_angle_triangle(1, 2, 3) == false);\n assert (right_angle_triangle(10, 6, 8) == true);\n assert (right_angle_triangle(2, 2, 2) == false);\n assert (right_angle_triangle(7, 24, 25) == true);\n assert (right_angle_triangle(10, 5, 7) == false);\n assert (right_angle_triangle(5, 12, 13) == true);\n assert (right_angle_triangle(15, 8, 17) == true);\n assert (right_angle_triangle(48, 55, 73) == true);\n assert (right_angle_triangle(1, 1, 1) == false);\n assert (right_angle_triangle(2, 2, 10) == false);\n}\n", "declaration": "#include<stdio.h>\n#include<math.h>\nusing namespace std;\n#include<algorithm>\n#include<stdlib.h>\nbool right_angle_triangle(float a,float b,float c){\n", "example_test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert (right_angle_triangle(3, 4, 5) == true);\n assert (right_angle_triangle(1, 2, 3) == false);\n}\n", "buggy_solution": " if (abs(a*a+b*b-c*c)<1e-4) return true;\n return false;\n}\n", "bug_type": "missing logic", "failure_symptoms": "incorrect output", "entry_point": "right_angle_triangle", "signature": "bool right_angle_triangle(float a,float b,float c)", "docstring": "Given the lengths of the three sides of a triangle. Return true if the three\nsides form a right-angled triangle, false otherwise.\nA right-angled triangle is a triangle in which one angle is right angle or\n90 degree.\nExample:\nright_angle_triangle(3, 4, 5) == true\nright_angle_triangle(1, 2, 3) == false", "instruction": "Write a C++ function `bool right_angle_triangle(float a,float b,float c)` to solve the following problem:\nGiven the lengths of the three sides of a triangle. Return true if the three\nsides form a right-angled triangle, false otherwise.\nA right-angled triangle is a triangle in which one angle is right angle or\n90 degree.\nExample:\nright_angle_triangle(3, 4, 5) == true\nright_angle_triangle(1, 2, 3) == false"}
159
  {"task_id": "CPP/158", "prompt": "/*\nWrite a function that accepts a vector of strings.\nThe vector contains different words. Return the word with maximum number\nof unique characters. If multiple strings have maximum number of unique\ncharacters, return the one which comes first in lexicographical order.\n\nfind_max({\"name\", \"of\", 'string\"}) == 'string\"\nfind_max({\"name\", \"enam\", \"game\"}) == \"enam\"\nfind_max({\"aaaaaaa\", \"bb\" ,\"cc\"}) == \"aaaaaaa\"\n*/\n#include<stdio.h>\n#include<vector>\n#include<string>\n#include<algorithm>\nusing namespace std;\nstring find_max(vector<string> words){\n", "canonical_solution": " string max=\"\";\n int maxu=0;\n for (int i=0;i<words.size();i++)\n {\n string unique=\"\";\n for (int j=0;j<words[i].length();j++)\n if (find(unique.begin(),unique.end(),words[i][j])==unique.end())\n unique=unique+words[i][j];\n if (unique.length()>maxu or (unique.length()==maxu and words[i]<max))\n {\n max=words[i];\n maxu=unique.length();\n }\n }\n return max;\n}\n", "test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert ((find_max({\"name\", \"of\", \"string\"}) == \"string\"));\n assert ((find_max({\"name\", \"enam\", \"game\"}) == \"enam\"));\n assert ((find_max({\"aaaaaaa\", \"bb\", \"cc\"}) == \"aaaaaaa\"));\n assert ((find_max({\"abc\", \"cba\"}) == \"abc\"));\n assert ((find_max({\"play\", \"this\", \"game\", \"of\",\"footbott\"}) == \"footbott\"));\n assert ((find_max({\"we\", \"are\", \"gonna\", \"rock\"}) == \"gonna\"));\n assert ((find_max({\"we\", \"are\", \"a\", \"mad\", \"nation\"}) == \"nation\"));\n assert ((find_max({\"this\", \"is\", \"a\", \"prrk\"}) == \"this\"));\n assert ((find_max({\"b\"}) == \"b\"));\n assert ((find_max({\"play\", \"play\", \"play\"}) == \"play\"));\n}\n", "declaration": "#include<stdio.h>\n#include<vector>\n#include<string>\n#include<algorithm>\nusing namespace std;\n#include<math.h>\n#include<stdlib.h>\nstring find_max(vector<string> words){\n", "example_test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert ((find_max({\"name\", \"of\", \"string\"}) == \"string\"));\n assert ((find_max({\"name\", \"enam\", \"game\"}) == \"enam\"));\n assert ((find_max({\"aaaaaaa\", \"bb\", \"cc\"}) == \"aaaaaaa\"));\n}\n", "buggy_solution": " string max=\"\";\n int maxu=0;\n for (int i=0;i<words.size();i++)\n {\n string unique=\"\";\n for (int j=0;j<words[i].length();j++)\n if (find(unique.begin(),unique.end(),words[i][j])==unique.end())\n unique=unique+words[i][j];\n if (unique.length()>maxu or unique.length()==maxu)\n {\n max=words[i];\n maxu=unique.length();\n }\n }\n return max;\n}\n", "bug_type": "missing logic", "failure_symptoms": "incorrect output", "entry_point": "find_max", "signature": "string find_max(vector<string> words)", "docstring": "Write a function that accepts a vector of strings.\nThe vector contains different words. Return the word with maximum number\nof unique characters. If multiple strings have maximum number of unique\ncharacters, return the one which comes first in lexicographical order.\nfind_max({\"name\", \"of\", 'string\"}) == 'string\"\nfind_max({\"name\", \"enam\", \"game\"}) == \"enam\"\nfind_max({\"aaaaaaa\", \"bb\" ,\"cc\"}) == \"aaaaaaa\"", "instruction": "Write a C++ function `string find_max(vector<string> words)` to solve the following problem:\nWrite a function that accepts a vector of strings.\nThe vector contains different words. Return the word with maximum number\nof unique characters. If multiple strings have maximum number of unique\ncharacters, return the one which comes first in lexicographical order.\nfind_max({\"name\", \"of\", 'string\"}) == 'string\"\nfind_max({\"name\", \"enam\", \"game\"}) == \"enam\"\nfind_max({\"aaaaaaa\", \"bb\" ,\"cc\"}) == \"aaaaaaa\""}
160
  {"task_id": "CPP/159", "prompt": "/*\nYou\"re a hungry rabbit, and you already have eaten a certain number of carrots,\nbut now you need to eat more carrots to complete the day's meals.\nyou should return a vector of { total number of eaten carrots after your meals,\n the number of carrots left after your meals }\nif there are not enough remaining carrots, you will eat all remaining carrots, but will still be hungry.\n\nExample:\n* eat(5, 6, 10) -> {11, 4}\n* eat(4, 8, 9) -> {12, 1}\n* eat(1, 10, 10) -> {11, 0}\n* eat(2, 11, 5) -> {7, 0}\n\nVariables:\n@number : integer\n the number of carrots that you have eaten.\n@need : integer\n the number of carrots that you need to eat.\n@remaining : integer\n the number of remaining carrots thet exist in stock\n\nConstrain:\n* 0 <= number <= 1000\n* 0 <= need <= 1000\n* 0 <= remaining <= 1000\n\nHave fun :)\n*/\n#include<stdio.h>\n#include<vector>\nusing namespace std;\nvector<int> eat(int number,int need,int remaining){\n", "canonical_solution": " if (need>remaining) return {number+remaining, 0};\n return {number+need,remaining-need};\n}\n", "test": "#undef NDEBUG\n#include<assert.h>\nbool issame(vector<int> a,vector<int>b){\n if (a.size()!=b.size()) return false;\n for (int i=0;i<a.size();i++)\n {\n if (a[i]!=b[i]) return false;\n }\n return true;\n}\nint main(){\n assert (issame(eat(5, 6, 10) , {11, 4}));\n assert (issame(eat(4, 8, 9) , {12, 1}));\n assert (issame(eat(1, 10, 10) , {11, 0}));\n assert (issame(eat(2, 11, 5) , {7, 0}));\n \n assert (issame(eat(4, 5, 7) , {9, 2}));\n assert (issame(eat(4, 5, 1) , {5, 0}));\n}\n", "declaration": "#include<stdio.h>\n#include<vector>\nusing namespace std;\n#include<algorithm>\n#include<math.h>\n#include<stdlib.h>\nvector<int> eat(int number,int need,int remaining){\n", "example_test": "#undef NDEBUG\n#include<assert.h>\nbool issame(vector<int> a,vector<int>b){\n if (a.size()!=b.size()) return false;\n for (int i=0;i<a.size();i++)\n {\n if (a[i]!=b[i]) return false;\n }\n return true;\n}\nint main(){\n assert (issame(eat(5, 6, 10) , {11, 4}));\n assert (issame(eat(4, 8, 9) , {12, 1}));\n assert (issame(eat(1, 10, 10) , {11, 0}));\n assert (issame(eat(2, 11, 5) , {7, 0}));\n}\n", "buggy_solution": " if (need>remaining) return {number+need+remaining, 0};\n return {number+need,number+remaining-need};\n}\n", "bug_type": "excess logic", "failure_symptoms": "incorrect output", "entry_point": "eat", "signature": "vector<int> eat(int number,int need,int remaining)", "docstring": "You\"re a hungry rabbit, and you already have eaten a certain number of carrots,\nbut now you need to eat more carrots to complete the day's meals.\nyou should return a vector of { total number of eaten carrots after your meals,\nthe number of carrots left after your meals }\nif there are not enough remaining carrots, you will eat all remaining carrots, but will still be hungry.\nExample:\n* eat(5, 6, 10) -> {11, 4}\n* eat(4, 8, 9) -> {12, 1}\n* eat(1, 10, 10) -> {11, 0}\n* eat(2, 11, 5) -> {7, 0}\nVariables:\n@number : integer\nthe number of carrots that you have eaten.\n@need : integer\nthe number of carrots that you need to eat.\n@remaining : integer\nthe number of remaining carrots thet exist in stock\nConstrain:\n* 0 <= number <= 1000\n* 0 <= need <= 1000\n* 0 <= remaining <= 1000\nHave fun :)", "instruction": "Write a C++ function `vector<int> eat(int number,int need,int remaining)` to solve the following problem:\nYou\"re a hungry rabbit, and you already have eaten a certain number of carrots,\nbut now you need to eat more carrots to complete the day's meals.\nyou should return a vector of { total number of eaten carrots after your meals,\nthe number of carrots left after your meals }\nif there are not enough remaining carrots, you will eat all remaining carrots, but will still be hungry.\nExample:\n* eat(5, 6, 10) -> {11, 4}\n* eat(4, 8, 9) -> {12, 1}\n* eat(1, 10, 10) -> {11, 0}\n* eat(2, 11, 5) -> {7, 0}\nVariables:\n@number : integer\nthe number of carrots that you have eaten.\n@need : integer\nthe number of carrots that you need to eat.\n@remaining : integer\nthe number of remaining carrots thet exist in stock\nConstrain:\n* 0 <= number <= 1000\n* 0 <= need <= 1000\n* 0 <= remaining <= 1000\nHave fun :)"}
 
119
  {"task_id": "CPP/118", "prompt": "/*\nYou are given a word. Your task is to find the closest vowel that stands between \ntwo consonants from the right side of the word (case sensitive).\n\nVowels in the beginning and ending doesn't count. Return empty string if you didn't\nfind any vowel met the above condition. \n\nYou may assume that the given string contains English letter only.\n\nExample:\nget_closest_vowel(\"yogurt\") ==> \"u\"\nget_closest_vowel(\"FULL\") ==> \"U\"\nget_closest_vowel(\"quick\") ==> \"\"\nget_closest_vowel(\"ab\") ==> \"\"\n*/\n#include<stdio.h>\n#include<string>\n#include<algorithm>\nusing namespace std;\nstring get_closest_vowel(string word){\n", "canonical_solution": " string out=\"\";\n string vowels=\"AEIOUaeiou\";\n for (int i=word.length()-2;i>=1;i-=1)\n if (find(vowels.begin(),vowels.end(),word[i])!=vowels.end())\n if (find(vowels.begin(),vowels.end(),word[i+1])==vowels.end())\n if (find(vowels.begin(),vowels.end(),word[i-1])==vowels.end())\n return out+word[i];\n return out;\n}\n", "test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert (get_closest_vowel(\"yogurt\") == \"u\");\n assert (get_closest_vowel(\"full\") == \"u\");\n assert (get_closest_vowel(\"easy\") == \"\");\n assert (get_closest_vowel(\"eAsy\") == \"\");\n assert (get_closest_vowel(\"ali\") == \"\");\n assert (get_closest_vowel(\"bad\") == \"a\");\n assert (get_closest_vowel(\"most\") ==\"o\");\n assert (get_closest_vowel(\"ab\") == \"\");\n assert (get_closest_vowel(\"ba\") == \"\");\n assert (get_closest_vowel(\"quick\") == \"\");\n assert (get_closest_vowel(\"anime\") == \"i\");\n assert (get_closest_vowel(\"Asia\") == \"\");\n assert (get_closest_vowel(\"Above\") == \"o\");\n}\n", "declaration": "#include<stdio.h>\n#include<math.h>\n#include<string>\n#include<algorithm>\nusing namespace std;\n#include<stdlib.h>\nstring get_closest_vowel(string word){\n", "example_test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert (get_closest_vowel(\"yogurt\") == \"u\");\n assert (get_closest_vowel(\"FULL\") == \"U\");\n assert (get_closest_vowel(\"ab\") == \"\");\n assert (get_closest_vowel(\"quick\") == \"\");\n}\n", "buggy_solution": " string out=\" \";\n string vowels=\"AEIOUaeiou\";\n for (int i=word.length()-2;i>=1;i-=1)\n if (find(vowels.begin(),vowels.end(),word[i])!=vowels.end())\n if (find(vowels.begin(),vowels.end(),word[i+1])==vowels.end())\n if (find(vowels.begin(),vowels.end(),word[i-1])==vowels.end())\n return out+word[i];\n return out;\n}\n", "bug_type": "excess logic", "failure_symptoms": "incorrect output", "entry_point": "get_closest_vowel", "signature": "string get_closest_vowel(string word)", "docstring": "You are given a word. Your task is to find the closest vowel that stands between\ntwo consonants from the right side of the word (case sensitive).\nVowels in the beginning and ending doesn't count. Return empty string if you didn't\nfind any vowel met the above condition.\nYou may assume that the given string contains English letter only.\nExample:\nget_closest_vowel(\"yogurt\") ==> \"u\"\nget_closest_vowel(\"FULL\") ==> \"U\"\nget_closest_vowel(\"quick\") ==> \"\"\nget_closest_vowel(\"ab\") ==> \"\"", "instruction": "Write a C++ function `string get_closest_vowel(string word)` to solve the following problem:\nYou are given a word. Your task is to find the closest vowel that stands between\ntwo consonants from the right side of the word (case sensitive).\nVowels in the beginning and ending doesn't count. Return empty string if you didn't\nfind any vowel met the above condition.\nYou may assume that the given string contains English letter only.\nExample:\nget_closest_vowel(\"yogurt\") ==> \"u\"\nget_closest_vowel(\"FULL\") ==> \"U\"\nget_closest_vowel(\"quick\") ==> \"\"\nget_closest_vowel(\"ab\") ==> \"\""}
120
  {"task_id": "CPP/119", "prompt": "/*\nYou are given a vector of two strings, both strings consist of open\nparentheses '(' or close parentheses ')' only.\nYour job is to check if it is possible to concatenate the two strings in\nsome order, that the resulting string will be good.\nA string S is considered to be good if and only if all parentheses in S\nare balanced. For example: the string \"(())()\" is good, while the string\n\"())\" is not.\nReturn \"Yes\" if there's a way to make a good string, and return \"No\" otherwise.\n\nExamples:\nmatch_parens({\"()(\", \")\"}) == \"Yes\"\nmatch_parens({\")\", \")\"}) == \"No\"\n*/\n#include<stdio.h>\n#include<vector>\n#include<string>\nusing namespace std;\nstring match_parens(vector<string> lst){\n", "canonical_solution": " string l1=lst[0]+lst[1];\n int i,count=0;\n bool can=true;\n for (i=0;i<l1.length();i++)\n {\n if (l1[i]=='(') count+=1;\n if (l1[i]==')') count-=1;\n if (count<0) can=false;\n }\n if (count!=0) return \"No\";\n if (can==true) return \"Yes\";\n l1=lst[1]+lst[0];\n can=true;\n for (i=0;i<l1.length();i++)\n {\n if (l1[i]=='(') count+=1;\n if (l1[i]==')') count-=1;\n if (count<0) can=false;\n }\n if (can==true) return \"Yes\";\n return \"No\";\n}\n", "test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert (match_parens({\"()(\", \")\"}) == \"Yes\");\n assert (match_parens({\")\", \")\"}) == \"No\");\n assert (match_parens({\"(()(())\", \"())())\"}) == \"No\");\n assert (match_parens({\")())\", \"(()()(\"}) == \"Yes\");\n assert (match_parens({\"(())))\", \"(()())((\"}) == \"Yes\");\n assert (match_parens({\"()\", \"())\"}) == \"No\");\n assert (match_parens({\"(()(\", \"()))()\"}) == \"Yes\");\n assert (match_parens({\"((((\", \"((())\"}) == \"No\");\n assert (match_parens({\")(()\", \"(()(\"}) == \"No\");\n assert (match_parens({\")(\", \")(\"}) == \"No\");\n assert (match_parens({\"(\", \")\"}) == \"Yes\");\n assert (match_parens({\")\", \"(\"}) == \"Yes\" );\n}\n", "declaration": "#include<stdio.h>\n#include<math.h>\n#include<vector>\n#include<string>\nusing namespace std;\n#include<algorithm>\n#include<stdlib.h>\nstring match_parens(vector<string> lst){\n", "example_test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert (match_parens({\"()(\", \")\"}) == \"Yes\");\n assert (match_parens({\")\", \")\"}) == \"No\");\n}\n", "buggy_solution": " string l1=lst[0]+lst[1];\n int i,count=0;\n bool can=true;\n for (i=0;i<l1.length();i++)\n {\n if (l1[i]=='(') count+=1;\n if (l1[i]==')') count-=1;\n if (count<0) can=false;\n }\n if (count!=0) return \"No\";\n if (can==true) return \"Yes\";\n l1=lst[1]+lst[0];\n can=true;\n for (i=0;i<l1.length();i++)\n {\n if (l1[i]=='(') count+=1;\n if (l1[i]==')') count-=1;\n if (count<0) can=false;\n }\n if (can==true) return \"yes\";\n return \"no\";\n}\n", "bug_type": "value misuse", "failure_symptoms": "incorrect output", "entry_point": "match_parens", "signature": "string match_parens(vector<string> lst)", "docstring": "You are given a vector of two strings, both strings consist of open\nparentheses '(' or close parentheses ')' only.\nYour job is to check if it is possible to concatenate the two strings in\nsome order, that the resulting string will be good.\nA string S is considered to be good if and only if all parentheses in S\nare balanced. For example: the string \"(())()\" is good, while the string\n\"())\" is not.\nReturn \"Yes\" if there's a way to make a good string, and return \"No\" otherwise.\nExamples:\nmatch_parens({\"()(\", \")\"}) == \"Yes\"\nmatch_parens({\")\", \")\"}) == \"No\"", "instruction": "Write a C++ function `string match_parens(vector<string> lst)` to solve the following problem:\nYou are given a vector of two strings, both strings consist of open\nparentheses '(' or close parentheses ')' only.\nYour job is to check if it is possible to concatenate the two strings in\nsome order, that the resulting string will be good.\nA string S is considered to be good if and only if all parentheses in S\nare balanced. For example: the string \"(())()\" is good, while the string\n\"())\" is not.\nReturn \"Yes\" if there's a way to make a good string, and return \"No\" otherwise.\nExamples:\nmatch_parens({\"()(\", \")\"}) == \"Yes\"\nmatch_parens({\")\", \")\"}) == \"No\""}
121
  {"task_id": "CPP/120", "prompt": "/*\nGiven a vector arr of integers and a positive integer k, return a sorted vector \nof length k with the maximum k numbers in arr.\n\nExample 1:\n\n Input: arr = {-3, -4, 5}, k = 3\n Output: {-4, -3, 5}\n\nExample 2:\n\n Input: arr = {4, -4, 4}, k = 2\n Output: {4, 4}\n\nExample 3:\n\n Input: arr = {-3, 2, 1, 2, -1, -2, 1}, k = 1\n Output: {2}\n\nNote:\n 1. The length of the vector will be in the range of {1, 1000}.\n 2. The elements in the vector will be in the range of {-1000, 1000}.\n 3. 0 <= k <= len(arr)\n*/\n#include<stdio.h>\n#include<vector>\n#include<algorithm>\nusing namespace std;\nvector<int> maximum(vector<int> arr,int k){\n", "canonical_solution": " sort(arr.begin(),arr.end());\n vector<int> out(arr.end()-k,arr.end());\n return out;\n}\n", "test": "#undef NDEBUG\n#include<assert.h>\nbool issame(vector<int> a,vector<int>b){\n if (a.size()!=b.size()) return false;\n for (int i=0;i<a.size();i++)\n {\n if (a[i]!=b[i]) return false;\n }\n return true;\n}\nint main(){\n assert (issame(maximum({-3, -4, 5}, 3) , {-4, -3, 5}));\n assert (issame(maximum({4, -4, 4}, 2) , {4, 4}));\n assert (issame(maximum({-3, 2, 1, 2, -1, -2, 1}, 1) , {2}));\n assert (issame(maximum({123, -123, 20, 0 , 1, 2, -3}, 3) , {2, 20, 123}));\n assert (issame(maximum({-123, 20, 0 , 1, 2, -3}, 4) , {0, 1, 2, 20}));\n assert (issame(maximum({5, 15, 0, 3, -13, -8, 0}, 7) , {-13, -8, 0, 0, 3, 5, 15}));\n assert (issame(maximum({-1, 0, 2, 5, 3, -10}, 2) , {3, 5}));\n assert (issame(maximum({1, 0, 5, -7}, 1) , {5}));\n assert (issame(maximum({4, -4}, 2) , {-4, 4}));\n assert (issame(maximum({-10, 10}, 2) , {-10, 10}));\n assert (issame(maximum({1, 2, 3, -23, 243, -400, 0}, 0) , {}));\n}\n", "declaration": "#include<stdio.h>\n#include<math.h>\n#include<vector>\n#include<algorithm>\nusing namespace std;\n#include<stdlib.h>\nvector<int> maximum(vector<int> arr,int k){\n", "example_test": "#undef NDEBUG\n#include<assert.h>\nbool issame(vector<int> a,vector<int>b){\n if (a.size()!=b.size()) return false;\n for (int i=0;i<a.size();i++)\n {\n if (a[i]!=b[i]) return false;\n }\n return true;\n}\nint main(){\n assert (issame(maximum({-3, -4, 5}, 3) , {-4, -3, 5}));\n assert (issame(maximum({4, -4, 4}, 2) , {4, 4}));\n assert (issame(maximum({-3, 2, 1, 2, -1, -2, 1}, 1) , {2}));\n}\n", "buggy_solution": " sort(arr.begin(),arr.end());\n vector<int> out(arr.end()-k,arr.end());\n sort(out.end(),out.begin());\n return out;\n}\n", "bug_type": "excess logic", "failure_symptoms": "incorrect output", "entry_point": "maximum", "signature": "vector<int> maximum(vector<int> arr,int k)", "docstring": "Given a vector arr of integers and a positive integer k, return a sorted vector\nof length k with the maximum k numbers in arr.\nExample 1:\nInput: arr = {-3, -4, 5}, k = 3\nOutput: {-4, -3, 5}\nExample 2:\nInput: arr = {4, -4, 4}, k = 2\nOutput: {4, 4}\nExample 3:\nInput: arr = {-3, 2, 1, 2, -1, -2, 1}, k = 1\nOutput: {2}\nNote:\n1. The length of the vector will be in the range of {1, 1000}.\n2. The elements in the vector will be in the range of {-1000, 1000}.\n3. 0 <= k <= len(arr)", "instruction": "Write a C++ function `vector<int> maximum(vector<int> arr,int k)` to solve the following problem:\nGiven a vector arr of integers and a positive integer k, return a sorted vector\nof length k with the maximum k numbers in arr.\nExample 1:\nInput: arr = {-3, -4, 5}, k = 3\nOutput: {-4, -3, 5}\nExample 2:\nInput: arr = {4, -4, 4}, k = 2\nOutput: {4, 4}\nExample 3:\nInput: arr = {-3, 2, 1, 2, -1, -2, 1}, k = 1\nOutput: {2}\nNote:\n1. The length of the vector will be in the range of {1, 1000}.\n2. The elements in the vector will be in the range of {-1000, 1000}.\n3. 0 <= k <= len(arr)"}
122
+ {"task_id": "CPP/121", "prompt": "/*\nGiven a non-empty vector of integers, return the sum of all of the odd elements that are in even positions.\n\n\nExamples\nsolution({5, 8, 7, 1}) ==> 12\nsolution({3, 3, 3, 3, 3}) ==> 9\nsolution({30, 13, 24, 321}) ==>0\n*/\n#include<stdio.h>\n#include<vector>\nusing namespace std;\nint solution(vector<int> lst){\n", "canonical_solution": " int sum=0;\n for (int i=0;i*2<lst.size();i++)\n if (lst[i*2]%2==1) sum+=lst[i*2];\n return sum;\n}\n", "test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert (solution({5, 8, 7, 1}) == 12);\n assert (solution({3, 3, 3, 3, 3}) == 9);\n assert (solution({30, 13, 24, 321}) == 0);\n assert (solution({5, 9}) == 5);\n assert (solution({2, 4, 8}) == 0);\n assert (solution({30, 13, 23, 32}) == 23);\n assert (solution({3, 13, 2, 9}) == 3);\n}\n", "declaration": "#include<stdio.h>\n#include<math.h>\n#include<vector>\nusing namespace std;\n#include<algorithm>\n#include<stdlib.h>\nint solution(vector<int> lst){\n", "example_test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert (solution({5, 8, 7, 1}) == 12);\n assert (solution({3, 3, 3, 3, 3}) == 9);\n assert (solution({30, 13, 24, 321}) == 0);\n}\n", "buggy_solution": " int sum=1;\n for (int i=0;i*2<lst.size();i++)\n if (lst[i*2]%2==1) sum+=lst[i*2];\n return sum;\n}\n", "bug_type": "value misuse", "failure_symptoms": "incorrect output", "entry_point": "solution", "signature": "int solution(vector<int> lst)", "docstring": "Given a non-empty vector of integers, return the sum of all of the odd elements that are in even positions.\nExamples\nsolution({5, 8, 7, 1}) ==> 12\nsolution({3, 3, 3, 3, 3}) ==> 9\nsolution({30, 13, 24, 321}) ==>0", "instruction": "Write a C++ function `int solution(vector<int> lst)` to solve the following problem:\nGiven a non-empty vector of integers, return the sum of all of the odd elements that are in even positions.\nExamples\nsolution({5, 8, 7, 1}) ==> 12\nsolution({3, 3, 3, 3, 3}) ==> 9\nsolution({30, 13, 24, 321}) ==>0"}
123
  {"task_id": "CPP/122", "prompt": "/*\nGiven a non-empty vector of integers arr and an integer k, return\nthe sum of the elements with at most two digits from the first k elements of arr.\n\nExample:\n\n Input: arr = {111,21,3,4000,5,6,7,8,9}, k = 4\n Output: 24 # sum of 21 + 3\n\nConstraints:\n 1. 1 <= len(arr) <= 100\n 2. 1 <= k <= len(arr)\n*/\n#include<stdio.h>\n#include<vector>\nusing namespace std;\nint add_elements(vector<int> arr,int k){\n", "canonical_solution": " int sum=0;\n for (int i=0;i<k;i++)\n if( arr[i]>=-99 and arr[i]<=99)\n sum+=arr[i];\n return sum;\n}\n", "test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert (add_elements({1,-2,-3,41,57,76,87,88,99}, 3) == -4);\n assert (add_elements({111,121,3,4000,5,6}, 2) == 0);\n assert (add_elements({11,21,3,90,5,6,7,8,9}, 4) == 125);\n assert (add_elements({111,21,3,4000,5,6,7,8,9}, 4) == 24);\n assert (add_elements({1}, 1) == 1);\n}\n", "declaration": "#include<stdio.h>\n#include<math.h>\n#include<vector>\nusing namespace std;\n#include<algorithm>\n#include<stdlib.h>\nint add_elements(vector<int> arr,int k){\n", "example_test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert (add_elements({111,21,3,4000,5,6,7,8,9}, 4) == 24);\n}\n", "buggy_solution": " int sum=0;\n for (int i=0;i<arr.size();i++)\n if( arr[i]>=-99 and arr[i]<=99)\n sum+=arr[i];\n return sum;\n}\n", "bug_type": "missing logic", "failure_symptoms": "incorrect output", "entry_point": "add_elements", "signature": "int add_elements(vector<int> arr,int k)", "docstring": "Given a non-empty vector of integers arr and an integer k, return\nthe sum of the elements with at most two digits from the first k elements of arr.\nExample:\nInput: arr = {111,21,3,4000,5,6,7,8,9}, k = 4\nOutput: 24 # sum of 21 + 3\nConstraints:\n1. 1 <= len(arr) <= 100\n2. 1 <= k <= len(arr)", "instruction": "Write a C++ function `int add_elements(vector<int> arr,int k)` to solve the following problem:\nGiven a non-empty vector of integers arr and an integer k, return\nthe sum of the elements with at most two digits from the first k elements of arr.\nExample:\nInput: arr = {111,21,3,4000,5,6,7,8,9}, k = 4\nOutput: 24 # sum of 21 + 3\nConstraints:\n1. 1 <= len(arr) <= 100\n2. 1 <= k <= len(arr)"}
124
  {"task_id": "CPP/123", "prompt": "/*\nGiven a positive integer n, return a sorted vector that has the odd numbers in collatz sequence.\n\nThe Collatz conjecture is a conjecture in mathematics that concerns a sequence defined\nas follows: start with any positive integer n. Then each term is obtained from the \nprevious term as follows: if the previous term is even, the next term is one half of \nthe previous term. If the previous term is odd, the next term is 3 times the previous\nterm plus 1. The conjecture is that no matter what value of n, the sequence will always reach 1.\n\nNote: \n 1. Collatz(1) is {1}.\n 2. returned vector sorted in increasing order.\n\nFor example:\nget_odd_collatz(5) returns {1, 5} // The collatz sequence for 5 is {5, 16, 8, 4, 2, 1}, so the odd numbers are only 1, and 5.\n*/\n#include<stdio.h>\n#include<vector>\n#include<algorithm>\nusing namespace std;\nvector<int> get_odd_collatz(int n){\n", "canonical_solution": " vector<int> out={1};\n while (n!=1)\n {\n if (n%2==1) {out.push_back(n); n=n*3+1;}\n else n=n/2;\n }\n sort(out.begin(),out.end());\n return out;\n}\n", "test": "#undef NDEBUG\n#include<assert.h>\nbool issame(vector<int> a,vector<int>b){\n if (a.size()!=b.size()) return false;\n for (int i=0;i<a.size();i++)\n {\n if (a[i]!=b[i]) return false;\n }\n return true;\n}\nint main(){\n assert (issame(get_odd_collatz(14) , {1, 5, 7, 11, 13, 17}));\n assert (issame(get_odd_collatz(5) , {1, 5}));\n assert (issame(get_odd_collatz(12) , {1, 3, 5}));\n assert (issame(get_odd_collatz(1) , {1}));\n}\n", "declaration": "#include<stdio.h>\n#include<math.h>\n#include<vector>\n#include<algorithm>\nusing namespace std;\n#include<stdlib.h>\nvector<int> get_odd_collatz(int n){\n", "example_test": "#undef NDEBUG\n#include<assert.h>\nbool issame(vector<int> a,vector<int>b){\n if (a.size()!=b.size()) return false;\n for (int i=0;i<a.size();i++)\n {\n if (a[i]!=b[i]) return false;\n }\n return true;\n}\nint main(){\n assert (issame(get_odd_collatz(5) , {1, 5}));\n}\n", "buggy_solution": " vector<int> out={1};\n while (n!=1)\n {\n if (n%2==1) {out.push_back(n); n=n*2+1;}\n else n=n/2;\n }\n sort(out.begin(),out.end());\n return out;\n}\n", "bug_type": "value misuse", "failure_symptoms": "incorrect output", "entry_point": "get_odd_collatz", "signature": "vector<int> get_odd_collatz(int n)", "docstring": "Given a positive integer n, return a sorted vector that has the odd numbers in collatz sequence.\nThe Collatz conjecture is a conjecture in mathematics that concerns a sequence defined\nas follows: start with any positive integer n. Then each term is obtained from the\nprevious term as follows: if the previous term is even, the next term is one half of\nthe previous term. If the previous term is odd, the next term is 3 times the previous\nterm plus 1. The conjecture is that no matter what value of n, the sequence will always reach 1.\nNote:\n1. Collatz(1) is {1}.\n2. returned vector sorted in increasing order.\nFor example:\nget_odd_collatz(5) returns {1, 5} // The collatz sequence for 5 is {5, 16, 8, 4, 2, 1}, so the odd numbers are only 1, and 5.", "instruction": "Write a C++ function `vector<int> get_odd_collatz(int n)` to solve the following problem:\nGiven a positive integer n, return a sorted vector that has the odd numbers in collatz sequence.\nThe Collatz conjecture is a conjecture in mathematics that concerns a sequence defined\nas follows: start with any positive integer n. Then each term is obtained from the\nprevious term as follows: if the previous term is even, the next term is one half of\nthe previous term. If the previous term is odd, the next term is 3 times the previous\nterm plus 1. The conjecture is that no matter what value of n, the sequence will always reach 1.\nNote:\n1. Collatz(1) is {1}.\n2. returned vector sorted in increasing order.\nFor example:\nget_odd_collatz(5) returns {1, 5} // The collatz sequence for 5 is {5, 16, 8, 4, 2, 1}, so the odd numbers are only 1, and 5."}
125
  {"task_id": "CPP/124", "prompt": "/*\nYou have to write a function which validates a given date string and\nreturns true if the date is valid otherwise false.\nThe date is valid if all of the following rules are satisfied:\n1. The date string is not empty.\n2. The number of days is not less than 1 or higher than 31 days for months 1,3,5,7,8,10,12. And the number of days is not less than 1 or higher than 30 days for months 4,6,9,11. And, the number of days is not less than 1 or higher than 29 for the month 2.\n3. The months should not be less than 1 or higher than 12.\n4. The date should be in the format: mm-dd-yyyy\n\nfor example: \nvalid_date(\"03-11-2000\") => true\n\nvalid_date(\"15-01-2012\") => false\n\nvalid_date(\"04-0-2040\") => false\n\nvalid_date(\"06-04-2020\") => true\n\nvalid_date(\"06/04/2020\") => false\n*/\n#include<stdio.h>\n#include<string>\nusing namespace std;\nbool valid_date(string date){\n", "canonical_solution": " int mm,dd,yy,i;\n if (date.length()!=10) return false;\n for (int i=0;i<10;i++)\n if (i==2 or i==5)\n {\n if (date[i]!='-') return false;\n }\n else\n if (date[i]<48 or date[i]>57) return false;\n\n mm=atoi(date.substr(0,2).c_str());\n dd=atoi(date.substr(3,2).c_str());\n yy=atoi(date.substr(6,4).c_str());\n if (mm<1 or mm>12) return false;\n if (dd<1 or dd>31) return false;\n if (dd==31 and (mm==4 or mm==6 or mm==9 or mm==11 or mm==2)) return false;\n if (dd==30 and mm==2) return false;\n return true;\n\n}\n", "test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert (valid_date(\"03-11-2000\") == true);\n assert (valid_date(\"15-01-2012\") == false);\n assert (valid_date(\"04-0-2040\") == false);\n assert (valid_date(\"06-04-2020\") == true);\n assert (valid_date(\"01-01-2007\") == true);\n assert (valid_date(\"03-32-2011\") == false);\n assert (valid_date(\"\") == false);\n assert (valid_date(\"04-31-3000\") == false);\n assert (valid_date(\"06-06-2005\") == true);\n assert (valid_date(\"21-31-2000\") == false);\n assert (valid_date(\"04-12-2003\") == true);\n assert (valid_date(\"04122003\") == false);\n assert (valid_date(\"20030412\") == false);\n assert (valid_date(\"2003-04\") == false);\n assert (valid_date(\"2003-04-12\") == false);\n assert (valid_date(\"04-2003\") == false);\n}\n", "declaration": "#include<stdio.h>\n#include<math.h>\n#include<string>\n#include<algorithm>\nusing namespace std;\n#include<stdlib.h>\nbool valid_date(string date){\n", "example_test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert (valid_date(\"03-11-2000\") == true);\n assert (valid_date(\"15-01-2012\") == false);\n assert (valid_date(\"04-0-2040\") == false);\n assert (valid_date(\"06-04-2020\") == true);\n assert (valid_date(\"06/04/2020\") == false);\n}\n", "buggy_solution": " int dd,mm,yy,i;\n if (date.length()!=10) return false;\n for (int i=0;i<10;i++)\n if (i==2 or i==5)\n {\n if (date[i]!='-') return false;\n }\n else\n if (date[i]<48 or date[i]>57) return false;\n\n dd=atoi(date.substr(0,2).c_str());\n mm=atoi(date.substr(3,2).c_str());\n yy=atoi(date.substr(6,4).c_str());\n if (mm<1 or mm>12) return false;\n if (dd<1 or dd>31) return false;\n if (dd==31 and (mm==4 or mm==6 or mm==9 or mm==11 or mm==2)) return false;\n if (dd==30 and mm==2) return false;\n return true;\n\n}\n", "bug_type": "variable misuse", "failure_symptoms": "incorrect output", "entry_point": "valid_date", "signature": "bool valid_date(string date)", "docstring": "You have to write a function which validates a given date string and\nreturns true if the date is valid otherwise false.\nThe date is valid if all of the following rules are satisfied:\n1. The date string is not empty.\n2. The number of days is not less than 1 or higher than 31 days for months 1,3,5,7,8,10,12. And the number of days is not less than 1 or higher than 30 days for months 4,6,9,11. And, the number of days is not less than 1 or higher than 29 for the month 2.\n3. The months should not be less than 1 or higher than 12.\n4. The date should be in the format: mm-dd-yyyy\nfor example:\nvalid_date(\"03-11-2000\") => true\nvalid_date(\"15-01-2012\") => false\nvalid_date(\"04-0-2040\") => false\nvalid_date(\"06-04-2020\") => true\nvalid_date(\"06/04/2020\") => false", "instruction": "Write a C++ function `bool valid_date(string date)` to solve the following problem:\nYou have to write a function which validates a given date string and\nreturns true if the date is valid otherwise false.\nThe date is valid if all of the following rules are satisfied:\n1. The date string is not empty.\n2. The number of days is not less than 1 or higher than 31 days for months 1,3,5,7,8,10,12. And the number of days is not less than 1 or higher than 30 days for months 4,6,9,11. And, the number of days is not less than 1 or higher than 29 for the month 2.\n3. The months should not be less than 1 or higher than 12.\n4. The date should be in the format: mm-dd-yyyy\nfor example:\nvalid_date(\"03-11-2000\") => true\nvalid_date(\"15-01-2012\") => false\nvalid_date(\"04-0-2040\") => false\nvalid_date(\"06-04-2020\") => true\nvalid_date(\"06/04/2020\") => false"}
 
154
  {"task_id": "CPP/153", "prompt": "/*\nYou will be given the name of a class (a string) and a vector of extensions.\nThe extensions are to be used to load additional classes to the class. The\nstrength of the extension is as follows: Let CAP be the number of the uppercase\nletters in the extension's name, and let SM be the number of lowercase letters \nin the extension's name, the strength is given by the fraction CAP - SM. \nYou should find the strongest extension and return a string in this \nformat: ClassName.StrongestExtensionName.\nIf there are two or more extensions with the same strength, you should\nchoose the one that comes first in the vector.\nFor example, if you are given \"Slices\" as the class and a vector of the\nextensions: {\"SErviNGSliCes\", \"Cheese\", \"StuFfed\"} then you should\nreturn \"Slices.SErviNGSliCes\" since \"SErviNGSliCes\" is the strongest extension \n(its strength is -1).\nExample:\nfor Strongest_Extension(\"my_class\", {\"AA\", \"Be\", \"CC\"}) == \"my_class.AA\"\n*/\n#include<stdio.h>\n#include<vector>\n#include<string>\nusing namespace std;\nstring Strongest_Extension(string class_name,vector<string> extensions){\n", "canonical_solution": " string strongest=\"\";\n int max=-1000;\n for (int i=0;i<extensions.size();i++)\n {\n int strength=0;\n for (int j=0;j<extensions[i].length();j++)\n {\n char chr=extensions[i][j];\n if (chr>=65 and chr<=90) strength+=1;\n if (chr>=97 and chr<=122) strength-=1;\n }\n if (strength>max) \n {\n max=strength;\n strongest=extensions[i];\n }\n }\n return class_name+'.'+strongest;\n}\n", "test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert (Strongest_Extension(\"Watashi\", {\"tEN\", \"niNE\", \"eIGHt8OKe\"}) == \"Watashi.eIGHt8OKe\");\n assert (Strongest_Extension(\"Boku123\", {\"nani\", \"NazeDa\", \"YEs.WeCaNe\", \"32145tggg\"}) == \"Boku123.YEs.WeCaNe\");\n assert (Strongest_Extension(\"__YESIMHERE\", {\"t\", \"eMptY\", \"(nothing\", \"zeR00\", \"NuLl__\", \"123NoooneB321\"}) == \"__YESIMHERE.NuLl__\");\n assert (Strongest_Extension(\"K\", {\"Ta\", \"TAR\", \"t234An\", \"cosSo\"}) == \"K.TAR\");\n assert (Strongest_Extension(\"__HAHA\", {\"Tab\", \"123\", \"781345\", \"-_-\"}) == \"__HAHA.123\");\n assert (Strongest_Extension(\"YameRore\", {\"HhAas\", \"okIWILL123\", \"WorkOut\", \"Fails\", \"-_-\"}) == \"YameRore.okIWILL123\");\n assert (Strongest_Extension(\"finNNalLLly\", {\"Die\", \"NowW\", \"Wow\", \"WoW\"}) == \"finNNalLLly.WoW\");\n assert (Strongest_Extension(\"_\", {\"Bb\", \"91245\"}) == \"_.Bb\");\n assert (Strongest_Extension(\"Sp\", {\"671235\", \"Bb\"}) == \"Sp.671235\");\n}\n", "declaration": "#include<stdio.h>\n#include<math.h>\n#include<vector>\n#include<string>\n#include<algorithm>\nusing namespace std;\n#include<stdlib.h>\nstring Strongest_Extension(string class_name,vector<string> extensions){\n", "example_test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert (Strongest_Extension(\"my_class\", {\"AA\", \"Be\", \"CC\"}) == \"my_class.AA\");\n}\n", "buggy_solution": " string strongest=\"\";\n int max=-1000;\n for (int i=0;i<extensions.size();i++)\n {\n int strength=0;\n for (int j=0;j<extensions[i].length();j++)\n {\n char chr=extensions[i][j];\n if (chr>=65 and chr<=90) strength+=1;\n if (chr>=97 and chr<=122) strength-=1;\n }\n if (strength>max) \n {\n max=strength;\n strongest=extensions[i];\n }\n }\n return class_name+strongest;\n}\n", "bug_type": "missing logic", "failure_symptoms": "incorrect output", "entry_point": "Strongest_Extension", "signature": "string Strongest_Extension(string class_name,vector<string> extensions)", "docstring": "You will be given the name of a class (a string) and a vector of extensions.\nThe extensions are to be used to load additional classes to the class. The\nstrength of the extension is as follows: Let CAP be the number of the uppercase\nletters in the extension's name, and let SM be the number of lowercase letters\nin the extension's name, the strength is given by the fraction CAP - SM.\nYou should find the strongest extension and return a string in this\nformat: ClassName.StrongestExtensionName.\nIf there are two or more extensions with the same strength, you should\nchoose the one that comes first in the vector.\nFor example, if you are given \"Slices\" as the class and a vector of the\nextensions: {\"SErviNGSliCes\", \"Cheese\", \"StuFfed\"} then you should\nreturn \"Slices.SErviNGSliCes\" since \"SErviNGSliCes\" is the strongest extension\n(its strength is -1).\nExample:\nfor Strongest_Extension(\"my_class\", {\"AA\", \"Be\", \"CC\"}) == \"my_class.AA\"", "instruction": "Write a C++ function `string Strongest_Extension(string class_name,vector<string> extensions)` to solve the following problem:\nYou will be given the name of a class (a string) and a vector of extensions.\nThe extensions are to be used to load additional classes to the class. The\nstrength of the extension is as follows: Let CAP be the number of the uppercase\nletters in the extension's name, and let SM be the number of lowercase letters\nin the extension's name, the strength is given by the fraction CAP - SM.\nYou should find the strongest extension and return a string in this\nformat: ClassName.StrongestExtensionName.\nIf there are two or more extensions with the same strength, you should\nchoose the one that comes first in the vector.\nFor example, if you are given \"Slices\" as the class and a vector of the\nextensions: {\"SErviNGSliCes\", \"Cheese\", \"StuFfed\"} then you should\nreturn \"Slices.SErviNGSliCes\" since \"SErviNGSliCes\" is the strongest extension\n(its strength is -1).\nExample:\nfor Strongest_Extension(\"my_class\", {\"AA\", \"Be\", \"CC\"}) == \"my_class.AA\""}
155
  {"task_id": "CPP/154", "prompt": "/*\nYou are given 2 words. You need to return true if the second word or any of its rotations is a substring in the first word\ncycpattern_check(\"abcd\",\"abd\") => false\ncycpattern_check(\"hello\",\"ell\") => true\ncycpattern_check(\"whassup\",\"psus\") => false\ncycpattern_check(\"abab\",\"baa\") => true\ncycpattern_check(\"efef\",\"eeff\") => false\ncycpattern_check(\"himenss\",'simen\") => true\n\n*/\n#include<stdio.h>\n#include<string>\nusing namespace std;\nbool cycpattern_check(string a,string b){\n", "canonical_solution": " for (int i=0;i<b.size();i++)\n {\n string rotate=b.substr(i)+b.substr(0,i);\n if (a.find(rotate)!=string::npos) return true;\n }\n return false;\n\n}\n", "test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert (cycpattern_check(\"xyzw\",\"xyw\") == false );\n assert (cycpattern_check(\"yello\",\"ell\") == true );\n assert (cycpattern_check(\"whattup\",\"ptut\") == false );\n assert (cycpattern_check(\"efef\",\"fee\") == true );\n assert (cycpattern_check(\"abab\",\"aabb\") == false );\n assert (cycpattern_check(\"winemtt\",\"tinem\") == true );\n}\n", "declaration": "#include<stdio.h>\n#include<string>\nusing namespace std;\n#include<algorithm>\n#include<math.h>\n#include<stdlib.h>\nbool cycpattern_check(string a,string b){\n", "example_test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert (cycpattern_check(\"abcd\",\"abd\") == false );\n assert (cycpattern_check(\"hello\",\"ell\") == true );\n assert (cycpattern_check(\"whassup\",\"psus\") == false );\n assert (cycpattern_check(\"abab\",\"baa\") == true );\n assert (cycpattern_check(\"efef\",\"eeff\") == false );\n assert (cycpattern_check(\"himenss\",\"simen\") == true );\n}\n", "buggy_solution": " for (int i=0;i<b.size();i++)\n {\n string rotate=b.substr(i)+b.substr(0);\n if (a.find(rotate)!=string::npos) return true;\n }\n return false;\n\n}\n", "bug_type": "value misuse", "failure_symptoms": "incorrect output", "entry_point": "cycpattern_check", "signature": "bool cycpattern_check(string a,string b)", "docstring": "You are given 2 words. You need to return true if the second word or any of its rotations is a substring in the first word\ncycpattern_check(\"abcd\",\"abd\") => false\ncycpattern_check(\"hello\",\"ell\") => true\ncycpattern_check(\"whassup\",\"psus\") => false\ncycpattern_check(\"abab\",\"baa\") => true\ncycpattern_check(\"efef\",\"eeff\") => false\ncycpattern_check(\"himenss\",'simen\") => true", "instruction": "Write a C++ function `bool cycpattern_check(string a,string b)` to solve the following problem:\nYou are given 2 words. You need to return true if the second word or any of its rotations is a substring in the first word\ncycpattern_check(\"abcd\",\"abd\") => false\ncycpattern_check(\"hello\",\"ell\") => true\ncycpattern_check(\"whassup\",\"psus\") => false\ncycpattern_check(\"abab\",\"baa\") => true\ncycpattern_check(\"efef\",\"eeff\") => false\ncycpattern_check(\"himenss\",'simen\") => true"}
156
  {"task_id": "CPP/155", "prompt": "/*\nGiven an integer. return a vector that has the number of even and odd digits respectively.\n\n Example:\n even_odd_count(-12) ==> {1, 1}\n even_odd_count(123) ==> {1, 2}\n*/\n#include<stdio.h>\n#include<math.h>\n#include<string>\n#include<vector>\nusing namespace std;\nvector<int> even_odd_count(int num){\n", "canonical_solution": " string w=to_string(abs(num));\n int n1=0,n2=0;\n for (int i=0;i<w.length();i++)\n if (w[i]%2==1) n1+=1;\n else n2+=1;\n return {n2,n1};\n}\n", "test": "#undef NDEBUG\n#include<assert.h>\nbool issame(vector<int> a,vector<int>b){\n if (a.size()!=b.size()) return false;\n for (int i=0;i<a.size();i++)\n {\n if (a[i]!=b[i]) return false;\n }\n return true;\n}\nint main(){\n assert (issame(even_odd_count(7) , {0, 1}));\n assert (issame(even_odd_count(-78) , {1, 1}));\n assert (issame(even_odd_count(3452) , {2, 2}));\n assert (issame(even_odd_count(346211) , {3, 3}));\n assert (issame(even_odd_count(-345821) , {3, 3}));\n assert (issame(even_odd_count(-2) , {1, 0}));\n assert (issame(even_odd_count(-45347) , {2, 3}));\n assert (issame(even_odd_count(0) , {1, 0}));\n}\n", "declaration": "#include<stdio.h>\n#include<math.h>\n#include<string>\n#include<vector>\nusing namespace std;\n#include<algorithm>\n#include<stdlib.h>\nvector<int> even_odd_count(int num){\n", "example_test": "#undef NDEBUG\n#include<assert.h>\nbool issame(vector<int> a,vector<int>b){\n if (a.size()!=b.size()) return false;\n for (int i=0;i<a.size();i++)\n {\n if (a[i]!=b[i]) return false;\n }\n return true;\n}\nint main(){\n assert (issame(even_odd_count(-12) , {1, 1}));\n assert (issame(even_odd_count(123) , {1, 2}));\n}\n", "buggy_solution": " string w=to_string(abs(num));\n int n1=0,n2=0;\n for (int i=0;i<w.length();i++)\n if (w[i]%2==1) n1+=1;\n return {n2,n1};\n}\n", "bug_type": "missing logic", "failure_symptoms": "incorrect output", "entry_point": "even_odd_count", "signature": "vector<int> even_odd_count(int num)", "docstring": "Given an integer. return a vector that has the number of even and odd digits respectively.\nExample:\neven_odd_count(-12) ==> {1, 1}\neven_odd_count(123) ==> {1, 2}", "instruction": "Write a C++ function `vector<int> even_odd_count(int num)` to solve the following problem:\nGiven an integer. return a vector that has the number of even and odd digits respectively.\nExample:\neven_odd_count(-12) ==> {1, 1}\neven_odd_count(123) ==> {1, 2}"}
157
+ {"task_id": "CPP/156", "prompt": "/*\nGiven a positive integer, obtain its roman numeral equivalent as a string,\nand return it in lowercase.\nRestrictions: 1 <= num <= 1000\n\nExamples:\n>>> int_to_mini_roman(19) == \"xix\"\n>>> int_to_mini_roman(152) == \"clii\"\n>>> int_to_mini_roman(426) == \"cdxxvi\"\n*/\n#include<stdio.h>\n#include<vector>\n#include<string>\nusing namespace std;\nstring int_to_mini_roman(int number){\n", "canonical_solution": " string current=\"\";\n vector<string> rep={\"m\",\"cm\",\"d\",\"cd\",\"c\",\"xc\",\"l\",\"xl\",\"x\",\"ix\",\"v\",\"iv\",\"i\"};\n vector<int> num={1000,900,500,400,100,90,50,40,10,9,5,4,1};\n int pos=0;\n while(number>0)\n {\n while (number>=num[pos])\n {\n current=current+rep[pos];\n number-=num[pos];\n }\n if (number>0) pos+=1;\n }\n return current;\n}\n", "test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert (int_to_mini_roman(19) == \"xix\");\n assert (int_to_mini_roman(152) == \"clii\");\n assert (int_to_mini_roman(251) == \"ccli\");\n assert (int_to_mini_roman(426) == \"cdxxvi\");\n assert (int_to_mini_roman(500) == \"d\");\n assert (int_to_mini_roman(1) == \"i\");\n assert (int_to_mini_roman(4) == \"iv\");\n assert (int_to_mini_roman(43) == \"xliii\");\n assert (int_to_mini_roman(90) == \"xc\");\n assert (int_to_mini_roman(94) == \"xciv\");\n assert (int_to_mini_roman(532) == \"dxxxii\");\n assert (int_to_mini_roman(900) == \"cm\");\n assert (int_to_mini_roman(994) == \"cmxciv\");\n assert (int_to_mini_roman(1000) == \"m\");\n}\n", "declaration": "#include<stdio.h>\n#include<vector>\n#include<string>\nusing namespace std;\n#include<algorithm>\n#include<math.h>\n#include<stdlib.h>\nstring int_to_mini_roman(int number){\n", "example_test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert (int_to_mini_roman(19) == \"xix\");\n assert (int_to_mini_roman(152) == \"clii\");\n assert (int_to_mini_roman(426) == \"cdxxvi\");\n}\n", "buggy_solution": " string current=\"\";\n vector<string> rep={\"m\",\"cm\",\"d\",\"cd\",\"c\",\"xc\",\"l\",\"xl\",\"x\",\"ix\",\"v\",\"iv\",\"i\"};\n vector<int> num={1000,900,500,400,100,90,50,40,10,9,5,4,1};\n int pos=0;\n while(number>0)\n {\n while (number>=num[pos])\n {\n current=current+rep[pos];\n }\n if (number>0) pos+=1;\n }\n return current;\n}\n", "bug_type": "missing logic", "failure_symptoms": "infinite loop", "entry_point": "int_to_mini_roman", "signature": "string int_to_mini_roman(int number)", "docstring": "Given a positive integer, obtain its roman numeral equivalent as a string,\nand return it in lowercase.\nRestrictions: 1 <= num <= 1000\nExamples:\n>>> int_to_mini_roman(19) == \"xix\"\n>>> int_to_mini_roman(152) == \"clii\"\n>>> int_to_mini_roman(426) == \"cdxxvi\"", "instruction": "Write a C++ function `string int_to_mini_roman(int number)` to solve the following problem:\nGiven a positive integer, obtain its roman numeral equivalent as a string,\nand return it in lowercase.\nRestrictions: 1 <= num <= 1000\nExamples:\n>>> int_to_mini_roman(19) == \"xix\"\n>>> int_to_mini_roman(152) == \"clii\"\n>>> int_to_mini_roman(426) == \"cdxxvi\""}
158
  {"task_id": "CPP/157", "prompt": "/*\nGiven the lengths of the three sides of a triangle. Return true if the three\nsides form a right-angled triangle, false otherwise.\nA right-angled triangle is a triangle in which one angle is right angle or \n90 degree.\nExample:\nright_angle_triangle(3, 4, 5) == true\nright_angle_triangle(1, 2, 3) == false\n*/\n#include<stdio.h>\n#include<math.h>\nusing namespace std;\nbool right_angle_triangle(float a,float b,float c){\n", "canonical_solution": " if (abs(a*a+b*b-c*c)<1e-4 or abs(a*a+c*c-b*b)<1e-4 or abs(b*b+c*c-a*a)<1e-4) return true;\n return false;\n}\n", "test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert (right_angle_triangle(3, 4, 5) == true);\n assert (right_angle_triangle(1, 2, 3) == false);\n assert (right_angle_triangle(10, 6, 8) == true);\n assert (right_angle_triangle(2, 2, 2) == false);\n assert (right_angle_triangle(7, 24, 25) == true);\n assert (right_angle_triangle(10, 5, 7) == false);\n assert (right_angle_triangle(5, 12, 13) == true);\n assert (right_angle_triangle(15, 8, 17) == true);\n assert (right_angle_triangle(48, 55, 73) == true);\n assert (right_angle_triangle(1, 1, 1) == false);\n assert (right_angle_triangle(2, 2, 10) == false);\n}\n", "declaration": "#include<stdio.h>\n#include<math.h>\nusing namespace std;\n#include<algorithm>\n#include<stdlib.h>\nbool right_angle_triangle(float a,float b,float c){\n", "example_test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert (right_angle_triangle(3, 4, 5) == true);\n assert (right_angle_triangle(1, 2, 3) == false);\n}\n", "buggy_solution": " if (abs(a*a+b*b-c*c)<1e-4) return true;\n return false;\n}\n", "bug_type": "missing logic", "failure_symptoms": "incorrect output", "entry_point": "right_angle_triangle", "signature": "bool right_angle_triangle(float a,float b,float c)", "docstring": "Given the lengths of the three sides of a triangle. Return true if the three\nsides form a right-angled triangle, false otherwise.\nA right-angled triangle is a triangle in which one angle is right angle or\n90 degree.\nExample:\nright_angle_triangle(3, 4, 5) == true\nright_angle_triangle(1, 2, 3) == false", "instruction": "Write a C++ function `bool right_angle_triangle(float a,float b,float c)` to solve the following problem:\nGiven the lengths of the three sides of a triangle. Return true if the three\nsides form a right-angled triangle, false otherwise.\nA right-angled triangle is a triangle in which one angle is right angle or\n90 degree.\nExample:\nright_angle_triangle(3, 4, 5) == true\nright_angle_triangle(1, 2, 3) == false"}
159
  {"task_id": "CPP/158", "prompt": "/*\nWrite a function that accepts a vector of strings.\nThe vector contains different words. Return the word with maximum number\nof unique characters. If multiple strings have maximum number of unique\ncharacters, return the one which comes first in lexicographical order.\n\nfind_max({\"name\", \"of\", 'string\"}) == 'string\"\nfind_max({\"name\", \"enam\", \"game\"}) == \"enam\"\nfind_max({\"aaaaaaa\", \"bb\" ,\"cc\"}) == \"aaaaaaa\"\n*/\n#include<stdio.h>\n#include<vector>\n#include<string>\n#include<algorithm>\nusing namespace std;\nstring find_max(vector<string> words){\n", "canonical_solution": " string max=\"\";\n int maxu=0;\n for (int i=0;i<words.size();i++)\n {\n string unique=\"\";\n for (int j=0;j<words[i].length();j++)\n if (find(unique.begin(),unique.end(),words[i][j])==unique.end())\n unique=unique+words[i][j];\n if (unique.length()>maxu or (unique.length()==maxu and words[i]<max))\n {\n max=words[i];\n maxu=unique.length();\n }\n }\n return max;\n}\n", "test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert ((find_max({\"name\", \"of\", \"string\"}) == \"string\"));\n assert ((find_max({\"name\", \"enam\", \"game\"}) == \"enam\"));\n assert ((find_max({\"aaaaaaa\", \"bb\", \"cc\"}) == \"aaaaaaa\"));\n assert ((find_max({\"abc\", \"cba\"}) == \"abc\"));\n assert ((find_max({\"play\", \"this\", \"game\", \"of\",\"footbott\"}) == \"footbott\"));\n assert ((find_max({\"we\", \"are\", \"gonna\", \"rock\"}) == \"gonna\"));\n assert ((find_max({\"we\", \"are\", \"a\", \"mad\", \"nation\"}) == \"nation\"));\n assert ((find_max({\"this\", \"is\", \"a\", \"prrk\"}) == \"this\"));\n assert ((find_max({\"b\"}) == \"b\"));\n assert ((find_max({\"play\", \"play\", \"play\"}) == \"play\"));\n}\n", "declaration": "#include<stdio.h>\n#include<vector>\n#include<string>\n#include<algorithm>\nusing namespace std;\n#include<math.h>\n#include<stdlib.h>\nstring find_max(vector<string> words){\n", "example_test": "#undef NDEBUG\n#include<assert.h>\nint main(){\n assert ((find_max({\"name\", \"of\", \"string\"}) == \"string\"));\n assert ((find_max({\"name\", \"enam\", \"game\"}) == \"enam\"));\n assert ((find_max({\"aaaaaaa\", \"bb\", \"cc\"}) == \"aaaaaaa\"));\n}\n", "buggy_solution": " string max=\"\";\n int maxu=0;\n for (int i=0;i<words.size();i++)\n {\n string unique=\"\";\n for (int j=0;j<words[i].length();j++)\n if (find(unique.begin(),unique.end(),words[i][j])==unique.end())\n unique=unique+words[i][j];\n if (unique.length()>maxu or unique.length()==maxu)\n {\n max=words[i];\n maxu=unique.length();\n }\n }\n return max;\n}\n", "bug_type": "missing logic", "failure_symptoms": "incorrect output", "entry_point": "find_max", "signature": "string find_max(vector<string> words)", "docstring": "Write a function that accepts a vector of strings.\nThe vector contains different words. Return the word with maximum number\nof unique characters. If multiple strings have maximum number of unique\ncharacters, return the one which comes first in lexicographical order.\nfind_max({\"name\", \"of\", 'string\"}) == 'string\"\nfind_max({\"name\", \"enam\", \"game\"}) == \"enam\"\nfind_max({\"aaaaaaa\", \"bb\" ,\"cc\"}) == \"aaaaaaa\"", "instruction": "Write a C++ function `string find_max(vector<string> words)` to solve the following problem:\nWrite a function that accepts a vector of strings.\nThe vector contains different words. Return the word with maximum number\nof unique characters. If multiple strings have maximum number of unique\ncharacters, return the one which comes first in lexicographical order.\nfind_max({\"name\", \"of\", 'string\"}) == 'string\"\nfind_max({\"name\", \"enam\", \"game\"}) == \"enam\"\nfind_max({\"aaaaaaa\", \"bb\" ,\"cc\"}) == \"aaaaaaa\""}
160
  {"task_id": "CPP/159", "prompt": "/*\nYou\"re a hungry rabbit, and you already have eaten a certain number of carrots,\nbut now you need to eat more carrots to complete the day's meals.\nyou should return a vector of { total number of eaten carrots after your meals,\n the number of carrots left after your meals }\nif there are not enough remaining carrots, you will eat all remaining carrots, but will still be hungry.\n\nExample:\n* eat(5, 6, 10) -> {11, 4}\n* eat(4, 8, 9) -> {12, 1}\n* eat(1, 10, 10) -> {11, 0}\n* eat(2, 11, 5) -> {7, 0}\n\nVariables:\n@number : integer\n the number of carrots that you have eaten.\n@need : integer\n the number of carrots that you need to eat.\n@remaining : integer\n the number of remaining carrots thet exist in stock\n\nConstrain:\n* 0 <= number <= 1000\n* 0 <= need <= 1000\n* 0 <= remaining <= 1000\n\nHave fun :)\n*/\n#include<stdio.h>\n#include<vector>\nusing namespace std;\nvector<int> eat(int number,int need,int remaining){\n", "canonical_solution": " if (need>remaining) return {number+remaining, 0};\n return {number+need,remaining-need};\n}\n", "test": "#undef NDEBUG\n#include<assert.h>\nbool issame(vector<int> a,vector<int>b){\n if (a.size()!=b.size()) return false;\n for (int i=0;i<a.size();i++)\n {\n if (a[i]!=b[i]) return false;\n }\n return true;\n}\nint main(){\n assert (issame(eat(5, 6, 10) , {11, 4}));\n assert (issame(eat(4, 8, 9) , {12, 1}));\n assert (issame(eat(1, 10, 10) , {11, 0}));\n assert (issame(eat(2, 11, 5) , {7, 0}));\n \n assert (issame(eat(4, 5, 7) , {9, 2}));\n assert (issame(eat(4, 5, 1) , {5, 0}));\n}\n", "declaration": "#include<stdio.h>\n#include<vector>\nusing namespace std;\n#include<algorithm>\n#include<math.h>\n#include<stdlib.h>\nvector<int> eat(int number,int need,int remaining){\n", "example_test": "#undef NDEBUG\n#include<assert.h>\nbool issame(vector<int> a,vector<int>b){\n if (a.size()!=b.size()) return false;\n for (int i=0;i<a.size();i++)\n {\n if (a[i]!=b[i]) return false;\n }\n return true;\n}\nint main(){\n assert (issame(eat(5, 6, 10) , {11, 4}));\n assert (issame(eat(4, 8, 9) , {12, 1}));\n assert (issame(eat(1, 10, 10) , {11, 0}));\n assert (issame(eat(2, 11, 5) , {7, 0}));\n}\n", "buggy_solution": " if (need>remaining) return {number+need+remaining, 0};\n return {number+need,number+remaining-need};\n}\n", "bug_type": "excess logic", "failure_symptoms": "incorrect output", "entry_point": "eat", "signature": "vector<int> eat(int number,int need,int remaining)", "docstring": "You\"re a hungry rabbit, and you already have eaten a certain number of carrots,\nbut now you need to eat more carrots to complete the day's meals.\nyou should return a vector of { total number of eaten carrots after your meals,\nthe number of carrots left after your meals }\nif there are not enough remaining carrots, you will eat all remaining carrots, but will still be hungry.\nExample:\n* eat(5, 6, 10) -> {11, 4}\n* eat(4, 8, 9) -> {12, 1}\n* eat(1, 10, 10) -> {11, 0}\n* eat(2, 11, 5) -> {7, 0}\nVariables:\n@number : integer\nthe number of carrots that you have eaten.\n@need : integer\nthe number of carrots that you need to eat.\n@remaining : integer\nthe number of remaining carrots thet exist in stock\nConstrain:\n* 0 <= number <= 1000\n* 0 <= need <= 1000\n* 0 <= remaining <= 1000\nHave fun :)", "instruction": "Write a C++ function `vector<int> eat(int number,int need,int remaining)` to solve the following problem:\nYou\"re a hungry rabbit, and you already have eaten a certain number of carrots,\nbut now you need to eat more carrots to complete the day's meals.\nyou should return a vector of { total number of eaten carrots after your meals,\nthe number of carrots left after your meals }\nif there are not enough remaining carrots, you will eat all remaining carrots, but will still be hungry.\nExample:\n* eat(5, 6, 10) -> {11, 4}\n* eat(4, 8, 9) -> {12, 1}\n* eat(1, 10, 10) -> {11, 0}\n* eat(2, 11, 5) -> {7, 0}\nVariables:\n@number : integer\nthe number of carrots that you have eaten.\n@need : integer\nthe number of carrots that you need to eat.\n@remaining : integer\nthe number of remaining carrots thet exist in stock\nConstrain:\n* 0 <= number <= 1000\n* 0 <= need <= 1000\n* 0 <= remaining <= 1000\nHave fun :)"}