diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a4afd04 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +# python cache +__pycache__/ + +# All jsonl files +data/bi/code_llama_13b/*.jsonl + +# logs folder +logs/ + +# slurm files +*.slurm \ No newline at end of file diff --git a/conversation.py b/conversation.py deleted file mode 100644 index b9c0eae..0000000 --- a/conversation.py +++ /dev/null @@ -1,71 +0,0 @@ -from dataclasses import dataclass - - -@dataclass -class Template: - """ - Defines the prompting format used to generate instructions as well as test cases. We advocate for 3 tokens, here is an example - Code : - {code} - - Instruction : - {instruction} - - Test cases : - {test case 1} - {test case 2} - {test case 3} - """ - - code_token: str = "Code:" - instruction_token: str = "Instruction:" - cases_token: str = "Test cases:" - - def get_triprompt(self, example) -> str: - """ - takes as input a dictionary, i.e. a seed example with a code, an instruction and seed tasks. - code : - def maximum(arr): - return max(arr) - instruction : - write a function which takes as input a list arr and return its maximum. - test cases : - assert maximum([1, 2, 3]) == 3 - assert maximum([1]) == 1 - """ - prompt = f"{self.code_token}\n{example['code']}\n\n{self.instruction_token}\n{example['instruction']}\n\n{self.cases_token}\n" - return prompt.strip() - - def get_biprompt(self, example) -> str: - """ - takes as input a dictionary, i.e. a seed example with a code, an instruction and seed tasks. - code : - def maximum(arr): - return max(arr) - test cases : - assert maximum([1, 2, 3]) == 3 - assert maximum([1]) == 1 - """ - prompt = f"{self.code_token}\n{example['code']}\n\n{self.cases_token}\n" - for case in example["cases"]: - prompt += f"{case}\n" - return prompt.strip() - - def copy(self): - return Template( - code_token=self.code_token, - instruction_token=self.instruction_token, - cases_token=self.cases_token - ) - -default_template = Template() - -SUPPORTED_TEMPLATES = { - "default": default_template, -} - - -def get_dialogue_template(template: str) -> Template: - if template not in SUPPORTED_TEMPLATES.keys(): - raise ValueError(f"Template {template} is not supported!") - return SUPPORTED_TEMPLATES[template].copy() diff --git a/data/bi/code_llama_13b/output.jsonl b/data/bi/code_llama_13b/output.jsonl new file mode 100644 index 0000000..e6010b7 --- /dev/null +++ b/data/bi/code_llama_13b/output.jsonl @@ -0,0 +1,45 @@ +{"instruction": "Alice has been working hard on her new programming language, but she needs some help debugging it. She wrote down a few test cases, but when Alice runs these tests, they don\u2019t work correctly. Can you figure out why?\n\n```\n>>> add(3, 4)\n7\n>>> subtract(7, 5)\n2\n>>> multiply(2, 3)\n6\n>>> divide(6, 3)\n2\n```", "input": "", "output": "In order to debug the program, we need to know what functions were defined before running the above statements. Since none of those functions appear to exist, we can assume that the problem lies within the definition of the functions themselves. Let us examine the definitions of the four functions:\n\nadd(x, y), subtract(x, y), multiply(x, y), divide(x, y)\n\nWe notice that the parameters passed into the functions are named x and y instead of a and b. This means that the variables being added/subtracted/multiplied/divided must be called x and y respectively. Thus, the expected results of the above statements are incorrect. In order to fix this bug, we simply change the names of the arguments inside the parentheses so that they match their corresponding values.\n\nFor example, the statement \u201c>>> add(3, 4)\u201d becomes \u201c>>> add(a, b)\u201d. Now, the interpreter knows that the sum of 3 and 4 equals 7. Similarly, the other three statements become \u201c>>> subtract(a, b)\u201d, \u201c>>> multiply(a, b)\u201d, and \u201c>>> divide(a, b)\u201d.", "most_similar": {"Parse the natural language query into a SQL query that can be executed on the table.": 0.08333333333333333, "Create a calculator in the Python programming language": 0.0625, "Write a python script that runs shellscript.sh every 60 minutes": 0.05970149253731343, "How do I compile a go program on Linux to a windows executable?": 0.05797101449275363, "Hey! In php, when I use `ini_set('memory_limit','6GB');`, it gives blank page? Why is that?": 0.05405405405405406, "def _process(self, data):\n X = data[1] + \" \" + data[2]\n Y = pd.get_dummies(data[0], prefix=\"y\").astype(np.float32)\n return X, Y, len(data)\nI have a bug `Failed to convert a NumPy array to a Tensor (Unsupported object type float).`. Can you show me where is the problem and how to fix it": 0.05405405405405405, "I have 2 EC2 machines on AWS, I'm having trouble making them communicate. How could I troubleshoot it?": 0.05333333333333334, "Can you provide a shell script that displays the total number of lines in all '*.txt' files in the current directory?": 0.051948051948051945, "Make a python function that takes time segments and combine then if they overlap, like this: [[0, 10], [8, 20], [25, 30]] => [[0, 20], [25, 30]]": 0.04878048780487805, "Fill in the in the html document with a propoer text. You should take the html tag into consideration. You output should be the completed html document.": 0.047619047619047616}, "avg_similarity_score": 0.02697708080135611} +{"instruction": "Implement a function that accepts a string containing digits from 2-9 with various lengths. The function should replace every digit with the word equivalent of that digit (e.g., 2 becomes \u2018two\u2019, 3 becomes \u2018three\u2019, \u2026 , 9 becomes \u2018nine\u2019). There is no need to validate the contents of the input string.", "input": "", "output": "Here is an example solution:\n\n```javascript\nfunction numToWord(str){\n var dict={};\n dict['2']='two';dict['3']='three';dict['4']='four';dict['5']='five';dict['6']='six';dict['7']='seven';dict['8']='eight';dict['9']='nine';\n str=str.split(\"\");\n for(var i=0;i List[List]:\n partitions = [] # Initialize empty list of partitions\n startIndexes = [index+1 for index in range(math.floor(numberOfElements / 2))] # Get indexes of elements to use in generating partitions\n for startIndex in startIndexes:\n partitions += recursiveGeneratePartition([startIndex], numberOfElements, startIndex) # Generate partitions recursively\n return partitions\n\ndef recursiveGeneratePartition(currentSubset: List, totalNumberOfElements: int, lastElementAdded: int) -> List:\n subsets = [] # Initialize empty list of subsets\n if len(currentSubset) >= totalNumberOfElements: # Base Case: Subset already contains enough elements\n subsets.append(currentSubset[:]) # Add copy of subset to list of subsets\n else: # Recursive Step: Keep adding more elements to the subset\n for element in range(lastElementAdded+1,totalNumberOfElements+1):\n subsets += recursiveGeneratePartition(currentSubset + [element], totalNumberOfElements, element) # Call function again with updated subset\n return subsets\n\nprint(generatePartitions(5))\n```\n\nLet us breakdown how the algorithm works:\n\nFirst, we declare an empty list of partitions. Next, we find the indices of the elements that we wish to use in our final partitions. Specifically, we choose the middle element of the desired partition plus the remaining elements on both sides of the middle element. So, for instance, if we wanted to split 5 into 3 parts, we would select the elements 2, 3, and 4.\n\nNext, we call the recursive function to generate the actual partitions. As mentioned earlier, the base case occurs when the size of the current subset reaches the target size. At this point, we append a copy of the current subset to the list of partitions. Otherwise, we keep calling the function recursively with additional elements appended onto the current subset.\n\nFinally, once the recursion terminates, we return the list of generated partitions.", "most_similar": {"Please write a Rust function that takes a u64 input and returns the largest prime number less than that value.": 0.31746031746031744, "Write a Python function that takes two numbers as input and returns their sum.": 0.2807017543859649, "Write a Python function to reverse a given list of integers.": 0.2592592592592593, "Write a python function that sorts a list from large to small.": 0.2545454545454546, "Write a C++ function that takes a map as an input and returns the largest pair in the map, in 8 lines or fewer. A pair is considered larger if its second value is larger than another pair's second value.": 0.2380952380952381, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.23333333333333336, "The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. That is,\n\nF(0) = 0, F(1) = 1\nF(n) = F(n - 1) + F(n - 2), for n > 1.\nGiven n, calculate F(n)": 0.22448979591836737, "Write a script to output the mean of a list of integers.": 0.21818181818181817, "Write a Python program that takes a list of numbers as input from the user, calculates the sum of all even numbers in the list, and returns the result. The program should check if the input is valid (i.e., if it's a list of numbers), and if it's not, it should return an error message. The program should also handle exceptions gracefully and return a user-friendly error message in case of any exceptions.": 0.21666666666666667, "Write a program to compute the sum of integers from k to n.": 0.21428571428571427}, "avg_similarity_score": 0.10766498933351276} +{"instruction": "Write a function that takes a nonnegative integer N as input and computes the binary representation of N.\n\nExample:\nInput: 5\nOutput: [1,0,1]", "input": "", "output": "Here is an example solution:\n\n```python\ndef convertBinary(decimalValue):\n binaryArray = []\n remainder = decimalValue%2\n quotient = decimalValue//2\n while True:\n binaryArray.insert(0,remainder)\n if quotient==0:break\n remainder = quotient%2\n quotient = quotient//2\n return binaryArray\n\nconvertBinary(5)\n```\n\nLet us walkthrough the logic behind the algorithm:\n\nFirst, we initialize an empty array to store the binary representation of the input. Second, we compute the modulus of the input divided by 2 and assign it to the variable remainder. Third, we compute the floor division of the input divided by 2 and assign it to the variable quotient. Fourth, we insert the remainder into the beginning of the array. Fifth, we continue looping until the quotient is zero. Sixth, we compute the modulus of the quotient divided by 2 and assign it to the variable remainder. Seventh, we compute the floor division of the quotient divided by 2 and assign it to the variable quotient. Eighth, we go back to step five. Once the quotient is zero, we exit the loop and return the resulting array.", "most_similar": {"Write a function that takes a positive integer N as input and outputs a list of lists representing all the ways of partitioning N such that each sublist contains consecutive integers starting from 1.\n\nExample:\nInput: 5\nOutput: [[1],[2,3],[4,5]]": 0.5588235294117647, "Write a Python function that takes two numbers as input and returns their sum.": 0.41025641025641024, "Please write a Rust function that takes a u64 input and returns the largest prime number less than that value.": 0.39999999999999997, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.3333333333333333, "Write a C++ function that takes a map as an input and returns the largest pair in the map, in 8 lines or fewer. A pair is considered larger if its second value is larger than another pair's second value.": 0.30303030303030304, "write a java function that implements gray code and returns the next sequence code after a given code in a given direction of rotation": 0.2857142857142857, "Write a Python function to reverse a given list of integers.": 0.2777777777777778, "write a c++ program that calculates the perimeter of a square": 0.2777777777777778, "Write a python function that sorts a list from large to small.": 0.2702702702702703, "Write a program to compute the sum of integers from k to n.": 0.2631578947368421}, "avg_similarity_score": 0.13908700203322966} +{"instruction": "Write a function that takes a string s consisting of lowercase letters and brackets, and returns whether or not the brackets in the string are balanced.\n\nExample:\nInput: \"(())()\"\nOutput: True", "input": "", "output": "Here is an example solution:\n\n```python\ndef isBalanceBrackets(string):\n stack = []\n for char in string:\n if char == '(':\n stack.append(char)\n elif char == ')':\n if len(stack)>0:\n topChar = stack[-1]\n if topChar != '(':\n return False\n else:\n stack.pop(-1)\n else:\n return False\n if len(stack)!=0:\n return False\n return True\n\nprint(isBalanceBrackets(\"(()\"))\n```\n\nLet us walkthrough the logic behind the algorithm:\n\nFirst, we initialize an empty stack. Second, we iterate over the characters in the input string. If we encounter an opening parenthesis, we push it onto the stack. On the other hand, if we encounter a closing parenthesis, we pop off the most recently pushed item from the stack. If the popped item was not an opening parenthesis, we immediately terminate the execution of the function and return False. Lastly, if the stack still contains items left in it upon termination of the iteration, we return False. Otherwise, we return True.", "most_similar": {"Write a function that takes a nonnegative integer N as input and computes the binary representation of N.\n\nExample:\nInput: 5\nOutput: [1,0,1]": 0.4, "Please write a Rust function that takes a u64 input and returns the largest prime number less than that value.": 0.36000000000000004, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.3404255319148936, "Write a Python function that takes two numbers as input and returns their sum.": 0.3181818181818182, "Write a C++ function that takes a map as an input and returns the largest pair in the map, in 8 lines or fewer. A pair is considered larger if its second value is larger than another pair's second value.": 0.30985915492957744, "Write a function that takes a positive integer N as input and outputs a list of lists representing all the ways of partitioning N such that each sublist contains consecutive integers starting from 1.\n\nExample:\nInput: 5\nOutput: [[1],[2,3],[4,5]]": 0.30136986301369856, "write a java function that implements gray code and returns the next sequence code after a given code in a given direction of rotation": 0.2962962962962963, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.2456140350877193, "Write a Python function to reverse a given list of integers.": 0.2439024390243902, "Write a python function that sorts a list from large to small.": 0.23809523809523808}, "avg_similarity_score": 0.1397313719017387} +{"instruction": "What is the difference between a pointer variable and a reference variable in Java?", "input": "", "output": "A pointer variable holds the memory location of some data while a reference variable refers to some data directly without holding its own copy. In short, a pointer variable holds the address of some data while a reference variable holds the actual data.\n\nFor instance, consider the following piece of code:\n\nclass TestClass {\n public:\n\tTestClass(String name) {\n\t\tSystem.out.println(\"\\n\\nObject created...\");\n\t\tthis.name = name;\n\t}\n\tprivate String name;\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\tpublic void setName(String name) {\n\t\tthis.name = name;\n\t}\n}\n\npublic class PointerReferenceDemo {\n\tpublic static void main(String[] args) {\n\t\tTestClass tObj = new TestClass(\"Java\");\n\t\tTestClass refVar = tObj;\n\t\trefVar.setName(\"C++\");\n\t\tSystem.out.println(\"Value of tObj.getName(): \"+tObj.getName());\n\t\tSystem.out.println(\"Value of refVar.getName(): \"+refVar.getName());\n\t}\n}\nWhen the above code is executed, it produces the following result:\n\nObject created...\nValue of tObj.getName(): C++\nValue of refVar.getName(): C++\nAs shown in the above example, both variables refer to the same object. So, whenever there is a change made to the referenced object via one variable, the changes become visible to all the references pointing to the same object.\n\nOn the contrary, let us see what happens when we try to achieve the same thing using pointers instead of references:\n\nclass TestClass {\n public:\n\tTestClass(String name) {\n\t\tSystem.out.println(\"\\n\\nObject created...\");\n\t\tthis.name = name;\n\t}\n\tprivate String name;\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\tpublic void setName(String name) {\n\t\tthis.name = name;\n\t}\n}\n\npublic class PointerReferenceDemo {\n\tpublic static void main(String[] args) {\n\t\tTestClass tObj = new TestClass(\"Java\");\n\t\tTestClass* ptrVar = &tObj;\n\t\tptrVar->setName(\"C++\");\n\t\tSystem.out.println(\"Value of tObj.getName(): \"+tObj.getName());\n\t\tSystem.out.println(\"Value of ptrVar.getName(): \"+(*ptrVar).getName());\n\t}\n}\nWhen the above code is compiled and run, it throws NullPointerException. Let us understand why this exception occurs.\n\nAt first, the constructor of the TestClass object is called to allocate space for the object in heap memory. Next, the address of the newly allocated object is assigned to the pointer variable ptrVar. Finally, the setter method of the TestClass object is invoked to update the value of the private field named name. However, since the pointer variable ptrVar doesn't hold the address of the object but rather just the address of the pointer variable tObj, the setter method fails to find the target object and hence throws NullPointerException.\n\nTherefore, it is clear that although both the pointer variable and the reference variable seem similar, they differ significantly in their behavior. While a pointer variable holds the address of some data, a reference variable refers to some data directly without holding its own copy.", "most_similar": {"Translate the following code from python in Java.": 0.2727272727272727, "How do I get the power of a number in python?": 0.23999999999999996, "What is Kubernetes ?": 0.23529411764705882, "How do you output all the contents of a list in Python?": 0.23076923076923075, "Implement a Java method to reverse a string without using any built-in functions.": 0.21428571428571427, "write a java function that implements gray code and returns the next sequence code after a given code in a given direction of rotation": 0.2105263157894737, "write a sum function in asm": 0.2, "Using the comment as a guide, replace the \"TODO\" comment in the code with the proper code.": 0.1935483870967742, "write a code to get the current value of a Bitcoin in US dollars using the bitcoincharts API.": 0.1875, "Create a calculator in the Python programming language": 0.18181818181818182}, "avg_similarity_score": 0.11339017349213858} +{"instruction": "Write a function that reverses a string. The input string is given as an array of characters s.", "input": "", "output": "Here is an example solution:\n\n```cpp\nvector reverseString(vector& s) {\n vector::iterator begin = s.begin(), end = s.end() - 1;\n while (begin < end) {\n swap(*begin++, *end--);\n }\n return s;\n}\n```\n\nWe define iterators begin and end to mark the beginning and ending positions of the string respectively. We keep swapping elements until begin reaches the middle of the string. At this stage, begin and end meet and stop swapping.", "most_similar": {"Write a Python function to reverse a given list of integers.": 0.41379310344827586, "write a c++ program that calculates the perimeter of a square": 0.3448275862068966, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.34285714285714286, "Write a function that takes a string s consisting of lowercase letters and brackets, and returns whether or not the brackets in the string are balanced.\n\nExample:\nInput: \"(())()\"\nOutput: True": 0.33333333333333337, "Write a python function that sorts a list from large to small.": 0.33333333333333337, "write a java function that implements gray code and returns the next sequence code after a given code in a given direction of rotation": 0.3333333333333333, "Write a function that takes a nonnegative integer N as input and computes the binary representation of N.\n\nExample:\nInput: 5\nOutput: [1,0,1]": 0.32558139534883723, "Please write a Rust function that takes a u64 input and returns the largest prime number less than that value.": 0.3157894736842105, "Given a string `s`, find the length of the longest substring without repeating characters.": 0.31250000000000006, "Write a Python function that takes two numbers as input and returns their sum.": 0.31250000000000006}, "avg_similarity_score": 0.16031378254361608} +{"instruction": "Write a function that finds the longest common prefix string amongst an array of strings.\n\nIf there is no common prefix, return an empty string \"\".", "input": "", "output": "Here is an example solution:\n\n```python\ndef longestCommonPrefix(self, strs):\n \"\"\"\n :type strs: List[str]\n :rtype: str\n \"\"\"\n if not strs:\n return \"\"\n \n minLen = float('inf')\n for s in strs:\n minLen = min(minLen,len(s))\n \n for i in range(minLen):\n ch = strs[0][i]\n for j in range(1,len(strs)):\n if strs[j][i] != ch:\n return strs[0][:i]\n return strs[0][:minLen]\n```\n\nLet us walkthrough the logic behind the algorithm:\n\nFirst, we check if the input array is empty. If yes, we simply return an empty string.\nNext, we calculate the minimum length among all the strings present in the array.\nFinally, we compare the characters at the current index of each string against the previous ones. As soon as we detect a mismatch, we return the substring formed till now.", "most_similar": {"Write a function that reverses a string. The input string is given as an array of characters s.": 0.41860465116279066, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.28571428571428564, "write a c++ program that calculates the perimeter of a square": 0.2777777777777778, "Write a function that takes a string s consisting of lowercase letters and brackets, and returns whether or not the brackets in the string are balanced.\n\nExample:\nInput: \"(())()\"\nOutput: True": 0.2545454545454545, "write a java function that implements gray code and returns the next sequence code after a given code in a given direction of rotation": 0.24489795918367346, "Write a function that takes a nonnegative integer N as input and computes the binary representation of N.\n\nExample:\nInput: 5\nOutput: [1,0,1]": 0.24, "Implement a function that accepts a string containing digits from 2-9 with various lengths. The function should replace every digit with the word equivalent of that digit (e.g., 2 becomes \u2018two\u2019, 3 becomes \u2018three\u2019, \u2026 , 9 becomes \u2018nine\u2019). There is no need to validate the contents of the input string.": 0.2368421052631579, "Please write a Rust function that takes a u64 input and returns the largest prime number less than that value.": 0.22222222222222224, "Write a Python function to reverse a given list of integers.": 0.2222222222222222, "Could you please write me Rust code that takes ownership of an array of integers and sorts them in ascending order?": 0.21739130434782608}, "avg_similarity_score": 0.1275296217250447} +{"instruction": "Write a function that checks if a binary tree is symmetric around its center.", "input": "", "output": "Here is an example solution:\n\n```python\ndef isSymmetric(root):\n def helper(left,right):\n if left==None and right==None:\n return True\n if left==None or right==None:\n return False\n if left.val!=right.val:\n return False\n return helper(left.left,right.right) and helper(left.right,right.left)\n return helper(root.left, root.right)\n```\n\nLet us walkthrough the logic behind the algorithm:\n\nFirst, we write a recursive helper function that compares the nodes of the left subtree with the nodes of the right subtree. To make things easier, we assume that the node values are integers.\nThen, we call the helper function passing the roots of the left and right subtrees.", "most_similar": {"Write a python function that sorts a list from large to small.": 0.3846153846153846, "Write a function that reverses a string. The input string is given as an array of characters s.": 0.375, "write a c++ program that calculates the perimeter of a square": 0.32, "Write a Python function to reverse a given list of integers.": 0.32, "Write a function that finds the longest common prefix string amongst an array of strings.\n\nIf there is no common prefix, return an empty string \"\".": 0.30769230769230765, "Write a function that takes a nonnegative integer N as input and computes the binary representation of N.\n\nExample:\nInput: 5\nOutput: [1,0,1]": 0.30769230769230765, "write a sum function in asm": 0.3, "Please write a Rust function that takes a u64 input and returns the largest prime number less than that value.": 0.2941176470588235, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.29268292682926833, "Write a Python function that takes two numbers as input and returns their sum.": 0.2857142857142857}, "avg_similarity_score": 0.13259273316179096} +{"instruction": "Write a function that calculates the sum of all odd fibonacci numbers below n.", "input": "", "output": "Here is an example solution:\n\n```python\ndef sumOfOddNumbersBelowNthFibonacciNumber(n):\n arr=[0]*(n+1)\n arr[0]=arr[1]=1\n for i in range(2,n+1):\n arr[i]+=(arr[i-1])+(arr[i-2])\n res=sum([ele for ele in arr[:n] if ele%2!=0])\n return res\n```\n\nLet us walkthrough the logic behind the algorithm:\n\nFirst, we declare an array of size n+1 and assign the initial values of the first two terms of the series to the indices 0 and 1 respectively.\nNow, we traverse the remaining indices starting from 2 and add the last two terms together to form the next term.\nLastly, we take the sum of all even indexed terms in the array.", "most_similar": {"write a c++ program that calculates the perimeter of a square": 0.4799999999999999, "Write a program to compute the sum of integers from k to n.": 0.4444444444444445, "Write a Python function to find all prime numbers up to the given number n.": 0.4137931034482759, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.3870967741935484, "Write a function that reverses a string. The input string is given as an array of characters s.": 0.375, "Write a function that takes a nonnegative integer N as input and computes the binary representation of N.\n\nExample:\nInput: 5\nOutput: [1,0,1]": 0.358974358974359, "Write a Python function that takes two numbers as input and returns their sum.": 0.35714285714285715, "Write a Python function to reverse a given list of integers.": 0.32, "write a java function that implements gray code and returns the next sequence code after a given code in a given direction of rotation": 0.3157894736842105, "Write a python function that sorts a list from large to small.": 0.30769230769230765}, "avg_similarity_score": 0.16548529336121703} +{"instruction": "Write a function that computes the greatest common divisor of two positive integer numbers. Use Euclid's Algorithm.", "input": "", "output": "Here is an example solution:\n\n```python\ndef gcd(m,n):\n while m % n > 0:\n temp = m\n m = n\n n = temp % n\n return n\n```\n\nLet us walkthrough the logic behind the algorithm:\n\nEuclid's Algorithm states that the GCD of two numbers is equal to the GCD of the remainder obtained after dividing them by their smaller number. Therefore, we repeatedly divide the larger number by the smaller number until the quotient is zero. Once the quotient is zero, the smaller number is our answer.", "most_similar": {"Write a function that calculates the sum of all odd fibonacci numbers below n.": 0.43750000000000006, "Write a function that reverses a string. The input string is given as an array of characters s.": 0.3888888888888889, "Write a Python function that takes two numbers as input and returns their sum.": 0.375, "write a c++ program that calculates the perimeter of a square": 0.3448275862068966, "Write a function that takes a nonnegative integer N as input and computes the binary representation of N.\n\nExample:\nInput: 5\nOutput: [1,0,1]": 0.32558139534883723, "Write a function that finds the longest common prefix string amongst an array of strings.\n\nIf there is no common prefix, return an empty string \"\".": 0.32558139534883723, "Write me a function in C++ to find the distance between two points": 0.3225806451612903, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.28571428571428575, "write a java function that implements gray code and returns the next sequence code after a given code in a given direction of rotation": 0.28571428571428575, "Write a Python function to reverse a given list of integers.": 0.27586206896551724}, "avg_similarity_score": 0.1469322682005941} +{"instruction": "Write a function that counts the total number of prime numbers up to N.", "input": "", "output": "Here is an example solution:\n\n```python\ndef countPrimes(n):\n primes = [True] * n\n primes[0],primes[1] = False,False\n for i in range(2,int((n/2)+1)):\n if primes[i]:\n for j in range(i*2,(n),i):\n primes[j] = False\n return sum(primes)-2\n```\n\nLet us walkthrough the logic behind the algorithm:\n\nFirst, we initialize an array of booleans where each index represents a number. Initially, we set all entries to True except for the first two entries.\nNext, we iterate over the array and identify all composite numbers. Since we know that all non-prime numbers are multiples of prime numbers, we can skip checking all numbers that are multiples of previously identified prime numbers.\nOnce we finish identifying all composite numbers, we return the sum of all entries in the array minus 2. Note that we subtract 2 because initially we marked the first two entries as False.", "most_similar": {"Write a function that calculates the sum of all odd fibonacci numbers below n.": 0.5714285714285714, "Write a Python function to find all prime numbers up to the given number n.": 0.5517241379310344, "Write a program to compute the sum of integers from k to n.": 0.4444444444444445, "Write a function that computes the greatest common divisor of two positive integer numbers. Use Euclid's Algorithm.": 0.43750000000000006, "write a c++ program that calculates the perimeter of a square": 0.4, "Write a python function that sorts a list from large to small.": 0.3846153846153846, "Write a function that reverses a string. The input string is given as an array of characters s.": 0.375, "Write a function that takes a nonnegative integer N as input and computes the binary representation of N.\n\nExample:\nInput: 5\nOutput: [1,0,1]": 0.358974358974359, "Write a Python function that takes two numbers as input and returns their sum.": 0.35714285714285715, "Please write a Rust function that takes a u64 input and returns the largest prime number less than that value.": 0.3529411764705882}, "avg_similarity_score": 0.183596076786091} +{"instruction": "Write a function that determines whether a triangle is equilateral, isosceles, scalene based on three side lengths provided.", "input": "", "output": "Here is an example solution:\n\n```python\ndef determineTriangleType(sideLengthOne, sideLengthTwo, sideLengthThree):\n sides = sorted([sideLengthOne, sideLengthTwo, sideLengthThree])\n if sides[0] >= sides[1] + sides[2]:\n raise ValueError(\"Invalid Triangle\")\n if sides[0] == sides[1] == sides[2]:\n return \"equilateral\"\n if sides[0] == sides[1] or sides[1] == sides[2] or sides[0] == sides[2]:\n return \"isosceles\"\n return \"scalene\"\n```\n\nLet us walkthrough the logic behind the algorithm:\n\nFirst, we sort the three side lengths in ascending order.\nSecond, we verify that none of the side lengths exceed the sum of the other two side lengths. If this condition is satisfied, we throw a ValueError indicating invalid triangle.\nThird, we check if all the side lengths are equal. If this condition is satisfied, we return \u201cequilateral\u201d.\nOtherwise, we check if exactly two side lengths are equal. If this condition is satisfied, we return \u201cisosceles\u201d otherwise we return \u201cscalene\u201d.", "most_similar": {"Write a function that checks if a binary tree is symmetric around its center.": 0.375, "Write a python function that sorts a list from large to small.": 0.33333333333333337, "Write a function that reverses a string. The input string is given as an array of characters s.": 0.3333333333333333, "write a c++ program that calculates the perimeter of a square": 0.27586206896551724, "Write a Python function to reverse a given list of integers.": 0.27586206896551724, "Please write a Rust function that takes a u64 input and returns the largest prime number less than that value.": 0.2631578947368421, "Write a function that counts the total number of prime numbers up to N.": 0.25, "Write a function that calculates the sum of all odd fibonacci numbers below n.": 0.25, "Write a Python function that takes two numbers as input and returns their sum.": 0.25, "write a sum function in asm": 0.25}, "avg_similarity_score": 0.11998219747419492} +{"instruction": "Write a function that removes duplicate words from a string. All whitespace characters must separate the words.", "input": "", "output": "Here is an example solution:\n\n```python\ndef removeDuplicateWords(text):\n textArr = text.lower().strip().replace('.','').split()\n uniqueTextArr = []\n for word in textArr:\n if word not in uniqueTextArr:\n uniqueTextArr.append(word)\n return (' '.join(uniqueTextArr)).capitalize()\n```\n\nLet us walkthrough the logic behind the algorithm:\n\nFirst, we split the input string into individual words and strip out punctuation marks.\nNext, we iterate over the resulting array and append each word to a temporary array if it isn't already present in the temporary array.\nFinally, we join the words back into a string separated by spaces and capitalize the first letter.", "most_similar": {"Write a function that reverses a string. The input string is given as an array of characters s.": 0.39999999999999997, "Write a python function that sorts a list from large to small.": 0.3448275862068966, "Please write a Rust function that takes a u64 input and returns the largest prime number less than that value.": 0.3243243243243243, "Write a function that counts the total number of prime numbers up to N.": 0.3225806451612903, "Write a function that calculates the sum of all odd fibonacci numbers below n.": 0.3225806451612903, "Write a function that checks if a binary tree is symmetric around its center.": 0.3225806451612903, "Write a Python function to find all prime numbers up to the given number n.": 0.3125, "Write a function that takes a string s consisting of lowercase letters and brackets, and returns whether or not the brackets in the string are balanced.\n\nExample:\nInput: \"(())()\"\nOutput: True": 0.2978723404255319, "Write a function that determines whether a triangle is equilateral, isosceles, scalene based on three side lengths provided.": 0.28571428571428575, "Write a function that computes the greatest common divisor of two positive integer numbers. Use Euclid's Algorithm.": 0.28571428571428575}, "avg_similarity_score": 0.1538466677914246} +{"instruction": "Write a function that returns the maximum profit earned from buying and selling stocks on a particular day.\n\nYou are given an array prices where prices[i] is the price of a given stock on the ith day. Find the maximum profit you can achieve. You may complete as many transactions as you like (i.e., buy one and sell one share of the stock multiple times).\n\nNote: You may not engage in multiple transactions simultaneously (i.e., you must sell the stock before you buy again).", "input": "", "output": "Here is an example solution:\n\n```python\ndef maxProfit(prices):\n maxprofit = 0\n for i in range(len(prices)):\n for j in range(i+1,len(prices)):\n diff = prices[j] - prices[i]\n if diff > maxprofit:\n maxprofit = diff\n return maxprofit\n```\n\nLet us walkthrough the logic behind the algorithm:\n\nFirst, we initialize a variable maxprofit to track the maximum profit achieved so far.\nNext, we iterate over the entire array twice. First, we iterate over the outer loop from 0 to n-1. Inside the inner loop, we iterate over the second half of the array from i+1 to n-1.\nWithin these loops, we calculate the difference between the current pair of consecutive days and update the maxprofit accordingly.\nAfter exiting the nested loops, we return the maximum profit.", "most_similar": {"Given an array of integers `nums` and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order.": 0.20289855072463767, "write a java function that implements gray code and returns the next sequence code after a given code in a given direction of rotation": 0.1981981981981982, "Write a function that reverses a string. The input string is given as an array of characters s.": 0.17142857142857143, "Write a function that takes a string s consisting of lowercase letters and brackets, and returns whether or not the brackets in the string are balanced.\n\nExample:\nInput: \"(())()\"\nOutput: True": 0.17094017094017092, "Write a Python program that takes a list of numbers as input from the user, calculates the sum of all even numbers in the list, and returns the result. The program should check if the input is valid (i.e., if it's a list of numbers), and if it's not, it should return an error message. The program should also handle exceptions gracefully and return a user-friendly error message in case of any exceptions.": 0.1585365853658537, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.15789473684210528, "Write a C++ function that takes a map as an input and returns the largest pair in the map, in 8 lines or fewer. A pair is considered larger if its second value is larger than another pair's second value.": 0.15625, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.15384615384615385, "Write a function that removes duplicate words from a string. All whitespace characters must separate the words.": 0.15384615384615385, "Write a function that finds the longest common prefix string amongst an array of strings.\n\nIf there is no common prefix, return an empty string \"\".": 0.14285714285714285}, "avg_similarity_score": 0.08678604176579306} +{"instruction": "Given a non-empty array of integers, write a function that returns the minimum difference between the largest and smallest values in the array.\n\nFor example, given \\[3, 10, 5\\], the function should return 7 since the largest value is 10 and the smallest is 3. But given \\[10, 3, 5\\], the function should return 2 since the largest value is 10 and the smallest is 5.", "input": "", "output": "The following JavaScript snippet solves the problem:\n\n```js\nconst minDiff = arr => Math.max(...arr)-Math.min(...arr);\nconsole.log(minDiff([3, 10, 5])) // Output: 7\nconsole.log(minDiff([10, 3, 5])) // Output: 2\n```\n\nIn the above code, the spread syntax \\(...\\) allows us to pass arrays directly to functions without having to convert them to arguments using apply. In addition, the rest parameter \\.\\.\\.\\. is used to collect multiple parameters passed to a function into an array. This makes it easy to compute the maximum and minimum values in the array.", "most_similar": {"Write a Python program that takes a list of numbers as input from the user, calculates the sum of all even numbers in the list, and returns the result. The program should check if the input is valid (i.e., if it's a list of numbers), and if it's not, it should return an error message. The program should also handle exceptions gracefully and return a user-friendly error message in case of any exceptions.": 0.22222222222222224, "Write a C++ function that takes a map as an input and returns the largest pair in the map, in 8 lines or fewer. A pair is considered larger if its second value is larger than another pair's second value.": 0.2222222222222222, "Write a function that returns the maximum profit earned from buying and selling stocks on a particular day.\n\nYou are given an array prices where prices[i] is the price of a given stock on the ith day. Find the maximum profit you can achieve. You may complete as many transactions as you like (i.e., buy one and sell one share of the stock multiple times).\n\nNote: You may not engage in multiple transactions simultaneously (i.e., you must sell the stock before you buy again).": 0.19480519480519484, "Given an array of integers `nums` and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order.": 0.18644067796610167, "Write a function that takes a string s consisting of lowercase letters and brackets, and returns whether or not the brackets in the string are balanced.\n\nExample:\nInput: \"(())()\"\nOutput: True": 0.18556701030927836, "Please write a Rust function that takes a u64 input and returns the largest prime number less than that value.": 0.1839080459770115, "Write a function that takes a positive integer N as input and outputs a list of lists representing all the ways of partitioning N such that each sublist contains consecutive integers starting from 1.\n\nExample:\nInput: 5\nOutput: [[1],[2,3],[4,5]]": 0.18181818181818182, "write a java function that implements gray code and returns the next sequence code after a given code in a given direction of rotation": 0.1758241758241758, "Write a function that finds the longest common prefix string amongst an array of strings.\n\nIf there is no common prefix, return an empty string \"\".": 0.17391304347826086, "Write a function that takes a nonnegative integer N as input and computes the binary representation of N.\n\nExample:\nInput: 5\nOutput: [1,0,1]": 0.17391304347826086}, "avg_similarity_score": 0.09447356626793622} +{"instruction": "Alice has some coins and Bob wants to give Alice money. Write a program which takes as input the amount of money Alice needs and outputs the least number of coins needed to pay Alice. Assume there are infinite supply of coins.", "input": "", "output": "```python\nimport math\n\ndef coinChange(amount, denoms=[1, 5, 10, 25, 50]):\n \"\"\"Returns the fewest number of coins required to change the amount.\"\"\"\n numCoins = float('inf')\n for d in denoms:\n while amount >= d:\n amount -= d\n numCoins = min(numCoins, 1+math.floor(float(amount)/d))\n return numCoins\n```", "most_similar": {"Write a function that takes a nonnegative integer N as input and computes the binary representation of N.\n\nExample:\nInput: 5\nOutput: [1,0,1]": 0.2388059701492537, "Please write a Rust function that takes a u64 input and returns the largest prime number less than that value.": 0.22580645161290322, "Write a program to compute the sum of integers from k to n.": 0.21818181818181817, "Write a function that counts the total number of prime numbers up to N.": 0.21428571428571427, "Write a Python function that takes two numbers as input and returns their sum.": 0.21428571428571427, "Write a function that takes a positive integer N as input and outputs a list of lists representing all the ways of partitioning N such that each sublist contains consecutive integers starting from 1.\n\nExample:\nInput: 5\nOutput: [[1],[2,3],[4,5]]": 0.21176470588235297, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.20338983050847456, "Write a Python program that takes a list of numbers as input from the user, calculates the sum of all even numbers in the list, and returns the result. The program should check if the input is valid (i.e., if it's a list of numbers), and if it's not, it should return an error message. The program should also handle exceptions gracefully and return a user-friendly error message in case of any exceptions.": 0.20168067226890757, "Write a function that takes a string s consisting of lowercase letters and brackets, and returns whether or not the brackets in the string are balanced.\n\nExample:\nInput: \"(())()\"\nOutput: True": 0.19444444444444445, "write a c++ program that calculates the perimeter of a square": 0.18867924528301885}, "avg_similarity_score": 0.1017367030195241} +{"instruction": "Implement a method that accepts a positive integer and returns its corresponding Roman numeral.", "input": "", "output": "```java\npublic static String romanNumerals(long arabicNumber){\n StringBuilder sb = new StringBuilder();\n Map map = new HashMap<>();\n map.put(1,'I');map.put(5,'V');map.put(10,'X');map.put(50,'L');map.put(100,'C');map.put(500,'D');map.put(1000,'M');\n Set> entries = map.entrySet();\n Iterator> iterator = entries.iterator();\n boolean flag = false;\n while(arabicNumber!=0 && iterator.hasNext()) {\n Map.Entry entry = iterator.next();\n Integer key = (Integer) entry.getKey();\n char val = ((Character) entry.getValue());\n if(!flag&&key<=arabicNumber) {\n sb.append(val);\n arabicNumber -= key;\n }else if((!flag||key==arabicNumber)&&key>=arabicNumber) {\n sb.insert(sb.lastIndexOf(val), 'V'.equals(val)?'IV':(key%5==0?'IX':'X'));\n break;\n }else if(flag&&key<=arabicNumber) {\n sb.deleteCharAt(sb.indexOf(val));\n sb.setCharAt(sb.indexOf(val)+1,(char)(val+'M'-'C'+1));\n arabicNumber -= key;\n flag = true;\n }\n }\n return sb.toString();\n}\n```", "most_similar": {"Please write a Rust function that takes a u64 input and returns the largest prime number less than that value.": 0.2941176470588235, "Implement a Java method to reverse a string without using any built-in functions.": 0.2857142857142857, "Write a function that checks if a binary tree is symmetric around its center.": 0.2857142857142857, "Write a Python function that takes two numbers as input and returns their sum.": 0.2857142857142857, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.2580645161290323, "Write a function that takes a nonnegative integer N as input and computes the binary representation of N.\n\nExample:\nInput: 5\nOutput: [1,0,1]": 0.25641025641025644, "Write a function that computes the greatest common divisor of two positive integer numbers. Use Euclid's Algorithm.": 0.25, "write a c++ program that calculates the perimeter of a square": 0.23999999999999996, "Write a python function that sorts a list from large to small.": 0.23076923076923075, "Write a function that takes a string s consisting of lowercase letters and brackets, and returns whether or not the brackets in the string are balanced.\n\nExample:\nInput: \"(())()\"\nOutput: True": 0.22727272727272724}, "avg_similarity_score": 0.10317562916480194} +{"instruction": "Create a function that converts a name into initials. Given a name, the function should return the first letter of every word capitalized.", "input": "", "output": "```javascript\nfunction abbrevName(name) {\n var result = \"\";\n const names = name.toUpperCase().trim().replace(/ /g,\"\").match(/.{1}/gi);\n for (let i = 0; i < names.length; ++i) {\n result+=names[i];\n };\n return result;\n};\nabbrevName(\"Sam Harris\");//SH\nabbrevName(\"pPPpPppppp\");//PP\nabbrevName(\"\");//\"\"\n```", "most_similar": {"Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.3, "write a java function that implements gray code and returns the next sequence code after a given code in a given direction of rotation": 0.2978723404255319, "Write a Python function to reverse a given list of integers.": 0.29411764705882354, "Write a function that reverses a string. The input string is given as an array of characters s.": 0.2926829268292683, "Write a function that counts the total number of prime numbers up to N.": 0.27027027027027023, "Write a function that calculates the sum of all odd fibonacci numbers below n.": 0.27027027027027023, "Given the `root` of a binary tree, return the inorder traversal of its nodes' values.": 0.26315789473684204, "Write a function that removes duplicate words from a string. All whitespace characters must separate the words.": 0.25, "Write a function that takes a nonnegative integer N as input and computes the binary representation of N.\n\nExample:\nInput: 5\nOutput: [1,0,1]": 0.24999999999999994, "Write a function that computes the greatest common divisor of two positive integer numbers. Use Euclid's Algorithm.": 0.24390243902439024}, "avg_similarity_score": 0.1352603459951307} +{"instruction": "Write a function that reverses a string. The input string is given as an array of characters char[]. Do not allocate extra space for another array, you must do this by modifying the input array itself. You may assume all the characters consist of printable ascii characters.", "input": "", "output": "```c++\nvector& ReverseString(vector& s) {\n reverse(begin(s), end(s));\n return s;\n}\n```", "most_similar": {"Write a function that reverses a string. The input string is given as an array of characters s.": 0.5230769230769231, "Write a function that removes duplicate words from a string. All whitespace characters must separate the words.": 0.28125, "Write a function that takes a string s consisting of lowercase letters and brackets, and returns whether or not the brackets in the string are balanced.\n\nExample:\nInput: \"(())()\"\nOutput: True": 0.2597402597402597, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.25, "Write a function that finds the longest common prefix string amongst an array of strings.\n\nIf there is no common prefix, return an empty string \"\".": 0.24999999999999994, "Write a function that takes a nonnegative integer N as input and computes the binary representation of N.\n\nExample:\nInput: 5\nOutput: [1,0,1]": 0.24999999999999994, "Write a function that calculates the sum of all odd fibonacci numbers below n.": 0.22950819672131148, "Create a function that converts a name into initials. Given a name, the function should return the first letter of every word capitalized.": 0.22857142857142854, "Write a function that takes a positive integer N as input and outputs a list of lists representing all the ways of partitioning N such that each sublist contains consecutive integers starting from 1.\n\nExample:\nInput: 5\nOutput: [[1],[2,3],[4,5]]": 0.22222222222222224, "Write a function that returns the maximum profit earned from buying and selling stocks on a particular day.\n\nYou are given an array prices where prices[i] is the price of a given stock on the ith day. Find the maximum profit you can achieve. You may complete as many transactions as you like (i.e., buy one and sell one share of the stock multiple times).\n\nNote: You may not engage in multiple transactions simultaneously (i.e., you must sell the stock before you buy again).": 0.208955223880597}, "avg_similarity_score": 0.12343827490268472} +{"instruction": "Write a function that removes duplicates from an unsorted linked list. Follow up: How would you solve this problem if a temporary buffer is not allowed?", "input": "", "output": "```cpp\nstruct ListNode {\n int val;\n struct ListNode * next;\n ListNode(int x) : val(x), next(NULL) {}\n};\n\nstatic void deleteDuplicates(ListNode ** headRef) {\n auto curr = (*headRef)->next;\n auto prev = *headRef;\n bool found = false;\n while (curr != NULL) {\n if (!found || curr->val != prev->val) {\n prev->next = curr;\n prev = curr;\n curr = curr->next;\n found = false;\n } else {\n prev->next = curr->next;\n free(curr);\n curr = prev->next;\n found = true;\n }\n }\n}\n```", "most_similar": {"Write a function that checks if a binary tree is symmetric around its center.": 0.35000000000000003, "Write a function that removes duplicate words from a string. All whitespace characters must separate the words.": 0.3255813953488372, "Write a function that finds the longest common prefix string amongst an array of strings.\n\nIf there is no common prefix, return an empty string \"\".": 0.27450980392156865, "Write a function that reverses a string. The input string is given as an array of characters s.": 0.27272727272727276, "Write a function that determines whether a triangle is equilateral, isosceles, scalene based on three side lengths provided.": 0.27272727272727276, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.2641509433962264, "Write a python function that sorts a list from large to small.": 0.2631578947368421, "Write a function that counts the total number of prime numbers up to N.": 0.25, "Write Python code to solve this leetcode problem.": 0.23529411764705882, "Please write a Rust function that takes a u64 input and returns the largest prime number less than that value.": 0.2173913043478261}, "avg_similarity_score": 0.12412311334669597} +{"instruction": "Write a function that takes a string as input and returns the string reversed. Example: Given s = \"hello\", return \"olleh\".", "input": "", "output": "```python\ndef reverseString(s):\n return s[::-1]\n```", "most_similar": {"Write a Python function that takes two numbers as input and returns their sum.": 0.5294117647058824, "Write a function that reverses a string. The input string is given as an array of characters s.": 0.5263157894736842, "Please write a Rust function that takes a u64 input and returns the largest prime number less than that value.": 0.5, "Write a function that takes a nonnegative integer N as input and computes the binary representation of N.\n\nExample:\nInput: 5\nOutput: [1,0,1]": 0.48888888888888893, "Write a function that takes a string s consisting of lowercase letters and brackets, and returns whether or not the brackets in the string are balanced.\n\nExample:\nInput: \"(())()\"\nOutput: True": 0.48, "Write a C++ function that takes a map as an input and returns the largest pair in the map, in 8 lines or fewer. A pair is considered larger if its second value is larger than another pair's second value.": 0.39344262295081966, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.37837837837837834, "Write a function that removes duplicate words from a string. All whitespace characters must separate the words.": 0.37837837837837834, "write a java function that implements gray code and returns the next sequence code after a given code in a given direction of rotation": 0.3636363636363636, "Write a function that takes a positive integer N as input and outputs a list of lists representing all the ways of partitioning N such that each sublist contains consecutive integers starting from 1.\n\nExample:\nInput: 5\nOutput: [[1],[2,3],[4,5]]": 0.34920634920634924}, "avg_similarity_score": 0.1751423979693773} +{"instruction": "What does the following piece of code print out?\n```js\nvar arr = ['hello', 'world'];\narr['foo'] = 'bar';\nconsole.log(JSON.stringify(arr));\n```", "input": "", "output": "When executed, the above JavaScript program prints `[ \"hello\", \"world\" ]`, since the assignment statement `arr['foo']='bar'` creates a property named `'foo'` whose value is `'bar'`. However, note that arrays in JavaScript are actually objects underneath, so assigning properties directly to an array works just fine.\n\nFor more information about how arrays work in JavaScript, see our article on [arrays](https://www.freecodecamp.org/news/javascript-arrays/).", "most_similar": {"Translate the following code from python in Java.": 0.19999999999999998, "Suggest a completion for the following python code.": 0.19999999999999998, "Find the bug in the following code piece:\n\na = 1\nwhile a == 1:\n b = input(\"what's your name ?\")\nprint(\"Hi \",b, \" this is infinity loop !\")": 0.16666666666666669, "Write a simple C# program that prints \"Hello, World!\".": 0.1290322580645161, "Write a script to output 'Hello World' in python": 0.1290322580645161, "Write a simple C++ program that prints \"Hello, World!\".": 0.1290322580645161, "What does this Python code do?\n```\nimport random\n\n\ndef montecarloPi(calcs):\n hits = 0\n\n for i in range(calcs):\n x = random.random()\n y = random.random()\n if (x**2 + y**2) < 1:\n hits = hits + 1\n\n return 4.0 * hits / calcs\n\n\nprint(montecarloPi(10000))\n```": 0.12698412698412698, "Generate a correct python program to fulfill the following purpose:": 0.12500000000000003, "Solve the following equation system. Give me the final answer.": 0.12500000000000003, "How do I get the power of a number in python?": 0.12121212121212123}, "avg_similarity_score": 0.06314170337096124} +{"instruction": "Given a string s consisting of lowercase English letters, find the length of the longest substring without repeating characters. If there are multiple substrings with equal lengths, return the leftmost one.", "input": "", "output": "We can solve this problem using sliding window technique. We maintain a hashmap to keep track of visited character indices. Whenever we encounter a repeated character, we shrink the window size till the last occurrence of the current character. At every step, we update the maximum length variable accordingly. Here\u2019s the pseudocode:\n\n```py\nmaxLength = 0\nstart = end = 0\nhashmap = {}\nwhile end < len(string):\n if string[end] in hashmap:\n start = max(start, hashmap[string[end]] + 1)\n else:\n maxLength = max(maxLength, end - start + 1)\n hashmap[string[end]] = end\n end+=1\nreturn maxLength\n```\n\nTime complexity : O(n).\nSpace Complexity : O(min(n, k)), where \u2018k\u2019 is the number of distinct characters present in the string.", "most_similar": {"Given a string `s`, find the length of the longest substring without repeating characters.": 0.6222222222222222, "Write a function that takes a string s consisting of lowercase letters and brackets, and returns whether or not the brackets in the string are balanced.\n\nExample:\nInput: \"(())()\"\nOutput: True": 0.32786885245901637, "Given the `root` of a binary tree, return the inorder traversal of its nodes' values.": 0.21739130434782605, "Write a function that finds the longest common prefix string amongst an array of strings.\n\nIf there is no common prefix, return an empty string \"\".": 0.21428571428571427, "Given an integer array nums, find the subarray with the largest sum, and return its sum.": 0.2127659574468085, "Using the comment as a guide, replace the \"TODO\" comment in the code with the proper code.": 0.20833333333333331, "Write a function that reverses a string. The input string is given as an array of characters s.": 0.20408163265306123, "Identify the pos tag of the word in the given sentence.": 0.19047619047619047, "Create a function that converts a name into initials. Given a name, the function should return the first letter of every word capitalized.": 0.18518518518518517, "Replace the token in the text with proper words that are consistent with the context. You can use multiple words for each token.": 0.17857142857142855}, "avg_similarity_score": 0.10340609478269205} +{"instruction": "You are given a binary tree in which each node contains an integer value. Find the largest value in each row of the tree.\n\nExample:\nInput:\n\n 1\n / \\\n 3 2\nOutput: [1, 3, 2]\nExplanation:\nRow 1: 1 is the largest integer in the row.\nRow 2: 3 is the largest integer in the row.\nRow 3: 2 is the largest integer in the row.", "input": "", "output": "```cpp\nvector largestValues(TreeNode* root) {\n vector res;\n queue> q;\n TreeNode* cur;\n pair p;\n int levelSize;\n if(root != NULL)\n q.push({root, 1});\n while(!q.empty())\n {\n p = q.front(), q.pop();\n cur = p.first;\n levelSize = p.second;\n if(res.size() >= levelSize)\n res[levelSize-1]=max(cur->val, res[levelSize-1]);\n else\n res.push_back(cur->val);\n if(cur->left != NULL)\n q.push({cur->left, levelSize+1});\n if(cur->right != NULL)\n q.push({cur->right, levelSize+1});\n }\n return res;\n}\n```", "most_similar": {"Given a non-empty array of integers, write a function that returns the minimum difference between the largest and smallest values in the array.\n\nFor example, given \\[3, 10, 5\\], the function should return 7 since the largest value is 10 and the smallest is 3. But given \\[10, 3, 5\\], the function should return 2 since the largest value is 10 and the smallest is 5.": 0.2595419847328244, "Write a function that takes a nonnegative integer N as input and computes the binary representation of N.\n\nExample:\nInput: 5\nOutput: [1,0,1]": 0.20224719101123595, "Write a function that takes a positive integer N as input and outputs a list of lists representing all the ways of partitioning N such that each sublist contains consecutive integers starting from 1.\n\nExample:\nInput: 5\nOutput: [[1],[2,3],[4,5]]": 0.1869158878504673, "Given an integer array nums, find the subarray with the largest sum, and return its sum.": 0.175, "Write a C++ function that takes a map as an input and returns the largest pair in the map, in 8 lines or fewer. A pair is considered larger if its second value is larger than another pair's second value.": 0.17142857142857143, "The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. That is,\n\nF(0) = 0, F(1) = 1\nF(n) = F(n - 1) + F(n - 2), for n > 1.\nGiven n, calculate F(n)": 0.16806722689075632, "Can you provide a shell script that displays the total number of lines in all '*.txt' files in the current directory?": 0.16470588235294117, "Implement a function that accepts a string containing digits from 2-9 with various lengths. The function should replace every digit with the word equivalent of that digit (e.g., 2 becomes \u2018two\u2019, 3 becomes \u2018three\u2019, \u2026 , 9 becomes \u2018nine\u2019). There is no need to validate the contents of the input string.": 0.15652173913043477, "Given an array of integers `nums` and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order.": 0.15652173913043477, "Write a Python program that takes a list of numbers as input from the user, calculates the sum of all even numbers in the list, and returns the result. The program should check if the input is valid (i.e., if it's a list of numbers), and if it's not, it should return an error message. The program should also handle exceptions gracefully and return a user-friendly error message in case of any exceptions.": 0.15602836879432624}, "avg_similarity_score": 0.08283623123605557} +{"instruction": "Alice wants to buy a keyboard and a USB drive from her favorite online store. She goes to the item page and sees the prices are $14.99 and $39.99 respectively. Alice has exactly $80 dollars in her wallet. What is the minimum amount she needs to spend in order to purchase both items together? Assume that Alice doesn't need to pay shipping costs.", "input": "", "output": "Since Alice has $80 dollars in her wallet, she must spend no more than $80 dollars. Therefore, she can either spend $14.99 on the keyboard alone or $39.99 on the USB drive alone. In addition, she can spend $54.99 on both products. Thus, the answer is $54.99.", "most_similar": {"Alice has some coins and Bob wants to give Alice money. Write a program which takes as input the amount of money Alice needs and outputs the least number of coins needed to pay Alice. Assume there are infinite supply of coins.": 0.16666666666666663, "Implement a function that accepts a string containing digits from 2-9 with various lengths. The function should replace every digit with the word equivalent of that digit (e.g., 2 becomes \u2018two\u2019, 3 becomes \u2018three\u2019, \u2026 , 9 becomes \u2018nine\u2019). There is no need to validate the contents of the input string.": 0.13675213675213677, "Write a C++ function that takes a map as an input and returns the largest pair in the map, in 8 lines or fewer. A pair is considered larger if its second value is larger than another pair's second value.": 0.13084112149532712, "Write a Python program that takes a list of numbers as input from the user, calculates the sum of all even numbers in the list, and returns the result. The program should check if the input is valid (i.e., if it's a list of numbers), and if it's not, it should return an error message. The program should also handle exceptions gracefully and return a user-friendly error message in case of any exceptions.": 0.1258741258741259, "Write a function that takes a string s consisting of lowercase letters and brackets, and returns whether or not the brackets in the string are balanced.\n\nExample:\nInput: \"(())()\"\nOutput: True": 0.12500000000000003, "Given a non-empty array of integers, write a function that returns the minimum difference between the largest and smallest values in the array.\n\nFor example, given \\[3, 10, 5\\], the function should return 7 since the largest value is 10 and the smallest is 3. But given \\[10, 3, 5\\], the function should return 2 since the largest value is 10 and the smallest is 5.": 0.12030075187969924, "Given an array of integers `nums` and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order.": 0.11965811965811966, "write a code to get the current value of a Bitcoin in US dollars using the bitcoincharts API.": 0.11904761904761905, "Please write a Rust function that takes a u64 input and returns the largest prime number less than that value.": 0.11627906976744187, "Write me a python script, which reads data from a json file and saves the data in an appropriate data structure.": 0.11494252873563218}, "avg_similarity_score": 0.07375782330182085} +{"instruction": "Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitions of s.\n\nAn empty string is also considered valid.\n\nExample 1:\nInput: s = \"aab\"\nOutput: [[\"aa\",\"b\"],[\"a\",\"a\",\"b\"]]\n\nExample 2:\nInput: s = \"a\"\nOutput: [[\"a\"]]", "input": "", "output": "```py\nfrom typing import List\nimport collections\nclass Solution:\n def partition(self, s: str) -> List[List[str]]:\n result = []\n def backtracking(S, path):\n if S == '':\n result.append([item for item in path])\n for i in range(len(S)):\n if self.isPalindromic(S[:i+1]):\n path.append(S[:i+1])\n backtracking(S[i+1:], path)\n path.pop(-1)\n backtracking(s,[])\n return result\n def isPalindromic(self, s):\n stack = collections.deque()\n for i in range(len(s)):\n stack.append(s[-i-1])\n return ''.join(stack) == s\n```", "most_similar": {"Write a function that takes a string s consisting of lowercase letters and brackets, and returns whether or not the brackets in the string are balanced.\n\nExample:\nInput: \"(())()\"\nOutput: True": 0.23076923076923075, "Write a function that finds the longest common prefix string amongst an array of strings.\n\nIf there is no common prefix, return an empty string \"\".": 0.2191780821917808, "Write a function that takes a string as input and returns the string reversed. Example: Given s = \"hello\", return \"olleh\".": 0.20588235294117646, "Write a function that takes a positive integer N as input and outputs a list of lists representing all the ways of partitioning N such that each sublist contains consecutive integers starting from 1.\n\nExample:\nInput: 5\nOutput: [[1],[2,3],[4,5]]": 0.1978021978021978, "Given a string `s`, find the length of the longest substring without repeating characters.": 0.19354838709677416, "Write a function that takes a nonnegative integer N as input and computes the binary representation of N.\n\nExample:\nInput: 5\nOutput: [1,0,1]": 0.1917808219178082, "Find the bug in the following code piece:\n\na = 1\nwhile a == 1:\n b = input(\"what's your name ?\")\nprint(\"Hi \",b, \" this is infinity loop !\")": 0.1891891891891892, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.18666666666666668, "Write a function that reverses a string. The input string is given as an array of characters s.": 0.18181818181818182, "Given a string s consisting of lowercase English letters, find the length of the longest substring without repeating characters. If there are multiple substrings with equal lengths, return the leftmost one.": 0.17721518987341772}, "avg_similarity_score": 0.0900988640685536} +{"instruction": "Given a string s, reverse the string according to the following rules:\nAll the characters that are not English letters remain in the same position.\nAll the English letters (lowercase or uppercase) should be reversed.\nReturn s after reversing it.\n\nExample 1:\nInput: s = \"ab-cd\"\nOutput: \"dc-ba\"\n\nExample 2:\nInput: s = \"a-bC-dEf-ghIj\"\nOutput: \"j-Ih-gfE-dCba\"\n\nExample 3:\nInput: s = \"Test1ng-Leet=code-Q!\"\nOutput: \"Qedo1ct-eeLg=ntse-T!\"", "input": "", "output": "```py\nclass Solution:\n def reverseOnlyLetters(self, s: str) -> str:\n l = []\n r = []\n for i in range(len(s)):\n if ord(\"a\") <= ord(s[i].lower()) <= ord(\"z\"):\n l.append(s[i])\n elif ord(\"A\") <= ord(s[i]) <= ord(\"Z\"):\n r.append(s[i])\n l.reverse()\n r.reverse()\n return \"\".join(l)+\"\".join(r)+\"\".join([s[i] for i in range(len(s)) if i not in range(len(l))]+[s[i] for i in range(len(s)) if i not in range(len(r))])\n```", "most_similar": {"Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitions of s.\n\nAn empty string is also considered valid.\n\nExample 1:\nInput: s = \"aab\"\nOutput: [[\"aa\",\"b\"],[\"a\",\"a\",\"b\"]]\n\nExample 2:\nInput: s = \"a\"\nOutput: [[\"a\"]]": 0.3089430894308943, "Write a function that takes a string s consisting of lowercase letters and brackets, and returns whether or not the brackets in the string are balanced.\n\nExample:\nInput: \"(())()\"\nOutput: True": 0.17142857142857143, "Given a string s consisting of lowercase English letters, find the length of the longest substring without repeating characters. If there are multiple substrings with equal lengths, return the leftmost one.": 0.169811320754717, "Write a Python program that takes a list of numbers as input from the user, calculates the sum of all even numbers in the list, and returns the result. The program should check if the input is valid (i.e., if it's a list of numbers), and if it's not, it should return an error message. The program should also handle exceptions gracefully and return a user-friendly error message in case of any exceptions.": 0.15789473684210528, "Given a string `s`, find the length of the longest substring without repeating characters.": 0.15730337078651685, "Write a function that takes a positive integer N as input and outputs a list of lists representing all the ways of partitioning N such that each sublist contains consecutive integers starting from 1.\n\nExample:\nInput: 5\nOutput: [[1],[2,3],[4,5]]": 0.15254237288135591, "Write a function that reverses a string. The input string is given as an array of characters char[]. Do not allocate extra space for another array, you must do this by modifying the input array itself. You may assume all the characters consist of printable ascii characters.": 0.14754098360655737, "Write a function that takes a string as input and returns the string reversed. Example: Given s = \"hello\", return \"olleh\".": 0.14736842105263157, "You are given a binary tree in which each node contains an integer value. Find the largest value in each row of the tree.\n\nExample:\nInput:\n\n 1\n / \\\n 3 2\nOutput: [1, 3, 2]\nExplanation:\nRow 1: 1 is the largest integer in the row.\nRow 2: 3 is the largest integer in the row.\nRow 3: 2 is the largest integer in the row.": 0.14388489208633093, "Given a non-empty array of integers, write a function that returns the minimum difference between the largest and smallest values in the array.\n\nFor example, given \\[3, 10, 5\\], the function should return 7 since the largest value is 10 and the smallest is 3. But given \\[10, 3, 5\\], the function should return 2 since the largest value is 10 and the smallest is 5.": 0.14084507042253522}, "avg_similarity_score": 0.07906793509372816} +{"instruction": "Given a string s, determine whether it is a palindrome, considering only alphanumeric characters and ignoring cases.\n\nExample 1:\nInput: s = \"A man, a plan, a canal: Panama\"\nOutput: true\nExplanation: \"amanaplanacanalpanama\" is a palindrome.\n\nExample 2:\nInput: s = \"race a car\"\nOutput: false\nExplanation: \"raceacar\" is not a palindrome.\n\nExample 3:\nInput: s = \" \"\nOutput: true\nExplanation: s consists of only space characters.\nBecause whitespace characters are ignored, it is treated as an empty string \"\", which is a palindrome.\n\nExample 4:\nInput: s = \"-.\"\nOutput: true\nExplanation: \"-.\" is a palindrome.\n\nExample 5:\nInput: s = \"*#@&$%\"\nOutput: true\nExplanation: \"*#@&$%\" is a palindrome.\nAlthough we treat \"#\" differently from other symbols, it is still a palindrome.", "input": "", "output": "```py\nclass Solution:\n def isPalindrome(self, s: str) -> bool:\n s = re.sub('\\W|_|\\d',' ',s).strip().replace(' ','').upper()\n return s == s[::-1]\n```", "most_similar": {"Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitions of s.\n\nAn empty string is also considered valid.\n\nExample 1:\nInput: s = \"aab\"\nOutput: [[\"aa\",\"b\"],[\"a\",\"a\",\"b\"]]\n\nExample 2:\nInput: s = \"a\"\nOutput: [[\"a\"]]": 0.3018867924528302, "Given a string s, reverse the string according to the following rules:\nAll the characters that are not English letters remain in the same position.\nAll the English letters (lowercase or uppercase) should be reversed.\nReturn s after reversing it.\n\nExample 1:\nInput: s = \"ab-cd\"\nOutput: \"dc-ba\"\n\nExample 2:\nInput: s = \"a-bC-dEf-ghIj\"\nOutput: \"j-Ih-gfE-dCba\"\n\nExample 3:\nInput: s = \"Test1ng-Leet=code-Q!\"\nOutput: \"Qedo1ct-eeLg=ntse-T!\"": 0.22580645161290325, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.14492753623188406, "Write a function that takes a string s consisting of lowercase letters and brackets, and returns whether or not the brackets in the string are balanced.\n\nExample:\nInput: \"(())()\"\nOutput: True": 0.14184397163120566, "Write a function that takes a positive integer N as input and outputs a list of lists representing all the ways of partitioning N such that each sublist contains consecutive integers starting from 1.\n\nExample:\nInput: 5\nOutput: [[1],[2,3],[4,5]]": 0.12987012987012986, "You need to read a code and detect if there is a syntax error or not. Outpus true if there is error, output false if there is not.": 0.12949640287769784, "Write a Python program that takes a list of numbers as input from the user, calculates the sum of all even numbers in the list, and returns the result. The program should check if the input is valid (i.e., if it's a list of numbers), and if it's not, it should return an error message. The program should also handle exceptions gracefully and return a user-friendly error message in case of any exceptions.": 0.1276595744680851, "You are given a binary tree in which each node contains an integer value. Find the largest value in each row of the tree.\n\nExample:\nInput:\n\n 1\n / \\\n 3 2\nOutput: [1, 3, 2]\nExplanation:\nRow 1: 1 is the largest integer in the row.\nRow 2: 3 is the largest integer in the row.\nRow 3: 2 is the largest integer in the row.": 0.12571428571428572, "Given a non-empty array of integers, write a function that returns the minimum difference between the largest and smallest values in the array.\n\nFor example, given \\[3, 10, 5\\], the function should return 7 since the largest value is 10 and the smallest is 3. But given \\[10, 3, 5\\], the function should return 2 since the largest value is 10 and the smallest is 5.": 0.12359550561797752, "Write a function that takes a nonnegative integer N as input and computes the binary representation of N.\n\nExample:\nInput: 5\nOutput: [1,0,1]": 0.11764705882352941}, "avg_similarity_score": 0.049976461038202157} +{"instruction": "Given a string s, remove duplicate letters so that every letter appears once and only once. You must make sure your result is the smallest in lexicographical order among all possible results.\n\nNote: This question is the same as 1081: https://leetcode.com/problems/smallest-subsequence-of-distinct-characters/\n\nExample 1:\nInput: s = \"bcabc\"\nOutput: \"abc\"\n\nExample 2:\nInput: s = \"cbacdcbc\"\nOutput: \"acdb\"", "input": "", "output": "```py\nclass Solution:\n def removeDuplicateLetters(self, s: str) -> str:\n freq = collections.Counter(s)\n st = []\n seen = set()\n for i in s:\n if i not in seen:\n while st and st[-1] > i and freq[st[-1]] > 0:\n seen.remove(st.pop())\n if i not in seen:\n st.append(i)\n seen.add(i)\n freq[i] -= 1\n return ''.join(st)\n```", "most_similar": {"Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitions of s.\n\nAn empty string is also considered valid.\n\nExample 1:\nInput: s = \"aab\"\nOutput: [[\"aa\",\"b\"],[\"a\",\"a\",\"b\"]]\n\nExample 2:\nInput: s = \"a\"\nOutput: [[\"a\"]]": 0.3603603603603603, "Given a string s, reverse the string according to the following rules:\nAll the characters that are not English letters remain in the same position.\nAll the English letters (lowercase or uppercase) should be reversed.\nReturn s after reversing it.\n\nExample 1:\nInput: s = \"ab-cd\"\nOutput: \"dc-ba\"\n\nExample 2:\nInput: s = \"a-bC-dEf-ghIj\"\nOutput: \"j-Ih-gfE-dCba\"\n\nExample 3:\nInput: s = \"Test1ng-Leet=code-Q!\"\nOutput: \"Qedo1ct-eeLg=ntse-T!\"": 0.2608695652173913, "Write a function that takes a string s consisting of lowercase letters and brackets, and returns whether or not the brackets in the string are balanced.\n\nExample:\nInput: \"(())()\"\nOutput: True": 0.2365591397849462, "Write a function that reverses a string. The input string is given as an array of characters s.": 0.19753086419753085, "Given a string s, determine whether it is a palindrome, considering only alphanumeric characters and ignoring cases.\n\nExample 1:\nInput: s = \"A man, a plan, a canal: Panama\"\nOutput: true\nExplanation: \"amanaplanacanalpanama\" is a palindrome.\n\nExample 2:\nInput: s = \"race a car\"\nOutput: false\nExplanation: \"raceacar\" is not a palindrome.\n\nExample 3:\nInput: s = \" \"\nOutput: true\nExplanation: s consists of only space characters.\nBecause whitespace characters are ignored, it is treated as an empty string \"\", which is a palindrome.\n\nExample 4:\nInput: s = \"-.\"\nOutput: true\nExplanation: \"-.\" is a palindrome.\n\nExample 5:\nInput: s = \"*#@&$%\"\nOutput: true\nExplanation: \"*#@&$%\" is a palindrome.\nAlthough we treat \"#\" differently from other symbols, it is still a palindrome.": 0.1954022988505747, "Write a function that takes a positive integer N as input and outputs a list of lists representing all the ways of partitioning N such that each sublist contains consecutive integers starting from 1.\n\nExample:\nInput: 5\nOutput: [[1],[2,3],[4,5]]": 0.18867924528301885, "Write a function that takes a nonnegative integer N as input and computes the binary representation of N.\n\nExample:\nInput: 5\nOutput: [1,0,1]": 0.18181818181818182, "Given a string `s`, find the length of the longest substring without repeating characters.": 0.1818181818181818, "Given a string s consisting of lowercase English letters, find the length of the longest substring without repeating characters. If there are multiple substrings with equal lengths, return the leftmost one.": 0.1702127659574468, "Write a function that reverses a string. The input string is given as an array of characters char[]. Do not allocate extra space for another array, you must do this by modifying the input array itself. You may assume all the characters consist of printable ascii characters.": 0.16363636363636364}, "avg_similarity_score": 0.08872785214562005} +{"instruction": "You need to write a function that accepts three parameters:\na positive integer n\nan array containing k distinct elements\nanother array containing l distinct elements\nYour function needs to find out whether the arrays contain subsets whose sums equal n. If yes, return true; otherwise, return false.\n\nFor instance, let\u2019s say n equals 10, k equals 3, and our first array contains the following elements: [1, 2, 3]. Our second array contains the following elements: [1, 2, 4]. Since both arrays contain subsets whose sums equal 10, your function should return true. On the other hand, if n equals 10, k equals 3, and our first array contains the following elements: [1, 2, 3]. Our second array contains the following elements: [1, 2, 5]. In this case, neither array contains a subset whose sum equals 10, therefore, your function should return false.", "input": "", "output": "We can solve this problem efficiently using dynamic programming. We maintain a boolean matrix dp where dp[i][j] represents whether the subarray starting at index j and ending at index i (both inclusive) forms a contiguous subarray whose sum equals n. To fill the entries of this matrix, we consider all possible combinations of adding a new element to the existing subarray formed till now. Let\u2019s take an example to understand how this works. Consider the above mentioned example where n equals 10, k equals 3, and our first array contains the following elements: [1, 2, 3]. Our second array contains the following elements: [1, 2, 4]. Now, suppose we want to know whether the subarray starting at index 0 and ending at index 2 (both inclusive) forms a contiguous subarray whose sum equals 10. There are four ways to form a contiguous subarray whose sum equals 10:\n\nSubarray starting at index 0 and ending at index 0: [1]\nSubarray starting at index 0 and ending at index 1: [1, 2]\nSubarray starting at index 0 and ending at index 2: [1, 2, 3]\nSubarray starting at index 1 and ending at index 2: [2, 3]\nNow, since the last entry in the previous row corresponds to the subarray starting at index 0 and ending at index 0, we update the value of dp[2][0] to true. Similarly, since the fourth entry in the previous row corresponds to the subarray starting at index 1 and ending at index 2, we update the value of dp[2][2] to true. Finally, since the fifth entry in the previous row corresponds to the subarray starting at index 0 and ending at index 1, we update the value of dp[2][1] to true. After filling the entire matrix, we can easily determine whether either of the two arrays contains a subset whose sum equals n.\n\nBelow is the implementation of the above idea:\n\n```java\npublic class SubsetSumDP {\n public static void main(String[] args){\n // Input: arr1 = [1, 2, 3]; arr2 = [1, 2, 4]; n = 10\n int[] arr1 = {1, 2, 3};\n int[] arr2 = {1, 2, 4};\n System.out.println(subsetSum(arr1, arr2));\n }\n private static boolean subsetSum(int[] arr1, int[] arr2){\n /* Create a boolean matrix dp where dp[i][j] stores whether the subarray starting at index j and ending at index i (both inclusive) forms a contiguous subarray whose sum equals n */\n boolean[][] dp = new boolean[arr1.length+1][arr2.length+1];\n /* Fill the entries of this matrix */\n for(int i=0; i<=arr1.length; ++i){\n for(int j=0; j<=arr2.length; ++j){\n if((i==0 && j!=0) || (i!=0 && j==0)){\n dp[i][j]=false;\n }else if(i==0 && j==0){\n dp[i][j]=true;\n }else{\n dp[i][j]=(dp[i-1][j]+dp[i][j-1]);\n }\n }\n }\n /* Return true if either of the two arrays contains a subset whose sum equals n */\n return Arrays.stream(dp[arr1.length]).anyMatch(x-> x);\n }\n}\n```\n\nTime complexity : O(kn)O(kn)\nSpace Complexity : O(kn)O(kn)", "most_similar": {"Given a non-empty array of integers, write a function that returns the minimum difference between the largest and smallest values in the array.\n\nFor example, given \\[3, 10, 5\\], the function should return 7 since the largest value is 10 and the smallest is 3. But given \\[10, 3, 5\\], the function should return 2 since the largest value is 10 and the smallest is 5.": 0.1990521327014218, "Write a function that takes a positive integer N as input and outputs a list of lists representing all the ways of partitioning N such that each sublist contains consecutive integers starting from 1.\n\nExample:\nInput: 5\nOutput: [[1],[2,3],[4,5]]": 0.1711229946524064, "You are given a binary tree in which each node contains an integer value. Find the largest value in each row of the tree.\n\nExample:\nInput:\n\n 1\n / \\\n 3 2\nOutput: [1, 3, 2]\nExplanation:\nRow 1: 1 is the largest integer in the row.\nRow 2: 3 is the largest integer in the row.\nRow 3: 2 is the largest integer in the row.": 0.16346153846153844, "Implement a function that accepts a string containing digits from 2-9 with various lengths. The function should replace every digit with the word equivalent of that digit (e.g., 2 becomes \u2018two\u2019, 3 becomes \u2018three\u2019, \u2026 , 9 becomes \u2018nine\u2019). There is no need to validate the contents of the input string.": 0.14358974358974358, "Write a function that takes a nonnegative integer N as input and computes the binary representation of N.\n\nExample:\nInput: 5\nOutput: [1,0,1]": 0.1420118343195266, "Write a Python program that takes a list of numbers as input from the user, calculates the sum of all even numbers in the list, and returns the result. The program should check if the input is valid (i.e., if it's a list of numbers), and if it's not, it should return an error message. The program should also handle exceptions gracefully and return a user-friendly error message in case of any exceptions.": 0.13574660633484165, "Write a function that reverses a string. The input string is given as an array of characters char[]. Do not allocate extra space for another array, you must do this by modifying the input array itself. You may assume all the characters consist of printable ascii characters.": 0.1256544502617801, "Create a function that converts a name into initials. Given a name, the function should return the first letter of every word capitalized.": 0.11976047904191615, "Write a C++ function that takes a map as an input and returns the largest pair in the map, in 8 lines or fewer. A pair is considered larger if its second value is larger than another pair's second value.": 0.11891891891891894, "Write a function that takes a string s consisting of lowercase letters and brackets, and returns whether or not the brackets in the string are balanced.\n\nExample:\nInput: \"(())()\"\nOutput: True": 0.11494252873563217}, "avg_similarity_score": 0.06544015785499308} +{"instruction": "Imagine you are building a compiler for a very basic programming language. Your job is to implement a parser for arithmetic expressions. An expression consists of digits, addition, multiplication, parenthesis, and negative signs. Expressions look something like this:\n\n```\n1+(2-(3*(-4)))\n```\n\nIn this example, the expression evaluates to 1+(2-(3*(-4))) = 1+(2-(-12)) = 1+(2+12) = 14.\n\nA sample input could be:\n\n```\n1+(2-(3*(-4)))\n```\n\nAnd a corresponding output could be:\n\n```\n14\n```\n\nIf the input does not represent a well-formed expression, throw an exception.", "input": "", "output": "Here's a sample implementation of a parser for arithmetic expressions written in Java:\n\n``` java\nimport java.util.*;\n\npublic class ArithmeticParser {\n\tprivate String expr;\n\tprivate Stack stack;\n\tprivate Map precedenceMap;\n\n\tArithmeticParser(){\n\t\tstack = new Stack<>();\n\t\tprecedenceMap = new HashMap<>();\n\t\tprecedenceMap.put('(', 0);\n\t\tprecedenceMap.put('+', 1);\n\t\tprecedenceMap.put('-', 1);\n\t\tprecedenceMap.put('*', 2);\n\t\tprecedenceMap.put('/', 2);\n\t}\n\n\tvoid parseExpression(String expr){\n\t\tthis.expr = expr;\n\t\tfor(int i=0; i 1.\nGiven n, calculate F(n)": 0.1388888888888889, "You need to read a code and detect if there is a syntax error or not. Outpus true if there is error, output false if there is not.": 0.13675213675213674, "Write a function that takes a string s consisting of lowercase letters and brackets, and returns whether or not the brackets in the string are balanced.\n\nExample:\nInput: \"(())()\"\nOutput: True": 0.13445378151260504, "Write a Python program that takes a list of numbers as input from the user, calculates the sum of all even numbers in the list, and returns the result. The program should check if the input is valid (i.e., if it's a list of numbers), and if it's not, it should return an error message. The program should also handle exceptions gracefully and return a user-friendly error message in case of any exceptions.": 0.1325301204819277, "Write a function that reverses a string. The input string is given as an array of characters char[]. Do not allocate extra space for another array, you must do this by modifying the input array itself. You may assume all the characters consist of printable ascii characters.": 0.13235294117647062, "Given a string s, remove duplicate letters so that every letter appears once and only once. You must make sure your result is the smallest in lexicographical order among all possible results.\n\nNote: This question is the same as 1081: https://leetcode.com/problems/smallest-subsequence-of-distinct-characters/\n\nExample 1:\nInput: s = \"bcabc\"\nOutput: \"abc\"\n\nExample 2:\nInput: s = \"cbacdcbc\"\nOutput: \"acdb\"": 0.13157894736842105}, "avg_similarity_score": 0.07513690547358957} +{"instruction": "Write a function that reverses a singly linked list. Do NOT use recursion!", "input": "", "output": "Here's a sample implementation of a doubly linked list in C++:\n\n``` cpp\nstruct Node {\n int key;\n struct Node *prev;\n struct Node *next;\n};\n\nNode *head = NULL;\n\n/* Function to reverse the linked list */\nvoid reverseLinkedList() {\n Node *tempHead = head;\n Node *curr = tempHead;\n Node *next = curr->next;\n\n while (curr != NULL) {\n next = curr->next;\n curr->next = curr->prev;\n curr->prev = next;\n curr = next;\n }\n\n head = tempHead->prev;\n}\n```\n\nTime Complexity : O(N)O(N)\nSpace Complexity : O(1)O(1)", "most_similar": {"Write a python function that sorts a list from large to small.": 0.48000000000000004, "Write a Python function to reverse a given list of integers.": 0.41666666666666663, "Write a function that reverses a string. The input string is given as an array of characters s.": 0.3870967741935484, "Write a function that checks if a binary tree is symmetric around its center.": 0.3703703703703704, "Write a function that removes duplicates from an unsorted linked list. Follow up: How would you solve this problem if a temporary buffer is not allowed?": 0.3589743589743589, "Write a function that removes duplicate words from a string. All whitespace characters must separate the words.": 0.33333333333333337, "write a c++ program that calculates the perimeter of a square": 0.33333333333333337, "Write a function that computes the greatest common divisor of two positive integer numbers. Use Euclid's Algorithm.": 0.3225806451612903, "Write a function that determines whether a triangle is equilateral, isosceles, scalene based on three side lengths provided.": 0.3225806451612903, "Write a script to output the mean of a list of integers.": 0.32}, "avg_similarity_score": 0.14053554097921855} +{"instruction": "Write a function that checks if a given string is a palindrome. Assume that the maximum length of the string is 1000 characters. What techniques can you use to speed up the checking process?", "input": "", "output": "There are many different approaches to solving this problem. One straightforward method is to compare the character at position i with the character at position n\u2212i\u22121, where n is the length of the string. However, this approach is too slow because it involves comparing each character with every other character in the string. Instead, we can use a technique known as divide and conquer.\n\nDivide and Conquer\n\nInstead of directly comparing each character with every other character, we can partition the string into two halves and compare them separately. Then, we can merge the comparison results together to produce the final result.\n\nConsider the following example:\n\n```\nabcdcba\n```\n\nWe can partition the string into \u201cab\u201d and \u201cdcba\u201d. First, we compare ab and cd. Next, we compare ba and dc. Note that we ignore the middle character \u2018c\u2019 because it is already compared during the first stage. Therefore, we end up with the following table:\n\nComparison Result Table\n\nSince both comparisons resulted in true, we conclude that the original string was indeed a palindrome.\n\nAnother example:\n\n```\nabbad\n```\n\nWe can again partition the string into \u201cab\u201d and \u201cbad\u201d, but this time, the first comparison fails. Hence, we stop immediately without performing the second comparison. As a result, we end up with the following table:\n\nComparison Result Table\n\nBecause the first comparison failed, we conclude that the original string was not a palindrome.\n\nHere's a sample implementation of the above idea in C++:\n\n```cpp\nbool isPalindrome(string& s) {\n bool res = true;\n int size = s.size();\n for (int i = 0; i < size / 2; i++) {\n if (s[i] != s[size - i - 1]) {\n res = false;\n break;\n }\n }\n return res;\n}\n```\n\nTime Complexity : O(N)O(N)\nSpace Complexity : O(1)O(1)", "most_similar": {"Write a function that reverses a string. The input string is given as an array of characters s.": 0.3846153846153846, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.36065573770491804, "Write a function that checks if a binary tree is symmetric around its center.": 0.3333333333333333, "Write a function that removes duplicate words from a string. All whitespace characters must separate the words.": 0.3137254901960785, "Write a function that takes a string as input and returns the string reversed. Example: Given s = \"hello\", return \"olleh\".": 0.29629629629629634, "Write a function that reverses a string. The input string is given as an array of characters char[]. Do not allocate extra space for another array, you must do this by modifying the input array itself. You may assume all the characters consist of printable ascii characters.": 0.2962962962962963, "Given a string `s`, find the length of the longest substring without repeating characters.": 0.2916666666666667, "Write a function that counts the total number of prime numbers up to N.": 0.2916666666666667, "Write a function that takes a string s consisting of lowercase letters and brackets, and returns whether or not the brackets in the string are balanced.\n\nExample:\nInput: \"(())()\"\nOutput: True": 0.28125, "Create a function that converts a name into initials. Given a name, the function should return the first letter of every word capitalized.": 0.28070175438596484}, "avg_similarity_score": 0.14985872060167707} +{"instruction": "Write a function that counts the occurrences of a substring within a string.", "input": "", "output": "Here's a sample implementation of the above idea in JavaScript:\n\n``` js\nfunction substrCount(str, pattern) {\n var count = 0;\n var idx = str.indexOf(pattern);\n while (idx != -1) {\n count++;\n idx = str.indexOf(pattern, idx + 1);\n }\n return count;\n}\nconsole.log(substrCount('aaaaaaa', 'aa'))\n```\n\nTime Complexity : O(M\u00d7N)O(M\u00d7N)\nSpace Complexity : O(1)O(1)", "most_similar": {"Write a function that counts the total number of prime numbers up to N.": 0.5185185185185186, "write a c++ program that calculates the perimeter of a square": 0.4999999999999999, "Write a function that calculates the sum of all odd fibonacci numbers below n.": 0.4444444444444445, "Write a function that removes duplicate words from a string. All whitespace characters must separate the words.": 0.4000000000000001, "Write a python function that sorts a list from large to small.": 0.4, "Write a script to output the mean of a list of integers.": 0.4, "Write a function that reverses a string. The input string is given as an array of characters s.": 0.3870967741935484, "Write a function that computes the greatest common divisor of two positive integer numbers. Use Euclid's Algorithm.": 0.3870967741935484, "Write a function that reverses a singly linked list. Do NOT use recursion!": 0.38461538461538464, "write a java function that implements gray code and returns the next sequence code after a given code in a given direction of rotation": 0.3783783783783784}, "avg_similarity_score": 0.18788135397254435} +{"instruction": "What does the \u201c*\u201d operator mean in python?", "input": "", "output": "When applied before a variable name, the unary star (*) acts as a placeholder for zero or more arguments. This means that the argument passed to the function must be iterable. When applied after a parameter name, the starred parameter collects positional arguments as a tuple. Here\u2019s an example:\n\n```\n>>> def func(*args):\n... print('Received',len(args), 'arguments')\n... print('Argument List: ', end=' ')\n... for arg in args:\n... print(arg,end=' ')\n...\n>>> func(1,2,'three','four')\nReceived 4 arguments\nArgument List: 1 2 three four\n>>> func()\nReceived 0 arguments\nArgument List:\n>>>\n```\n\nIf you pass multiple arguments to a function expecting only one argument, they get grouped together inside a tuple.\n\n```\n>>> def func(arg):\n... print ('Single Argument:', arg)\n...\n>>> func(1,2,\"Three\")\nTraceback (most recent call last):\nFile \"\", line 1, in ?\nTypeError: func expected 1 arguments, got 3\n>>> func(*(1,2,\"Three\"))\nSingle Argument: (1, 2, Three)\n>>>\n```\n\nSimilarly, if you have a function accepting multiple arguments but you want to pass just one argument, you can wrap them around parenthesis.\n\n```\n>>> def func(arg1, arg2, arg3):\n... print (\"Arg1:\", arg1)\n... print (\"Arg2:\", arg2)\n... print (\"Arg3:\", arg3)\n...\n>>> func(1,(2,3,4),(5,6,7))\nArg1: 1\nArg2: (2, 3, 4)\nArg3: (5, 6, 7)\n>>>\n```\n\nThis behavior is similar to what happens when passing keyword arguments to functions.\n\n```\n>>> def func(**kwargs):\n... print kwargs\n...\n>>> func(key1=1, key2=[2,3,4], key3={\"five\": 5})\n{'key1': 1, 'key2': [2, 3, 4], 'key3': {'five': 5}}\n>>>\n```\n\nNote that the ** operator has no effect unless followed by a dictionary object.\n\n```\n>>> def func(**kwargs):\n... print kwargs\n...\n>>> func(key1=1, key2=[2,3,4], key3={\"five\": 5}, key4=None)\nTraceback (most recent call last):\nFile \"\", line 1, in ?\nTypeError: func() keywords must be strings\n>>>\n```", "most_similar": {"How do I get the power of a number in python?": 0.33333333333333326, "How do you output all the contents of a list in Python?": 0.3157894736842105, "bubble sort list of int in python": 0.2857142857142857, "What is the difference between a pointer variable and a reference variable in Java?": 0.2857142857142857, "Suggest a completion for the following python code.": 0.26666666666666666, "Create a calculator in the Python programming language": 0.26666666666666666, "Translate the following code from python in Java.": 0.26666666666666666, "Write a script to output 'Hello World' in python": 0.25, "Replace all the human names in the paragraph with .": 0.23529411764705882, "Identify the pos tag of the word in the given sentence.": 0.2222222222222222}, "avg_similarity_score": 0.09656818256830285} +{"instruction": "Given a string s consisting of small English letters, find and return the first instance of a non-repeating character in it. If there is no such character, return '_'.\n\nExamples:\n\nInput: s = \"abacabad\"\nOutput: \"b\"\nExplanation: The first non-repeating character is 'b'.\n\nInput: s = \"zabbaxxxxyyyyzzzyabcd\"\nOutput: \"_\"\nExplanation: There are no characters that appear exactly once.\n\nInput: s = \"abcdeeeefghiijklmnoppqqrrssstuvwxyz\"\nOutput: \"t\"\nExplanation: The first non-repeating character is 't'.\n\nInput: s = \"\"\nOutput: \"_\"\nExplanation: An empty string has no characters.", "input": "", "output": "A straightforward approach is to iterate over every character in the string and count their frequency. Then, we can pick the first unique character encountered while traversing through the string. However, this approach requires extra space proportional to the size of the alphabet. Can we optimize it further without using extra space?\n\nYes, we can. Instead of counting frequencies, we can directly store the occurrence of each character in the string. Once we encounter a repeated character, we can immediately stop searching for the next unique character. Below is the implementation of this idea:\n\n```cpp\nclass Solution {\npublic:\n char firstUniqChar(string s) {\n vector seen(26, false);\n for (char ch : s) {\n if (!seen[(ch - 'a')]) {\n seen[(ch - 'a')] = true;\n } else {\n seen[(ch - 'a')] = false;\n }\n }\n for (size_t i = 0; i != seen.size(); ++i) {\n if (seen[i]) {\n return 'a' + i;\n }\n }\n return '_';\n }\n};\n```\n\nTime complexity : O(|s|)O(|s|). Each character is visited twice.\nSpace complexity : O(1)O(1). Constant space is used.", "most_similar": {"Given a string s consisting of lowercase English letters, find the length of the longest substring without repeating characters. If there are multiple substrings with equal lengths, return the leftmost one.": 0.2909090909090909, "Given a string s, determine whether it is a palindrome, considering only alphanumeric characters and ignoring cases.\n\nExample 1:\nInput: s = \"A man, a plan, a canal: Panama\"\nOutput: true\nExplanation: \"amanaplanacanalpanama\" is a palindrome.\n\nExample 2:\nInput: s = \"race a car\"\nOutput: false\nExplanation: \"raceacar\" is not a palindrome.\n\nExample 3:\nInput: s = \" \"\nOutput: true\nExplanation: s consists of only space characters.\nBecause whitespace characters are ignored, it is treated as an empty string \"\", which is a palindrome.\n\nExample 4:\nInput: s = \"-.\"\nOutput: true\nExplanation: \"-.\" is a palindrome.\n\nExample 5:\nInput: s = \"*#@&$%\"\nOutput: true\nExplanation: \"*#@&$%\" is a palindrome.\nAlthough we treat \"#\" differently from other symbols, it is still a palindrome.": 0.27368421052631575, "Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitions of s.\n\nAn empty string is also considered valid.\n\nExample 1:\nInput: s = \"aab\"\nOutput: [[\"aa\",\"b\"],[\"a\",\"a\",\"b\"]]\n\nExample 2:\nInput: s = \"a\"\nOutput: [[\"a\"]]": 0.25196850393700787, "Given a string s, remove duplicate letters so that every letter appears once and only once. You must make sure your result is the smallest in lexicographical order among all possible results.\n\nNote: This question is the same as 1081: https://leetcode.com/problems/smallest-subsequence-of-distinct-characters/\n\nExample 1:\nInput: s = \"bcabc\"\nOutput: \"abc\"\n\nExample 2:\nInput: s = \"cbacdcbc\"\nOutput: \"acdb\"": 0.23943661971830987, "Write a function that takes a string s consisting of lowercase letters and brackets, and returns whether or not the brackets in the string are balanced.\n\nExample:\nInput: \"(())()\"\nOutput: True": 0.23853211009174313, "Given a string s, reverse the string according to the following rules:\nAll the characters that are not English letters remain in the same position.\nAll the English letters (lowercase or uppercase) should be reversed.\nReturn s after reversing it.\n\nExample 1:\nInput: s = \"ab-cd\"\nOutput: \"dc-ba\"\n\nExample 2:\nInput: s = \"a-bC-dEf-ghIj\"\nOutput: \"j-Ih-gfE-dCba\"\n\nExample 3:\nInput: s = \"Test1ng-Leet=code-Q!\"\nOutput: \"Qedo1ct-eeLg=ntse-T!\"": 0.23376623376623376, "Given a string `s`, find the length of the longest substring without repeating characters.": 0.21505376344086025, "Write a function that finds the longest common prefix string amongst an array of strings.\n\nIf there is no common prefix, return an empty string \"\".": 0.2115384615384615, "Implement a function that accepts a string containing digits from 2-9 with various lengths. The function should replace every digit with the word equivalent of that digit (e.g., 2 becomes \u2018two\u2019, 3 becomes \u2018three\u2019, \u2026 , 9 becomes \u2018nine\u2019). There is no need to validate the contents of the input string.": 0.16923076923076924, "You need to read a code and detect if there is a syntax error or not. Outpus true if there is error, output false if there is not.": 0.16822429906542058}, "avg_similarity_score": 0.08477766008782972} +{"instruction": "Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.\n\nPush(x) -- Push element x onto stack.\nPop() -- Removes the element on top of the stack.\nTop() -- Get the top element.\nGetMin() -- Retrieve the minimum element in the stack.", "input": "", "output": "Since we need to retrieve the minimum element in constant time, we cannot rely on storing the minimum element along with the rest of the elements in the stack. One alternative is to scan the whole stack everytime we invoke the GetMin() method. However, this approach results in quadratic runtime.\n\nInstead, we can utilize the fact that the minimum element lies somewhere between the bottom of the stack and the top of the stack. Thus, we can maintain a separate min stack that keeps track of the minimum element seen so far during the insertion process. Everytime we push a new element onto the original stack, we also push the smaller of the newly inserted element and the current minimum element onto the min stack. Lastly, when popping off an element from the original stack, we also pop off the corresponding element from the min stack.\n\nBelow is the implementation of the above idea:\n\n```js\nvar MinStack = function () {\n\tthis.stack = [];\n\tthis.minStack = [];\n};\n\n/**\n * @param {number} val\n * @return {void}\n */\nMinStack.prototype.push = function (val) {\n\tif (this.isEmpty()) {\n\t\t// First element pushed onto the stack\n\t\tthis.stack.push(val);\n\t\tthis.minStack.push(val);\n\t} else {\n\t\tconst currMinVal = Math.min(...this.getMin());\n\t\tthis.stack.push(Math.max(currMinVal, val));\n\t\tthis.minStack.push(Math.min(currMinVal, val));\n\t}\n};\n\n/**\n * @return {void}\n */\nMinStack.prototype.pop = function () {\n\tthis.stack.pop();\n\tthis.minStack.pop();\n};\n\n/**\n * @return {number}\n */\nMinStack.prototype.top = function () {\n\treturn this.stack[this.stack.length - 1];\n};\n\n/**\n * @return {number}\n */\nMinStack.prototype.getMin = function () {\n\treturn this.minStack[this.minStack.length - 1];\n};\n\n/**\n * @return {boolean}\n */\nMinStack.prototype.isEmpty = function () {\n\treturn !this.stack.length;\n};\n\n/**\n * Your MinStack object will be instantiated and called as such:\n * var obj = Object.create(MinStack).createNew()\n * obj.push(val)\n * obj.pop()\n * var param_3 = obj.top()\n * var param_4 = obj.getMin()\n */\n```\n\nTime complexity : O(1)O(1) for each operation.\nSpace complexity : O(N)O(N) where NN is the maximum capacity of the stack.", "most_similar": {"Can you provide a shell script that displays the total number of lines in all '*.txt' files in the current directory?": 0.18181818181818182, "Given a non-empty array of integers, write a function that returns the minimum difference between the largest and smallest values in the array.\n\nFor example, given \\[3, 10, 5\\], the function should return 7 since the largest value is 10 and the smallest is 3. But given \\[10, 3, 5\\], the function should return 2 since the largest value is 10 and the smallest is 5.": 0.17857142857142855, "Identify the pos tag of the word in the given sentence.": 0.17857142857142855, "write a java function that implements gray code and returns the next sequence code after a given code in a given direction of rotation": 0.1739130434782609, "You are given a binary tree in which each node contains an integer value. Find the largest value in each row of the tree.\n\nExample:\nInput:\n\n 1\n / \\\n 3 2\nOutput: [1, 3, 2]\nExplanation:\nRow 1: 1 is the largest integer in the row.\nRow 2: 3 is the largest integer in the row.\nRow 3: 2 is the largest integer in the row.": 0.1651376146788991, "Write a C++ function that takes a map as an input and returns the largest pair in the map, in 8 lines or fewer. A pair is considered larger if its second value is larger than another pair's second value.": 0.1627906976744186, "Using the comment as a guide, replace the \"TODO\" comment in the code with the proper code.": 0.16129032258064516, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.16129032258064516, "Write a function that takes a string s consisting of lowercase letters and brackets, and returns whether or not the brackets in the string are balanced.\n\nExample:\nInput: \"(())()\"\nOutput: True": 0.16, "write a code to get the current value of a Bitcoin in US dollars using the bitcoincharts API.": 0.15873015873015872}, "avg_similarity_score": 0.09321192283956124} +{"instruction": "Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia: \u201cThe lowest common ancestor is defined between two nodes p and q as the lowest node in T that has both p and q as descendants (where we allow a node to be a descendant of itself).\u201d", "input": "", "output": "Here's a recursive approach to solving this problem:\n\n```java\npublic TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) {\n\tif (root == null || root == p || root == q) return root; // base case\n\t// Recursively check left subtree\n\tTreeNode left = lowestCommonAncestor(root.left, p, q);\n\t// Recursively check right subtree\n\tTreeNode right = lowestCommonAncestor(root.right, p, q);\n\t// Check if either the left or right child is the LCA\n\tif (left != null && right != null) return root;\n\telse if (left != null) return left;\n\telse return right;\n}\n```\nLet's break down what happens here. First, we define our base cases which are when either the root is null, or when the root equals either p or q. In these situations, there is no lower common ancestor since the root doesn't exist or it is the same as one of the other nodes. Next, we recursively call the function twice, once for the left subtree and again for the right subtree. We store the results of those calls into variables named left and right respectively. Then, we check whether either the left or right child is the answer. This is done by checking if neither left nor right is null. If only one of them is non-null, then that must be the answer. Otherwise, if none of them were non-null, then the parent node was the lowest common ancestor.\n\nWe could also solve this problem iteratively instead of recursively. To do so, we would keep track of three things: the current node being visited, the path taken to get to the current node, and the depth of the current node. As soon as we encounter a leaf node, we stop traversing the tree. At this point, we compare the paths taken to determine if the two leaves share a common ancestor. If they do, then the shared ancestor is the lowest common ancestor.\n\nIf you want to learn more about finding the lowest common ancestor, check out my post on how to find the lowest common ancestor of two nodes in a binary search tree.", "most_similar": {"You are given a binary tree in which each node contains an integer value. Find the largest value in each row of the tree.\n\nExample:\nInput:\n\n 1\n / \\\n 3 2\nOutput: [1, 3, 2]\nExplanation:\nRow 1: 1 is the largest integer in the row.\nRow 2: 3 is the largest integer in the row.\nRow 3: 2 is the largest integer in the row.": 0.2222222222222222, "Write a Python program that takes a list of numbers as input from the user, calculates the sum of all even numbers in the list, and returns the result. The program should check if the input is valid (i.e., if it's a list of numbers), and if it's not, it should return an error message. The program should also handle exceptions gracefully and return a user-friendly error message in case of any exceptions.": 0.18705035971223022, "Given the `root` of a binary tree, return the inorder traversal of its nodes' values.": 0.18181818181818182, "Given a non-empty array of integers, write a function that returns the minimum difference between the largest and smallest values in the array.\n\nFor example, given \\[3, 10, 5\\], the function should return 7 since the largest value is 10 and the smallest is 3. But given \\[10, 3, 5\\], the function should return 2 since the largest value is 10 and the smallest is 5.": 0.17054263565891475, "Write a script to output the mean of a list of integers.": 0.16216216216216214, "Write me a function in C++ to find the distance between two points": 0.15999999999999998, "Given a string `s`, find the length of the longest substring without repeating characters.": 0.15789473684210525, "Given a string s consisting of small English letters, find and return the first instance of a non-repeating character in it. If there is no such character, return '_'.\n\nExamples:\n\nInput: s = \"abacabad\"\nOutput: \"b\"\nExplanation: The first non-repeating character is 'b'.\n\nInput: s = \"zabbaxxxxyyyyzzzyabcd\"\nOutput: \"_\"\nExplanation: There are no characters that appear exactly once.\n\nInput: s = \"abcdeeeefghiijklmnoppqqrrssstuvwxyz\"\nOutput: \"t\"\nExplanation: The first non-repeating character is 't'.\n\nInput: s = \"\"\nOutput: \"_\"\nExplanation: An empty string has no characters.": 0.15602836879432622, "Given a string s consisting of lowercase English letters, find the length of the longest substring without repeating characters. If there are multiple substrings with equal lengths, return the leftmost one.": 0.15053763440860216, "Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.\n\nPush(x) -- Push element x onto stack.\nPop() -- Removes the element on top of the stack.\nTop() -- Get the top element.\nGetMin() -- Retrieve the minimum element in the stack.": 0.14953271028037382}, "avg_similarity_score": 0.0937898808430073} +{"instruction": "You are given a string s consisting of small English letters. Your task is to reverse the order of vowels in this string.\nA vowel is a letter 'a','o','u','e','i'.\nExample 1:\nInput: s = \"hello\"\nOutput: \"holle\"\nExample 2:\nInput: s = \"leetcode\"\nOutput: \"leotcede\"\nConstraints:\n1 <= s.length <= 3 * 10^5\ns consists of printable ASCII characters.", "input": "", "output": "Here's a simple Java program to accomplish this task:\n\n``` java\nclass Solution {\n public String reverseVowels(String s) {\n \n char[] chars = new char[s.length()];\n Set vowels = new HashSet<>();\n vowels.addAll(Arrays.asList('a', 'e', 'i', 'o', 'u'));\n \n for (int i = 0; i < s.length(); ++i) {\n Character c = s.charAt(i);\n if (!vowels.contains(c)){\n chars[i]=c;\n }\n else{\n Stack stack = new Stack<>();\n stack.push(c);\n while(!stack.isEmpty()) {\n chars[i++] = stack.pop();\n }\n }\n }\n return new String(chars);\n }\n}\n```\nIn the above program, we initialize a hashset called vowels to contain all five vowels. We iterate through the string s and check if the current character is a vowel. If it isn't, we simply copy it to the final string without reversal. However, if it is a vowel, we put it onto a stack. Once we reach the end of the string, we empty the stack back into the original string starting at the index after the previous vowel.\n\nFor example, consider the string \"hello\". After processing the h, we move on to the e. Since e is a vowel, we push it onto the stack. Now, we continue processing llo. Since l is not a vowel, we just copy it directly to the final string. But now we hit o, which is a vowel. So we push it onto the stack. Finally, we finish off the iteration by popping the stack back into the final string. Thus, the final string looks something like this: heollll. Note that the vowels appear in reverse order compared to the original string.\n\nNow, suppose we had a different string, say \"leetcode\". Again, we begin by pushing the first vowel, e, onto the stack. Then, we proceed to process codel. Since d is not a vowel, we copy it straight to the final string. Next, we hit e, which is a vowel. So we push it onto the stack. And finally, we finish off the iteration by copying the leek backwards into the final string. Hence, the final string looks like this: elecodlee. Notice that the vowels appear in reverse order compared to the original string.", "most_similar": {"Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitions of s.\n\nAn empty string is also considered valid.\n\nExample 1:\nInput: s = \"aab\"\nOutput: [[\"aa\",\"b\"],[\"a\",\"a\",\"b\"]]\n\nExample 2:\nInput: s = \"a\"\nOutput: [[\"a\"]]": 0.3518518518518519, "Given a string s, remove duplicate letters so that every letter appears once and only once. You must make sure your result is the smallest in lexicographical order among all possible results.\n\nNote: This question is the same as 1081: https://leetcode.com/problems/smallest-subsequence-of-distinct-characters/\n\nExample 1:\nInput: s = \"bcabc\"\nOutput: \"abc\"\n\nExample 2:\nInput: s = \"cbacdcbc\"\nOutput: \"acdb\"": 0.3414634146341463, "Given a string s consisting of small English letters, find and return the first instance of a non-repeating character in it. If there is no such character, return '_'.\n\nExamples:\n\nInput: s = \"abacabad\"\nOutput: \"b\"\nExplanation: The first non-repeating character is 'b'.\n\nInput: s = \"zabbaxxxxyyyyzzzyabcd\"\nOutput: \"_\"\nExplanation: There are no characters that appear exactly once.\n\nInput: s = \"abcdeeeefghiijklmnoppqqrrssstuvwxyz\"\nOutput: \"t\"\nExplanation: The first non-repeating character is 't'.\n\nInput: s = \"\"\nOutput: \"_\"\nExplanation: An empty string has no characters.": 0.31654676258992803, "Given a string s, reverse the string according to the following rules:\nAll the characters that are not English letters remain in the same position.\nAll the English letters (lowercase or uppercase) should be reversed.\nReturn s after reversing it.\n\nExample 1:\nInput: s = \"ab-cd\"\nOutput: \"dc-ba\"\n\nExample 2:\nInput: s = \"a-bC-dEf-ghIj\"\nOutput: \"j-Ih-gfE-dCba\"\n\nExample 3:\nInput: s = \"Test1ng-Leet=code-Q!\"\nOutput: \"Qedo1ct-eeLg=ntse-T!\"": 0.28148148148148144, "Write a function that takes a string s consisting of lowercase letters and brackets, and returns whether or not the brackets in the string are balanced.\n\nExample:\nInput: \"(())()\"\nOutput: True": 0.26666666666666666, "Given a string s consisting of lowercase English letters, find the length of the longest substring without repeating characters. If there are multiple substrings with equal lengths, return the leftmost one.": 0.26373626373626374, "Given a string s, determine whether it is a palindrome, considering only alphanumeric characters and ignoring cases.\n\nExample 1:\nInput: s = \"A man, a plan, a canal: Panama\"\nOutput: true\nExplanation: \"amanaplanacanalpanama\" is a palindrome.\n\nExample 2:\nInput: s = \"race a car\"\nOutput: false\nExplanation: \"raceacar\" is not a palindrome.\n\nExample 3:\nInput: s = \" \"\nOutput: true\nExplanation: s consists of only space characters.\nBecause whitespace characters are ignored, it is treated as an empty string \"\", which is a palindrome.\n\nExample 4:\nInput: s = \"-.\"\nOutput: true\nExplanation: \"-.\" is a palindrome.\n\nExample 5:\nInput: s = \"*#@&$%\"\nOutput: true\nExplanation: \"*#@&$%\" is a palindrome.\nAlthough we treat \"#\" differently from other symbols, it is still a palindrome.": 0.24561403508771934, "Given a string `s`, find the length of the longest substring without repeating characters.": 0.21621621621621623, "Write a function that takes a positive integer N as input and outputs a list of lists representing all the ways of partitioning N such that each sublist contains consecutive integers starting from 1.\n\nExample:\nInput: 5\nOutput: [[1],[2,3],[4,5]]": 0.2135922330097087, "Imagine you are building a compiler for a very basic programming language. Your job is to implement a parser for arithmetic expressions. An expression consists of digits, addition, multiplication, parenthesis, and negative signs. Expressions look something like this:\n\n```\n1+(2-(3*(-4)))\n```\n\nIn this example, the expression evaluates to 1+(2-(3*(-4))) = 1+(2-(-12)) = 1+(2+12) = 14.\n\nA sample input could be:\n\n```\n1+(2-(3*(-4)))\n```\n\nAnd a corresponding output could be:\n\n```\n14\n```\n\nIf the input does not represent a well-formed expression, throw an exception.": 0.20134228187919465}, "avg_similarity_score": 0.1007168507488438} +{"instruction": "Given a positive integer N, write a function that computes the smallest number of coins needed to make change for N cents, if you have infinite supply of each of S = { S1, S2, .. , Sm} valued coins.", "input": "", "output": "Here's a dynamic programming based solution to this problem:\n\n```cpp\nvector coinChangeMinCoin(const vector& coins, const int& amount) {\n vector minCoins(amount + 1, INT_MAX), ans;\n minCoins[0] = 0;\n for (auto coin : coins) {\n for (size_t amt = 1; amt <= amount; ++amt) {\n auto prev = minCoins[amt - coin];\n if ((prev != INT_MAX) && (minCoins[amt] > prev + 1)) {\n minCoins[amt] = prev + 1;\n }\n }\n }\n size_t currAmount = amount;\n while (currAmount--) {\n ans.insert(ans.begin(), minCoins[currAmount]);\n }\n return ans;\n}\n```\nFirst, we initialize a vector minCoins of size amount + 1 whose entries initially take the value INT_MAX. We then update the entry minCoins[0] to zero. Why did we choose to initialize minCoins[0] to zero? Well, if we didn't, then we wouldn't be able to handle the situation where amount is zero. That's why we initialized minCoins[0] to zero.\n\nNext, we iterate through the coins and compute the minimum number of coins required to make change for amounts ranging from 1 to amount inclusive. To do so, we iterate through the coins and for each coin, we try to subtract it from the current amount. If the difference is still valid, we update the minimum number of coins required accordingly.\n\nAfter computing the minimum number of coins required for all possible amounts, we traverse the vector minCoins backwards until we reach the desired amount. Along the way, we record the minimum number of coins required along the way.", "most_similar": {"Write a function that counts the total number of prime numbers up to N.": 0.36, "Alice has some coins and Bob wants to give Alice money. Write a program which takes as input the amount of money Alice needs and outputs the least number of coins needed to pay Alice. Assume there are infinite supply of coins.": 0.30769230769230765, "Write a function that computes the greatest common divisor of two positive integer numbers. Use Euclid's Algorithm.": 0.2962962962962963, "Write a function that calculates the sum of all odd fibonacci numbers below n.": 0.28, "Write a function that takes a nonnegative integer N as input and computes the binary representation of N.\n\nExample:\nInput: 5\nOutput: [1,0,1]": 0.26229508196721313, "Write a function that reverses a string. The input string is given as an array of characters s.": 0.25925925925925924, "Write a program to compute the sum of integers from k to n.": 0.2448979591836735, "Write a function that counts the occurrences of a substring within a string.": 0.2448979591836735, "Write a Python function to find all prime numbers up to the given number n.": 0.23529411764705882, "Write a function that finds the longest common prefix string amongst an array of strings.\n\nIf there is no common prefix, return an empty string \"\".": 0.22950819672131148}, "avg_similarity_score": 0.12638045064609715} +{"instruction": "Given a sorted linked list, delete all duplicates such that each element appear only once.", "input": "", "output": "Here's a straightforward solution to this problem:\n\n```js\n/**\n * Definition for singly-linked list.\n * function ListNode(val) {\n * this.val = val;\n * this.next = null;\n * }\n */\n/**\n * @param {ListNode} head\n * @return {ListNode}\n */\nvar deleteDuplicates = function(head) {\n if (head === null) {\n return null;\n }\n let cur = head;\n while (cur !== null) {\n while (cur.next !== null && cur.val === cur.next.val) {\n cur.next = cur.next.next;\n }\n cur = cur.next;\n }\n return head;\n};\n```\nIn the above program, we maintain a pointer cur pointing to the current node. Initially, cur points to the head of the linked list. While cur is not null, we repeatedly advance cur forward until we reach a node whose value differs from the next node. Once we reach such a node, we remove all subsequent duplicate nodes. Finally, we return the updated linked list.", "most_similar": {"Write a function that reverses a singly linked list. Do NOT use recursion!": 0.21428571428571427, "Write a function that takes a positive integer N as input and outputs a list of lists representing all the ways of partitioning N such that each sublist contains consecutive integers starting from 1.\n\nExample:\nInput: 5\nOutput: [[1],[2,3],[4,5]]": 0.2068965517241379, "Write a simple C++ program that prints \"Hello, World!\".": 0.16666666666666669, "Write a simple C# program that prints \"Hello, World!\".": 0.16666666666666669, "Given a positive integer N, write a function that computes the smallest number of coins needed to make change for N cents, if you have infinite supply of each of S = { S1, S2, .. , Sm} valued coins.": 0.1568627450980392, "Write a Python function to reverse a given list of integers.": 0.15384615384615383, "Write a python script that runs shellscript.sh every 60 minutes": 0.15384615384615383, "write a c++ program that calculates the perimeter of a square": 0.15384615384615383, "Given an array of integers `nums` and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order.": 0.1515151515151515, "Write a python function that sorts a list from large to small.": 0.14814814814814814}, "avg_similarity_score": 0.0803651770605334} +{"instruction": "Given a string, your task is to count how many palindromic substrings in this string.\n\nThe substrings with different start indexes or end indexes are counted as different substrings even they consist of same characters.\n\nExample 1:\nInput: \"abc\"\nOutput: 3\nExplanation: Three palindromic strings: \"a\", \"b\", \"c\".\n\nExample 2:\nInput: \"aaa\"\nOutput: 6\nExplanation: Six palindromic strings: \"a\", \"a\", \"a\", \"aa\", \"aa\", \"aaa\".\n\nNote:\nThe input string length won't exceed 1000.", "input": "", "output": "Here's a simple C++ program to accomplish this task:\n\n```cpp\nint countSubstrings(string s) {\n int n = s.size(), count = 0;\n bool t[n][n];\n memset(t, false, sizeof(t));\n for (int i = n - 1; i >= 0; --i) {\n for (int j = i; j < n; ++j) {\n if (s[i] == s[j] && (j - i < 3 || t[i + 1][j - 1])) {\n t[i][j] = true;\n ++count;\n }\n }\n }\n return count;\n}\n```\nIn the above program, we declare a 2d boolean matrix t of dimension n \u00d7 n. Each cell t[i][j] denotes whether the substring s[i..j] is a palindrome. We fill the cells row-wise. Specifically, we first fill the bottom-most row. Then, we go upwards filling the rest of the rows.\n\nOnce we have computed the table t, we scan across it to count the total number of palindromic substrings.", "most_similar": {"You are given a string s consisting of small English letters. Your task is to reverse the order of vowels in this string.\nA vowel is a letter 'a','o','u','e','i'.\nExample 1:\nInput: s = \"hello\"\nOutput: \"holle\"\nExample 2:\nInput: s = \"leetcode\"\nOutput: \"leotcede\"\nConstraints:\n1 <= s.length <= 3 * 10^5\ns consists of printable ASCII characters.": 0.2857142857142857, "Given a string s, remove duplicate letters so that every letter appears once and only once. You must make sure your result is the smallest in lexicographical order among all possible results.\n\nNote: This question is the same as 1081: https://leetcode.com/problems/smallest-subsequence-of-distinct-characters/\n\nExample 1:\nInput: s = \"bcabc\"\nOutput: \"abc\"\n\nExample 2:\nInput: s = \"cbacdcbc\"\nOutput: \"acdb\"": 0.27941176470588236, "Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitions of s.\n\nAn empty string is also considered valid.\n\nExample 1:\nInput: s = \"aab\"\nOutput: [[\"aa\",\"b\"],[\"a\",\"a\",\"b\"]]\n\nExample 2:\nInput: s = \"a\"\nOutput: [[\"a\"]]": 0.2644628099173554, "Given a string s, reverse the string according to the following rules:\nAll the characters that are not English letters remain in the same position.\nAll the English letters (lowercase or uppercase) should be reversed.\nReturn s after reversing it.\n\nExample 1:\nInput: s = \"ab-cd\"\nOutput: \"dc-ba\"\n\nExample 2:\nInput: s = \"a-bC-dEf-ghIj\"\nOutput: \"j-Ih-gfE-dCba\"\n\nExample 3:\nInput: s = \"Test1ng-Leet=code-Q!\"\nOutput: \"Qedo1ct-eeLg=ntse-T!\"": 0.22972972972972974, "Given a string s, determine whether it is a palindrome, considering only alphanumeric characters and ignoring cases.\n\nExample 1:\nInput: s = \"A man, a plan, a canal: Panama\"\nOutput: true\nExplanation: \"amanaplanacanalpanama\" is a palindrome.\n\nExample 2:\nInput: s = \"race a car\"\nOutput: false\nExplanation: \"raceacar\" is not a palindrome.\n\nExample 3:\nInput: s = \" \"\nOutput: true\nExplanation: s consists of only space characters.\nBecause whitespace characters are ignored, it is treated as an empty string \"\", which is a palindrome.\n\nExample 4:\nInput: s = \"-.\"\nOutput: true\nExplanation: \"-.\" is a palindrome.\n\nExample 5:\nInput: s = \"*#@&$%\"\nOutput: true\nExplanation: \"*#@&$%\" is a palindrome.\nAlthough we treat \"#\" differently from other symbols, it is still a palindrome.": 0.21739130434782608, "Given a string s consisting of small English letters, find and return the first instance of a non-repeating character in it. If there is no such character, return '_'.\n\nExamples:\n\nInput: s = \"abacabad\"\nOutput: \"b\"\nExplanation: The first non-repeating character is 'b'.\n\nInput: s = \"zabbaxxxxyyyyzzzyabcd\"\nOutput: \"_\"\nExplanation: There are no characters that appear exactly once.\n\nInput: s = \"abcdeeeefghiijklmnoppqqrrssstuvwxyz\"\nOutput: \"t\"\nExplanation: The first non-repeating character is 't'.\n\nInput: s = \"\"\nOutput: \"_\"\nExplanation: An empty string has no characters.": 0.19736842105263158, "You are given a binary tree in which each node contains an integer value. Find the largest value in each row of the tree.\n\nExample:\nInput:\n\n 1\n / \\\n 3 2\nOutput: [1, 3, 2]\nExplanation:\nRow 1: 1 is the largest integer in the row.\nRow 2: 3 is the largest integer in the row.\nRow 3: 2 is the largest integer in the row.": 0.17518248175182483, "Imagine you are building a compiler for a very basic programming language. Your job is to implement a parser for arithmetic expressions. An expression consists of digits, addition, multiplication, parenthesis, and negative signs. Expressions look something like this:\n\n```\n1+(2-(3*(-4)))\n```\n\nIn this example, the expression evaluates to 1+(2-(3*(-4))) = 1+(2-(-12)) = 1+(2+12) = 14.\n\nA sample input could be:\n\n```\n1+(2-(3*(-4)))\n```\n\nAnd a corresponding output could be:\n\n```\n14\n```\n\nIf the input does not represent a well-formed expression, throw an exception.": 0.1728395061728395, "Implement a function that accepts a string containing digits from 2-9 with various lengths. The function should replace every digit with the word equivalent of that digit (e.g., 2 becomes \u2018two\u2019, 3 becomes \u2018three\u2019, \u2026 , 9 becomes \u2018nine\u2019). There is no need to validate the contents of the input string.": 0.16129032258064516, "Write a function that takes a string s consisting of lowercase letters and brackets, and returns whether or not the brackets in the string are balanced.\n\nExample:\nInput: \"(())()\"\nOutput: True": 0.1553398058252427}, "avg_similarity_score": 0.08547671669770772} +{"instruction": "Given a string, find the longest palindromic contiguous substring. Substring of string s:\nS[i...j]\nLength of a substring: j \u2013 i + 1\nPalindrome string: Elements read the same backward as well as forward.\nLongest Palindromic Substring: Longest substring of a given string which is also a palindrome.\n\nExample 1:\nInput: \"banana\"\nOutput: \"anana\"\n\nExample 2:\nInput: \"abcdzdcab\"\nOutput: \"cdcaba\"", "input": "", "output": "Here's a simple C++ program to accomplish this task:\n\n```cpp\nstring longestPalindrome(string s) {\n int n = s.size();\n int start = 0, maxLen = 0;\n bool p[n][n];\n memset(p, false, sizeof(p));\n for (int i = n - 1; i >= 0; --i) {\n for (int j = i; j < n; ++j) {\n if (s[i] == s[j] && (j - i < 3 || p[i + 1][j - 1])) {\n p[i][j] = true;\n if (maxLen < j - i + 1) {\n start = i;\n maxLen = j - i + 1;\n }\n }\n }\n }\n return s.substr(start, maxLen);\n}\n```\nIn the above program, we declare a 2d boolean matrix p of dimension n \u00d7 n. Each cell p[i][j] denotes whether the substring s[i\u2026j] is a palindrome. We fill the cells row-wise. Specifically, we first fill the bottom-most row. Then, we go upwards filling the rest of the rows.\n\nOnce we have computed the table p, we scan across it to locate the longest palindromic substring.", "most_similar": {"Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitions of s.\n\nAn empty string is also considered valid.\n\nExample 1:\nInput: s = \"aab\"\nOutput: [[\"aa\",\"b\"],[\"a\",\"a\",\"b\"]]\n\nExample 2:\nInput: s = \"a\"\nOutput: [[\"a\"]]": 0.3703703703703704, "You are given a string s consisting of small English letters. Your task is to reverse the order of vowels in this string.\nA vowel is a letter 'a','o','u','e','i'.\nExample 1:\nInput: s = \"hello\"\nOutput: \"holle\"\nExample 2:\nInput: s = \"leetcode\"\nOutput: \"leotcede\"\nConstraints:\n1 <= s.length <= 3 * 10^5\ns consists of printable ASCII characters.": 0.3, "Given a string `s`, find the length of the longest substring without repeating characters.": 0.2702702702702703, "Given a string s, remove duplicate letters so that every letter appears once and only once. You must make sure your result is the smallest in lexicographical order among all possible results.\n\nNote: This question is the same as 1081: https://leetcode.com/problems/smallest-subsequence-of-distinct-characters/\n\nExample 1:\nInput: s = \"bcabc\"\nOutput: \"abc\"\n\nExample 2:\nInput: s = \"cbacdcbc\"\nOutput: \"acdb\"": 0.2601626016260163, "Given a string, your task is to count how many palindromic substrings in this string.\n\nThe substrings with different start indexes or end indexes are counted as different substrings even they consist of same characters.\n\nExample 1:\nInput: \"abc\"\nOutput: 3\nExplanation: Three palindromic strings: \"a\", \"b\", \"c\".\n\nExample 2:\nInput: \"aaa\"\nOutput: 6\nExplanation: Six palindromic strings: \"a\", \"a\", \"a\", \"aa\", \"aa\", \"aaa\".\n\nNote:\nThe input string length won't exceed 1000.": 0.24060150375939848, "Given a string s, reverse the string according to the following rules:\nAll the characters that are not English letters remain in the same position.\nAll the English letters (lowercase or uppercase) should be reversed.\nReturn s after reversing it.\n\nExample 1:\nInput: s = \"ab-cd\"\nOutput: \"dc-ba\"\n\nExample 2:\nInput: s = \"a-bC-dEf-ghIj\"\nOutput: \"j-Ih-gfE-dCba\"\n\nExample 3:\nInput: s = \"Test1ng-Leet=code-Q!\"\nOutput: \"Qedo1ct-eeLg=ntse-T!\"": 0.22222222222222224, "Given a string s, determine whether it is a palindrome, considering only alphanumeric characters and ignoring cases.\n\nExample 1:\nInput: s = \"A man, a plan, a canal: Panama\"\nOutput: true\nExplanation: \"amanaplanacanalpanama\" is a palindrome.\n\nExample 2:\nInput: s = \"race a car\"\nOutput: false\nExplanation: \"raceacar\" is not a palindrome.\n\nExample 3:\nInput: s = \" \"\nOutput: true\nExplanation: s consists of only space characters.\nBecause whitespace characters are ignored, it is treated as an empty string \"\", which is a palindrome.\n\nExample 4:\nInput: s = \"-.\"\nOutput: true\nExplanation: \"-.\" is a palindrome.\n\nExample 5:\nInput: s = \"*#@&$%\"\nOutput: true\nExplanation: \"*#@&$%\" is a palindrome.\nAlthough we treat \"#\" differently from other symbols, it is still a palindrome.": 0.2222222222222222, "Given a string s consisting of lowercase English letters, find the length of the longest substring without repeating characters. If there are multiple substrings with equal lengths, return the leftmost one.": 0.21978021978021975, "Write a function that takes a string s consisting of lowercase letters and brackets, and returns whether or not the brackets in the string are balanced.\n\nExample:\nInput: \"(())()\"\nOutput: True": 0.2, "Write a function that counts the occurrences of a substring within a string.": 0.1917808219178082}, "avg_similarity_score": 0.09271632773481962} +{"instruction": "Given a string, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.\n\nExample 1:\nInput: \"babad\"\nOutput: \"bab\"\nNote: \"aba\" is also a valid answer.\n\nExample 2:\nInput: \"cbbd\"\nOutput: \"bb\"", "input": "", "output": "Here's a simple C++ program to accomplish this task:\n\n```cpp\nstring longestPalindrome(string s) {\n int n = s.size();\n int start = 0, maxLen = 0;\n bool p[n][n];\n memset(p, false, sizeof(p));\n for (int i = n - 1; i >= 0; --i) {\n for (int j = i; j < n; ++j) {\n if (s[i] == s[j] && (j - i < 3 || p[i + 1][j - 1])) {\n p[i][j] = true;\n if (maxLen < j - i + 1) {\n start = i;\n maxLen = j - i + 1;\n }\n }\n }\n }\n return s.substr(start, maxLen);\n}\n```\nIn the above program, we declare a 2d boolean matrix p of dimension n \u00d7 n. Each cell p[i][j] denotes whether the substring s[i\u2026j] is a palindrome. We fill the cells row-wise. Specifically, we first fill the bottom-most row. Then, we go upwards filling the rest of the rows.\n\nOnce we have computed the table p, we scan across it to locate the longest palindromic substring.", "most_similar": {"Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitions of s.\n\nAn empty string is also considered valid.\n\nExample 1:\nInput: s = \"aab\"\nOutput: [[\"aa\",\"b\"],[\"a\",\"a\",\"b\"]]\n\nExample 2:\nInput: s = \"a\"\nOutput: [[\"a\"]]": 0.4090909090909091, "Given a string, find the longest palindromic contiguous substring. Substring of string s:\nS[i...j]\nLength of a substring: j \u2013 i + 1\nPalindrome string: Elements read the same backward as well as forward.\nLongest Palindromic Substring: Longest substring of a given string which is also a palindrome.\n\nExample 1:\nInput: \"banana\"\nOutput: \"anana\"\n\nExample 2:\nInput: \"abcdzdcab\"\nOutput: \"cdcaba\"": 0.4, "You are given a string s consisting of small English letters. Your task is to reverse the order of vowels in this string.\nA vowel is a letter 'a','o','u','e','i'.\nExample 1:\nInput: s = \"hello\"\nOutput: \"holle\"\nExample 2:\nInput: s = \"leetcode\"\nOutput: \"leotcede\"\nConstraints:\n1 <= s.length <= 3 * 10^5\ns consists of printable ASCII characters.": 0.3, "Given a string s, remove duplicate letters so that every letter appears once and only once. You must make sure your result is the smallest in lexicographical order among all possible results.\n\nNote: This question is the same as 1081: https://leetcode.com/problems/smallest-subsequence-of-distinct-characters/\n\nExample 1:\nInput: s = \"bcabc\"\nOutput: \"abc\"\n\nExample 2:\nInput: s = \"cbacdcbc\"\nOutput: \"acdb\"": 0.29126213592233, "Given a string, your task is to count how many palindromic substrings in this string.\n\nThe substrings with different start indexes or end indexes are counted as different substrings even they consist of same characters.\n\nExample 1:\nInput: \"abc\"\nOutput: 3\nExplanation: Three palindromic strings: \"a\", \"b\", \"c\".\n\nExample 2:\nInput: \"aaa\"\nOutput: 6\nExplanation: Six palindromic strings: \"a\", \"a\", \"a\", \"aa\", \"aa\", \"aaa\".\n\nNote:\nThe input string length won't exceed 1000.": 0.2831858407079646, "Write a function that checks if a given string is a palindrome. Assume that the maximum length of the string is 1000 characters. What techniques can you use to speed up the checking process?": 0.27027027027027023, "Given a string s, reverse the string according to the following rules:\nAll the characters that are not English letters remain in the same position.\nAll the English letters (lowercase or uppercase) should be reversed.\nReturn s after reversing it.\n\nExample 1:\nInput: s = \"ab-cd\"\nOutput: \"dc-ba\"\n\nExample 2:\nInput: s = \"a-bC-dEf-ghIj\"\nOutput: \"j-Ih-gfE-dCba\"\n\nExample 3:\nInput: s = \"Test1ng-Leet=code-Q!\"\nOutput: \"Qedo1ct-eeLg=ntse-T!\"": 0.26086956521739135, "Given a string `s`, find the length of the longest substring without repeating characters.": 0.25925925925925924, "Given a string s consisting of small English letters, find and return the first instance of a non-repeating character in it. If there is no such character, return '_'.\n\nExamples:\n\nInput: s = \"abacabad\"\nOutput: \"b\"\nExplanation: The first non-repeating character is 'b'.\n\nInput: s = \"zabbaxxxxyyyyzzzyabcd\"\nOutput: \"_\"\nExplanation: There are no characters that appear exactly once.\n\nInput: s = \"abcdeeeefghiijklmnoppqqrrssstuvwxyz\"\nOutput: \"t\"\nExplanation: The first non-repeating character is 't'.\n\nInput: s = \"\"\nOutput: \"_\"\nExplanation: An empty string has no characters.": 0.23529411764705885, "Write a function that takes a string s consisting of lowercase letters and brackets, and returns whether or not the brackets in the string are balanced.\n\nExample:\nInput: \"(())()\"\nOutput: True": 0.2285714285714286}, "avg_similarity_score": 0.12206988086643582} diff --git a/data/code_tasks.jsonl b/data/code_tasks.jsonl index 62fe141..16d47be 100644 --- a/data/code_tasks.jsonl +++ b/data/code_tasks.jsonl @@ -27,55 +27,55 @@ {"id": "seed_task_26", "name": "python_reverse_list", "instruction": "Write a Python function to reverse a given list of integers.", "instances": [{"input": "", "output": "def reverse_list(numbers):\n return numbers[::-1]"}], "is_classification": false} {"id": "seed_task_27", "name": "html_basic_structure", "instruction": "Write a basic HTML structure with a title \"My First Web Page\".", "instances": [{"input": "", "output": "\n\n\n \n \n My First Web Page\n \n\n\n\n"}], "is_classification": false} {"id": "seed_task_28", "name": "c_plus_plus_hello_world", "instruction": "Write a simple C++ program that prints \"Hello, World!\".", "instances": [{"input": "", "output": "#include \n\nint main() {\n std::cout << \"Hello, World!\" << std::endl;\n return 0;\n}"}], "is_classification": false} -{"id": "seed_task_29", "name": "python_summation", "instruction": "Write a Python function that takes two numbers as input and returns their sum.", "instances": [{"input": "5, 7", "output": "def add_numbers(a, b):\n return a + b\n\nresult = add_numbers(5, 7)\nprint(result)"}], "is_classification": false} -{"id": "seed_task_30", "name": "java_loop_array", "instruction": "Create a JavaScript function that takes an array of numbers and returns the product of all elements.", "instances": [{"input": "[2, 3, 4]", "output": "function multiplyArrayElements(arr) {\n let product = 1;\n for (const num of arr) {\n product *= num;\n }\n return product;\n}\n\nconst result = multiplyArrayElements([2, 3, 4]);\nconsole.log(result);"}], "is_classification": false} +{"id": "seed_task_29", "name": "python_summation", "instruction": "Write a Python function `add_number`that takes two numbers as input and returns their sum.", "instances": [{"input": "5, 7", "output": "def add_numbers(a, b):\n return a + b\n\nresult = add_numbers(5, 7)\nprint(result)"}], "is_classification": false} +{"id": "seed_task_30", "name": "java_loop_array", "instruction": "Create a JavaScript function `multiplyArrayElements` that takes an array of numbers and returns the product of all elements.", "instances": [{"input": "[2, 3, 4]", "output": "function multiplyArrayElements(arr) {\n let product = 1;\n for (const num of arr) {\n product *= num;\n }\n return product;\n}\n\nconst result = multiplyArrayElements([2, 3, 4]);\nconsole.log(result);"}], "is_classification": false} {"id": "seed_task_31", "name": "shell_total_lines_in_txt_file", "instruction": "Can you provide a shell script that displays the total number of lines in all '*.txt' files in the current directory?", "instances": [{"input": "\"file1.txt:\\nHello\\nWorld\\n\\nfile2.txt:\\nAnother\\nExample\"", "output": "#!/bin/sh\n\ntotal_lines=0\n\nfor file in *.txt; do\n lines=$(wc -l < \"$file\")\n total_lines=$((total_lines + lines))\ndone\n\necho \"Total lines: $total_lines\""}], "is_classification": false} -{"id": "seed_task_32", "name": "java_reverse_string_no_builtin", "instruction": "Implement a Java method to reverse a string without using any built-in functions.", "instances": [{"input": "\"Hello, World!\"", "output": "public class StringReversal {\n public static String reverseString(String input) {\n char[] charArray = input.toCharArray();\n int left = 0;\n int right = charArray.length - 1;\n\n while (left < right) {\n char temp = charArray[left];\n charArray[left] = charArray[right];\n charArray[right] = temp;\n\n left++;\n right--;\n }\n return new String(charArray);\n }\n\n public static void main(String[] args) {\n String str = \"Hello, World!\";\n System.out.println(\"Reversed string: \" + reverseString(str));\n }\n}"}], "is_classification": false} +{"id": "seed_task_32", "name": "java_reverse_string_no_builtin", "instruction": "Implement a Java method `reverseString` to reverse a string without using any built-in functions.", "instances": [{"input": "\"Hello, World!\"", "output": "public class StringReversal {\n public static String reverseString(String input) {\n char[] charArray = input.toCharArray();\n int left = 0;\n int right = charArray.length - 1;\n\n while (left < right) {\n char temp = charArray[left];\n charArray[left] = charArray[right];\n charArray[right] = temp;\n\n left++;\n right--;\n }\n return new String(charArray);\n }\n\n public static void main(String[] args) {\n String str = \"Hello, World!\";\n System.out.println(\"Reversed string: \" + reverseString(str));\n }\n}"}], "is_classification": false} {"id": "seed_task_33", "name": "translate_python_java", "instruction": "Translate the following code from python in Java.", "instances": [{"input" : "def function(a : int, b : int, c : int):\n if a > b :\n print('You lost.')\n else :\n if c > a :\n print('Nice try.')\n else :\n print('You won.')", "output" : "public static void function(int a, int b, int c) {\n if (a > b) {\n System.out.println('You lost.');\n } else {\n if (c > a) {\n System.out.println('Nice try.');\n } else {\n System.out.println('You won.');\n }\n }\n}"}], "is_classification": false} {"id": "seed_task_34", "name": "python_leetcode_twosum", "instruction": "Given an array of integers `nums` and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order.", "instances": [{"input" : "", "output" : "class Solution:\n def twoSum(self, nums: List[int], target: int) -> List[int]:\n hashmap = {}\n for i in range(len(nums)):\n complement = target - nums[i]\n if complement in hashmap:\n return [i, hashmap[complement]]\n hashmap[nums[i]] = i"}], "is_classification": false} -{"id": "seed_task_35", "name": "python_leetcode_longest_substring_without_repeating_characters", "instruction": "Given a string `s`, find the length of the longest substring without repeating characters.", "instances": [{"input" : "", "output" : "class Solution:\n def lengthOfLongestSubstring(self, s: str) -> int:\n n = len(s)\n ans = 0\n # mp stores the current index of a character\n mp = {}\n\n i = 0\n # try to extend the range [i, j]\n for j in range(n):\n if s[j] in mp:\n i = max(mp[s[j]], i)\n\n ans = max(ans, j - i + 1)\n mp[s[j]] = j + 1\n\n return ans"}], "is_classification": false} +{"id": "seed_task_35", "name": "python_leetcode_longest_substring_without_repeating_characters", "instruction": "Write a python function `lengthOfLongestSubstring` such that, given a string `s`, finds the length of its longest substring without repeating characters.", "instances": [{"input" : "", "output" : "class Solution:\n def lengthOfLongestSubstring(self, s: str) -> int:\n n = len(s)\n ans = 0\n # mp stores the current index of a character\n mp = {}\n\n i = 0\n # try to extend the range [i, j]\n for j in range(n):\n if s[j] in mp:\n i = max(mp[s[j]], i)\n\n ans = max(ans, j - i + 1)\n mp[s[j]] = j + 1\n\n return ans"}], "is_classification": false} {"id": "seed_task_36", "name": "python_leetcode_maximum_subarray", "instruction": "Given an integer array nums, find the subarray with the largest sum, and return its sum.", "instances": [{"input" : "", "output" : "class Solution:\n def maxSubArray(self, nums: List[int]) -> int:\n N = len(nums)\n maxSum = float('-inf')\n maxSumEndi = float('-inf')\n for i in range(N):\n maxSumEndi = max(nums[i], maxSumEndi+nums[i])\n maxSum = max(maxSum, maxSumEndi)\n return maxSum"}], "is_classification" : false} {"id": "seed_task_37", "name": "python_leetcode_best_time_to_buy_and_sell_stocks", "instruction": "Write a script to output 'Hello World' in python", "instances": [{"input" : "You are given an array `prices` where `prices[i]` is the price of a given stock on the i^th day. You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. Return the maximum profit you can achieve from this transaction. If you cannot achieve any profit, return 0.", "output" : "class Solution:\n def maxProfit(self, prices: List[int]) -> int:\n min_price = float('inf')\n max_profit = 0\n for i in range(len(prices)):\n if prices[i] < min_price:\n min_price = prices[i]\n elif prices[i] - min_price > max_profit:\n max_profit = prices[i] - min_price\n \n return max_profit"}], "is_classification": false} {"id": "seed_task_38", "name": "python_leetcode_binary_tree_inorder_traversal", "instruction": "Given the `root` of a binary tree, return the inorder traversal of its nodes' values.", "instances": [{"input" : "# Definition for a binary tree node.\nclass TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right", "output" : "class Solution:\n def inorderTraversal(self, root: Optional[TreeNode]) -> List[int]:\n return self.inorderTraversal(root.left) + [root.val] + self.inorderTraversal(root.right) if root else []"}], "is_classification" : false} {"id": "seed_task_39", "name": "python_leetcode_fibonacci_numbers", "instruction": "The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. That is,\n\nF(0) = 0, F(1) = 1\nF(n) = F(n - 1) + F(n - 2), for n > 1.\nGiven n, calculate F(n)", "instances": [{"input" : "", "output" : "class Solution:\n def fib(self, n: int) -> int:\n if n == 0 :\n return 0\n elif n == 1 :\n return 1\n else :\n a = 0\n b = 1\n for i in range(1, n):\n a, b = b, a+b\n return b"}], "is_classification" : false} {"id": "seed_task_40", "name": "python_mean", "instruction": "Write a script to output the mean of a list of integers.", "instances": [{"input" : "", "output" : "def mean(arr):\n if len(arr) == 0 :\n return None\n else :\n return sum(arr)/len(arr)"}], "is_classification" : false} -{"id": "seed_task_41", "name": "oasst_0", "instruction": "How do I compile a go program on Linux to a windows executable?", "instances": [{"input": "", "output": "You can easily cross-compile code written in Go for Windows, macOS, and Linux by using the ```GOARCH``` and ```GOOS``` environmental variables, which represent the compilation architecture and the name of the target operating system respectively. They are set to your host compilation architecture (```GOHOSTARCH```) and operating system (```GOHOSTOS```) by default. You need to modify these values in order to compile for Windows instead of Linux. Here\u2019s the command you need to run to compile your Go project for a 64-bit Windows machine: ``` $ GOOS=windows GOARCH=amd64 go build -o bin/app-amd64.exe app.go ``` In this scenario, ```GOOS``` is windows, and ```GOARCH``` is amd64 indicating a 64-bit architecture. The ```go build -o bin/app-amd64.exe app.go``` command compiles app.go into a .exe compatable with 64-bit versions of Windows. If you need to support a 32-bit architecture, all you need to do is change ```GOARCH``` to 386. ``` $ GOOS=windows GOARCH=386 go build -o bin/app-386.exe app.go ``` After you've compiled your Go program for Windows, it's a good idea to change these values back so you can compile for Linux again. ``` # 64-bit $ GOOS=linux GOARCH=amd64 go build -o bin/app-amd64-linux app.go # 32-bit $ GOOS=linux GOARCH=386 go build -o bin/app-386-linux app.go ``` I hope I answered your question, let me know if I can help you with anything else!"}], "is_classification": false} -{"id": "seed_task_42", "name": "oasst_1", "instruction": "Write Python code to generate N Tribonacci numbers", "instances": [{"input": "", "output": "```python def tribonacci(n): if n == 0 or n == 1: return 0 if n == 2: return 1 return tribonacci(n-1) + tribonacci(n-2) + tribonacci(n-3) ```"}], "is_classification": false} -{"id": "seed_task_43", "name": "oasst_2", "instruction": "Find the bug in the following code piece: a = 1 while a == 1: b = input(\"what's your name ?\") print(\"Hi \",b, \" this is infinity loop !\")", "instances": [{"input": "", "output": "Sure! It looks like the while loop will never conclude because `a` is always set to 1. Perhaps you meant to check the value of `b` to determine if the user had entered their name correctly? Additionally the print statement will never execute because of the infinity loop above."}], "is_classification": false} -{"id": "seed_task_44", "name": "oasst_3", "instruction": "Please write a Rust function that takes a u64 input and returns the largest prime number less than that value.", "instances": [{"input": "", "output": "Here is an example implementation of the function: ``` rustCopy codefn largest_prime_less_than(x: u64) -> u64 { if x <= 2 { return 0; } let mut n = x - 1; while n > 1 { if is_prime(n) { return n; } n -= 1; } 0 } fn is_prime(x: u64) -> bool { if x <= 1 { return false; } for i in 2..=(x as f64).sqrt() as u64 + 1 { if x % i == 0 { return false; } } true } ``` This implementation first checks if the input `x` is less than or equal to 2, in which case it returns 0 since there are no prime numbers less than 2. Then, it starts from `x - 1` and decrements `n` until it finds the largest prime number less than `x`, which it returns. The helper function `is_prime` checks if a given number is prime or not by iterating over all the numbers up to the square root of the number and checking if the number is evenly divisible by any of them. If the number is not divisible by any of them, it is considered to be a prime number."}], "is_classification": false} -{"id": "seed_task_45", "name": "oasst_4", "instruction": "I have 2 EC2 machines on AWS, I'm having trouble making them communicate. How could I troubleshoot it?", "instances": [{"input": "", "output": "There are several possible causes for EC2 machines not communicating on AWS. I would suggest the following steps to get you started on fixing the issue: 1. Check the security group rules and network ACLs for your instances. 2. Verify that your instances have public IP addresses or Elastic IP addresses if you are connecting over the internet. 3. Ensure that your instances have the correct route tables, internet gateways, and NAT devices configured. 4. Test the network connectivity using ping, traceroute, or telnet commands."}], "is_classification": false} -{"id": "seed_task_46", "name": "oasst_5", "instruction": "Write a python code to implement quick sort", "instances": [{"input": "", "output": "Sure, here's an example implementation of quick sort in Python: ``` def quick_sort(arr): if len(arr) <= 1: return arr else: pivot = arr[0] left = [] right = [] for i in range(1, len(arr)): if arr[i] < pivot: left.append(arr[i]) else: right.append(arr[i]) return quick_sort(left) + [pivot] + quick_sort(right) ``` This implementation uses the first element of the array as the pivot, and then partitions the array into two sub-arrays based on whether their elements are less than or greater than the pivot. It then recursively applies the same process to each sub-array and concatenates the results. To use this implementation, you can simply call the quick_sort() function and pass in the array you want to sort as an argument, like this: ``` arr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5] sorted_arr = quick_sort(arr) print(sorted_arr) # Output: [1, 1, 2, 3, 3, 4, 5, 5, 5, 6, 9] ``` I hope this helps!"}], "is_classification": false} -{"id": "seed_task_47", "name": "oasst_6", "instruction": "Break down this C++ code and explain what it does: ``` #include \"Graphics.h\" #include \"Texture.h\" #include \"Camera.h\" #define SET_COLOR() SDL_SetRenderDrawColor(handle, color.r, color.g, color.b, color.a) #define CAM Camera::getActive() #define CAM_POS CAM->position void Graphics::drawLine(const Vec2 &from, const Vec2 &to, const Color &color) { SET_COLOR(); Vec2 f = from - CAM_POS; SDL_RenderDrawLineF(handle, f.x, f.y, to.x, to.y); } void Graphics::drawLine(const Vec2 &origin, const Vec2 &direction, const Vec2 &length, const Color &color) { drawLine(origin, origin + direction * length, color); } void Graphics::drawPoint(const Vec2 &position, const Color &color) { SET_COLOR(); Vec2 p = position - CAM_POS; SDL_RenderDrawPointF(handle, position.x, position.y); } void Graphics::drawRect(const Rect &rect, const Color &color) { SET_COLOR(); SDL_FRect r = rect; r.x -= CAM_POS.x; r.y -= CAM_POS.y; SDL_RenderDrawRectF(handle, &r); } void Graphics::fillRect(const Rect &rect, const Color &color) { SET_COLOR(); SDL_FRect r = rect; r.x -= CAM_POS.x; r.y -= CAM_POS.y; SDL_RenderFillRectF(handle, &r); } ```", "instances": [{"input": "", "output": "This code is a part of a C++ program that uses the SDL (Simple DirectMedia Layer) library for graphics rendering. It defines several functions for drawing basic shapes (lines, points, and rectangles) onto the screen. Here is a detailed explanation of each function: drawLine: This function draws a line between two points on the screen, specified by the from and to arguments. The color of the line is specified by the color argument. The line is drawn with respect to the active camera, as defined by the CAM macro. The macro SET_COLOR sets the color for the line. drawLine (overloaded function): This function is an overloaded version of drawLine, which allows you to specify the direction and length of the line. The origin of the line is specified by the origin argument, the direction is specified by the direction argument, and the length is specified by the length argument. The color of the line is specified by the color argument. drawPoint: This function draws a single point on the screen, specified by the position argument. The color of the point is specified by the color argument. The point is drawn with respect to the active camera, as defined by the CAM macro. drawRect: This function draws an empty rectangle on the screen, specified by the rect argument. The color of the rectangle is specified by the color argument. The rectangle is drawn with respect to the active camera, as defined by the CAM macro. fillRect: This function draws a filled rectangle on the screen, specified by the rect argument. The color of the rectangle is specified by the color argument. The rectangle is drawn with respect to the active camera, as defined by the CAM macro."}], "is_classification": false} -{"id": "seed_task_48", "name": "oasst_7", "instruction": "Hey! In php, when I use `ini_set('memory_limit','6GB');`, it gives blank page? Why is that?", "instances": [{"input": "", "output": "A blank page in PHP usually indicates a fatal error that stops the script from executing further. When you set the memory limit to '6GB' using ini_set('memory_limit', '6GB'); and encounter a blank page, it could be due to one of the following reasons: 1. Insufficient system memory: If your system does not have enough available memory to allocate 6GB to the PHP script, it may cause a fatal error. 1. PHP configuration: Some server configurations may restrict the maximum memory limit that can be set for a PHP script. Check your PHP configuration file (php.ini) to see if there's a hard limit set for the memory_limit directive. 1. Error reporting/display settings: PHP may be suppressing error messages or not displaying them on the page. You can enable error reporting and display to get more information about the issue. Add the following lines to the beginning of your PHP script: ```php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); ``` After adding these lines, run your script again and see if any error messages are displayed. 1. Web server timeout: If your PHP script takes too long to execute, the web server may time out, causing the script to stop running and returning a blank page. Check your web server's timeout settings and adjust them if needed. To resolve the issue, you can try: - Reducing the memory limit to a lower value, e.g., '512M', '1G', or '2G', and see if the script runs without issues. - Checking your server's available memory and ensuring it can accommodate the desired memory limit. - Reviewing your PHP and web server configurations for any restrictions or timeout settings that might be causing the problem. If none of these suggestions resolve the issue, consider checking the server logs for any errors or clues about what may be causing the blank page."}], "is_classification": false} -{"id": "seed_task_49", "name": "oasst_8", "instruction": "Write python code to connect to a FTP server.", "instances": [{"input": "", "output": "To connect to an FTP server in Python, you can use the built-in ftplib module. Here is an example function that connects to an FTP server: ``` import ftplib def ftp_connect(host, username, password): ftp = ftplib.FTP(host) ftp.login(username, password) return ftp ``` In this function, host is the hostname or IP address of the FTP server, username and password are the login credentials for the FTP server. The ftp.login() method is used to authenticate the user with the FTP server. The function returns the FTP object, which can be used to perform operations on the FTP server, such as uploading or downloading files. Here's an example of how to use this function to connect to an FTP server: ``` ftp = ftp_connect('ftp.example.com', 'username', 'password') print(ftp.getwelcome()) # prints the welcome message from the FTP server ftp.quit() # disconnects from the FTP server ``` In this example, ftp.example.com is the hostname of the FTP server, and username and password are the login credentials. The ftp.getwelcome() method is used to print the welcome message from the FTP server. The ftp.quit() method is used to disconnect from the FTP server."}], "is_classification": false} -{"id": "seed_task_50", "name": "oasst_9", "instruction": "How do I get the power of a number in python?", "instances": [{"input": "", "output": "The pow() function returns the value of x to the power of y in python. The syntax for the pow() looks like this: ``` a = 4 # a is the base number. b = 3 # b is the exponent, or the power that a would be raised to. c = 5 # c is an optional parameter for the pow() function. c here is the modulus. x = pow(a,b,c) # This is the same as (4 * 4 * 4) % 5 # Remember, the third parameter, ie. c here is optional. Hence, pow() can also be written as following: y = pow(4,3) # This is the same as 4 * 4 * 4. print(x) # The output would be 12. print(y) # The output would be 64. ```"}], "is_classification": false} -{"id": "seed_task_51", "name": "oasst_10", "instruction": "I have the following python function: ```python def resize_images(images, res_x, res_y): resized_images = np.zeros((images.shape[0], res_x, res_y)) for n in range(len(images)): resized_images[n, :, :] = resize(images[n, :, :], resized_images.shape[1:], anti_aliasing=False) return resized_images ``` What does the function do?", "instances": [{"input": "", "output": "Hmm, let me see. I think the function is used for Image Resizing. It takes in an array of `images`, two integers related to resolution one is the x-axis: `res_x` and a second one on the y-axis: `res_y` as inputs. The function then loops through each image in the array and uses the resizing function (resize) from the Python library Scikit-image to resize the images to the specified resolution. Finally, the function returns an array of resized images. Here is an in-depth look: ```python #It takes in a numpy array of images and two integers `res_x` and `res_y` as inputs and then returns a numpy array of resized images. def resize_images(images, res_x, res_y): # It creates a numpy array resized_images with dimensions (images.shape[0], res_x, res_y) filled with zeros, where images.shape[0] represents the number of images in the input array. resized_images = np.zeros((images.shape[0], res_x, res_y)) #It iterates over the length of the input images and for each image, it uses the resize function from the scikit-image library to resize the image to the specified `res_x` and `res_y` resolution, with the anti_aliasing boolean argument set to False. meaning that the resizing process will not apply anti-aliasing to the images. for n in range(len(images)): resized_images[n, :, :] = resize(images[n, :, :], resized_images.shape[1:], anti_aliasing=False) # Finally, the resized_images array is returned. return resized_images ```"}], "is_classification": false} -{"id": "seed_task_52", "name": "oasst_11", "instruction": "How can I iterate through each item in an array in a random order using c++?", "instances": [{"input": "", "output": "I am assuming you only want to access each element once and don't want to modify the original array. To do this you could start by making a new array of random indexes then using those indexes when accessing the array. This method has the advantage of not changing the original array. For example say you have an array of numbers **[6,8,13]** and you want to access this in random order. This array has a length 3 so you would create a new index array of this size with each possible index **[0,1,2]**. Then you shuffle this array using the **std::random_shuffle** function to obtain an array like **[1,2,0]**. Then when you iterate through your loop and access an element, you get the index from the index_array (which is in random order) to access your original array. This could look **my_array[index_array[i]]**. Here is an example full program ``` #include #include #include #include int main(){ std::srand( unsigned (std::time(0)));//set seed const int size_of_array = 3;//array length int my_array[size_of_array] = {6,8,13};//data int index_array[size_of_array];//index array int i; for(i = 0;i < size_of_array;i++) index_array[i] = i;//initialize indexes std::random_shuffle(index_array,index_array+size_of_array);//shuffle indexes for(i = 0;i < size_of_array;i++){//access in random order int random_index = index_array[i]; std::cout << my_array[random_index] << std::endl; } } ```"}], "is_classification": false} -{"id": "seed_task_53", "name": "oasst_12", "instruction": "How do I incorporate CSS in my HTML page?", "instances": [{"input": "", "output": "There are multiple ways to add CSS to HTML. \u2013 Inline \u2013 Internal \u2013 External The most common method is to use an second *.css file, that is linked to your *.html file, also known as external CSS. To implement this, create a file called \u201cstyle.css\u201d in the same directory as your *.html file. Add this code to your *.html file to link the style sheet with your document. After linking these files, changes made in the style.css file should affect your HTML content. If you have further questions on how to create, inline/internal CSS or want to know some tips and tricks on how to write CSS. Don\u2019t hesitate to ask."}], "is_classification": false} -{"id": "seed_task_54", "name": "oasst_13", "instruction": "bubble sort list of int in python", "instances": [{"input": "", "output": "This is code to bubble sort a list of integers in python: ``` def bubbleSort(arr): n = len(arr) # Traverse through all elements in the array for i in range(n): # Last i elements are already in place for j in range(0, n-i-1): # Swap if the element found is greater than the next element if arr[j] > arr[j+1]: arr[j], arr[j+1] = arr[j+1], arr[j] return arr # Test the implementation with a sample list of integers arr = [64, 34, 25, 12, 22, 11, 90] print(\"Sorted array is:\", bubbleSort(arr)) ```"}], "is_classification": false} -{"id": "seed_task_55", "name": "oasst_14", "instruction": "Write a Python program that takes a list of numbers as input from the user, calculates the sum of all even numbers in the list, and returns the result. The program should check if the input is valid (i.e., if it's a list of numbers), and if it's not, it should return an error message. The program should also handle exceptions gracefully and return a user-friendly error message in case of any exceptions.", "instances": [{"input": "", "output": "Here's a python program that uses the third-party docopt library to sum all the even numbers the user enters in a command line: ``` python \"\"\"Sum Even. Usage: sum_even ... \"\"\" from docopt import docopt def sum_even(numbers): \"\"\"Sum all the even numbers in a list.\"\"\" assert isinstance(numbers, list), \"numbers must be a list\" total = 0 for n in numbers: try: n_flt = float(n) if n_flt % 2 == 0: total += int(n_flt) # it's an int if it's even, and python ints can be much larger than floats except ValueError: return f\"{n} is not a number\" return total if __name__ == \"__main__\": arguments = docopt(__doc__, version='Sum All v1.0') numbers = arguments[''] try: print(sum_even(numbers)) except Exception as e: print(f\"Could not sum all even numbers:\n {e}\") ``` Docopt can be installed with: ``` pip install docopt ``` The program can then be run with: ``` python sum_even.py 1 2 3 4.0 4.1 1e3 ``` However, it doesn't have any specific code for handling inf or nan, which float would convert. It instead just skips those because they don't result in 0 after the %2. It also requires a call to python instead of just calling sum_even. It's possible to make it its own command line argument by making the right setup file and pip installing it."}], "is_classification": false} -{"id": "seed_task_56", "name": "oasst_15", "instruction": "xpath to get a span node that contains the text \" Estimate \". HTML Estimate 25 - 35 EUR ", "instances": [{"input": "", "output": "Here's an example of an XPath expression to select the span node that contains the text \"Estimate\": //span[normalize-space(text())=\"Estimate\"] This selects any \"span\" element that has normalized text content of \"Estimate\"."}], "is_classification": false} -{"id": "seed_task_57", "name": "oasst_16", "instruction": "write a sum function in asm", "instances": [{"input": "", "output": "Certainly! Here's an example of a sum function in x86 assembly language: ```asm section .text global sum sum: push ebp mov ebp, esp mov eax, [ebp+8] ; eax = first parameter mov ebx, [ebp+12] ; ebx = second parameter add eax, ebx ; eax = eax + ebx pop ebp ret ``` This function takes two parameters (the values to be added) and returns their sum. It uses the add instruction to perform the addition and then returns the result using the ret instruction. I hope this helps! Let me know if you have any further questions."}], "is_classification": false} -{"id": "seed_task_58", "name": "oasst_17", "instruction": "Python code for a rotating square", "instances": [{"input": "", "output": "Here's an example of Python code using the Pygame library to draw a rotating square: ```python import pygame import math # Initialize Pygame pygame.init() # Set the screen size screen_width = 640 screen_height = 480 screen = pygame.display.set_mode((screen_width, screen_height)) # Define the colors white = (255, 255, 255) red = (255, 0, 0) # Define the square square_width = 50 square_height = 50 square = pygame.Rect(screen_width/2 - square_width/2, screen_height/2 - square_height/2, square_width, square_height) # Set the rotation angle angle = 0 # Define the main game loop running = True while running: # Handle events for event in pygame.event.get(): if event.type == pygame.QUIT: running = False # Rotate the square angle += 1 rotated_square = pygame.transform.rotate(pygame.Surface((square_width, square_height)), angle) # Clear the screen screen.fill(white) # Draw the square screen.blit(rotated_square, square) # Update the screen pygame.display.flip() # Quit Pygame pygame.quit() ``` This code sets up a Pygame window with a square in the center that rotates around its center point. The rotation angle is increased by 1 on each loop of the main game loop. The square is rotated using the pygame.transform.rotate() function, and the rotated square is drawn on the screen using the pygame.Surface.blit() function. The screen is then updated using the pygame.display.flip() function. The program will continue to run until the user closes the window."}], "is_classification": false} -{"id": "seed_task_59", "name": "oasst_18", "instruction": "How do I output a string in C++ programming?", "instances": [{"input": "", "output": "You can output strings in many ways one of the simplest methods is : ```cout << string```"}], "is_classification": false} +{"id": "seed_task_41", "name": "oasst_0", "instruction": "How do I compile a go program on Linux to a windows executable?", "instances": [{"input": "", "output": "You can easily cross-compile code written in Go for Windows, macOS, and Linux by using the ```GOARCH``` and ```GOOS``` environmental variables, which represent the compilation architecture and the name of the target operating system respectively. They are set to your host compilation architecture (```GOHOSTARCH```) and operating system (```GOHOSTOS```) by default. You need to modify these values in order to compile for Windows instead of Linux.\n\nHere\u2019s the command you need to run to compile your Go project for a 64-bit Windows machine:\n```\n$ GOOS=windows GOARCH=amd64 go build -o bin/app-amd64.exe app.go\n```\nIn this scenario, ```GOOS``` is windows, and ```GOARCH``` is amd64 indicating a 64-bit architecture. The ```go build -o bin/app-amd64.exe app.go``` command compiles app.go into a .exe compatable with 64-bit versions of Windows. If you need to support a 32-bit architecture, all you need to do is change ```GOARCH``` to 386.\n```\n$ GOOS=windows GOARCH=386 go build -o bin/app-386.exe app.go\n```\nAfter you've compiled your Go program for Windows, it's a good idea to change these values back so you can compile for Linux again.\n```\n# 64-bit\n$ GOOS=linux GOARCH=amd64 go build -o bin/app-amd64-linux app.go\n\n# 32-bit\n$ GOOS=linux GOARCH=386 go build -o bin/app-386-linux app.go\n```\nI hope I answered your question, let me know if I can help you with anything else!"}], "is_classification": false} +{"id": "seed_task_42", "name": "oasst_1", "instruction": "Write Python code to generate N Tribonacci numbers", "instances": [{"input": "", "output": "```python\ndef tribonacci(n):\n if n == 0 or n == 1:\n return 0\n if n == 2:\n return 1\n return tribonacci(n-1) + tribonacci(n-2) + tribonacci(n-3)\n```"}], "is_classification": false} +{"id": "seed_task_43", "name": "oasst_2", "instruction": "Find the bug in the following code piece:\n\na = 1\nwhile a == 1:\n b = input(\"what's your name ?\")\nprint(\"Hi \",b, \" this is infinity loop !\")", "instances": [{"input": "", "output": "Sure! It looks like the while loop will never conclude because `a` is always set to 1. Perhaps you meant to check the value of `b` to determine if the user had entered their name correctly?\n\nAdditionally the print statement will never execute because of the infinity loop above."}], "is_classification": false} +{"id": "seed_task_44", "name": "oasst_3", "instruction": "Please write a Rust function `largest_prime_less_than` that takes a u64 input and returns the largest prime number less than that value.", "instances": [{"input": "", "output": "Here is an example implementation of the function:\n\n```\nrustCopy codefn largest_prime_less_than(x: u64) -> u64 {\n if x <= 2 {\n return 0;\n }\n let mut n = x - 1;\n while n > 1 {\n if is_prime(n) {\n return n;\n }\n n -= 1;\n }\n 0\n}\n\nfn is_prime(x: u64) -> bool {\n if x <= 1 {\n return false;\n }\n for i in 2..=(x as f64).sqrt() as u64 + 1 {\n if x % i == 0 {\n return false;\n }\n }\n true\n}\n\n```\n\nThis implementation first checks if the input `x` is less than or equal to 2, in which case it returns 0 since there are no prime numbers less than 2. Then, it starts from `x - 1` and decrements `n` until it finds the largest prime number less than `x`, which it returns. The helper function `is_prime` checks if a given number is prime or not by iterating over all the numbers up to the square root of the number and checking if the number is evenly divisible by any of them. If the number is not divisible by any of them, it is considered to be a prime number."}], "is_classification": false} +{"id": "seed_task_45", "name": "oasst_4", "instruction": "I have 2 EC2 machines on AWS, I'm having trouble making them communicate. How could I troubleshoot it?", "instances": [{"input": "", "output": "There are several possible causes for EC2 machines not communicating on AWS. I would suggest the following steps to get you started on fixing the issue:\n\n1. Check the security group rules and network ACLs for your instances.\n2. Verify that your instances have public IP addresses or Elastic IP addresses if you are connecting over the internet.\n3. Ensure that your instances have the correct route tables, internet gateways, and NAT devices configured.\n4. Test the network connectivity using ping, traceroute, or telnet commands."}], "is_classification": false} +{"id": "seed_task_46", "name": "oasst_5", "instruction": "Write a python code to implement quick sort", "instances": [{"input": "", "output": "Sure, here's an example implementation of quick sort in Python:\n\n``` \ndef quick_sort(arr):\n if len(arr) <= 1:\n return arr\n else:\n pivot = arr[0]\n left = []\n right = []\n for i in range(1, len(arr)):\n if arr[i] < pivot:\n left.append(arr[i])\n else:\n right.append(arr[i])\n return quick_sort(left) + [pivot] + quick_sort(right)\n``` \nThis implementation uses the first element of the array as the pivot, and then partitions the array into two sub-arrays based on whether their elements are less than or greater than the pivot. It then recursively applies the same process to each sub-array and concatenates the results.\n\nTo use this implementation, you can simply call the quick_sort() function and pass in the array you want to sort as an argument, like this:\n``` \narr = [3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]\nsorted_arr = quick_sort(arr)\nprint(sorted_arr) # Output: [1, 1, 2, 3, 3, 4, 5, 5, 5, 6, 9]\n``` \nI hope this helps!"}], "is_classification": false} +{"id": "seed_task_47", "name": "oasst_6", "instruction": "Break down this C++ code and explain what it does:\n\n```\n#include \"Graphics.h\"\n\n#include \"Texture.h\"\n#include \"Camera.h\"\n\n#define SET_COLOR() SDL_SetRenderDrawColor(handle, color.r, color.g, color.b, color.a)\n\n#define CAM Camera::getActive()\n#define CAM_POS CAM->position\n\nvoid Graphics::drawLine(const Vec2 &from, const Vec2 &to, const Color &color) {\n SET_COLOR();\n Vec2 f = from - CAM_POS;\n SDL_RenderDrawLineF(handle, f.x, f.y, to.x, to.y);\n}\n\nvoid Graphics::drawLine(const Vec2 &origin, const Vec2 &direction,\n const Vec2 &length, const Color &color) {\n drawLine(origin, origin + direction * length, color);\n}\n\nvoid Graphics::drawPoint(const Vec2 &position, const Color &color) {\n SET_COLOR();\n Vec2 p = position - CAM_POS;\n SDL_RenderDrawPointF(handle, position.x, position.y);\n}\n\nvoid Graphics::drawRect(const Rect &rect, const Color &color) {\n SET_COLOR();\n SDL_FRect r = rect;\n r.x -= CAM_POS.x;\n r.y -= CAM_POS.y;\n SDL_RenderDrawRectF(handle, &r);\n}\n\nvoid Graphics::fillRect(const Rect &rect, const Color &color) {\n SET_COLOR();\n SDL_FRect r = rect;\n r.x -= CAM_POS.x;\n r.y -= CAM_POS.y;\n SDL_RenderFillRectF(handle, &r);\n}\n```", "instances": [{"input": "", "output": "This code is a part of a C++ program that uses the SDL (Simple DirectMedia Layer) library for graphics rendering. It defines several functions for drawing basic shapes (lines, points, and rectangles) onto the screen.\n\nHere is a detailed explanation of each function:\n\ndrawLine: This function draws a line between two points on the screen, specified by the from and to arguments. The color of the line is specified by the color argument. The line is drawn with respect to the active camera, as defined by the CAM macro. The macro SET_COLOR sets the color for the line.\n\ndrawLine (overloaded function): This function is an overloaded version of drawLine, which allows you to specify the direction and length of the line. The origin of the line is specified by the origin argument, the direction is specified by the direction argument, and the length is specified by the length argument. The color of the line is specified by the color argument.\n\ndrawPoint: This function draws a single point on the screen, specified by the position argument. The color of the point is specified by the color argument. The point is drawn with respect to the active camera, as defined by the CAM macro.\n\ndrawRect: This function draws an empty rectangle on the screen, specified by the rect argument. The color of the rectangle is specified by the color argument. The rectangle is drawn with respect to the active camera, as defined by the CAM macro.\n\nfillRect: This function draws a filled rectangle on the screen, specified by the rect argument. The color of the rectangle is specified by the color argument. The rectangle is drawn with respect to the active camera, as defined by the CAM macro."}], "is_classification": false} +{"id": "seed_task_48", "name": "oasst_7", "instruction": "Hey! In php, when I use `ini_set('memory_limit','6GB');`, it gives blank page? Why is that?", "instances": [{"input": "", "output": "A blank page in PHP usually indicates a fatal error that stops the script from executing further. When you set the memory limit to '6GB' using ini_set('memory_limit', '6GB'); and encounter a blank page, it could be due to one of the following reasons:\n\n1. Insufficient system memory: If your system does not have enough available memory to allocate 6GB to the PHP script, it may cause a fatal error.\n\n1. PHP configuration: Some server configurations may restrict the maximum memory limit that can be set for a PHP script. Check your PHP configuration file (php.ini) to see if there's a hard limit set for the memory_limit directive.\n\n1. Error reporting/display settings: PHP may be suppressing error messages or not displaying them on the page. You can enable error reporting and display to get more information about the issue. Add the following lines to the beginning of your PHP script:\n\n```php\nini_set('display_errors', 1);\nini_set('display_startup_errors', 1);\nerror_reporting(E_ALL);\n```\n\nAfter adding these lines, run your script again and see if any error messages are displayed.\n\n1. Web server timeout: If your PHP script takes too long to execute, the web server may time out, causing the script to stop running and returning a blank page. Check your web server's timeout settings and adjust them if needed.\n\nTo resolve the issue, you can try:\n\n- Reducing the memory limit to a lower value, e.g., '512M', '1G', or '2G', and see if the script runs without issues.\n- Checking your server's available memory and ensuring it can accommodate the desired memory limit.\n- Reviewing your PHP and web server configurations for any restrictions or timeout settings that might be causing the problem.\n\nIf none of these suggestions resolve the issue, consider checking the server logs for any errors or clues about what may be causing the blank page."}], "is_classification": false} +{"id": "seed_task_49", "name": "oasst_8", "instruction": "Write python code to connect to a FTP server.", "instances": [{"input": "", "output": "To connect to an FTP server in Python, you can use the built-in ftplib module. Here is an example function that connects to an FTP server:\n\n```\nimport ftplib\n\ndef ftp_connect(host, username, password):\n ftp = ftplib.FTP(host)\n ftp.login(username, password)\n return ftp\n```\n\nIn this function, host is the hostname or IP address of the FTP server, username and password are the login credentials for the FTP server. The ftp.login() method is used to authenticate the user with the FTP server. The function returns the FTP object, which can be used to perform operations on the FTP server, such as uploading or downloading files.\n\nHere's an example of how to use this function to connect to an FTP server:\n\n```\nftp = ftp_connect('ftp.example.com', 'username', 'password')\nprint(ftp.getwelcome()) # prints the welcome message from the FTP server\nftp.quit() # disconnects from the FTP server\n```\n\nIn this example, ftp.example.com is the hostname of the FTP server, and username and password are the login credentials. The ftp.getwelcome() method is used to print the welcome message from the FTP server. The ftp.quit() method is used to disconnect from the FTP server."}], "is_classification": false} +{"id": "seed_task_50", "name": "oasst_9", "instruction": "How do I get the power of a number in python?", "instances": [{"input": "", "output": "The pow() function returns the value of x to the power of y in python. \nThe syntax for the pow() looks like this:\n```\na = 4 # a is the base number.\nb = 3 # b is the exponent, or the power that a would be raised to.\nc = 5 # c is an optional parameter for the pow() function. c here is the modulus.\n\nx = pow(a,b,c) # This is the same as (4 * 4 * 4) % 5\n\n# Remember, the third parameter, ie. c here is optional. Hence, pow() can also be written as following:\ny = pow(4,3) # This is the same as 4 * 4 * 4.\n\nprint(x) # The output would be 12.\nprint(y) # The output would be 64.\n```"}], "is_classification": false} +{"id": "seed_task_51", "name": "oasst_10", "instruction": "I have the following python function:\n\n```python\ndef resize_images(images, res_x, res_y):\n resized_images = np.zeros((images.shape[0], res_x, res_y))\n for n in range(len(images)):\n resized_images[n, :, :] = resize(images[n, :, :], resized_images.shape[1:], anti_aliasing=False)\n return resized_images\n```\n\nWhat does the function do?", "instances": [{"input": "", "output": "Hmm, let me see. I think the function is used for Image Resizing. It takes in an array of `images`, two integers related to resolution one is the x-axis: `res_x` and a second one on the y-axis: `res_y` as inputs. The function then loops through each image in the array and uses the resizing function (resize) from the Python library Scikit-image to resize the images to the specified resolution. Finally, the function returns an array of resized images. Here is an in-depth look:\n\n```python\n#It takes in a numpy array of images and two integers `res_x` and `res_y` as inputs and then returns a numpy array of resized images.\ndef resize_images(images, res_x, res_y):\n\n# It creates a numpy array resized_images with dimensions (images.shape[0], res_x, res_y) filled with zeros, where images.shape[0] represents the number of images in the input array.\n resized_images = np.zeros((images.shape[0], res_x, res_y))\n\n#It iterates over the length of the input images and for each image, it uses the resize function from the scikit-image library to resize the image to the specified `res_x` and `res_y` resolution, with the anti_aliasing boolean argument set to False. meaning that the resizing process will not apply anti-aliasing to the images.\n for n in range(len(images)): \n resized_images[n, :, :] = resize(images[n, :, :], resized_images.shape[1:], anti_aliasing=False)\n\n# Finally, the resized_images array is returned.\nreturn resized_images\n```"}], "is_classification": false} +{"id": "seed_task_52", "name": "oasst_11", "instruction": "How can I iterate through each item in an array in a random order using c++?", "instances": [{"input": "", "output": "I am assuming you only want to access each element once and don't want to modify the original array.\n\nTo do this you could start by making a new array of random indexes then using those indexes when accessing the array. This method has the advantage of not changing the original array. For example say you have an array of numbers **[6,8,13]** and you want to access this in random order. This array has a length 3 so you would create a new index array of this size with each possible index **[0,1,2]**. Then you shuffle this array using the **std::random_shuffle** function to obtain an array like **[1,2,0]**. Then when you iterate through your loop and access an element, you get the index from the index_array (which is in random order) to access your original array. This could look **my_array[index_array[i]]**.\n\nHere is an example full program\n```\n#include \n#include \n#include \n#include \n \nint main(){ \n std::srand( unsigned (std::time(0)));//set seed \n\n const int size_of_array = 3;//array length\n\n int my_array[size_of_array] = {6,8,13};//data\n\n int index_array[size_of_array];//index array\n int i;\n for(i = 0;i < size_of_array;i++) index_array[i] = i;//initialize indexes\n std::random_shuffle(index_array,index_array+size_of_array);//shuffle indexes\n\n for(i = 0;i < size_of_array;i++){//access in random order\n int random_index = index_array[i];\n std::cout << my_array[random_index] << std::endl;\n }\n\n}\n```"}], "is_classification": false} +{"id": "seed_task_53", "name": "oasst_12", "instruction": "How do I incorporate CSS in my HTML page?", "instances": [{"input": "", "output": "There are multiple ways to add CSS to HTML.\n\u2013\tInline\n\u2013\tInternal\n\u2013\tExternal\n\nThe most common method is to use an second *.css file, that is linked to your *.html file, also known as external CSS.\nTo implement this, create a file called \u201cstyle.css\u201d in the same directory as your *.html file.\nAdd this code to your *.html file to link the style sheet with your document.\n\nAfter linking these files, changes made in the style.css file should affect your HTML content.\n\nIf you have further questions on how to create, inline/internal CSS or want to know some tips and tricks on how to write CSS. Don\u2019t hesitate to ask."}], "is_classification": false} +{"id": "seed_task_54", "name": "oasst_13", "instruction": "bubble sort list of int in python", "instances": [{"input": "", "output": "This is code to bubble sort a list of integers in python:\n```\ndef bubbleSort(arr):\n n = len(arr)\n \n # Traverse through all elements in the array\n for i in range(n):\n # Last i elements are already in place\n for j in range(0, n-i-1):\n # Swap if the element found is greater than the next element\n if arr[j] > arr[j+1]:\n arr[j], arr[j+1] = arr[j+1], arr[j]\n \n return arr\n\n# Test the implementation with a sample list of integers\narr = [64, 34, 25, 12, 22, 11, 90]\nprint(\"Sorted array is:\", bubbleSort(arr))\n```"}], "is_classification": false} +{"id": "seed_task_55", "name": "oasst_14", "instruction": "Write a Python program that takes a list of numbers as input from the user, calculates the sum of all even numbers in the list, and returns the result. The program should check if the input is valid (i.e., if it's a list of numbers), and if it's not, it should return an error message. The program should also handle exceptions gracefully and return a user-friendly error message in case of any exceptions.", "instances": [{"input": "", "output": "Here's a python program that uses the third-party docopt library to sum all the even numbers the user enters in a command line:\n\n``` python\n\"\"\"Sum Even.\n\nUsage: sum_even ...\n\"\"\"\nfrom docopt import docopt\n\n\ndef sum_even(numbers):\n \"\"\"Sum all the even numbers in a list.\"\"\"\n assert isinstance(numbers, list), \"numbers must be a list\"\n\n total = 0\n for n in numbers:\n try:\n n_flt = float(n)\n if n_flt % 2 == 0:\n total += int(n_flt) # it's an int if it's even, and python ints can be much larger than floats\n except ValueError:\n return f\"{n} is not a number\"\n return total\n\n\nif __name__ == \"__main__\":\n arguments = docopt(__doc__, version='Sum All v1.0')\n\n numbers = arguments['']\n try:\n print(sum_even(numbers))\n except Exception as e:\n print(f\"Could not sum all even numbers:\\n {e}\")\n```\n\nDocopt can be installed with:\n```\npip install docopt\n```\n\nThe program can then be run with:\n```\npython sum_even.py 1 2 3 4.0 4.1 1e3\n```\n\nHowever, it doesn't have any specific code for handling inf or nan, which float would convert. It instead just skips those because they don't result in 0 after the %2.\n\nIt also requires a call to python instead of just calling sum_even. It's possible to make it its own command line argument by making the right setup file and pip installing it."}], "is_classification": false} +{"id": "seed_task_56", "name": "oasst_15", "instruction": "xpath to get a span node that contains the text \" Estimate \".\n\nHTML\n\n\nEstimate\n25 - 35 EUR\n", "instances": [{"input": "", "output": "Here's an example of an XPath expression to select the span node that contains the text \"Estimate\":\n\n//span[normalize-space(text())=\"Estimate\"]\n\nThis selects any \"span\" element that has normalized text content of \"Estimate\"."}], "is_classification": false} +{"id": "seed_task_57", "name": "oasst_16", "instruction": "write a sum function in asm", "instances": [{"input": "", "output": "Certainly! Here's an example of a sum function in x86 assembly language:\n```asm\nsection .text\nglobal sum\n\nsum:\n push ebp\n mov ebp, esp\n mov eax, [ebp+8] ; eax = first parameter\n mov ebx, [ebp+12] ; ebx = second parameter\n add eax, ebx ; eax = eax + ebx\n pop ebp\n ret\n```\nThis function takes two parameters (the values to be added) and returns their sum. It uses the add instruction to perform the addition and then returns the result using the ret instruction.\n\nI hope this helps! Let me know if you have any further questions."}], "is_classification": false} +{"id": "seed_task_58", "name": "oasst_17", "instruction": "Python code for a rotating square", "instances": [{"input": "", "output": "Here's an example of Python code using the Pygame library to draw a rotating square:\n\n```python\nimport pygame\nimport math\n\n# Initialize Pygame\npygame.init()\n\n# Set the screen size\nscreen_width = 640\nscreen_height = 480\nscreen = pygame.display.set_mode((screen_width, screen_height))\n\n# Define the colors\nwhite = (255, 255, 255)\nred = (255, 0, 0)\n\n# Define the square\nsquare_width = 50\nsquare_height = 50\nsquare = pygame.Rect(screen_width/2 - square_width/2, screen_height/2 - square_height/2, square_width, square_height)\n\n# Set the rotation angle\nangle = 0\n\n# Define the main game loop\nrunning = True\nwhile running:\n\n # Handle events\n for event in pygame.event.get():\n if event.type == pygame.QUIT:\n running = False\n\n # Rotate the square\n angle += 1\n rotated_square = pygame.transform.rotate(pygame.Surface((square_width, square_height)), angle)\n\n # Clear the screen\n screen.fill(white)\n\n # Draw the square\n screen.blit(rotated_square, square)\n\n # Update the screen\n pygame.display.flip()\n\n# Quit Pygame\npygame.quit()\n```\n\nThis code sets up a Pygame window with a square in the center that rotates around its center point. The rotation angle is increased by 1 on each loop of the main game loop. The square is rotated using the pygame.transform.rotate() function, and the rotated square is drawn on the screen using the pygame.Surface.blit() function. The screen is then updated using the pygame.display.flip() function. The program will continue to run until the user closes the window."}], "is_classification": false} +{"id": "seed_task_59", "name": "oasst_18", "instruction": "How do I output a string in C++ programming?", "instances": [{"input": "", "output": "You can output strings in many ways one of the simplest methods is :\n```cout << string```"}], "is_classification": false} {"id": "seed_task_60", "name": "oasst_19", "instruction": "What is Kubernetes ?", "instances": [{"input": "", "output": "Kubernetes is an open-source platform for automating deployment, scaling, and management of containerized applications. It provides a way to organize and orchestrate containers, making it easier to deploy, manage, and scale applications in a cloud-native environment."}], "is_classification": false} -{"id": "seed_task_61", "name": "oasst_20", "instruction": "How do you output all the contents of a list in Python?", "instances": [{"input": "", "output": "There are several ways to output all the contents of a list in Python. One of the most common ways is using a for loop: ``` list = [1, 2, 3, 4, 5] for item in list: print(item) ``` Another way is to use the join() method: ``` list = [1, 2, 3, 4, 5] print(*list, sep=\", \") ``` Finally, you can also use the str.format() method: ``` list = [1, 2, 3, 4, 5] print(\"The list contains: {}\".format(list)) ```"}], "is_classification": false} -{"id": "seed_task_62", "name": "oasst_21", "instruction": "How are C++, C# and C programming languages different from each other?", "instances": [{"input": "", "output": "C++, C#, and C are three different programming languages, each with its own syntax, features, and areas of application. C is a low-level programming language that was developed in the 1970s. It is widely used in operating systems, device drivers, embedded systems, and other applications that require low-level access to hardware resources. C is a procedural language, which means that it uses functions and procedures to structure code. C++ is an object-oriented programming language that was developed as an extension of C. It adds several features to C, including classes, templates, and exceptions. C++ is widely used in applications that require high-performance, such as gaming, graphics, and scientific computing. C# is a modern programming language that was developed by Microsoft in the early 2000s. It is a hybrid language that combines features of both C++ and Java. C# is used in the development of Windows applications, web applications, and video games. While all three languages are used for software development, they have several differences. C++ is a more complex language than C and C#, and it is more difficult to learn. C# is easier to learn than C++ and has more modern features, but it is only used on the Microsoft platform. C is a simpler language than C++ and is easier to learn, but it lacks some of the features of C++. In summary, C++, C#, and C are different programming languages with different syntax, features, and areas of application. Each language has its own strengths and weaknesses, and the choice of which language to use depends on the specific requirements of the project."}], "is_classification": false} -{"id": "seed_task_63", "name": "oasst_22", "instruction": "Write me a function in C++ to find the distance between two points", "instances": [{"input": "", "output": "Here's an example of a C++ function that calculates the distance between two points in a 2-dimensional space: #include double distance(double x1, double y1, double x2, double y2) { return sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2)); } In this example, the distance function takes four arguments: the x and y coordinates of two points. The function calculates the Euclidean distance between these two points using the Pythagorean theorem, and returns the result as a double value."}], "is_classification": false} -{"id": "seed_task_64", "name": "oasst_23", "instruction": "Could you please write me Rust code that takes ownership of an array of integers and sorts them in ascending order?", "instances": [{"input": "", "output": "Sure, here's an implementation in Rust: ``` fn sort_ascending(arr: &mut [i32]) { arr.sort_unstable(); } fn main() { let mut arr = [5, 2, 4, 1, 3]; sort_ascending(&mut arr); println!(\"{:?}\", arr); } ``` This code sorts the array arr in place using the sort_unstable method. The sort_unstable method sorts the slice in place and may not preserve the order of equal elements."}], "is_classification": false} -{"id": "seed_task_65", "name": "oasst_24", "instruction": "What does this Python code do? ``` import random def montecarloPi(calcs): hits = 0 for i in range(calcs): x = random.random() y = random.random() if (x**2 + y**2) < 1: hits = hits + 1 return 4.0 * hits / calcs print(montecarloPi(10000)) ```", "instances": [{"input": "", "output": "This code estimates the number pi using the Monte Carlo method (that is, by generating a large amount of random numbers and doing things to them to get results). To be more specific, the code generates two random numbers x and y, from 0 to 1 each. Those numbers will then implicitly be treated as coordinates of a point. It then measures the square of the distance between point (x,y) and point (0,0); it does so by squaring x and y and summing the squares. Next, it checks if this squared distance is less than 1 and thus, if the non-squared distance is less than the square root of 1, or simply 1. In other words, the code checks if this point lies inside a circle of radius 1 and origin (0,0). The code does the above 10 000 times, as defined by the last line of the code. The probability of a single iteration of the above method resulting in a hit (in a point hitting the inside of the circle) is pi/4 - that's because the points can land anywhere in a square of side 1, but it only counts in the area where this square overlaps with a circle - this area happens to be a quartercircle. The probability is thus equal to (area of the quartercircle)/(area of the square) = (pi * 1^2 /4) / 1 = pi / 4. While randomness will never be fully predictable, we can be statistically sure that given enough trials (10 000, as mentioned), the ratio of the number of hits to the total number of trials will be close to the above probability. Thus, the code takes this ratio and multiplies it by 4 to extract an approximation of pi from an approximation of this pi / 4 fraction. The code then prints out the result (the number pi)."}], "is_classification": false} -{"id": "seed_task_66", "name": "oasst_25", "instruction": "Help me to optimize this code: doe = DistanceOnEarth() def get_mdr_distance(row): route_geom = shapely.wkt.loads(row.provider_route) route_points = route_geom.coords[:] mdr_points = [] mdr_distance = 0 for points in split_list(route_points): point_1, point_2 = points line = shapely.geometry.LineString(points) is_mdr = ( requests.post( MDR_URL, data=line.wkt, headers={\"accept\": \"*/*\", \"Content-Type\": \"text/plain\"}, ).content == b\"true\" ) if is_mdr: mdr_points.extend(points) else: if len(mdr_points) > 0: mdr_points.extend([point_1]) mdr_distance += doe.get_4326_geometry_length_in_m(shapely.LineString(mdr_points)) mdr_points = [] if len(mdr_points) > 0: mdr_distance += doe.get_4326_geometry_length_in_m(shapely.LineString(mdr_points)) return mdr_distance", "instances": [{"input": "", "output": "One way to optimize this code is by reducing the number of requests made to the server and refactoring the loop to make it more efficient. Here's the modified code: ```python import requests import shapely.wkt import shapely.geometry from distance_on_earth import DistanceOnEarth # Assuming this is the correct import doe = DistanceOnEarth() def get_mdr_distance(row): route_geom = shapely.wkt.loads(row.provider_route) route_points = route_geom.coords[:] def chunks(lst, n=2): for i in range(0, len(lst) - 1, n - 1): yield lst[i:i + n] line_segments = list(chunks(route_points)) request_lines = [shapely.geometry.LineString(pair).wkt for pair in line_segments] request_payload = \"\n\".join(request_lines) response = requests.post( MDR_URL, data=request_payload, headers={\"accept\": \"/\", \"Content-Type\": \"text/plain\"}, ) is_mdr_list = response.content.decode().split('\n') mdr_points = [] mdr_distance = 0 for points, is_mdr in zip(line_segments, is_mdr_list): point_1, point_2 = points if is_mdr == \"true\": mdr_points.extend(points) else: if mdr_points: mdr_points.append(point_1) mdr_distance += doe.get_4326_geometry_length_in_m(shapely.geometry.LineString(mdr_points)) mdr_points = [] if mdr_points: mdr_distance += doe.get_4326_geometry_length_in_m(shapely.geometry.LineString(mdr_points)) return mdr_distance ``` Here's a summary of the changes made: 1. Created a helper function `chunks` to split the list of route points into pairs. 2. Combined all the LineStrings into a single request payload to reduce the number of requests made to the server. 3. Parsed the response content to obtain a list of `is_mdr` values. 4. Modified the loop to use the zip function to iterate over line_segments and `is_mdr_list` simultaneously. This should improve the performance of the code by reducing the number of requests made to the server and simplifying the loop logic. Make sure to test the modified code to ensure it still meets your requirements."}], "is_classification": false} -{"id": "seed_task_67", "name": "oasst_26", "instruction": "write a c++ program that calculates the perimeter of a square", "instances": [{"input": "", "output": "Here's a simple C++ program that calculates the perimeter of a square when the length of its side is given: ```c++ #include using namespace std; int main() { float side, perimeter; // Prompt the user to enter the side length cout << \"Enter the length of the side of the square: \"; cin >> side; // Calculate the perimeter perimeter = 4 * side; // Display the result cout << \"The perimeter of the square is: \" << perimeter << endl; return 0; } ``` The program prompts the user to enter the length of the side of the square, calculates the perimeter, and then displays the result. The formula for the perimeter of a square is simply the length of one side multiplied by 4."}], "is_classification": false} -{"id": "seed_task_68", "name": "oasst_27", "instruction": "Write a C++ function that takes a map as an input and returns the largest pair in the map, in 8 lines or fewer. A pair is considered larger if its second value is larger than another pair's second value.", "instances": [{"input": "", "output": "Here's an example C++ function that takes a map as input and returns the largest pair in the map based on the second value of each pair: ```c++ #include #include // Function to return the largest pair in a map based on the second value of each pair std::pair largest_pair(const std::map& my_map) { std::pair largest_pair = *my_map.begin(); for (auto& entry : my_map) { if (entry.second > largest_pair.second) { largest_pair = entry; } } return largest_pair; } ``` Explanation: - We include the necessary headers for using std::map and std::pair. - We define the largest_pair function that takes a constant reference to a std::map as input and returns a std::pair. - We initialize the largest_pair variable to the first entry in the map. - We loop through all the entries in the map using a range-based for loop and check if the current entry's second value is greater than the current largest_pair's second value. - If the current entry's second value is greater, we update the largest_pair variable to the current entry. - After the loop completes, we return the largest_pair variable. - The function is 8 lines long, including the function signature and braces. - Note that if there are multiple pairs with the same largest second value, this function will only return the first one encountered in the map."}], "is_classification": false} -{"id": "seed_task_69", "name": "oasst_28", "instruction": "Write me a python script, which reads data from a json file and saves the data in an appropriate data structure.", "instances": [{"input": "", "output": "Absolutely! Here's an example that reads data from a JSON file and saves it in a Python dictionary: import json # Open the file and read the data with open(\"data.json\", \"r\") as file: data = json.load(file) # Print the data print(data) In this example, we use the json module to read the data from the file data.json and save it in the variable data. The json.load function takes a file object and returns a Python object that represents the data in the file. In this case, the data in the JSON file is expected to be a JSON object, which will be converted to a Python dictionary. If the data in the file is a JSON array, you can use a list to store the data instead."}], "is_classification": false} -{"id": "seed_task_70", "name": "oasst_29", "instruction": "Make a python function that takes time segments and combine then if they overlap, like this: [[0, 10], [8, 20], [25, 30]] => [[0, 20], [25, 30]]", "instances": [{"input": "", "output": "Here's a Python function that takes a list of time segments and combines them if they overlap: ```py def combine_time_segments(segments): # Sort the segments by their start time segments.sort(key=lambda x: x[0]) # Initialize a list to hold the combined segments combined_segments = [] # Initialize a variable to hold the current segment current_segment = segments[0] # Loop through the remaining segments for segment in segments[1:]: # If the start time of the current segment is less than or equal to the end time of the next segment, # they overlap and should be merged if current_segment[1] >= segment[0]: # Update the end time of the current segment to the maximum of its current end time and the end # time of the next segment current_segment[1] = max(current_segment[1], segment[1]) else: # The segments don't overlap, so add the current segment to the list of combined segments and # make the next segment the current segment combined_segments.append(current_segment) current_segment = segment # Add the last segment to the list of combined segments combined_segments.append(current_segment) return combined_segments ``` Here's an example usage: ```py segments = [[0, 10], [8, 20], [25, 30]] combined_segments = combine_time_segments(segments) print(combined_segments) ``` This will output: `[[0, 20], [25, 30]]`"}], "is_classification": false} -{"id": "seed_task_71", "name": "oasst_30", "instruction": "Tranlate this `curl` command to Python: `curl ifconfig.me`", "instances": [{"input": "", "output": "```python import requests response = requests.get(\"http://ifconfig.me\") print(response.text) ```"}], "is_classification": false} -{"id": "seed_task_72", "name": "oasst_31", "instruction": "def _process(self, data): X = data[1] + \" \" + data[2] Y = pd.get_dummies(data[0], prefix=\"y\").astype(np.float32) return X, Y, len(data) I have a bug `Failed to convert a NumPy array to a Tensor (Unsupported object type float).`. Can you show me where is the problem and how to fix it?", "instances": [{"input": "", "output": "The error message `Failed to convert a NumPy array to a Tensor (Unsupported object type float).` indicates that the TensorFlow library is unable to handle the data type of the Y variable, which is float32. There could be several reasons for this issue. For example, the TensorFlow version you are using may not support float32 data, or the float32 data may have NaN or infinity values, which are not supported by TensorFlow. To resolve this issue, you could try converting the Y variable to a different data type that is supported by TensorFlow, such as float64 or int32. For example: Y = pd.get_dummies(data[0], prefix=\"y\").astype(np.float64) Alternatively, you could try preprocessing the data in Y to handle or remove any NaN or infinity values, and then convert it to float32."}], "is_classification": false} -{"id": "seed_task_73", "name": "oasst_32", "instruction": "I have this interface for a C# class. ``` public interface IPriorityQueue : IEnumerable { void Enqueue(TItem node, TPriority priority); TItem Dequeue(); void Clear(); bool Contains(TItem node); void Remove(TItem node); void UpdatePriority(TItem node, TPriority priority); TItem First { get; } int Count { get; } } ``` Show me how to get the length of the priority queue?", "instances": [{"input": "", "output": "You can get the length of the priority queue by accessing the Count property. For example: ``` int length = queue.Count; ``` Where queue is an instance of the priority queue. This will return the number of items currently in the queue."}], "is_classification": false} -{"id": "seed_task_74", "name": "oasst_33", "instruction": "The following code I wrote in haskell ```hs factorial(1)=1 factorial(n)=n*(n-1)*factorial(n-2) ``` gives me an error when I try to run it. Is there anything I did wrong?", "instances": [{"input": "", "output": "Yes, there is an issue with the recursive definition of the `factorial` function in your Haskell code. Specifically, the line `factorial(n)=n*(n-1)*factorial(n-2)` is incorrect, as it assumes that `n` is always odd, which is not the case for most values of `n`. To define the factorial function correctly, you can use the following code: ``` factorial 0 = 1 factorial n = n * factorial (n - 1) ``` This code defines the factorial function using a recursive approach that handles the base case for `n=0` and then recursively computes the factorial for `n-1` until it reaches the base case. Note that in Haskell, function definitions do not require parentheses around the argument list, so you can define the function as `factorial 0 = 1` instead of `factorial(0)=1`. Also, make sure to use spaces between function names, arguments, and operators, as this is required in Haskell syntax. With these changes, your `factorial` function should work correctly in Haskell."}], "is_classification": false} -{"id": "seed_task_75", "name": "oasst_34", "instruction": "How in JavaScript draw a circle with radius 10 pixels in a html canvas?", "instances": [{"input": "", "output": "To draw a circle with a radius of 10 pixels in a HTML canvas using JavaScript, you can use the following code: In this example, getElementById is used to obtain a reference to the canvas element in the HTML document, and getContext is used to obtain a 2D rendering context for the canvas. beginPath is called to start a new path, arc is used to create an arc with a given center, radius, start angle, and end angle, and fill and stroke are used to fill and outline the circle, respectively. You can adjust the position of the circle by changing the values passed to the arc method, and you can change the color of the fill by changing the value assigned to fillStyle."}], "is_classification": false} -{"id": "seed_task_76", "name": "oasst_35", "instruction": "Create a calculator in the Python programming language", "instances": [{"input": "", "output": "Sure, I can help you create a simple calculator in Python. Here's the code: ```python # Define a function to perform the calculation def calculator(): # Take input from the user num1 = float(input(\"Enter the first number: \")) num2 = float(input(\"Enter the second number: \")) operator = input(\"Enter the operation (+, -, *, /): \") # Perform the calculation based on the operator if operator == \"+\": result = num1 + num2 elif operator == \"-\": result = num1 - num2 elif operator == \"*\": result = num1 * num2 elif operator == \"/\": result = num1 / num2 else: print(\"Invalid operator entered\") return # Print the result print(\"Result: \", result) # Call the calculator function calculator() ``` This code defines a function called calculator() that takes input from the user for two numbers and the operation to be performed. It then performs the calculation based on the chosen operation and prints the result. To use the calculator, simply run the Python script and follow the prompts to enter the numbers and operation. The result will be printed to the console."}], "is_classification": false} -{"id": "seed_task_77", "name": "oasst_36", "instruction": "write a java function that implements gray code and returns the next sequence code after a given code in a given direction of rotation", "instances": [{"input": "", "output": "Here's a function that generates the next Gray code after the given one, in the given rotation direction: ```java public int nextGrayCode(int code, boolean clockwise) { int xor = code ^ (code >> 1); return clockwise ? xor : xor ^ 0xAAAAAAAA; } ``` It works by: XORing the code with a right-shifted version of itself - this flips adjacent bits Using the clockwise parameter to pick either the result of the XOR, or that result XORed with a pattern that flips alternating groups of 4 bits (this handles the \"wraparound\" case for counter-clockwise rotation) So for example: nextGrayCode(0, true); // 1 nextGrayCode(1, true); // 3 nextGrayCode(3, true); // 2 nextGrayCode(2, true); // 6 nextGrayCode(6, false); // 7 nextGrayCode(7, false); // 5 The function handles incrementing in either direction, and wraparounding at either end of the sequence."}], "is_classification": false} -{"id": "seed_task_78", "name": "oasst_37", "instruction": "Write a python script that runs shellscript.sh every 60 minutes", "instances": [{"input": "", "output": "Here is an example python program that runs shellscript.sh every 60 minutes: import time import subprocess while True: # Run the shell script subprocess.run([\"./shellscript.sh\"]) # Wait for 60 minutes before running again time.sleep(60 * 60)"}], "is_classification": false} -{"id": "seed_task_79", "name": "oasst_38", "instruction": "How to check quickly if a number is prime in C?", "instances": [{"input": "", "output": "If speed is a priority and your numbers are large, you're best off using a specialized library like GMP. For small numbers, a lookup table could also be viable. Otherwise, here's a reasonably efficient implementation: ```c #include int is_prime(unsigned int n) { unsigned int factor; if (n == 2) return 1; // 2 is the only even prime if (!(n & 1) || n == 0) return 0; // special case for even and 0 for (factor = 3; factor <= ceil(sqrt(n)); factor += 2) // we know it's not even so we can start at 3 if (!(n % factor)) return 0; return 1; } ```"}], "is_classification": false} -{"id": "seed_task_80", "name": "oasst_39", "instruction": "Write a python code for queues using stack", "instances": [{"input": "", "output": "You can implement a queue using two stacks like this: ```python class Queue: def init(self): self.in_stack = [] self.out_stack = [] def enqueue(self, item): self.in_stack.append(item) def dequeue(self): if not self.out_stack: while self.in_stack: self.out_stack.append(self.in_stack.pop()) return self.out_stack.pop() ``` The key insight here is that stacking and unstacking on a stack is an O(1) operation, but the order is reversed. So we use the in_stack to truly enqueue items, but then we transfer all the items to the out_stack for dequeuing, so that the order is preserved. This leads to an overall enqueue time of O(1) and dequeue time of O(N) in the worst case (when the out_stack is empty). For more balanced usage the amortized time will be closer to O(1)."}], "is_classification": false} +{"id": "seed_task_61", "name": "oasst_20", "instruction": "How do you output all the contents of a list in Python?", "instances": [{"input": "", "output": "There are several ways to output all the contents of a list in Python.\n\nOne of the most common ways is using a for loop:\n\n```\nlist = [1, 2, 3, 4, 5]\nfor item in list:\n print(item)\n```\n\nAnother way is to use the join() method:\n\n```\nlist = [1, 2, 3, 4, 5]\nprint(*list, sep=\", \")\n```\n\nFinally, you can also use the str.format() method:\n\n```\nlist = [1, 2, 3, 4, 5]\nprint(\"The list contains: {}\".format(list))\n```"}], "is_classification": false} +{"id": "seed_task_62", "name": "oasst_21", "instruction": "How are C++, C# and C programming languages different from each other?", "instances": [{"input": "", "output": "C++, C#, and C are three different programming languages, each with its own syntax, features, and areas of application.\n\nC is a low-level programming language that was developed in the 1970s. It is widely used in operating systems, device drivers, embedded systems, and other applications that require low-level access to hardware resources. C is a procedural language, which means that it uses functions and procedures to structure code.\n\nC++ is an object-oriented programming language that was developed as an extension of C. It adds several features to C, including classes, templates, and exceptions. C++ is widely used in applications that require high-performance, such as gaming, graphics, and scientific computing.\n\nC# is a modern programming language that was developed by Microsoft in the early 2000s. It is a hybrid language that combines features of both C++ and Java. C# is used in the development of Windows applications, web applications, and video games.\n\nWhile all three languages are used for software development, they have several differences. C++ is a more complex language than C and C#, and it is more difficult to learn. C# is easier to learn than C++ and has more modern features, but it is only used on the Microsoft platform. C is a simpler language than C++ and is easier to learn, but it lacks some of the features of C++.\n\nIn summary, C++, C#, and C are different programming languages with different syntax, features, and areas of application. Each language has its own strengths and weaknesses, and the choice of which language to use depends on the specific requirements of the project."}], "is_classification": false} +{"id": "seed_task_63", "name": "oasst_22", "instruction": "Write me a function in C++ to find the distance between two points", "instances": [{"input": "", "output": "Here's an example of a C++ function that calculates the distance between two points in a 2-dimensional space:\n#include \n\ndouble distance(double x1, double y1, double x2, double y2) {\n return sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));\n}\n\nIn this example, the distance function takes four arguments: the x and y coordinates of two points. The function calculates the Euclidean distance between these two points using the Pythagorean theorem, and returns the result as a double value."}], "is_classification": false} +{"id": "seed_task_64", "name": "oasst_23", "instruction": "Could you please write me Rust code that takes ownership of an array of integers and sorts them in ascending order?", "instances": [{"input": "", "output": "Sure, here's an implementation in Rust:\n\n```\nfn sort_ascending(arr: &mut [i32]) {\n arr.sort_unstable();\n}\n\nfn main() {\n let mut arr = [5, 2, 4, 1, 3];\n sort_ascending(&mut arr);\n println!(\"{:?}\", arr);\n}\n```\n\nThis code sorts the array arr in place using the sort_unstable method. The sort_unstable method sorts the slice in place and may not preserve the order of equal elements."}], "is_classification": false} +{"id": "seed_task_65", "name": "oasst_24", "instruction": "What does this Python code do?\n```\nimport random\n\n\ndef montecarloPi(calcs):\n hits = 0\n\n for i in range(calcs):\n x = random.random()\n y = random.random()\n if (x**2 + y**2) < 1:\n hits = hits + 1\n\n return 4.0 * hits / calcs\n\n\nprint(montecarloPi(10000))\n```", "instances": [{"input": "", "output": "This code estimates the number pi using the Monte Carlo method (that is, by generating a large amount of random numbers and doing things to them to get results).\n\nTo be more specific, the code generates two random numbers x and y, from 0 to 1 each. Those numbers will then implicitly be treated as coordinates of a point. It then measures the square of the distance between point (x,y) and point (0,0); it does so by squaring x and y and summing the squares. Next, it checks if this squared distance is less than 1 and thus, if the non-squared distance is less than the square root of 1, or simply 1. In other words, the code checks if this point lies inside a circle of radius 1 and origin (0,0).\n\nThe code does the above 10 000 times, as defined by the last line of the code. \n\nThe probability of a single iteration of the above method resulting in a hit (in a point hitting the inside of the circle) is pi/4 - that's because the points can land anywhere in a square of side 1, but it only counts in the area where this square overlaps with a circle - this area happens to be a quartercircle. The probability is thus equal to (area of the quartercircle)/(area of the square) = (pi * 1^2 /4) / 1 = pi / 4.\n\nWhile randomness will never be fully predictable, we can be statistically sure that given enough trials (10 000, as mentioned), the ratio of the number of hits to the total number of trials will be close to the above probability. Thus, the code takes this ratio and multiplies it by 4 to extract an approximation of pi from an approximation of this pi / 4 fraction.\n\nThe code then prints out the result (the number pi)."}], "is_classification": false} +{"id": "seed_task_66", "name": "oasst_25", "instruction": "Help me to optimize this code:\ndoe = DistanceOnEarth()\ndef get_mdr_distance(row):\n\u00a0\u00a0\u00a0 route_geom = shapely.wkt.loads(row.provider_route)\n\u00a0\u00a0\u00a0 route_points = route_geom.coords[:]\n\u00a0\u00a0\u00a0 mdr_points = []\n\u00a0\u00a0\u00a0 mdr_distance = 0\n\u00a0\u00a0\u00a0 for points in split_list(route_points):\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 point_1, point_2 = points\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 line = shapely.geometry.LineString(points)\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 is_mdr = (\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 requests.post(\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 MDR_URL,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 data=line.wkt,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 headers={\"accept\": \"*/*\", \"Content-Type\": \"text/plain\"},\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ).content\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 == b\"true\"\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 )\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if is_mdr:\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 mdr_points.extend(points)\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 else:\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if len(mdr_points) > 0:\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 mdr_points.extend([point_1])\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 mdr_distance += doe.get_4326_geometry_length_in_m(shapely.LineString(mdr_points))\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 mdr_points = []\n\u00a0\u00a0\u00a0 if len(mdr_points) > 0:\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 mdr_distance += doe.get_4326_geometry_length_in_m(shapely.LineString(mdr_points))\n\u00a0\u00a0\u00a0 return mdr_distance", "instances": [{"input": "", "output": "One way to optimize this code is by reducing the number of requests made to the server and refactoring the loop to make it more efficient. Here's the modified code:\n\n```python\n\n import requests\n import shapely.wkt\n import shapely.geometry\n from distance_on_earth import DistanceOnEarth # Assuming this is the correct import\n \n doe = DistanceOnEarth()\n\n def get_mdr_distance(row):\n route_geom = shapely.wkt.loads(row.provider_route)\n route_points = route_geom.coords[:]\n \n def chunks(lst, n=2):\n for i in range(0, len(lst) - 1, n - 1):\n yield lst[i:i + n]\n \n line_segments = list(chunks(route_points))\n request_lines = [shapely.geometry.LineString(pair).wkt for pair in line_segments]\n request_payload = \"\\n\".join(request_lines)\n \n response = requests.post(\n MDR_URL,\n data=request_payload,\n headers={\"accept\": \"/\", \"Content-Type\": \"text/plain\"},\n )\n \n is_mdr_list = response.content.decode().split('\\n')\n \n mdr_points = []\n mdr_distance = 0\n for points, is_mdr in zip(line_segments, is_mdr_list):\n point_1, point_2 = points\n if is_mdr == \"true\":\n mdr_points.extend(points)\n else:\n if mdr_points:\n mdr_points.append(point_1)\n mdr_distance += doe.get_4326_geometry_length_in_m(shapely.geometry.LineString(mdr_points))\n mdr_points = []\n \n if mdr_points:\n mdr_distance += doe.get_4326_geometry_length_in_m(shapely.geometry.LineString(mdr_points))\n \n return mdr_distance\n```\n\nHere's a summary of the changes made:\n\n1. Created a helper function `chunks` to split the list of route points into pairs.\n2. Combined all the LineStrings into a single request payload to reduce the number of requests made to the server.\n3. Parsed the response content to obtain a list of `is_mdr` values.\n4. Modified the loop to use the zip function to iterate over line_segments and `is_mdr_list` simultaneously.\n\nThis should improve the performance of the code by reducing the number of requests made to the server and simplifying the loop logic. Make sure to test the modified code to ensure it still meets your requirements."}], "is_classification": false} +{"id": "seed_task_67", "name": "oasst_26", "instruction": "write a c++ program that calculates the perimeter of a square", "instances": [{"input": "", "output": "Here's a simple C++ program that calculates the perimeter of a square when the length of its side is given:\n\n```c++\n#include \nusing namespace std;\n\nint main() {\n float side, perimeter;\n\n // Prompt the user to enter the side length\n cout << \"Enter the length of the side of the square: \";\n cin >> side;\n\n // Calculate the perimeter\n perimeter = 4 * side;\n\n // Display the result\n cout << \"The perimeter of the square is: \" << perimeter << endl;\n\n return 0;\n}\n```\n\nThe program prompts the user to enter the length of the side of the square, calculates the perimeter, and then displays the result. The formula for the perimeter of a square is simply the length of one side multiplied by 4."}], "is_classification": false} +{"id": "seed_task_68", "name": "oasst_27", "instruction": "Write a C++ function that takes a map as an input and returns the largest pair in the map, in 8 lines or fewer. A pair is considered larger if its second value is larger than another pair's second value.", "instances": [{"input": "", "output": "Here's an example C++ function that takes a map as input and returns the largest pair in the map based on the second value of each pair:\n\n```c++\n#include \n#include \n\n// Function to return the largest pair in a map based on the second value of each pair\nstd::pair largest_pair(const std::map& my_map) {\n std::pair largest_pair = *my_map.begin();\n for (auto& entry : my_map) {\n if (entry.second > largest_pair.second) {\n largest_pair = entry;\n }\n }\n return largest_pair;\n}\n```\n\nExplanation:\n\n- We include the necessary headers for using std::map and std::pair.\n- We define the largest_pair function that takes a constant reference to a std::map as input and returns a std::pair.\n- We initialize the largest_pair variable to the first entry in the map.\n- We loop through all the entries in the map using a range-based for loop and check if the current entry's second value is greater than the current largest_pair's second value.\n- If the current entry's second value is greater, we update the largest_pair variable to the current entry.\n- After the loop completes, we return the largest_pair variable.\n- The function is 8 lines long, including the function signature and braces.\n- Note that if there are multiple pairs with the same largest second value, this function will only return the first one encountered in the map."}], "is_classification": false} +{"id": "seed_task_69", "name": "oasst_28", "instruction": "Write me a python script, which reads data from a json file and saves the data in an appropriate data structure.", "instances": [{"input": "", "output": "Absolutely! Here's an example that reads data from a JSON file and saves it in a Python dictionary:\n\nimport json\n\n# Open the file and read the data\nwith open(\"data.json\", \"r\") as file:\n data = json.load(file)\n\n# Print the data\nprint(data)\n\nIn this example, we use the json module to read the data from the file data.json and save it in the variable data. The json.load function takes a file object and returns a Python object that represents the data in the file.\n\nIn this case, the data in the JSON file is expected to be a JSON object, which will be converted to a Python dictionary. If the data in the file is a JSON array, you can use a list to store the data instead."}], "is_classification": false} +{"id": "seed_task_70", "name": "oasst_29", "instruction": "Make a python function that takes time segments and combine then if they overlap, like this: [[0, 10], [8, 20], [25, 30]] => [[0, 20], [25, 30]]", "instances": [{"input": "", "output": "Here's a Python function that takes a list of time segments and combines them if they overlap:\n```py\ndef combine_time_segments(segments):\n # Sort the segments by their start time\n segments.sort(key=lambda x: x[0])\n \n # Initialize a list to hold the combined segments\n combined_segments = []\n \n # Initialize a variable to hold the current segment\n current_segment = segments[0]\n \n # Loop through the remaining segments\n for segment in segments[1:]:\n # If the start time of the current segment is less than or equal to the end time of the next segment,\n # they overlap and should be merged\n if current_segment[1] >= segment[0]:\n # Update the end time of the current segment to the maximum of its current end time and the end\n # time of the next segment\n current_segment[1] = max(current_segment[1], segment[1])\n else:\n # The segments don't overlap, so add the current segment to the list of combined segments and\n # make the next segment the current segment\n combined_segments.append(current_segment)\n current_segment = segment\n \n # Add the last segment to the list of combined segments\n combined_segments.append(current_segment)\n \n return combined_segments\n```\nHere's an example usage:\n```py\nsegments = [[0, 10], [8, 20], [25, 30]]\ncombined_segments = combine_time_segments(segments)\nprint(combined_segments)\n```\nThis will output: `[[0, 20], [25, 30]]`"}], "is_classification": false} +{"id": "seed_task_71", "name": "oasst_30", "instruction": "Tranlate this `curl` command to Python: `curl ifconfig.me`", "instances": [{"input": "", "output": "```python\nimport requests\n\nresponse = requests.get(\"http://ifconfig.me\")\nprint(response.text)\n```"}], "is_classification": false} +{"id": "seed_task_72", "name": "oasst_31", "instruction": "def _process(self, data):\n X = data[1] + \" \" + data[2]\n Y = pd.get_dummies(data[0], prefix=\"y\").astype(np.float32)\n return X, Y, len(data)\nI have a bug `Failed to convert a NumPy array to a Tensor (Unsupported object type float).`. Can you show me where is the problem and how to fix it", "instances": [{"input": "", "output": "The error message `Failed to convert a NumPy array to a Tensor (Unsupported object type float).` indicates that the TensorFlow library is unable to handle the data type of the Y variable, which is float32.\n\nThere could be several reasons for this issue. For example, the TensorFlow version you are using may not support float32 data, or the float32 data may have NaN or infinity values, which are not supported by TensorFlow. To resolve this issue, you could try converting the Y variable to a different data type that is supported by TensorFlow, such as float64 or int32. For example:\n\nY = pd.get_dummies(data[0], prefix=\"y\").astype(np.float64)\n\nAlternatively, you could try preprocessing the data in Y to handle or remove any NaN or infinity values, and then convert it to float32."}], "is_classification": false} +{"id": "seed_task_73", "name": "oasst_32", "instruction": "I have this interface for a C# class.\n\n```\npublic interface IPriorityQueue : IEnumerable\n{\n\tvoid Enqueue(TItem node, TPriority priority);\n\tTItem Dequeue();\n\tvoid Clear();\n\tbool Contains(TItem node);\n\tvoid Remove(TItem node);\n\tvoid UpdatePriority(TItem node, TPriority priority);\n\tTItem First { get; }\n\tint Count { get; }\n}\n```\n\nShow me how to get the length of the priority queue?", "instances": [{"input": "", "output": "You can get the length of the priority queue by accessing the Count property. For example:\n\n```\nint length = queue.Count;\n```\n\nWhere queue is an instance of the priority queue. This will return the number of items currently in the queue."}], "is_classification": false} +{"id": "seed_task_74", "name": "oasst_33", "instruction": "The following code I wrote in haskell\n```hs\nfactorial(1)=1\nfactorial(n)=n*(n-1)*factorial(n-2)\n```\ngives me an error when I try to run it. Is there anything I did wrong?", "instances": [{"input": "", "output": "Yes, there is an issue with the recursive definition of the `factorial` function in your Haskell code. Specifically, the line `factorial(n)=n*(n-1)*factorial(n-2)` is incorrect, as it assumes that `n` is always odd, which is not the case for most values of `n`.\n\nTo define the factorial function correctly, you can use the following code:\n\n```\nfactorial 0 = 1\nfactorial n = n * factorial (n - 1)\n```\n\nThis code defines the factorial function using a recursive approach that handles the base case for `n=0` and then recursively computes the factorial for `n-1` until it reaches the base case. \n\nNote that in Haskell, function definitions do not require parentheses around the argument list, so you can define the function as `factorial 0 = 1` instead of `factorial(0)=1`. Also, make sure to use spaces between function names, arguments, and operators, as this is required in Haskell syntax.\n\nWith these changes, your `factorial` function should work correctly in Haskell."}], "is_classification": false} +{"id": "seed_task_75", "name": "oasst_34", "instruction": "How in JavaScript draw a circle with radius 10 pixels in a html canvas?", "instances": [{"input": "", "output": "To draw a circle with a radius of 10 pixels in a HTML canvas using JavaScript, you can use the following code:\n\n\n \n \n \n \n \n \n\n\nIn this example, getElementById is used to obtain a reference to the canvas element in the HTML document, and getContext is used to obtain a 2D rendering context for the canvas. beginPath is called to start a new path, arc is used to create an arc with a given center, radius, start angle, and end angle, and fill and stroke are used to fill and outline the circle, respectively.\n\nYou can adjust the position of the circle by changing the values passed to the arc method, and you can change the color of the fill by changing the value assigned to fillStyle."}], "is_classification": false} +{"id": "seed_task_76", "name": "oasst_35", "instruction": "Create a calculator in the Python programming language", "instances": [{"input": "", "output": "Sure, I can help you create a simple calculator in Python. Here's the code:\n\n```python\n# Define a function to perform the calculation\ndef calculator():\n # Take input from the user\n num1 = float(input(\"Enter the first number: \"))\n num2 = float(input(\"Enter the second number: \"))\n operator = input(\"Enter the operation (+, -, *, /): \")\n\n # Perform the calculation based on the operator\n if operator == \"+\":\n result = num1 + num2\n elif operator == \"-\":\n result = num1 - num2\n elif operator == \"*\":\n result = num1 * num2\n elif operator == \"/\":\n result = num1 / num2\n else:\n print(\"Invalid operator entered\")\n return\n\n # Print the result\n print(\"Result: \", result)\n\n# Call the calculator function\ncalculator()\n```\n\nThis code defines a function called calculator() that takes input from the user for two numbers and the operation to be performed. It then performs the calculation based on the chosen operation and prints the result.\n\nTo use the calculator, simply run the Python script and follow the prompts to enter the numbers and operation. The result will be printed to the console."}], "is_classification": false} +{"id": "seed_task_77", "name": "oasst_36", "instruction": "write a java function that implements gray code and returns the next sequence code after a given code in a given direction of rotation", "instances": [{"input": "", "output": "Here's a function that generates the next Gray code after the given one, in the given rotation direction:\n```java\npublic int nextGrayCode(int code, boolean clockwise) {\n int xor = code ^ (code >> 1);\n return clockwise ? xor : xor ^ 0xAAAAAAAA;\n}\n```\nIt works by:\n\nXORing the code with a right-shifted version of itself - this flips adjacent bits\nUsing the clockwise parameter to pick either the result of the XOR, or that result XORed with a pattern that flips alternating groups of 4 bits (this handles the \"wraparound\" case for counter-clockwise rotation)\n\nSo for example:\nnextGrayCode(0, true); // 1\nnextGrayCode(1, true); // 3\nnextGrayCode(3, true); // 2\nnextGrayCode(2, true); // 6\nnextGrayCode(6, false); // 7\nnextGrayCode(7, false); // 5\n\n\nThe function handles incrementing in either direction, and wraparounding at either end of the sequence."}], "is_classification": false} +{"id": "seed_task_78", "name": "oasst_37", "instruction": "Write a python script that runs shellscript.sh every 60 minutes", "instances": [{"input": "", "output": "Here is an example python program that runs shellscript.sh every 60 minutes:\n\n import time\n import subprocess\n \n while True:\n # Run the shell script\n subprocess.run([\"./shellscript.sh\"])\n \n # Wait for 60 minutes before running again\n time.sleep(60 * 60)"}], "is_classification": false} +{"id": "seed_task_79", "name": "oasst_38", "instruction": "How to check quickly if a number is prime in C?", "instances": [{"input": "", "output": "If speed is a priority and your numbers are large, you're best off using a specialized library like GMP. For small numbers, a lookup table could also be viable. Otherwise, here's a reasonably efficient implementation:\n```c\n#include \n\nint is_prime(unsigned int n)\n{\n\tunsigned int factor;\n if (n == 2) return 1; // 2 is the only even prime\n\tif (!(n & 1) || n == 0) return 0; // special case for even and 0\n\n\tfor (factor = 3; factor <= ceil(sqrt(n)); factor += 2) // we know it's not even so we can start at 3\n\t\tif (!(n % factor)) return 0;\n\treturn 1;\n}\n```"}], "is_classification": false} +{"id": "seed_task_80", "name": "oasst_39", "instruction": "Write a code for queues using stack", "instances": [{"input": "", "output": "You can implement a queue using two stacks like this:\n```python\nclass Queue:\n def init(self):\n self.in_stack = []\n self.out_stack = []\n\n def enqueue(self, item):\n self.in_stack.append(item)\n\n def dequeue(self):\n if not self.out_stack:\n while self.in_stack:\n self.out_stack.append(self.in_stack.pop())\n return self.out_stack.pop()\n```\n\nThe key insight here is that stacking and unstacking on a stack is an O(1) operation, but the order is reversed.\nSo we use the in_stack to truly enqueue items, but then we transfer all the items to the out_stack for dequeuing, so that the order is preserved.\nThis leads to an overall enqueue time of O(1) and dequeue time of O(N) in the worst case (when the out_stack is empty). For more balanced usage the amortized time will be closer to O(1)."}], "is_classification": false} diff --git a/data/output.jsonl b/data/output.jsonl deleted file mode 100644 index 736aacc..0000000 --- a/data/output.jsonl +++ /dev/null @@ -1,1019 +0,0 @@ -{"instruction": "Write a Python program to find the maximum and minimum number from a given list.", "input": "", "output": "```python def max_min(lst):\n return max(lst), min(lst) ```", "most_similar": {"Write a Python function to reverse a given list of integers.": 0.5384615384615385, "Write a Python function to find all prime numbers up to the given number n.": 0.4666666666666667, "Write a script to output the mean of a list of integers.": 0.4444444444444445, "Write a program to compute the sum of integers from k to n.": 0.42857142857142855, "Generate a correct python program to fulfill the following purpose:": 0.4, "write a c++ program that calculates the perimeter of a square": 0.3846153846153846, "Write a python function that sorts a list from large to small.": 0.3703703703703704, "Write me a function in C++ to find the distance between two points": 0.3571428571428571, "Write a python code to implement quick sort": 0.3478260869565218, "Write python code to connect to a FTP server.": 0.33333333333333337}, "avg_similarity_score": 0.18242350477492975} -{"instruction": "What is the difference between a for loop and a while loop?", "input": "", "output": "A for loop is a control flow statement that allows you to iterate over a sequence of items. A while loop is a control flow statement that allows you to execute a block of code repeatedly as long as a condition is true.", "most_similar": {"What is Kubernetes ?": 0.26666666666666666, "Write a script in JavaScript for printing the current date and time.": 0.25, "Write a Python program to find the maximum and minimum number from a given list.": 0.22222222222222224, "Python code for a rotating square": 0.2222222222222222, "Find the bug in the following code piece: a = 1 while a == 1: b = input(\"what's your name ?\") print(\"Hi \",b, \" this is infinity loop !\")": 0.21052631578947367, "Suggest a completion for the following python code.": 0.2, "Write a python code for queues using stack": 0.2, "write a c++ program that calculates the perimeter of a square": 0.17391304347826086, "Write a Python function to reverse a given list of integers.": 0.17391304347826086, "How do I get the power of a number in python?": 0.17391304347826086}, "avg_similarity_score": 0.10991693712632082} -{"instruction": "How can I find the maximum and minimum value in a list using Python?", "input": "", "output": "You can use the built-in **max()** and **min()** functions to find the maximum and minimum values in a list. For example: ``` my_list = [1, 2, 3, 4, 5] print(max(my_list)) # 5 print(min(my_list)) # 1 ```", "most_similar": {"Write a Python program to find the maximum and minimum number from a given list.": 0.4827586206896552, "How do I get the power of a number in python?": 0.4, "How can I iterate through each item in an array in a random order using c++?": 0.39999999999999997, "How do you output all the contents of a list in Python?": 0.3846153846153846, "How do I incorporate CSS in my HTML page?": 0.2608695652173913, "How do I output a string in C++ programming?": 0.2608695652173913, "write a code to get the current value of a Bitcoin in US dollars using the bitcoincharts API.": 0.25, "What is the difference between a for loop and a while loop?": 0.23076923076923075, "Solving the equation and find the value of X. Show your steps.": 0.23076923076923075, "Write a script to output the mean of a list of integers.": 0.23076923076923075}, "avg_similarity_score": 0.14161541752392853} -{"instruction": "Write a Python function to find the sum of all items in a list.", "input": "", "output": "def sum_list(lst):\n return sum(lst)", "most_similar": {"Write a Python function to reverse a given list of integers.": 0.56, "Write a Python program to find the maximum and minimum number from a given list.": 0.5517241379310344, "Write a script to output the mean of a list of integers.": 0.5384615384615384, "Write a Python function to find all prime numbers up to the given number n.": 0.4827586206896552, "Write a python function that sorts a list from large to small.": 0.4615384615384615, "Write a program to compute the sum of integers from k to n.": 0.4444444444444445, "Write me a function in C++ to find the distance between two points": 0.4444444444444445, "write a sum function in asm": 0.4, "write a c++ program that calculates the perimeter of a square": 0.4, "write a code to get the current value of a Bitcoin in US dollars using the bitcoincharts API.": 0.375}, "avg_similarity_score": 0.2184828259984655} -{"instruction": "Write a Python function to find the largest number in a dictionary.", "input": "", "output": "def max_dict(d):\n return max(d.values())", "most_similar": {"Write a Python function to find the sum of all items in a list.": 0.6923076923076924, "Write a Python program to find the maximum and minimum number from a given list.": 0.5925925925925926, "Write a Python function to find all prime numbers up to the given number n.": 0.5925925925925926, "Write a Python function to reverse a given list of integers.": 0.5217391304347826, "Write me a function in C++ to find the distance between two points": 0.48000000000000004, "write a sum function in asm": 0.4444444444444444, "Write a script to output the mean of a list of integers.": 0.4166666666666667, "Write a python function that sorts a list from large to small.": 0.4166666666666667, "Write a python code to implement quick sort": 0.4, "Write python code to connect to a FTP server.": 0.380952380952381}, "avg_similarity_score": 0.22253441000496815} -{"instruction": "Write a Python program to find the sum of the first 1000 prime numbers.", "input": "", "output": "Here's a Python program that finds the sum of the first 1000 prime numbers: ``` python def sum_primes(n): sum = 0 for i in range(2, n): if is_prime(i): sum += i return sum def is_prime(n): if n == 2: return True for i in range(2, n): if n % i == 0: return False return True print(sum_primes(1000)) ```", "most_similar": {"Write a Python function to find the sum of all items in a list.": 0.5714285714285714, "Write a program to compute the sum of integers from k to n.": 0.5185185185185186, "Write a Python program to find the maximum and minimum number from a given list.": 0.4827586206896552, "Write a Python function to find all prime numbers up to the given number n.": 0.4827586206896552, "Write a Python function to find the largest number in a dictionary.": 0.4615384615384615, "Generate a correct python program to fulfill the following purpose:": 0.41666666666666663, "write a c++ program that calculates the perimeter of a square": 0.4, "Write a Python function to reverse a given list of integers.": 0.4, "Write a script to output the mean of a list of integers.": 0.3846153846153846, "write a code to get the current value of a Bitcoin in US dollars using the bitcoincharts API.": 0.375}, "avg_similarity_score": 0.19607416798587654} -{"instruction": "Write a function that takes a string and returns the number of vowels in the string.", "input": "", "output": "Here's a function that takes a string and returns the number of vowels in the string: ```py def count_vowels(string): vowels = \"aeiou\" vowel_count = 0 for char in string: if char in vowels: vowel_count += 1 return vowel_count ``` Here's an example usage: ```py print(count_vowels(\"Hello World\")) # prints 3 ```", "most_similar": {"Please write a Rust function that takes a u64 input and returns the largest prime number less than that value.": 0.5555555555555556, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.48484848484848486, "Write a Python function that takes two numbers as input and returns their sum.": 0.4666666666666667, "Write a Python function to find the largest number in a dictionary.": 0.42857142857142855, "write a java function that implements gray code and returns the next sequence code after a given code in a given direction of rotation": 0.4, "Write a Python function to find the sum of all items in a list.": 0.39999999999999997, "Write a C++ function that takes a map as an input and returns the largest pair in the map, in 8 lines or fewer. A pair is considered larger if its second value is larger than another pair's second value.": 0.38596491228070173, "Can you provide a shell script that displays the total number of lines in all '*.txt' files in the current directory?": 0.37837837837837834, "Write a Python function to reverse a given list of integers.": 0.3703703703703703, "write a c++ program that calculates the perimeter of a square": 0.3703703703703703}, "avg_similarity_score": 0.20433953481861844} -{"instruction": "Write a Python program to find the first repeated character of a given string where the index of first occurrence is smallest.", "input": "", "output": "```python def first_repeated_char(s): seen = set() for c in s: if c in seen: return c seen.add(c) return None ```", "most_similar": {"Write a Python program to find the sum of the first 1000 prime numbers.": 0.5555555555555556, "Write a Python program to find the maximum and minimum number from a given list.": 0.4864864864864865, "Write a Python function to find the sum of all items in a list.": 0.4444444444444444, "Write a Python function to reverse a given list of integers.": 0.4242424242424242, "Write a Python function to find the largest number in a dictionary.": 0.4117647058823529, "Write a script to output the mean of a list of integers.": 0.4117647058823529, "Write a Python function to find all prime numbers up to the given number n.": 0.3783783783783784, "write a c++ program that calculates the perimeter of a square": 0.3636363636363636, "write a code to get the current value of a Bitcoin in US dollars using the bitcoincharts API.": 0.35000000000000003, "Write a program to compute the sum of integers from k to n.": 0.3428571428571428}, "avg_similarity_score": 0.18312692011591702} -{"instruction": "Write a Python program to find the unique common elements from two lists.", "input": "", "output": "```python def common_elements(list1, list2):\n return list(set(list1) & set(list2)) ```", "most_similar": {"Write a Python program to find the maximum and minimum number from a given list.": 0.5714285714285715, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.5185185185185186, "Write a Python function to find the largest number in a dictionary.": 0.48000000000000004, "Write a program to compute the sum of integers from k to n.": 0.46153846153846156, "Write me a function in C++ to find the distance between two points": 0.46153846153846156, "Write a Python function to find the sum of all items in a list.": 0.4444444444444445, "Generate a correct python program to fulfill the following purpose:": 0.4347826086956522, "Write a Python function to find all prime numbers up to the given number n.": 0.42857142857142855, "Write a Python program to find the first repeated character of a given string where the index of first occurrence is smallest.": 0.39999999999999997, "Write a python code to implement quick sort": 0.380952380952381}, "avg_similarity_score": 0.18352162105597458} -{"instruction": "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.", "input": "", "output": "```python def sum_list(lst):\n return sum(lst) ```", "most_similar": {"Write a function that takes a string and returns the number of vowels in the string.": 0.6486486486486486, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.5789473684210527, "Write a Python function to find the sum of all items in a list.": 0.5714285714285714, "Write a Python function that takes two numbers as input and returns their sum.": 0.5714285714285714, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.4571428571428571, "Please write a Rust function that takes a u64 input and returns the largest prime number less than that value.": 0.4390243902439024, "Write a Python function to reverse a given list of integers.": 0.43749999999999994, "Write a python function that sorts a list from large to small.": 0.4242424242424242, "Write a Python function to find all prime numbers up to the given number n.": 0.3888888888888889, "Write a Python function to find the largest number in a dictionary.": 0.36363636363636365}, "avg_similarity_score": 0.20934461633887375} -{"instruction": "Write a Python program to find the first non-repeated character in a string.", "input": "", "output": "def first_non_repeated_char(s):\n for i in range(len(s)):\n if s.count(s[i]) == 1:\n return s[i]\n return None", "most_similar": {"Write a Python program to find the first repeated character of a given string where the index of first occurrence is smallest.": 0.6666666666666665, "Write a Python function to find the largest number in a dictionary.": 0.6153846153846153, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.5714285714285714, "Write a Python function to find the sum of all items in a list.": 0.5714285714285714, "Write a Python program to find the maximum and minimum number from a given list.": 0.5517241379310344, "Write a Python program to find the unique common elements from two lists.": 0.5185185185185186, "Generate a correct python program to fulfill the following purpose:": 0.41666666666666663, "Write a Python function to find all prime numbers up to the given number n.": 0.4137931034482759, "Write a Python function to reverse a given list of integers.": 0.4, "write a c++ program that calculates the perimeter of a square": 0.4}, "avg_similarity_score": 0.21564879428191036} -{"instruction": "Write a C# program to find the sum of all the elements of an array.", "input": "", "output": "using System;\n\nnamespace ArraySum\n{\n class Program\n {\n static void Main(string[] args)\n {\n int[] array = { 1, 2, 3, 4, 5 };\n int sum = 0;\n\n foreach (int i in array)\n {\n sum += i;\n }\n\n Console.WriteLine(\"Sum of all elements of array: {0}\", sum);\n }\n }\n}", "most_similar": {"Write a Python program to find the sum of the first 1000 prime numbers.": 0.6206896551724138, "Write a Python function to find the sum of all items in a list.": 0.5517241379310344, "Write a program to compute the sum of integers from k to n.": 0.5, "Write a Python program to find the unique common elements from two lists.": 0.5, "Write a Python program to find the first repeated character of a given string where the index of first occurrence is smallest.": 0.4864864864864865, "write a c++ program that calculates the perimeter of a square": 0.4615384615384615, "Write a script to output the mean of a list of integers.": 0.4444444444444445, "Write me a function in C++ to find the distance between two points": 0.42857142857142855, "Write a Python program to find the first non-repeated character in a string.": 0.4137931034482759, "Write a Python program to find the maximum and minimum number from a given list.": 0.4000000000000001}, "avg_similarity_score": 0.20506206661365478} -{"instruction": "Write a Python program to find the number of even and odd numbers from a series of numbers.", "input": "", "output": "def even_odd(lst):\n even = 0\n odd = 0\n for i in lst:\n if i % 2 == 0:\n even += 1\n else:\n odd += 1\n return even, odd", "most_similar": {"Write a Python program to find the maximum and minimum number from a given list.": 0.606060606060606, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.5625000000000001, "Write a Python function to find the largest number in a dictionary.": 0.5333333333333333, "Write a Python program to find the unique common elements from two lists.": 0.5161290322580646, "Write a Python program to find the first non-repeated character in a string.": 0.5, "Write a Python program to find the first repeated character of a given string where the index of first occurrence is smallest.": 0.5, "Write a Python function to find the sum of all items in a list.": 0.5, "Write a C# program to find the sum of all the elements of an array.": 0.4848484848484848, "Write a script to output the mean of a list of integers.": 0.4666666666666666, "Write a program to compute the sum of integers from k to n.": 0.45161290322580644}, "avg_similarity_score": 0.2097917432056419} -{"instruction": "Write a Python program to find the number of strings where the string length is 2 or more and the first and last character are same from a given list of strings.", "input": "", "output": "def count_strings(lst):\n count = 0\n for s in lst:\n if len(s) >= 2 and s[0] == s[-1]:\n count += 1\n return count", "most_similar": {"Write a Python program to find the number of even and odd numbers from a series of numbers.": 0.52, "Write a Python program to find the maximum and minimum number from a given list.": 0.5106382978723405, "Write a Python program to find the first repeated character of a given string where the index of first occurrence is smallest.": 0.4444444444444444, "Write a Python program to find the first non-repeated character in a string.": 0.43478260869565216, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.43478260869565216, "Write a Python function to find the sum of all items in a list.": 0.391304347826087, "Write a C# program to find the sum of all the elements of an array.": 0.3829787234042553, "Write a Python function to reverse a given list of integers.": 0.37209302325581395, "Write a Python function to find the largest number in a dictionary.": 0.36363636363636365, "Write a script to output the mean of a list of integers.": 0.36363636363636365}, "avg_similarity_score": 0.1763301635265429} -{"instruction": "Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.", "input": "", "output": "class Solution:\n def longestPalindrome(self, s: str) -> str:\n if len(s) <= 1:\n return s\n max_len = 1\n start = 0\n for i in range(len(s)):\n if i - max_len >= 1 and s[i - max_len - 1: i + 1] == s[i - max_len - 1: i + 1][::-1]:\n start = i - max_len - 1\n max_len += 2\n continue\n if i - max_len >= 0 and s[i - max_len: i + 1] == s[i - max_len: i + 1][::-1]:\n start = i - max_len\n max_len += 1\n return s[start: start + max_len]", "most_similar": {"Given a string `s`, find the length of the longest substring without repeating characters.": 0.4444444444444444, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.2777777777777778, "Write a Python program to find the first repeated character of a given string where the index of first occurrence is smallest.": 0.2727272727272727, "Write a C# program to find the sum of all the elements of an array.": 0.27027027027027023, "Write a function that takes a string and returns the number of vowels in the string.": 0.2631578947368421, "Find the bug in the following code piece: a = 1 while a == 1: b = input(\"what's your name ?\") print(\"Hi \",b, \" this is infinity loop !\")": 0.24999999999999994, "write a c++ program that calculates the perimeter of a square": 0.24242424242424246, "Write a Python function to find the largest number in a dictionary.": 0.23529411764705885, "Write a Python program to find the number of strings where the string length is 2 or more and the first and last character are same from a given list of strings.": 0.2222222222222222, "Write a Python function to find the sum of all items in a list.": 0.2222222222222222}, "avg_similarity_score": 0.14015605789129165} -{"instruction": "What is the difference between a class and an object?", "input": "", "output": "A class is a blueprint for creating objects. An object is an instance of a class. For example, a class named \"Car\" could be used to create objects that represent specific cars, such as a \"Ford\" or a \"Toyota\".", "most_similar": {"What is the difference between a for loop and a while loop?": 0.6363636363636365, "What is Kubernetes ?": 0.30769230769230765, "Write me a python script, which reads data from a json file and saves the data in an appropriate data structure.": 0.19354838709677416, "How do I get the power of a number in python?": 0.1904761904761905, "write a c++ program that calculates the perimeter of a square": 0.1904761904761905, "How do you output all the contents of a list in Python?": 0.1818181818181818, "Write a Python function to find the largest number in a dictionary.": 0.1818181818181818, "Write a script to output the mean of a list of integers.": 0.1818181818181818, "Write a script in JavaScript for printing the current date and time.": 0.1818181818181818, "Solving the equation and find the value of X. Show your steps.": 0.1818181818181818}, "avg_similarity_score": 0.11327956459289468} -{"instruction": "How do you create a new list from two lists in Python by picking one element each?", "input": "", "output": "You can use the zip() function to create a new list from two lists in Python by picking one element each. The zip() function returns a list of tuples where the i-th tuple contains the i-th element from each of the argument sequences or iterables. For example: ``` list1 = [1, 2, 3] list2 = [4, 5, 6] list3 = [x + y for x, y in zip(list1, list2)] print(list3) ``` This will print the following output: ``` [5, 7, 9] ```", "most_similar": {"How do you output all the contents of a list in Python?": 0.4827586206896552, "How do I get the power of a number in python?": 0.35714285714285715, "Create a calculator in the Python programming language": 0.31999999999999995, "How do I output a string in C++ programming?": 0.30769230769230765, "Write a Python program to find the unique common elements from two lists.": 0.26666666666666666, "How can I find the maximum and minimum value in a list using Python?": 0.2580645161290323, "bubble sort list of int in python": 0.25, "Write a script to output 'Hello World' in python": 0.23076923076923078, "How do I incorporate CSS in my HTML page?": 0.23076923076923078, "How to check quickly if a number is prime in C?": 0.21428571428571427}, "avg_similarity_score": 0.11247389686987035} -{"instruction": "How do you find the index of an item in a list?", "input": "", "output": "You can use the index() method to find the index of an item in a list. The index() method returns the index of the first occurrence of the specified value. If the value is not found, it raises a ValueError. For example: ``` list = [1, 2, 3, 4, 5] print(list.index(3)) ``` This will print the following output: ``` 2 ```", "most_similar": {"How do you output all the contents of a list in Python?": 0.5833333333333334, "Write a Python function to find the sum of all items in a list.": 0.4615384615384615, "How can I find the maximum and minimum value in a list using Python?": 0.4615384615384615, "How do I get the power of a number in python?": 0.43478260869565216, "How do you create a new list from two lists in Python by picking one element each?": 0.3448275862068966, "Write a script to output the mean of a list of integers.": 0.3333333333333333, "Write a Python function to find the largest number in a dictionary.": 0.3333333333333333, "Write a Python program to find the first non-repeated character in a string.": 0.30769230769230765, "Write a Python program to find the maximum and minimum number from a given list.": 0.2962962962962963, "Write a C# program to find the sum of all the elements of an array.": 0.2962962962962963}, "avg_similarity_score": 0.16056774317206707} -{"instruction": "How do you sort a list of strings in Python?", "input": "", "output": "You can use the sorted() function to sort a list of strings in Python. The sorted() function returns a new sorted list while leaving the original list unchanged. For example: ``` list = ['banana', 'apple', 'orange'] sorted_list = sorted(list) print(sorted_list) ``` This will print the following output: ``` ['apple', 'banana', 'orange'] ```", "most_similar": {"How do you output all the contents of a list in Python?": 0.6363636363636365, "bubble sort list of int in python": 0.588235294117647, "How do you create a new list from two lists in Python by picking one element each?": 0.5185185185185185, "How do I get the power of a number in python?": 0.47619047619047616, "How do you find the index of an item in a list?": 0.45454545454545453, "How do I output a string in C++ programming?": 0.4210526315789474, "How can I find the maximum and minimum value in a list using Python?": 0.3333333333333333, "Create a calculator in the Python programming language": 0.33333333333333326, "How do I incorporate CSS in my HTML page?": 0.3157894736842105, "Write a script to output 'Hello World' in python": 0.3157894736842105}, "avg_similarity_score": 0.15994118748071223} -{"instruction": "How do you remove duplicates from a list in Python?", "input": "", "output": "You can use the set() function to remove duplicates from a list in Python. The set() function returns a new set object that is a collection of unique elements. For example: ``` list = [1, 2, 3, 4, 5, 1, 2, 3] set_list = set(list) print(set_list) ``` This will print the following output: ``` {1, 2, 3, 4, 5} ```", "most_similar": {"How do you sort a list of strings in Python?": 0.7, "How do you output all the contents of a list in Python?": 0.6363636363636365, "How do you create a new list from two lists in Python by picking one element each?": 0.5185185185185185, "How do I get the power of a number in python?": 0.47619047619047616, "How do you find the index of an item in a list?": 0.45454545454545453, "How do I output a string in C++ programming?": 0.4210526315789474, "bubble sort list of int in python": 0.3529411764705882, "How can I find the maximum and minimum value in a list using Python?": 0.3333333333333333, "Create a calculator in the Python programming language": 0.33333333333333326, "Write a script to output 'Hello World' in python": 0.3157894736842105}, "avg_similarity_score": 0.15306265366510508} -{"instruction": "How do you find the largest number in a list using Python?", "input": "", "output": "You can use the max() function to find the largest number in a list using Python. The max() function returns the largest item in an iterable. For example: ``` list = [1, 2, 3, 4, 5] print(max(list)) ``` This will print the following output: ``` 5 ```", "most_similar": {"How do you find the index of an item in a list?": 0.6666666666666666, "How can I find the maximum and minimum value in a list using Python?": 0.6153846153846153, "How do you output all the contents of a list in Python?": 0.5833333333333334, "How do you remove duplicates from a list in Python?": 0.5454545454545454, "How do you sort a list of strings in Python?": 0.5454545454545454, "How do I get the power of a number in python?": 0.5217391304347826, "Write a Python function to find the largest number in a dictionary.": 0.5, "How do you create a new list from two lists in Python by picking one element each?": 0.41379310344827586, "Write a Python function to find the sum of all items in a list.": 0.3846153846153846, "Write a Python program to find the maximum and minimum number from a given list.": 0.3703703703703704}, "avg_similarity_score": 0.18185602038691248} -{"instruction": "Write a Python program to find the first appearance of the substring 'not' and 'poor' from a given string, if 'not' follows the 'poor', replace the whole 'not'...'poor' substring with 'good'. Return the resulting string.", "input": "", "output": "def replace_not_poor(s):\n if 'not' in s and 'poor' in s:\n not_index = s.find('not')\n poor_index = s.find('poor')\n if poor_index > not_index:\n return s.replace(s[not_index:poor_index + 3], 'good')\n return s", "most_similar": {"Write a Python program to find the first repeated character of a given string where the index of first occurrence is smallest.": 0.4482758620689656, "Write a Python program to find the maximum and minimum number from a given list.": 0.43137254901960786, "Write a Python program to find the number of even and odd numbers from a series of numbers.": 0.40740740740740744, "Write a Python program to find the first non-repeated character in a string.": 0.4, "Write a Python program to find the number of strings where the string length is 2 or more and the first and last character are same from a given list of strings.": 0.38235294117647056, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.36, "Write a Python program to find the unique common elements from two lists.": 0.326530612244898, "Write a Python function to find the sum of all items in a list.": 0.32, "Write a C# program to find the sum of all the elements of an array.": 0.3137254901960784, "Write a Python function to find the largest number in a dictionary.": 0.2916666666666667}, "avg_similarity_score": 0.15786657888185154} -{"instruction": "Write a Python program to find the first pythagorean triplet for which a + b + c = 1000.", "input": "", "output": "def pythagorean_triplet(n):\n for a in range(1, n):\n for b in range(a + 1, n):\n c = n - a - b\n if a**2 + b**2 == c**2:\n return a, b, c\n return None", "most_similar": {"Write a Python program to find the sum of the first 1000 prime numbers.": 0.6000000000000001, "Write a Python program to find the first non-repeated character in a string.": 0.6000000000000001, "Write a Python program to find the maximum and minimum number from a given list.": 0.5161290322580646, "Write a Python function to find the largest number in a dictionary.": 0.5, "Write a Python program to find the unique common elements from two lists.": 0.4827586206896552, "Write a Python program to find the first repeated character of a given string where the index of first occurrence is smallest.": 0.47368421052631576, "Write a Python program to find the number of even and odd numbers from a series of numbers.": 0.47058823529411764, "Write a Python function to find the sum of all items in a list.": 0.4666666666666667, "Write a C# program to find the sum of all the elements of an array.": 0.38709677419354843, "Write a Python function to find all prime numbers up to the given number n.": 0.38709677419354843}, "avg_similarity_score": 0.20066303672983915} -{"instruction": "Write a Python program to find the first Fibonacci number greater than four million.", "input": "", "output": "def fibonacci(n):\n a, b = 0, 1\n while b < n:\n a, b = b, a + b\n return a\n\ndef first_fibonacci_greater_than(n):\n i = 1\n while True:\n if fibonacci(i) > n:\n return fibonacci(i)\n i += 1", "most_similar": {"Write a Python program to find the first non-repeated character in a string.": 0.5714285714285714, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.5714285714285714, "Write a Python program to find the maximum and minimum number from a given list.": 0.5517241379310344, "Write a Python function to find the largest number in a dictionary.": 0.5384615384615384, "Write a Python program to find the first pythagorean triplet for which a + b + c = 1000.": 0.5333333333333333, "Write a Python program to find the unique common elements from two lists.": 0.5185185185185186, "Write a Python program to find the number of even and odd numbers from a series of numbers.": 0.5, "Write a Python function to find all prime numbers up to the given number n.": 0.4827586206896552, "Write a Python program to find the first repeated character of a given string where the index of first occurrence is smallest.": 0.4444444444444444, "Write a Python function to find the sum of all items in a list.": 0.42857142857142855}, "avg_similarity_score": 0.19865206543457112} -{"instruction": "What is the output of the following code?\n```\npublic class Test {\n public static void main(String[] args) {\n int i = 1;\n while (i <= 5) {\n System.out.println(i);\n i++;\n }\n }\n}\n```", "input": "", "output": "The output of the code is:\n```\n1\n2\n3\n4\n5\n```", "most_similar": {"Find the bug in the following code piece: a = 1 while a == 1: b = input(\"what's your name ?\") print(\"Hi \",b, \" this is infinity loop !\")": 0.22222222222222224, "The following code I wrote in haskell ```hs factorial(1)=1 factorial(n)=n*(n-1)*factorial(n-2) ``` gives me an error when I try to run it. Is there anything I did wrong?": 0.22222222222222224, "What is the difference between a class and an object?": 0.21052631578947364, "What is the difference between a for loop and a while loop?": 0.2, "Write a function that takes a string and returns the number of vowels in the string.": 0.18181818181818182, "Suggest a completion for the following python code.": 0.16666666666666666, "Translate the following code from python in Java.": 0.16666666666666666, "Solve the following equation system. Give me the final answer.": 0.15789473684210525, "Identify the pos tag of the word in the given sentence.": 0.15384615384615383, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.14285714285714285}, "avg_similarity_score": 0.07915203883821097} -{"instruction": "Write a function that takes a string as input and reverse only the vowels of a string.", "input": "", "output": "def reverseVowels(s):\n vowels = 'aeiouAEIOU'\n s = list(s)\n left, right = 0, len(s) - 1\n while left < right:\n while left < len(s) and s[left] not in vowels:\n left += 1\n while right >= 0 and s[right] not in vowels:\n right -= 1\n if left < right:\n s[left], s[right] = s[right], s[left]\n left += 1\n right -= 1\n return ''.join(s)", "most_similar": {"Write a function that takes a string and returns the number of vowels in the string.": 0.6666666666666667, "Write a Python function that takes two numbers as input and returns their sum.": 0.5161290322580646, "Please write a Rust function that takes a u64 input and returns the largest prime number less than that value.": 0.48648648648648646, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.4736842105263158, "write a c++ program that calculates the perimeter of a square": 0.42857142857142855, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.4117647058823529, "Write a Python function to find the sum of all items in a list.": 0.3870967741935484, "Write a C++ function that takes a map as an input and returns the largest pair in the map, in 8 lines or fewer. A pair is considered larger if its second value is larger than another pair's second value.": 0.3793103448275862, "Write a Python function to reverse a given list of integers.": 0.35714285714285715, "Write a python function that sorts a list from large to small.": 0.3448275862068966}, "avg_similarity_score": 0.1851256147104254} -{"instruction": "What is the difference between a variable that is declared and defined and a variable that is only declared?", "input": "", "output": "A variable that is declared and defined is a variable that has been given a name and a value. A variable that is only declared is a variable that has been given a name but not a value.", "most_similar": {"What is the difference between a for loop and a while loop?": 0.5161290322580646, "What is the difference between a class and an object?": 0.48275862068965514, "Write a function that takes a string as input and reverse only the vowels of a string.": 0.2222222222222222, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.21739130434782608, "Please write a Rust function that takes a u64 input and returns the largest prime number less than that value.": 0.20512820512820512, "write a c++ program that calculates the perimeter of a square": 0.19999999999999998, "Write a Python program to find the number of strings where the string length is 2 or more and the first and last character are same from a given list of strings.": 0.19607843137254902, "Write a python function that sorts a list from large to small.": 0.1935483870967742, "The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. That is,\n\nF(0) = 0, F(1) = 1\nF(n) = F(n - 1) + F(n - 2), for n > 1.\nGiven n, calculate F(n)": 0.18918918918918917, "write a java function that implements gray code and returns the next sequence code after a given code in a given direction of rotation": 0.186046511627907}, "avg_similarity_score": 0.11164212486002745} -{"instruction": "Write a Python program to find the frequency of each word in a given string.", "input": "", "output": "```python def word_frequency(s):\n return {word: s.count(word) for word in set(s)} ```", "most_similar": {"Write a Python program to find the first non-repeated character in a string.": 0.689655172413793, "Write a Python function to find the sum of all items in a list.": 0.6206896551724138, "Write a Python program to find the maximum and minimum number from a given list.": 0.6, "Write a Python program to find the first repeated character of a given string where the index of first occurrence is smallest.": 0.5945945945945945, "Write a Python function to find the largest number in a dictionary.": 0.5925925925925926, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.5517241379310344, "Write a Python program to find the number of even and odd numbers from a series of numbers.": 0.5454545454545454, "Write a Python program to find the first pythagorean triplet for which a + b + c = 1000.": 0.5161290322580646, "Write a Python program to find the unique common elements from two lists.": 0.5, "Write a Python program to find the first Fibonacci number greater than four million.": 0.4827586206896552}, "avg_similarity_score": 0.2469917809735274} -{"instruction": "Given a string s, return the longest palindromic substring in s.", "input": "", "output": "class Solution:\n def longestPalindrome(self, s: str) -> str:\n if len(s) < 2 or s == s[::-1]:\n return s\n start, end = 0, 0\n for i in range(len(s)):\n len1, len2 = self.expand(s, i, i), self.expand(s, i, i+1)\n if len1 > end - start:\n start, end = i - (len1 - 1) // 2, i + len1 // 2\n if len2 > end - start:\n start, end = i - (len2 - 1) // 2, i + len2 // 2\n return s[start: end + 1]\n\n def expand(self, s, left, right):\n while left >= 0 and right < len(s) and s[left] == s[right]:\n left -= 1\n right += 1\n return right - left - 1", "most_similar": {"Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.": 0.6060606060606061, "Given a string `s`, find the length of the longest substring without repeating characters.": 0.56, "Given the `root` of a binary tree, return the inorder traversal of its nodes' values.": 0.30769230769230765, "How do I output a string in C++ programming?": 0.3, "Write a function that takes a string and returns the number of vowels in the string.": 0.2962962962962963, "Write a Python function to find the largest number in a dictionary.": 0.2608695652173913, "Write a Python program to find the first non-repeated character in a string.": 0.23999999999999996, "Write a Python function to find the sum of all items in a list.": 0.23999999999999996, "Implement a Java method to reverse a string without using any built-in functions.": 0.23999999999999996, "write a sum function in asm": 0.23529411764705885}, "avg_similarity_score": 0.14294611223038722} -{"instruction": "What is the difference between a list and a tuple in Python?", "input": "", "output": "A tuple is an immutable sequence of Python objects. A list is a mutable sequence of Python objects.", "most_similar": {"What is the difference between a for loop and a while loop?": 0.6666666666666666, "What is the difference between a class and an object?": 0.6363636363636365, "What is the difference between a variable that is declared and defined and a variable that is only declared?": 0.5161290322580646, "How do you output all the contents of a list in Python?": 0.4166666666666667, "How do you remove duplicates from a list in Python?": 0.3636363636363636, "How do you sort a list of strings in Python?": 0.3636363636363636, "How do I get the power of a number in python?": 0.34782608695652173, "How do you find the largest number in a list using Python?": 0.3333333333333333, "bubble sort list of int in python": 0.3157894736842105, "How can I find the maximum and minimum value in a list using Python?": 0.30769230769230765}, "avg_similarity_score": 0.16907460130040577} -{"instruction": "I have a list of numbers and I want to find the maximum number in the list. How can I do that?", "input": "", "output": "You can use the `max()` function to find the maximum number in a list. For example, the following code will print the maximum number in the list `[1, 2, 3, 4, 5]`: ``` print(max([1, 2, 3, 4, 5])) ```", "most_similar": {"Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.4186046511627907, "Write a Python program to find the maximum and minimum number from a given list.": 0.3783783783783784, "Write a Python function to find the largest number in a dictionary.": 0.3529411764705882, "Write a Python function to find the sum of all items in a list.": 0.33333333333333326, "How can I find the maximum and minimum value in a list using Python?": 0.33333333333333326, "Write a function that takes a string and returns the number of vowels in the string.": 0.3157894736842105, "How do you find the largest number in a list using Python?": 0.29411764705882354, "Write a Python program to find the first non-repeated character in a string.": 0.2777777777777778, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.2777777777777778, "Write a Python program to find the first Fibonacci number greater than four million.": 0.2777777777777778}, "avg_similarity_score": 0.17190526447704182} -{"instruction": "Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. A palindrome string is a string that reads the same backward as forward.", "input": "", "output": "class Solution:\n def partition(self, s: str) -> List[List[str]]:\n res = []\n self.dfs(s, [], res)\n return res\n def dfs(self, s, path, res):\n if not s:\n res.append(path[:])\n return\n for i in range(1, len(s) + 1):\n if self.isPalindrome(s[:i]):\n path.append(s[:i])\n self.dfs(s[i:], path, res)\n path.pop()\n def isPalindrome(self, s):\n return s == s[::-1]", "most_similar": {"Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.4126984126984127, "Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.": 0.3448275862068966, "Given a string `s`, find the length of the longest substring without repeating characters.": 0.28, "Given a string s, return the longest palindromic substring in s.": 0.2553191489361702, "Write a function that takes a string as input and reverse only the vowels of a string.": 0.22641509433962262, "write a c++ program that calculates the perimeter of a square": 0.21276595744680854, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.2105263157894737, "Write a Python program to find the first repeated character of a given string where the index of first occurrence is smallest.": 0.20689655172413793, "Write a Python program to find the number of strings where the string length is 2 or more and the first and last character are same from a given list of strings.": 0.2058823529411765, "Given the `root` of a binary tree, return the inorder traversal of its nodes' values.": 0.19607843137254902}, "avg_similarity_score": 0.11065816380735424} -{"instruction": "Write a python function that returns the sum of the elements of a list.", "input": "", "output": "def sum_of_list(lst):\n return sum(lst)", "most_similar": {"Write a Python function to find the sum of all items in a list.": 0.6428571428571429, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.6285714285714286, "Write a C# program to find the sum of all the elements of an array.": 0.5517241379310344, "Write a python function that sorts a list from large to small.": 0.5384615384615384, "Write a function that takes a string and returns the number of vowels in the string.": 0.5333333333333333, "Write a Python function that takes two numbers as input and returns their sum.": 0.5, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.5, "Write a Python function to reverse a given list of integers.": 0.4799999999999999, "write a c++ program that calculates the perimeter of a square": 0.4799999999999999, "Write a script to output the mean of a list of integers.": 0.4615384615384615}, "avg_similarity_score": 0.23507201666824107} -{"instruction": "How can I get the first 1000 prime numbers in Python?", "input": "", "output": "```python def is_prime(num):\n for i in range(2, num):\n if (num % i) == 0:\n return False\n return True\n\ndef get_primes(n):\n primes = []\n i = 2\n while len(primes) < n:\n if is_prime(i):\n primes.append(i)\n i += 1\n return primes\n\nprint(get_primes(1000)) ```", "most_similar": {"How do I get the power of a number in python?": 0.5454545454545454, "How can I find the maximum and minimum value in a list using Python?": 0.4799999999999999, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.4, "How do you find the largest number in a list using Python?": 0.34782608695652173, "How do you output all the contents of a list in Python?": 0.34782608695652173, "How do I output a string in C++ programming?": 0.3, "How do I incorporate CSS in my HTML page?": 0.3, "How can I iterate through each item in an array in a random order using c++?": 0.2962962962962963, "How do you sort a list of strings in Python?": 0.28571428571428564, "How do you remove duplicates from a list in Python?": 0.28571428571428564}, "avg_similarity_score": 0.13406105171898394} -{"instruction": "Write a Python program to find the sum of a non-negative integer.", "input": "", "output": "```python def sum_num(n):\n return sum(range(n+1)) ```", "most_similar": {"Write a Python program to find the sum of the first 1000 prime numbers.": 0.6666666666666666, "Write a Python function to find the sum of all items in a list.": 0.6666666666666666, "Write a Python program to find the frequency of each word in a given string.": 0.6428571428571429, "Write a Python program to find the first non-repeated character in a string.": 0.5925925925925927, "Write a Python program to find the number of even and odd numbers from a series of numbers.": 0.5806451612903226, "Write a Python program to find the maximum and minimum number from a given list.": 0.5714285714285715, "Write a C# program to find the sum of all the elements of an array.": 0.5714285714285715, "Write a Python function to find the largest number in a dictionary.": 0.5599999999999999, "Write a Python program to find the first pythagorean triplet for which a + b + c = 1000.": 0.5517241379310345, "Write a program to compute the sum of integers from k to n.": 0.5384615384615384}, "avg_similarity_score": 0.239786674613644} -{"instruction": "Write a Python program to find the list of words that are longer than n from a given list of words.", "input": "", "output": "```python def longer_than_n(lst, n):\n return [word for word in lst if len(word) > n] ```", "most_similar": {"Write a Python program to find the maximum and minimum number from a given list.": 0.611111111111111, "Write a Python program to find the number of even and odd numbers from a series of numbers.": 0.5641025641025642, "Write a Python program to find the frequency of each word in a given string.": 0.5555555555555556, "Write a Python program to find the sum of a non-negative integer.": 0.5294117647058824, "Write a Python program to find the number of strings where the string length is 2 or more and the first and last character are same from a given list of strings.": 0.5283018867924528, "Write a Python function to find the sum of all items in a list.": 0.5142857142857143, "Write a Python program to find the first repeated character of a given string where the index of first occurrence is smallest.": 0.5116279069767442, "Write a Python function to reverse a given list of integers.": 0.5, "Write a script to output the mean of a list of integers.": 0.4848484848484849, "Write a Python program to find the unique common elements from two lists.": 0.47058823529411764}, "avg_similarity_score": 0.2174453405822376} -{"instruction": "Write a function that takes a string and returns a new string with the first letter of each word capitalized.", "input": "", "output": "```python def capitalize_first(s):\n return ' '.join(w.capitalize() for w in s.split(' '))\n\nprint(capitalize_first('hello world')) ```", "most_similar": {"Write a function that takes a string and returns the number of vowels in the string.": 0.6111111111111112, "Write a function that takes a string as input and reverse only the vowels of a string.": 0.5405405405405405, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.4878048780487805, "Please write a Rust function that takes a u64 input and returns the largest prime number less than that value.": 0.45, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.4324324324324324, "Write a python function that returns the sum of the elements of a list.": 0.4117647058823529, "Write a Python function that takes two numbers as input and returns their sum.": 0.4117647058823529, "write a java function that implements gray code and returns the next sequence code after a given code in a given direction of rotation": 0.3636363636363636, "Write a Python program to find the frequency of each word in a given string.": 0.34285714285714286, "write a c++ program that calculates the perimeter of a square": 0.3225806451612903}, "avg_similarity_score": 0.1786030021544069} -{"instruction": "How can I get the current date and time in Python?", "input": "", "output": "You can use the datetime module to get the current date and time in Python. The datetime module provides classes for manipulating dates and times. For example, to get the current date and time, you can use the following code: ```import datetime now = datetime.now() print(now) ``` This will print the following output: ``` 2021-01-25 12:34:56.000000 ```", "most_similar": {"How can I get the first 1000 prime numbers in Python?": 0.6363636363636364, "How can I find the maximum and minimum value in a list using Python?": 0.56, "How do I get the power of a number in python?": 0.5454545454545454, "Write a script in JavaScript for printing the current date and time.": 0.43478260869565216, "How do you find the largest number in a list using Python?": 0.34782608695652173, "How do you output all the contents of a list in Python?": 0.34782608695652173, "What is the difference between a list and a tuple in Python?": 0.34782608695652173, "How do I incorporate CSS in my HTML page?": 0.3, "How do I output a string in C++ programming?": 0.3, "How can I iterate through each item in an array in a random order using c++?": 0.2962962962962963}, "avg_similarity_score": 0.1389343791230096} -{"instruction": "What does this python code do? ```python import numpy as np\n\ndef get_random_vector(n):\n return np.random.rand(n)\n\ndef get_random_matrix(n, m):\n return np.random.rand(n, m)\n\ndef get_random_symmetric_matrix(n):\n A = get_random_matrix(n, n)\n return A + A.T\n\ndef get_random_positive_definite_matrix(n):\n A = get_random_symmetric_matrix(n)\n return A.dot(A.T) ```", "input": "", "output": "This code defines four functions that return random vectors and matrices. The first function returns a vector of random numbers. The second function returns a matrix of random numbers. The third function returns a symmetric matrix. The fourth function returns a positive definite matrix.", "most_similar": {"What does this Python code do? ``` import random def montecarloPi(calcs): hits = 0 for i in range(calcs): x = random.random() y = random.random() if (x**2 + y**2) < 1: hits = hits + 1 return 4.0 * hits / calcs print(montecarloPi(10000)) ```": 0.25925925925925924, "I have the following python function: ```python def resize_images(images, res_x, res_y): resized_images = np.zeros((images.shape[0], res_x, res_y)) for n in range(len(images)): resized_images[n, :, :] = resize(images[n, :, :], resized_images.shape[1:], anti_aliasing=False) return resized_images ``` What does the function do?": 0.13333333333333333, "The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. That is,\n\nF(0) = 0, F(1) = 1\nF(n) = F(n - 1) + F(n - 2), for n > 1.\nGiven n, calculate F(n)": 0.11475409836065573, "def _process(self, data): X = data[1] + \" \" + data[2] Y = pd.get_dummies(data[0], prefix=\"y\").astype(np.float32) return X, Y, len(data) I have a bug `Failed to convert a NumPy array to a Tensor (Unsupported object type float).`. Can you show me where is the problem and how to fix it?": 0.11475409836065573, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.10638297872340424, "The following code I wrote in haskell ```hs factorial(1)=1 factorial(n)=n*(n-1)*factorial(n-2) ``` gives me an error when I try to run it. Is there anything I did wrong?": 0.0980392156862745, "Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. A palindrome string is a string that reads the same backward as forward.": 0.0970873786407767, "Help me to optimize this code: doe = DistanceOnEarth() def get_mdr_distance(row): route_geom = shapely.wkt.loads(row.provider_route) route_points = route_geom.coords[:] mdr_points = [] mdr_distance = 0 for points in split_list(route_points): point_1, point_2 = points line = shapely.geometry.LineString(points) is_mdr = ( requests.post( MDR_URL, data=line.wkt, headers={\"accept\": \"*/*\", \"Content-Type\": \"text/plain\"}, ).content == b\"true\" ) if is_mdr: mdr_points.extend(points) else: if len(mdr_points) > 0: mdr_points.extend([point_1]) mdr_distance += doe.get_4326_geometry_length_in_m(shapely.LineString(mdr_points)) mdr_points = [] if len(mdr_points) > 0: mdr_distance += doe.get_4326_geometry_length_in_m(shapely.LineString(mdr_points)) return mdr_distance": 0.0855614973262032, "Write a Python program that takes a list of numbers as input from the user, calculates the sum of all even numbers in the list, and returns the result. The program should check if the input is valid (i.e., if it's a list of numbers), and if it's not, it should return an error message. The program should also handle exceptions gracefully and return a user-friendly error message in case of any exceptions.": 0.08333333333333333, "Python code for a rotating square": 0.0821917808219178}, "avg_similarity_score": 0.046018405084068854} -{"instruction": "Write a Python program to find the most common words in a given text.", "input": "", "output": "import re\n\ndef most_common_words(s):\n d = {}\n for word in re.findall(r'\\w+', s):\n if word not in d:\n d[word] = 1\n else:\n d[word] += 1\n return sorted(d.items(), key=lambda x: x[1], reverse=True)", "most_similar": {"Write a Python program to find the frequency of each word in a given string.": 0.689655172413793, "Write a Python program to find the first non-repeated character in a string.": 0.6428571428571429, "Write a Python program to find the maximum and minimum number from a given list.": 0.6206896551724138, "Write a Python function to find the largest number in a dictionary.": 0.6153846153846153, "Write a Python program to find the unique common elements from two lists.": 0.5925925925925927, "Write a Python program to find the sum of a non-negative integer.": 0.5925925925925927, "Write a Python program to find the list of words that are longer than n from a given list of words.": 0.5714285714285714, "Write a Python function to find the sum of all items in a list.": 0.5714285714285714, "Write a Python program to find the first pythagorean triplet for which a + b + c = 1000.": 0.5333333333333333, "Write a Python program to find the first repeated character of a given string where the index of first occurrence is smallest.": 0.5000000000000001}, "avg_similarity_score": 0.23968095187224436} -{"instruction": "Write a Python program to find the longest common prefix of a given list of strings.", "input": "", "output": "def longest_common_prefix(lst):\n if not lst:\n return ''\n prefix = lst[0]\n for s in lst:\n for i in range(len(prefix)):\n if i >= len(s) or prefix[i] != s[i]:\n prefix = prefix[:i]\n break\n return prefix", "most_similar": {"Write a Python program to find the most common words in a given text.": 0.6666666666666666, "Write a Python program to find the list of words that are longer than n from a given list of words.": 0.6486486486486486, "Write a Python program to find the maximum and minimum number from a given list.": 0.6451612903225806, "Write a Python program to find the frequency of each word in a given string.": 0.6451612903225806, "Write a Python program to find the sum of a non-negative integer.": 0.6206896551724138, "Write a Python function to find the sum of all items in a list.": 0.6000000000000001, "Write a Python function to reverse a given list of integers.": 0.5925925925925926, "Write a Python program to find the number of even and odd numbers from a series of numbers.": 0.5882352941176471, "Write a Python program to find the first repeated character of a given string where the index of first occurrence is smallest.": 0.5789473684210527, "Write a script to output the mean of a list of integers.": 0.5714285714285715}, "avg_similarity_score": 0.2401556504333324} -{"instruction": "How do you find the length of a string in Python?", "input": "", "output": "You can use the **len()** function to find the length of a string in Python. For example: ``` my_string = \"Hello World\" print(len(my_string)) # 11 ```", "most_similar": {"How do you output all the contents of a list in Python?": 0.6956521739130435, "How do I get the power of a number in python?": 0.6363636363636364, "How do you find the largest number in a list using Python?": 0.6086956521739131, "How do you find the index of an item in a list?": 0.6086956521739131, "How do you remove duplicates from a list in Python?": 0.5714285714285713, "How do you sort a list of strings in Python?": 0.5714285714285713, "How do I output a string in C++ programming?": 0.5, "How do you create a new list from two lists in Python by picking one element each?": 0.42857142857142855, "How can I find the maximum and minimum value in a list using Python?": 0.4, "Write a Python program to find the frequency of each word in a given string.": 0.3846153846153846}, "avg_similarity_score": 0.20720080174789515} -{"instruction": "How do you find the standard deviation of all items in a list in Python?", "input": "", "output": "You can use the statistics module to find the standard deviation of all items in a list in Python. The statistics module provides functions for calculating mathematical statistics of numeric data. For example: ``` import statistics list = [1, 2, 3, 4, 5] standard_deviation = statistics.stdev(list) print(standard_deviation) ``` This will print the following output: ``` 1.4142135623730951 ```", "most_similar": {"How do you find the length of a string in Python?": 0.6923076923076923, "How do you find the largest number in a list using Python?": 0.6666666666666665, "How do you find the index of an item in a list?": 0.6666666666666665, "How do you output all the contents of a list in Python?": 0.6666666666666665, "How do you sort a list of strings in Python?": 0.56, "How do you remove duplicates from a list in Python?": 0.56, "Write a Python function to find the sum of all items in a list.": 0.5517241379310344, "How do I get the power of a number in python?": 0.5384615384615385, "How can I find the maximum and minimum value in a list using Python?": 0.4827586206896552, "How do you create a new list from two lists in Python by picking one element each?": 0.43749999999999994}, "avg_similarity_score": 0.1966291660738128} -{"instruction": "Write a program to find the sum of all the multiples of 3 or 5 below 1000.", "input": "", "output": "```python def sum_of_multiples(n):\n sum = 0\n for i in range(n):\n if i % 3 == 0 or i % 5 == 0:\n sum += i\n return sum\nprint(sum_of_multiples(1000)) ```", "most_similar": {"Write a C# program to find the sum of all the elements of an array.": 0.6875, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.6451612903225806, "Write a Python program to find the sum of a non-negative integer.": 0.5333333333333333, "Write a Python function to find the sum of all items in a list.": 0.5161290322580646, "Write a Python program to find the longest common prefix of a given list of strings.": 0.48484848484848486, "Write a program to compute the sum of integers from k to n.": 0.4666666666666667, "Write a Python program to find the first repeated character of a given string where the index of first occurrence is smallest.": 0.46153846153846156, "Write a Python program to find the number of even and odd numbers from a series of numbers.": 0.45714285714285713, "Write a python function that returns the sum of the elements of a list.": 0.45161290322580644, "Write a Python program to find the frequency of each word in a given string.": 0.43749999999999994}, "avg_similarity_score": 0.20352141381951974} -{"instruction": "Add comments in the given function to make the code more readable for humans.\ndef hill_climbing(initial_board):\n current = initial_board\n while current.has_successors():\n neighbour = Board(current.get_random_successor(), \"best\")\n if neighbour.value() >= current.value():\n return current\n current = neighbour\n return current", "input": "", "output": "def hill_climbing(initial_board):\n\"\"\" Hill Climbing Algorithm.\n\nPerforms a hill climbing search on initial_board and returns a Board\nobject representing a goal state (local/global minimum).\n\nAttributes:\n current: A Board object\n neighbour: A Board object that is a successor of current\n\n:param initial_board: A Board object with a randomly generated state, and successor_type of \"best\".\n i.e. a start state\n:return: A Board object that has no further successors. i.e. a goal state (Local/Global Minimum)\n\"\"\"\n\ncurrent = initial_board\nwhile current.has_successors():\n neighbour = Board(current.get_random_successor(), \"best\")\n if neighbour.value() >= current.value():\n return current\n current = neighbour\nreturn current", "most_similar": {"Add comments in the given function to make the code more readable for humans.": 0.4827586206896552, "Using the comment as a guide, replace the \"TODO\" comment in the code with the proper code.": 0.13114754098360656, "write a code to get the current value of a Bitcoin in US dollars using the bitcoincharts API.": 0.1290322580645161, "What does this Python code do? ``` import random def montecarloPi(calcs): hits = 0 for i in range(calcs): x = random.random() y = random.random() if (x**2 + y**2) < 1: hits = hits + 1 return 4.0 * hits / calcs print(montecarloPi(10000)) ```": 0.1176470588235294, "Write a C++ function that takes a map as an input and returns the largest pair in the map, in 8 lines or fewer. A pair is considered larger if its second value is larger than another pair's second value.": 0.1176470588235294, "Replace the token in the text with proper words that are consistent with the context. You can use multiple words for each token.": 0.11594202898550725, "Find the bug in the following code piece: a = 1 while a == 1: b = input(\"what's your name ?\") print(\"Hi \",b, \" this is infinity loop !\")": 0.1142857142857143, "What is the output of the following code?\n```\npublic class Test {\n public static void main(String[] args) {\n int i = 1;\n while (i <= 5) {\n System.out.println(i);\n i++;\n }\n }\n}\n```": 0.1111111111111111, "Identify the pos tag of the word in the given sentence.": 0.10909090909090909, "What does this python code do? ```python import numpy as np\n\ndef get_random_vector(n):\n return np.random.rand(n)\n\ndef get_random_matrix(n, m):\n return np.random.rand(n, m)\n\ndef get_random_symmetric_matrix(n):\n A = get_random_matrix(n, n)\n return A + A.T\n\ndef get_random_positive_definite_matrix(n):\n A = get_random_symmetric_matrix(n)\n return A.dot(A.T) ```": 0.1081081081081081}, "avg_similarity_score": 0.06690590345593213} -{"instruction": "Translate the following code from python in Java.\ndef function(a : int, b : int, c : int):\n if a > b :\n print('You lost.')\n else :\n if c > a :\n print('Nice try.')\n else :\n print('You won.')", "input": "", "output": "public static void function(int a, int b, int c) {\n if (a > b) {\n System.out.println('You lost.');\n } else {\n if (c > a) {\n System.out.println('Nice try.');\n } else {\n System.out.println('You won.');\n }\n }\n}", "most_similar": {"Translate the following code from python in Java.": 0.3902439024390244, "Find the bug in the following code piece: a = 1 while a == 1: b = input(\"what's your name ?\") print(\"Hi \",b, \" this is infinity loop !\")": 0.23728813559322037, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.16666666666666666, "Fill in the in the html document with a propoer text. You should take the html tag into consideration. You output should be the completed html document.": 0.16393442622950818, "Write a Python program to find the first pythagorean triplet for which a + b + c = 1000.": 0.163265306122449, "The following code I wrote in haskell ```hs factorial(1)=1 factorial(n)=n*(n-1)*factorial(n-2) ``` gives me an error when I try to run it. Is there anything I did wrong?": 0.14705882352941174, "Suggest a completion for the following python code.": 0.14634146341463414, "write a java function that implements gray code and returns the next sequence code after a given code in a given direction of rotation": 0.14035087719298245, "write a c++ program that calculates the perimeter of a square": 0.13636363636363635, "Write a Python function to reverse a given list of integers.": 0.13636363636363635}, "avg_similarity_score": 0.0943146815814689} -{"instruction": "Identify the pos tag of the word in the given sentence.\nWord: excited\nSentence: She felt so excited that her application got approval.", "input": "", "output": "Adjective, JJ.", "most_similar": {"Identify the pos tag of the word in the given sentence.": 0.6470588235294118, "Write a Python program to find the frequency of each word in a given string.": 0.26315789473684204, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.22727272727272724, "I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.22222222222222224, "Write a function that takes a string and returns the number of vowels in the string.": 0.20512820512820512, "Using the comment as a guide, replace the \"TODO\" comment in the code with the proper code.": 0.19999999999999998, "write a code to get the current value of a Bitcoin in US dollars using the bitcoincharts API.": 0.1951219512195122, "Replace all the human names in the paragraph with .": 0.18181818181818182, "Write a Python program to find the number of strings where the string length is 2 or more and the first and last character are same from a given list of strings.": 0.18181818181818182, "Can you provide a shell script that displays the total number of lines in all '*.txt' files in the current directory?": 0.1818181818181818}, "avg_similarity_score": 0.10079770718289667} -{"instruction": "Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product.", "input": "", "output": "```python def maxProduct(nums: List[int]) -> int:\n max_product = nums[0]\n current_product = 1\n for num in nums:\n current_product = max(num, current_product * num)\n max_product = max(max_product, current_product)\n return max_product\n\nprint(maxProduct([2,3,-2,4])) ```", "most_similar": {"Given an integer array nums, find the subarray with the largest sum, and return its sum.": 0.5263157894736842, "Given a string `s`, find the length of the longest substring without repeating characters.": 0.2222222222222222, "Write a C# program to find the sum of all the elements of an array.": 0.21621621621621623, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.20512820512820512, "Given an array of integers `nums` and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order.": 0.19178082191780824, "I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.18181818181818182, "Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.": 0.18181818181818182, "Write a Python function to find the largest number in a dictionary.": 0.1764705882352941, "How do you find the largest number in a list using Python?": 0.1764705882352941, "How do you find the index of an item in a list?": 0.1764705882352941}, "avg_similarity_score": 0.08143203776799715} -{"instruction": "Write a program to find the smallest number in a list.", "input": "", "output": "def smallest_number(list):\n return min(list)", "most_similar": {"Write a Python function to find the largest number in a dictionary.": 0.6956521739130435, "Write a Python program to find the maximum and minimum number from a given list.": 0.6923076923076923, "Write a Python program to find the most common words in a given text.": 0.64, "Write a Python program to find the first non-repeated character in a string.": 0.64, "Write a Python function to find the sum of all items in a list.": 0.64, "Write a Python program to find the frequency of each word in a given string.": 0.6153846153846153, "Write a Python program to find the longest common prefix of a given list of strings.": 0.5925925925925926, "Write a Python program to find the sum of a non-negative integer.": 0.5833333333333334, "Write a Python program to find the first Fibonacci number greater than four million.": 0.56, "Write a Python program to find the number of even and odd numbers from a series of numbers.": 0.5517241379310345}, "avg_similarity_score": 0.25901826944722084} -{"instruction": "How to get the last element of a list in Python?", "input": "", "output": "You can use the index -1 to get the last element of a list. For example, if you have a list called my_list, you can get the last element by doing my_list[-1].", "most_similar": {"How do I get the power of a number in python?": 0.6363636363636364, "How do you output all the contents of a list in Python?": 0.6086956521739131, "How do you find the length of a string in Python?": 0.5454545454545454, "How do you find the standard deviation of all items in a list in Python?": 0.5384615384615385, "How do you sort a list of strings in Python?": 0.47619047619047616, "How do you remove duplicates from a list in Python?": 0.47619047619047616, "How can I get the current date and time in Python?": 0.45454545454545453, "How can I get the first 1000 prime numbers in Python?": 0.45454545454545453, "How do you find the index of an item in a list?": 0.43478260869565216, "How do you find the largest number in a list using Python?": 0.43478260869565216}, "avg_similarity_score": 0.20758918361808512} -{"instruction": "Write a Python function to find the correlation between two lists.", "input": "", "output": "def correlation_list(numbers1, numbers2):\n numbers1.sort()\n numbers2.sort()\n mean1 = sum(numbers1) / len(numbers1)\n mean2 = sum(numbers2) / len(numbers2)\n return sum((numbers1[i] - mean1) * (numbers2[i] - mean2) for i in range(len(numbers1))) / (len(numbers1) - 1)", "most_similar": {"Write me a function in C++ to find the distance between two points": 0.6666666666666667, "Write a Python program to find the unique common elements from two lists.": 0.6666666666666667, "Write a Python function to find the largest number in a dictionary.": 0.6086956521739131, "Write a Python function to find the sum of all items in a list.": 0.56, "Write a Python function to find all prime numbers up to the given number n.": 0.5384615384615385, "Write a Python program to find the sum of a non-negative integer.": 0.4999999999999999, "Write a Python program to find the first non-repeated character in a string.": 0.4799999999999999, "Write a Python program to find the most common words in a given text.": 0.4799999999999999, "Write a Python program to find the first Fibonacci number greater than four million.": 0.4799999999999999, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.4799999999999999}, "avg_similarity_score": 0.22037288257307905} -{"instruction": "Write a Python function that takes a list and returns a new list with unique elements of the first list.", "input": "", "output": "def unique_list(l):\n return list(set(l))", "most_similar": {"Write a function that takes a string and returns a new string with the first letter of each word capitalized.": 0.65, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.6341463414634146, "Write a function that takes a string and returns the number of vowels in the string.": 0.5555555555555556, "Write a python function that returns the sum of the elements of a list.": 0.5294117647058824, "Write a Python function that takes two numbers as input and returns their sum.": 0.47058823529411764, "Write a Python function to reverse a given list of integers.": 0.45161290322580644, "Please write a Rust function that takes a u64 input and returns the largest prime number less than that value.": 0.45, "Write a python function that sorts a list from large to small.": 0.4375, "Write a function that takes a string as input and reverse only the vowels of a string.": 0.4324324324324324, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.37837837837837834}, "avg_similarity_score": 0.19346409647704305} -{"instruction": "How can I get the number of days between two dates in python?", "input": "", "output": "You can use the `datetime` module to get the number of days between two dates. Here's an example: ```py from datetime import date # Create two date objects d1 = date(2020, 1, 1) d2 = date(2020, 1, 10) # Get the difference between the two dates diff = d2 - d1 print(diff.days) ``` This will output: `9`", "most_similar": {"How can I get the first 1000 prime numbers in Python?": 0.5833333333333334, "How do I get the power of a number in python?": 0.5833333333333334, "How can I get the current date and time in Python?": 0.5833333333333334, "How to get the last element of a list in Python?": 0.4999999999999999, "How can I find the maximum and minimum value in a list using Python?": 0.4444444444444445, "How do you find the length of a string in Python?": 0.41666666666666663, "How do you output all the contents of a list in Python?": 0.4, "How do you find the largest number in a list using Python?": 0.4, "How do you find the standard deviation of all items in a list in Python?": 0.3571428571428571, "How do you sort a list of strings in Python?": 0.34782608695652173}, "avg_similarity_score": 0.15663787349648858} -{"instruction": "What is the difference between a static and a dynamic method?", "input": "", "output": "A static method is a method that is called on a class, rather than on an instance of a class. A dynamic method is a method that is called on an instance of a class. For example: ```java public class MyClass { public static void myStaticMethod() { System.out.println(\"Hello from myStaticMethod\"); } public void myDynamicMethod() { System.out.println(\"Hello from myDynamicMethod\"); } } ``` You can call the static method like this: ```java MyClass.myStaticMethod(); ``` You can call the dynamic method like this: ```java MyClass myInstance = new MyClass(); myInstance.myDynamicMethod(); ```", "most_similar": {"What is the difference between a list and a tuple in Python?": 0.6956521739130435, "What is the difference between a for loop and a while loop?": 0.6956521739130435, "What is the difference between a class and an object?": 0.6666666666666666, "What is the difference between a variable that is declared and defined and a variable that is only declared?": 0.5333333333333333, "What is Kubernetes ?": 0.28571428571428575, "How can I find the maximum and minimum value in a list using Python?": 0.23999999999999996, "Write a Python program to find the maximum and minimum number from a given list.": 0.23076923076923075, "Write a function that takes a string as input and reverse only the vowels of a string.": 0.21428571428571427, "Write a Python program to find the number of even and odd numbers from a series of numbers.": 0.20689655172413793, "What is the output of the following code?\n```\npublic class Test {\n public static void main(String[] args) {\n int i = 1;\n while (i <= 5) {\n System.out.println(i);\n i++;\n }\n }\n}\n```": 0.2051282051282051}, "avg_similarity_score": 0.13361654897560082} -{"instruction": "Write a Python function to check if a given number is a prime number or not.", "input": "", "output": "def is_prime(num):\n if num > 1:\n for i in range(2,num):\n if (num % i) == 0:\n return False\n return True", "most_similar": {"Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.6046511627906976, "How to check quickly if a number is prime in C?": 0.5185185185185185, "Write a Python function to reverse a given list of integers.": 0.5185185185185185, "Write a Python function to find the largest number in a dictionary.": 0.5, "Write a Python function to find all prime numbers up to the given number n.": 0.45161290322580644, "Write a Python function to find the sum of all items in a list.": 0.39999999999999997, "Write a Python program to find the most common words in a given text.": 0.39999999999999997, "Write a Python program to find the maximum and minimum number from a given list.": 0.38709677419354843, "Write a Python program to find the frequency of each word in a given string.": 0.38709677419354843, "Write a Python program to find the longest common prefix of a given list of strings.": 0.375}, "avg_similarity_score": 0.18631336424169942} -{"instruction": "Write a python script that prints the following pattern:\n```\n*\n**\n***\n****\n*****\n```", "input": "", "output": "for i in range(1, 6): print(\"*\" * i)", "most_similar": {"Write a python script that runs shellscript.sh every 60 minutes": 0.5, "Write a simple C++ program that prints \"Hello, World!\".": 0.4444444444444444, "Write a simple C# program that prints \"Hello, World!\".": 0.4444444444444444, "Write a python function that returns the sum of the elements of a list.": 0.43478260869565216, "Generate a correct python program to fulfill the following purpose:": 0.4210526315789474, "write a c++ program that calculates the perimeter of a square": 0.39999999999999997, "Write a Python function to find the correlation between two lists.": 0.39999999999999997, "Write a script in JavaScript for printing the current date and time.": 0.380952380952381, "Write a Python function to find the largest number in a dictionary.": 0.380952380952381, "Write a script to output the mean of a list of integers.": 0.380952380952381}, "avg_similarity_score": 0.20233019446628078} -{"instruction": "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]", "input": "", "output": "def max_list(list):\n max = list[0]\n for i in list:\n if i > max:\n max = i\n return max\n\nprint(max_list([1, 2, 3, 4, 5]))", "most_similar": {"Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.6341463414634146, "Write a function that takes a string and returns the number of vowels in the string.": 0.5555555555555556, "Write a Python function that takes a list and returns a new list with unique elements of the first list.": 0.55, "Please write a Rust function that takes a u64 input and returns the largest prime number less than that value.": 0.55, "Write a Python function that takes two numbers as input and returns their sum.": 0.5294117647058824, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.48648648648648646, "Write a Python function to reverse a given list of integers.": 0.45161290322580644, "Write a function that takes a string and returns a new string with the first letter of each word capitalized.": 0.45, "Write a python function that sorts a list from large to small.": 0.4375, "Write a Python function to find the largest number in a dictionary.": 0.4375}, "avg_similarity_score": 0.19658550463905614} -{"instruction": "Write a Python function that takes a string as input and returns the string in reverse order.\n'Hello'", "input": "", "output": "def reverse_string(string):\n return string[::-1]\n\nprint(reverse_string('Hello'))", "most_similar": {"Write a function that takes a string as input and reverse only the vowels of a string.": 0.6857142857142857, "Write a function that takes a string and returns the number of vowels in the string.": 0.6470588235294118, "Write a Python function that takes two numbers as input and returns their sum.": 0.6250000000000001, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.5641025641025642, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.5263157894736842, "Write a function that takes a string and returns a new string with the first letter of each word capitalized.": 0.5263157894736842, "Please write a Rust function that takes a u64 input and returns the largest prime number less than that value.": 0.5263157894736842, "Write a Python function that takes a list and returns a new list with unique elements of the first list.": 0.5263157894736842, "Write a python function that returns the sum of the elements of a list.": 0.43750000000000006, "Write a C++ function that takes a map as an input and returns the largest pair in the map, in 8 lines or fewer. A pair is considered larger if its second value is larger than another pair's second value.": 0.4067796610169492}, "avg_similarity_score": 0.20788831585038028} -{"instruction": "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]", "input": "", "output": "def mode_list(list):\n max_count = 0\n mode = None\n for element in list:\n count = 0\n for e in list:\n if e == element:\n count += 1\n if count > max_count:\n max_count = count\n mode = element\n return mode\n\nprint(mode_list([1, 2, 3, 4, 3]))", "most_similar": {"Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.6956521739130435, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.6666666666666665, "Write a Python function that takes a string as input and returns the string in reverse order.\n'Hello'": 0.6046511627906976, "Write a function that takes a string and returns the number of vowels in the string.": 0.5853658536585366, "Write a Python function that takes a list and returns a new list with unique elements of the first list.": 0.5777777777777778, "Write a python function that returns the sum of the elements of a list.": 0.5641025641025641, "Write a function that takes a string as input and reverse only the vowels of a string.": 0.5238095238095238, "Write a Python function that takes two numbers as input and returns their sum.": 0.5128205128205129, "Please write a Rust function that takes a u64 input and returns the largest prime number less than that value.": 0.4444444444444445, "Write a function that takes a string and returns a new string with the first letter of each word capitalized.": 0.4444444444444445}, "avg_similarity_score": 0.2095514604044808} -{"instruction": "Write a Python function to find the smallest number from a sequence of numbers.", "input": "", "output": "def smallest_number(numbers):\n smallest_number = numbers[0]\n for number in numbers:\n if number < smallest_number:\n smallest_number = number\n return smallest_number", "most_similar": {"Write a Python function to find the largest number in a dictionary.": 0.6923076923076924, "Write a Python program to find the number of even and odd numbers from a series of numbers.": 0.6875000000000001, "Write a program to find the smallest number in a list.": 0.64, "Write a Python program to find the maximum and minimum number from a given list.": 0.6206896551724138, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.5714285714285714, "Write a Python function to find the sum of all items in a list.": 0.5714285714285714, "Write a Python function to find the correlation between two lists.": 0.56, "Write a Python function to reverse a given list of integers.": 0.56, "Write a Python function to find all prime numbers up to the given number n.": 0.5517241379310344, "Write a Python program to find the longest common prefix of a given list of strings.": 0.5333333333333333}, "avg_similarity_score": 0.24989526686540678} -{"instruction": "How to find the sum of all the elements in a list in python?", "input": "", "output": "You can use the sum() function to find the sum of all the elements in a list in python. The sum() function takes an iterable as an argument and returns the sum of all the elements in the iterable. For example, you can use the following code to find the sum of all the elements in a list: ```my_list = [1, 2, 3, 4, 5] print(sum(my_list)) ``` This will print the following output: ``` 15 ```", "most_similar": {"How do you find the standard deviation of all items in a list in Python?": 0.689655172413793, "Write a Python function to find the sum of all items in a list.": 0.6428571428571429, "How to get the last element of a list in Python?": 0.64, "How do you find the length of a string in Python?": 0.56, "Write a C# program to find the sum of all the elements of an array.": 0.5517241379310344, "How do you find the largest number in a list using Python?": 0.5384615384615384, "How do you output all the contents of a list in Python?": 0.5384615384615384, "How do you find the index of an item in a list?": 0.5384615384615384, "Write a python function that returns the sum of the elements of a list.": 0.5, "How can I find the maximum and minimum value in a list using Python?": 0.5}, "avg_similarity_score": 0.23101087067502332} -{"instruction": "How to make a python program that will print the following pattern?\n```\n*\n**\n***\n****\n*****\n```", "input": "", "output": "Here's a Python program that prints the pattern: ```py for i in range(1, 6): print('*' * i) ``` Here's an example usage: ```py for i in range(1, 6): print('*' * i) ``` This will output: ``` *\n**\n***\n****\n***** ```", "most_similar": {"Write a python script that prints the following pattern:\n```\n*\n**\n***\n****\n*****\n```": 0.5714285714285715, "Generate a correct python program to fulfill the following purpose:": 0.45454545454545453, "write a c++ program that calculates the perimeter of a square": 0.34782608695652173, "How to get the last element of a list in Python?": 0.34782608695652173, "Write a Python program to find the unique common elements from two lists.": 0.32, "Write a Python program to find the sum of a non-negative integer.": 0.32, "Write a Python program to find the first Fibonacci number greater than four million.": 0.30769230769230765, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.30769230769230765, "Write a python function that returns the sum of the elements of a list.": 0.30769230769230765, "Write a Python program to find the most common words in a given text.": 0.30769230769230765}, "avg_similarity_score": 0.1832179541135541} -{"instruction": "How do I find the first and last occurrence of a substring in a string in C++?", "input": "", "output": "You can use the find_first_of and find_last_of methods to find the first and last occurrence of a substring in a string in C++. For example: ``` #include #include using namespace std; int main() { string str = \"Hello World\"; string sub = \"l\"; int first = str.find_first_of(sub); int last = str.find_last_of(sub); cout << \"First occurrence of substring \" << sub << \" in \" << str << \" is at index \" << first << endl; cout << \"Last occurrence of substring \" << sub << \" in \" << str << \" is at index \" << last << endl; return 0; } ``` This will print the following output: ``` First occurrence of substring l in Hello World is at index 2 Last occurrence of substring l in Hello World is at index 9 ```", "most_similar": {"How do you find the length of a string in Python?": 0.5714285714285714, "How do I output a string in C++ programming?": 0.5384615384615384, "How do I get the power of a number in python?": 0.5, "How do you find the standard deviation of all items in a list in Python?": 0.5, "How do you find the index of an item in a list?": 0.4827586206896552, "How to find the sum of all the elements in a list in python?": 0.45161290322580644, "How can I find the maximum and minimum value in a list using Python?": 0.45161290322580644, "How to get the last element of a list in Python?": 0.42857142857142855, "How do you output all the contents of a list in Python?": 0.41379310344827586, "How do you find the largest number in a list using Python?": 0.41379310344827586}, "avg_similarity_score": 0.18497747793763405} -{"instruction": "You need to read a code and detect if there is a syntax error or not. Outpus true if there is error, output false if there is not.\ndef quick_sort(arr):\n if len(arr) < 2:\n return arr\n else:\n pivot = arr[0]\n less = [i for i in arr[1:] if i <= pivot]\n greater = [i for i in arr[1:] if i > pivot]\n return quick_sort(less) + [pivot] + quick_sort(greater)", "input": "", "output": "false", "most_similar": {"You need to read a code and detect if there is a syntax error or not. Outpus true if there is error, output false if there is not.": 0.5714285714285715, "What does this Python code do? ``` import random def montecarloPi(calcs): hits = 0 for i in range(calcs): x = random.random() y = random.random() if (x**2 + y**2) < 1: hits = hits + 1 return 4.0 * hits / calcs print(montecarloPi(10000)) ```": 0.16216216216216217, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.14432989690721648, "What is the output of the following code?\n```\npublic class Test {\n public static void main(String[] args) {\n int i = 1;\n while (i <= 5) {\n System.out.println(i);\n i++;\n }\n }\n}\n```": 0.14285714285714288, "Write a Python function to check if a given number is a prime number or not.": 0.1395348837209302, "Help me to optimize this code: doe = DistanceOnEarth() def get_mdr_distance(row): route_geom = shapely.wkt.loads(row.provider_route) route_points = route_geom.coords[:] mdr_points = [] mdr_distance = 0 for points in split_list(route_points): point_1, point_2 = points line = shapely.geometry.LineString(points) is_mdr = ( requests.post( MDR_URL, data=line.wkt, headers={\"accept\": \"*/*\", \"Content-Type\": \"text/plain\"}, ).content == b\"true\" ) if is_mdr: mdr_points.extend(points) else: if len(mdr_points) > 0: mdr_points.extend([point_1]) mdr_distance += doe.get_4326_geometry_length_in_m(shapely.LineString(mdr_points)) mdr_points = [] if len(mdr_points) > 0: mdr_distance += doe.get_4326_geometry_length_in_m(shapely.LineString(mdr_points)) return mdr_distance": 0.1368421052631579, "How to check quickly if a number is prime in C?": 0.12345679012345678, "Write a Python program that takes a list of numbers as input from the user, calculates the sum of all even numbers in the list, and returns the result. The program should check if the input is valid (i.e., if it's a list of numbers), and if it's not, it should return an error message. The program should also handle exceptions gracefully and return a user-friendly error message in case of any exceptions.": 0.12244897959183673, "The following code I wrote in haskell ```hs factorial(1)=1 factorial(n)=n*(n-1)*factorial(n-2) ``` gives me an error when I try to run it. Is there anything I did wrong?": 0.11428571428571431, "Write a Python program to find the first appearance of the substring 'not' and 'poor' from a given string, if 'not' follows the 'poor', replace the whole 'not'...'poor' substring with 'good'. Return the resulting string.": 0.11320754716981132}, "avg_similarity_score": 0.06264476888585524} -{"instruction": "Write a Python function to find the maximum sum of a contiguous subsequence from a list of integers.", "input": "", "output": "def max_sum(lst):\n return max(sum(lst))", "most_similar": {"Write a Python function to find the sum of all items in a list.": 0.6875000000000001, "Write a Python function to find the smallest number from a sequence of numbers.": 0.6250000000000001, "Write a Python function to reverse a given list of integers.": 0.6206896551724137, "Write a Python program to find the maximum and minimum number from a given list.": 0.606060606060606, "Write a script to output the mean of a list of integers.": 0.6, "Write a Python program to find the longest common prefix of a given list of strings.": 0.5882352941176471, "Write a Python program to find the sum of a non-negative integer.": 0.5806451612903226, "Write a Python program to find the list of words that are longer than n from a given list of words.": 0.5641025641025642, "Write a python function that returns the sum of the elements of a list.": 0.5625000000000001, "Write a Python program to find the number of even and odd numbers from a series of numbers.": 0.5555555555555556}, "avg_similarity_score": 0.2470181024505361} -{"instruction": "Write a function that takes in a string of one or more words, and returns the same string, but with all five or more letter words reversed (Just like the name of this Kata). Strings passed in will consist of only letters and spaces. Spaces will be included only when more than one word is present.", "input": "", "output": "def solution(s):\n return ' '.join(word[::-1] if len(word) >= 5 else word for word in s.split(' '))", "most_similar": {"Write a function that takes a string and returns a new string with the first letter of each word capitalized.": 0.3684210526315789, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.33766233766233766, "Write a function that takes a string and returns the number of vowels in the string.": 0.3333333333333333, "Write a Python function that takes a string as input and returns the string in reverse order.\n'Hello'": 0.3243243243243243, "Write a function that takes a string as input and reverse only the vowels of a string.": 0.273972602739726, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.2716049382716049, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.2631578947368421, "Write a Python function that takes a list and returns a new list with unique elements of the first list.": 0.2631578947368421, "Please write a Rust function that takes a u64 input and returns the largest prime number less than that value.": 0.2631578947368421, "Write a C++ function that takes a map as an input and returns the largest pair in the map, in 8 lines or fewer. A pair is considered larger if its second value is larger than another pair's second value.": 0.24742268041237114}, "avg_similarity_score": 0.1161582229472482} -{"instruction": "Write a Python program to find the sum of the positive integers of a given range.", "input": "", "output": "```python def sum_range(a, b):\n return sum(range(a, b+1)) ```", "most_similar": {"Write a Python program to find the sum of a non-negative integer.": 0.6896551724137931, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.6666666666666666, "Write a C# program to find the sum of all the elements of an array.": 0.6451612903225806, "Write a Python program to find the frequency of each word in a given string.": 0.6451612903225806, "Write a Python program to find the longest common prefix of a given list of strings.": 0.625, "Write a program to find the sum of all the multiples of 3 or 5 below 1000.": 0.6060606060606061, "Write a Python function to find the sum of all items in a list.": 0.6000000000000001, "Write a python function that returns the sum of the elements of a list.": 0.6000000000000001, "Write a Python program to find the most common words in a given text.": 0.6000000000000001, "Write a Python program to find the maximum and minimum number from a given list.": 0.5806451612903225}, "avg_similarity_score": 0.2533651524161282} -{"instruction": "Write a python code for binary search", "input": "", "output": "```python def binary_search(arr, x):\n low = 0\n high = len(arr) - 1\n mid = 0\n\n while low <= high:\n\n mid = (high + low) // 2\n\n # Check if x is present at mid\n if arr[mid] < x:\n low = mid + 1\n\n # If x is greater, ignore left half\n elif arr[mid] > x:\n high = mid - 1\n\n # If x is smaller, ignore right half\n else:\n return mid\n\n # If we reach here, then the element was not present\n return -1 ```", "most_similar": {"Write a python code for queues using stack": 0.6666666666666666, "Write a python code to implement quick sort": 0.5333333333333333, "Python code for a rotating square": 0.4615384615384615, "Suggest a completion for the following python code.": 0.39999999999999997, "Write Python code to solve this leetcode problem.": 0.39999999999999997, "Write Python code to generate N Tribonacci numbers": 0.39999999999999997, "Write a python script that prints the following pattern:\n```\n*\n**\n***\n****\n*****\n```": 0.375, "Write a script to output 'Hello World' in python": 0.375, "Write python code to connect to a FTP server.": 0.375, "Write a Python program to find the first pythagorean triplet for which a + b + c = 1000.": 0.34782608695652173}, "avg_similarity_score": 0.17178819977940246} -{"instruction": "You are given a list of numbers. You need to find the number of pairs of indices (i, j) such that the difference between nums[i] and nums[j] is at most t and i < j.", "input": "", "output": "def count_pairs(nums, t):\n count = 0\n for i in range(len(nums)):\n for j in range(i + 1, len(nums)):\n if abs(nums[i] - nums[j]) <= t:\n count += 1\n return count", "most_similar": {"I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.3448275862068966, "Write a Python program to find the number of strings where the string length is 2 or more and the first and last character are same from a given list of strings.": 0.2647058823529412, "Write a Python program to find the number of even and odd numbers from a series of numbers.": 0.25925925925925924, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.24561403508771928, "Write a Python program to find the first repeated character of a given string where the index of first occurrence is smallest.": 0.2413793103448276, "Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.": 0.2413793103448276, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.24, "Given a string `s`, find the length of the longest substring without repeating characters.": 0.24, "Write a Python function to find the smallest number from a sequence of numbers.": 0.24, "Write a C# program to find the sum of all the elements of an array.": 0.23529411764705882}, "avg_similarity_score": 0.13469672686010492} -{"instruction": "Generate the regular expression based on the description.\nDescription: matching strings that start with numbers and end with space.", "input": "", "output": "^[0-9].*\\s$", "most_similar": {"Generate the regular expression based on the description.": 0.5925925925925926, "Replace all the human names in the paragraph with .": 0.20689655172413793, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.18181818181818182, "Write a Python function that takes two numbers as input and returns their sum.": 0.18181818181818182, "Replace the token in the text with proper words that are consistent with the context. You can use multiple words for each token.": 0.1818181818181818, "Parse the natural language query into a SQL query that can be executed on the table.": 0.17142857142857143, "Given an integer array nums, find the subarray with the largest sum, and return its sum.": 0.17142857142857143, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.16666666666666669, "Using the comment as a guide, replace the \"TODO\" comment in the code with the proper code.": 0.16666666666666669, "What is the difference between a variable that is declared and defined and a variable that is only declared?": 0.15789473684210525}, "avg_similarity_score": 0.08397940532537616} -{"instruction": "Write a Python function that takes a string and returns a new string with the words in sorted order and unique.", "input": "", "output": "def unique_sort_words(text):\n return ' '.join(sorted(set(text.split(' '))))", "most_similar": {"Write a function that takes a string and returns a new string with the first letter of each word capitalized.": 0.6829268292682926, "Write a Python function that takes a string as input and returns the string in reverse order.\n'Hello'": 0.6666666666666666, "Write a Python function that takes a list and returns a new list with unique elements of the first list.": 0.6341463414634146, "Write a function that takes a string and returns the number of vowels in the string.": 0.5945945945945946, "Write a function that takes a string as input and reverse only the vowels of a string.": 0.5263157894736842, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.5238095238095238, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.4878048780487805, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.4782608695652174, "Write a Python function that takes two numbers as input and returns their sum.": 0.4571428571428571, "Please write a Rust function that takes a u64 input and returns the largest prime number less than that value.": 0.4390243902439024}, "avg_similarity_score": 0.20466061631895752} -{"instruction": "How to find the largest prime factor of a given number?", "input": "", "output": "```c #include int main() { int n, i; scanf(\"%d\", &n); for (i = 2; i <= n / i; i++) { while (n % i == 0) { n /= i; } } printf(\"%d\\n\", n); return 0; } ```", "most_similar": {"How to find the sum of all the elements in a list in python?": 0.4799999999999999, "Write a Python program to find the frequency of each word in a given string.": 0.4615384615384615, "How do you find the length of a string in Python?": 0.45454545454545453, "How do I get the power of a number in python?": 0.45454545454545453, "How to get the last element of a list in Python?": 0.45454545454545453, "Write a Python program to find the sum of the positive integers of a given range.": 0.4444444444444444, "Write a Python program to find the longest common prefix of a given list of strings.": 0.4444444444444444, "How do you find the index of an item in a list?": 0.43478260869565216, "Write a Python function to find the largest number in a dictionary.": 0.43478260869565216, "How do you find the largest number in a list using Python?": 0.43478260869565216}, "avg_similarity_score": 0.19073218997560476} -{"instruction": "What is the output of the following code?\n```python\ndef func(x):\n return x + 1\n\ndef main():\n x = 1\n y = func(x)\n print(y)\n\nmain()\n```", "input": "", "output": "The output is 2.", "most_similar": {"What is the output of the following code?\n```\npublic class Test {\n public static void main(String[] args) {\n int i = 1;\n while (i <= 5) {\n System.out.println(i);\n i++;\n }\n }\n}\n```": 0.3773584905660378, "Find the bug in the following code piece: a = 1 while a == 1: b = input(\"what's your name ?\") print(\"Hi \",b, \" this is infinity loop !\")": 0.27450980392156865, "What does this Python code do? ``` import random def montecarloPi(calcs): hits = 0 for i in range(calcs): x = random.random() y = random.random() if (x**2 + y**2) < 1: hits = hits + 1 return 4.0 * hits / calcs print(montecarloPi(10000)) ```": 0.24242424242424243, "Translate the following code from python in Java.": 0.24242424242424243, "What is the difference between a list and a tuple in Python?": 0.21621621621621623, "Translate the following code from python in Java.\ndef function(a : int, b : int, c : int):\n if a > b :\n print('You lost.')\n else :\n if c > a :\n print('Nice try.')\n else :\n print('You won.')": 0.20689655172413793, "How to find the sum of all the elements in a list in python?": 0.20512820512820512, "I have the following python function: ```python def resize_images(images, res_x, res_y): resized_images = np.zeros((images.shape[0], res_x, res_y)) for n in range(len(images)): resized_images[n, :, :] = resize(images[n, :, :], resized_images.shape[1:], anti_aliasing=False) return resized_images ``` What does the function do?": 0.2051282051282051, "Suggest a completion for the following python code.": 0.18181818181818182, "What is the difference between a class and an object?": 0.17142857142857143}, "avg_similarity_score": 0.09911976450534409} -{"instruction": "Given an array of integers, find the first missing positive integer in linear time and constant space. In other words, find the lowest positive integer that does not exist in the array. The array can contain duplicates and negative numbers as well.", "input": "", "output": "```python def first_missing_positive(nums):\n n = len(nums)\n for i in range(n):\n while nums[i] > 0 and nums[i] <= n and nums[nums[i] - 1] != nums[i]:\n nums[nums[i] - 1], nums[i] = nums[i], nums[nums[i] - 1]\n for i in range(n):\n if nums[i] != i + 1:\n return i + 1\n return n + 1\n\nprint(first_missing_positive([3, 4, -1, 1])) ```", "most_similar": {"Given an integer array nums, find the subarray with the largest sum, and return its sum.": 0.24137931034482757, "Given an array of integers `nums` and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order.": 0.23655913978494625, "Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product.": 0.21874999999999997, "I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.21874999999999997, "How do I find the first and last occurrence of a substring in a string in C++?": 0.20338983050847456, "Could you please write me Rust code that takes ownership of an array of integers and sorts them in ascending order?": 0.19047619047619047, "Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.": 0.18749999999999997, "You are given a list of numbers. You need to find the number of pairs of indices (i, j) such that the difference between nums[i] and nums[j] is at most t and i < j.": 0.1794871794871795, "Write a Python program to find the first appearance of the substring 'not' and 'poor' from a given string, if 'not' follows the 'poor', replace the whole 'not'...'poor' substring with 'good'. Return the resulting string.": 0.1794871794871795, "Replace the token in the text with proper words that are consistent with the context. You can use multiple words for each token.": 0.1791044776119403}, "avg_similarity_score": 0.09216569477537155} -{"instruction": "Write a Python program to get a string made of the first 2 and the last 2 chars from a given a string. If the string length is less than 2, return instead of the empty string.", "input": "", "output": "```python def first_last(s):\n if len(s) < 2:\n return ''\n return s[:2] + s[-2:] ```", "most_similar": {"Write a Python program to find the first appearance of the substring 'not' and 'poor' from a given string, if 'not' follows the 'poor', replace the whole 'not'...'poor' substring with 'good'. Return the resulting string.": 0.4657534246575342, "Write a Python program to find the number of strings where the string length is 2 or more and the first and last character are same from a given list of strings.": 0.43478260869565216, "Write a Python program to find the first repeated character of a given string where the index of first occurrence is smallest.": 0.4067796610169491, "Write a Python program to find the maximum and minimum number from a given list.": 0.3846153846153846, "Write a Python program to find the number of even and odd numbers from a series of numbers.": 0.36363636363636365, "Write a Python program to find the first non-repeated character in a string.": 0.35294117647058826, "Write a Python program to find the frequency of each word in a given string.": 0.34615384615384615, "Write a Python program to find the list of words that are longer than n from a given list of words.": 0.3448275862068966, "Write a Python program to find the sum of the positive integers of a given range.": 0.339622641509434, "Write a Python program to find the longest common prefix of a given list of strings.": 0.339622641509434}, "avg_similarity_score": 0.17667248958483447} -{"instruction": "Write a Python program to get a string from a given string where all occurrences of its first char have been changed to '$', except the first char itself.", "input": "", "output": "```python def first_char(s):\n return s[0] + s[1:].replace(s[0], '$') ```", "most_similar": {"Write a Python program to find the first repeated character of a given string where the index of first occurrence is smallest.": 0.44, "Write a Python program to get a string made of the first 2 and the last 2 chars from a given a string. If the string length is less than 2, return instead of the empty string.": 0.4307692307692308, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.38095238095238093, "Write a Python program to find the maximum and minimum number from a given list.": 0.37209302325581395, "Write a Python program to find the frequency of each word in a given string.": 0.37209302325581395, "Write a Python program to find the list of words that are longer than n from a given list of words.": 0.3673469387755102, "Write a Python program to find the longest common prefix of a given list of strings.": 0.36363636363636365, "Write a Python function to reverse a given list of integers.": 0.358974358974359, "Write a Python function to find the maximum sum of a contiguous subsequence from a list of integers.": 0.34782608695652173, "Write a Python program to find the number of even and odd numbers from a series of numbers.": 0.34782608695652173}, "avg_similarity_score": 0.1679980289735616} -{"instruction": "Replace all the human names in the paragraph with .\nACM named Yoshua Bengio, Geoffrey Hinton, and Yann LeCun recipients of the 2018 ACM A.M. Turing Award for conceptual and engineering breakthroughs that have made deep neural networks a critical component of computing.", "input": "", "output": "ACM named , , and recipients of the 2018 ACM A.M. Turing Award for conceptual and engineering breakthroughs that have made deep neural networks a critical component of computing.", "most_similar": {"Replace all the human names in the paragraph with .": 0.37037037037037035, "Replace the token in the text with proper words that are consistent with the context. You can use multiple words for each token.": 0.2028985507246377, "Using the comment as a guide, replace the \"TODO\" comment in the code with the proper code.": 0.19672131147540983, "Write a Python program to find the number of strings where the string length is 2 or more and the first and last character are same from a given list of strings.": 0.18421052631578946, "What is the difference between a for loop and a while loop?": 0.17857142857142858, "How do I find the first and last occurrence of a substring in a string in C++?": 0.16393442622950818, "Write a Python program to find the number of even and odd numbers from a series of numbers.": 0.16129032258064516, "Write a Python function to find the maximum sum of a contiguous subsequence from a list of integers.": 0.16129032258064516, "Write a Python program to find the list of words that are longer than n from a given list of words.": 0.15384615384615383, "Write a Python program that takes a list of numbers as input from the user, calculates the sum of all even numbers in the list, and returns the result. The program should check if the input is valid (i.e., if it's a list of numbers), and if it's not, it should return an error message. The program should also handle exceptions gracefully and return a user-friendly error message in case of any exceptions.": 0.1487603305785124}, "avg_similarity_score": 0.09335334307025203} -{"instruction": "Write a Python program to find the number of occurrences of a specified element in a given array of integers.", "input": "", "output": "def count(arr, x):\n return arr.count(x)", "most_similar": {"Write a Python program to find the frequency of each word in a given string.": 0.6285714285714286, "Write a Python program to find the longest common prefix of a given list of strings.": 0.6111111111111112, "Write a Python program to find the sum of the positive integers of a given range.": 0.6111111111111112, "Write a Python program to find the most common words in a given text.": 0.588235294117647, "Write a program to find the smallest number in a list.": 0.5806451612903226, "Write a Python program to find the number of even and odd numbers from a series of numbers.": 0.5789473684210527, "Write a Python function to find the maximum sum of a contiguous subsequence from a list of integers.": 0.5789473684210527, "Write a Python program to find the maximum and minimum number from a given list.": 0.5714285714285715, "Write a Python function to find the largest number in a dictionary.": 0.5625000000000001, "Write a Python program to find the sum of a non-negative integer.": 0.5454545454545455}, "avg_similarity_score": 0.24648425563843082} -{"instruction": "Write a function to find the longest common prefix string amongst an array of strings.", "input": "", "output": "class Solution:\n def longestCommonPrefix(self, strs: List[str]) -> str:\n if not strs:\n return \"\"\n prefix = strs[0]\n for i in range(1, len(strs)):\n while strs[i].find(prefix) != 0:\n prefix = prefix[:-1]\n if not prefix:\n return \"\"\n return prefix", "most_similar": {"Write a Python program to find the longest common prefix of a given list of strings.": 0.6451612903225806, "Write a Python function to find the smallest number from a sequence of numbers.": 0.4827586206896552, "Write a Python function to find the sum of all items in a list.": 0.4827586206896552, "Write a C# program to find the sum of all the elements of an array.": 0.4666666666666667, "Write a Python function to find the correlation between two lists.": 0.4615384615384615, "Write a Python function to find the largest number in a dictionary.": 0.4444444444444445, "Write a Python program to find the unique common elements from two lists.": 0.42857142857142855, "Write me a function in C++ to find the distance between two points": 0.42857142857142855, "Write a Python program to find the sum of a non-negative integer.": 0.42857142857142855, "Write a Python function to find the maximum sum of a contiguous subsequence from a list of integers.": 0.42424242424242425}, "avg_similarity_score": 0.2029192346831531} -{"instruction": "How do I get the last element of an array?", "input": "", "output": "You can use the array length property to get the last element of an array.\n\n```javascript const last = array[array.length - 1]; ```", "most_similar": {"How to get the last element of a list in Python?": 0.5714285714285713, "How do I get the power of a number in python?": 0.5714285714285713, "How do you find the index of an item in a list?": 0.45454545454545453, "How do I find the first and last occurrence of a substring in a string in C++?": 0.4444444444444445, "How can I get the number of days between two dates in python?": 0.4347826086956522, "How do you find the length of a string in Python?": 0.380952380952381, "How can I get the first 1000 prime numbers in Python?": 0.380952380952381, "How can I get the current date and time in Python?": 0.380952380952381, "How do you output all the contents of a list in Python?": 0.3636363636363636, "Write a C# program to find the sum of all the elements of an array.": 0.32}, "avg_similarity_score": 0.12724159016406678} -{"instruction": "Write a Python program to find the first Fibonacci number with the first 1000 digits.", "input": "", "output": "```python def fibonacci_1000_digits():\n a, b = 0, 1\n while len(str(b)) < 1000:\n a, b = b, a + b\n return b ```", "most_similar": {"Write a Python program to find the first Fibonacci number greater than four million.": 0.689655172413793, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.689655172413793, "Write a Python program to find the first pythagorean triplet for which a + b + c = 1000.": 0.5806451612903225, "Write a Python program to find the first non-repeated character in a string.": 0.5517241379310344, "Write a Python program to find the first repeated character of a given string where the index of first occurrence is smallest.": 0.5405405405405405, "Write a program to find the smallest number in a list.": 0.5384615384615385, "Write a Python program to find the maximum and minimum number from a given list.": 0.5333333333333333, "Write a Python function to find the largest number in a dictionary.": 0.5185185185185186, "Write a Python program to find the sum of the positive integers of a given range.": 0.5161290322580646, "Write a Python program to find the sum of a non-negative integer.": 0.5}, "avg_similarity_score": 0.22789796551326225} -{"instruction": "Parse the natural language query into a SQL query that can be executed on the table.\nWhat are the name and budget of the departments with average instructor salary greater than the overall average?\nGiven two tables: instructor, department.", "input": "", "output": "SELECT d.name, d.budget FROM instructor i JOIN department d ON i.dept_name = d.name GROUP BY i.dept_name HAVING AVG(i.salary) > (SELECT AVG(salary) FROM instructor)", "most_similar": {"Parse the natural language query into a SQL query that can be executed on the table.": 0.5818181818181819, "Using the comment as a guide, replace the \"TODO\" comment in the code with the proper code.": 0.21428571428571433, "Write an SQL query to select all columns from a table named 'employees' where the age is greater than 30.": 0.2033898305084746, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.2, "Identify the pos tag of the word in the given sentence.": 0.19999999999999996, "Write a python function that returns the sum of the elements of a list.": 0.18867924528301885, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.18750000000000003, "Write a Python program to find the first appearance of the substring 'not' and 'poor' from a given string, if 'not' follows the 'poor', replace the whole 'not'...'poor' substring with 'good'. Return the resulting string.": 0.18666666666666665, "Write a function that takes a string and returns the number of vowels in the string.": 0.1818181818181818, "Write a Python program to find the sum of the positive integers of a given range.": 0.1818181818181818}, "avg_similarity_score": 0.10641327318881703} -{"instruction": "How can I make a button in HTML?", "input": "", "output": "To create a button in HTML, you use the ```", "most_similar": {"How do I output a string in C++ programming?": 0.47058823529411764, "How do I incorporate CSS in my HTML page?": 0.47058823529411764, "How can I get the first 1000 prime numbers in Python?": 0.4210526315789474, "How can I get the current date and time in Python?": 0.4210526315789474, "How do I get the power of a number in python?": 0.4210526315789474, "How can I get the number of days between two dates in python?": 0.380952380952381, "How can I find the maximum and minimum value in a list using Python?": 0.36363636363636365, "How in JavaScript draw a circle with radius 10 pixels in a html canvas?": 0.36363636363636365, "How can I iterate through each item in an array in a random order using c++?": 0.3333333333333333, "How do you remove duplicates from a list in Python?": 0.33333333333333326}, "avg_similarity_score": 0.12915138126422407} -{"instruction": "Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s.", "input": "", "output": "class Solution:\n def minCut(self, s: str) -> int:\n n = len(s)\n dp = [n] * n\n is_palindrome = [[False] * n for _ in range(n)]\n\n for i in range(n):\n # odd length palindrome\n for j in range(i, n):\n if s[i] == s[j] and (j - i < 2 or is_palindrome[i + 1][j - 1]):\n is_palindrome[i][j] = True\n dp[j] = min(dp[j], dp[i] + 1)\n\n # even length palindrome\n for j in range(i + 1, n):\n if s[i] == s[j] and is_palindrome[i + 1][j - 1]:\n is_palindrome[i][j] = True\n dp[j] = min(dp[j], dp[i] + 1)\n\n return dp[-1] - 1", "most_similar": {"Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. A palindrome string is a string that reads the same backward as forward.": 0.6666666666666666, "Given a string s, return the longest palindromic substring in s.": 0.368421052631579, "Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.": 0.36734693877551017, "Given a string `s`, find the length of the longest substring without repeating characters.": 0.29268292682926833, "Given the `root` of a binary tree, return the inorder traversal of its nodes' values.": 0.2857142857142857, "Write a python function that returns the sum of the elements of a list.": 0.24390243902439024, "Write a Python program to find the number of strings where the string length is 2 or more and the first and last character are same from a given list of strings.": 0.23728813559322032, "write a java function that implements gray code and returns the next sequence code after a given code in a given direction of rotation": 0.23529411764705882, "Write a function that takes a string and returns the number of vowels in the string.": 0.2325581395348837, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.22727272727272727}, "avg_similarity_score": 0.13515574564265023} -{"instruction": "Write a Python program to find the longest pallindrome substring from a given string.", "input": "", "output": "def longest_pallindrome(s):\n longest = \"\"\n for i in range(len(s)):\n for j in range(i, len(s)):\n substring = s[i:j + 1]\n if substring == substring[::-1] and len(substring) > len(longest):\n longest = substring\n return longest", "most_similar": {"Write a Python program to find the maximum and minimum number from a given list.": 0.689655172413793, "Write a Python program to find the frequency of each word in a given string.": 0.689655172413793, "Write a Python program to find the longest common prefix of a given list of strings.": 0.6666666666666666, "Write a Python program to find the first non-repeated character in a string.": 0.6428571428571429, "Write a Python program to find the most common words in a given text.": 0.6428571428571429, "Write a Python program to find the sum of the positive integers of a given range.": 0.6000000000000001, "Write a Python program to find the unique common elements from two lists.": 0.5925925925925927, "Write a Python program to find the sum of a non-negative integer.": 0.5925925925925927, "Write a Python function to find the smallest number from a sequence of numbers.": 0.5714285714285714, "Write a Python program to find the list of words that are longer than n from a given list of words.": 0.5714285714285714}, "avg_similarity_score": 0.24618397815213405} -{"instruction": "Write a Python program to find the longest common substring from two given strings allowing only one mismatch.", "input": "", "output": "def longest_common_substring(s1, s2):\n longest = \"\"\n for i in range(len(s1)):\n for j in range(len(s2)):\n for k in range(len(s1) - i + 1):\n if k > len(longest) and s1[i:i + k] == s2[j:j + k]:\n longest = s1[i:i + k]\n if k > len(longest) + 1 and s1[i:i + k] == s2[j:j + k][:-1]:\n longest = s1[i:i + k - 1]\n if k > len(longest) + 1 and s1[i:i + k] == s2[j:j + k][1:]:\n longest = s1[i:i + k - 1]\n return longest", "most_similar": {"Write a Python program to find the longest pallindrome substring from a given string.": 0.6875000000000001, "Write a Python program to find the longest common prefix of a given list of strings.": 0.6470588235294118, "Write a Python program to find the unique common elements from two lists.": 0.6451612903225806, "Write a Python program to find the most common words in a given text.": 0.5625000000000001, "Write a Python program to find the maximum and minimum number from a given list.": 0.5454545454545454, "Write a Python program to find the frequency of each word in a given string.": 0.4848484848484848, "Write a function to find the longest common prefix string amongst an array of strings.": 0.4848484848484848, "Write a Python function to find the correlation between two lists.": 0.4827586206896552, "Write a Python program to find the sum of the positive integers of a given range.": 0.47058823529411764, "Write a Python program to find the list of words that are longer than n from a given list of words.": 0.4615384615384615}, "avg_similarity_score": 0.19915059810909896} -{"instruction": "What is the difference between a replica set and a stateful set?", "input": "", "output": "A replica set is a Kubernetes object that ensures that a specified number of pod replicas are running at any given time. A stateful set is a Kubernetes object that manages the deployment and scaling of a set of pods based on an identical container spec. A stateful set is a Kubernetes object that manages the deployment and scaling of a set of pods based on an identical container spec.", "most_similar": {"What is the difference between a static and a dynamic method?": 0.6956521739130435, "What is the difference between a list and a tuple in Python?": 0.6666666666666666, "What is the difference between a for loop and a while loop?": 0.6666666666666666, "What is the difference between a class and an object?": 0.6363636363636365, "What is the difference between a variable that is declared and defined and a variable that is only declared?": 0.5161290322580646, "What is Kubernetes ?": 0.26666666666666666, "How can I find the maximum and minimum value in a list using Python?": 0.23076923076923075, "Write a Python program to find the maximum and minimum number from a given list.": 0.22222222222222224, "Write a function that takes a string as input and reverse only the vowels of a string.": 0.20689655172413793, "How do I find the first and last occurrence of a substring in a string in C++?": 0.20689655172413793}, "avg_similarity_score": 0.13142796476274002} -{"instruction": "What is the difference between an ingress and a persistent volume?", "input": "", "output": "An ingress is an object that allows inbound connections from outside the cluster to reach the cluster services. A persistent volume is a piece of storage in the cluster that has been provisioned by an administrator or dynamically provisioned using Storage Classes. A persistent volume is a piece of storage in the cluster that has been provisioned by an administrator or dynamically provisioned using Storage Classes.", "most_similar": {"What is the difference between a static and a dynamic method?": 0.6363636363636364, "What is the difference between a replica set and a stateful set?": 0.6086956521739131, "What is the difference between a for loop and a while loop?": 0.6086956521739131, "What is the difference between a list and a tuple in Python?": 0.6086956521739131, "What is the difference between a class and an object?": 0.5714285714285713, "What is the difference between a variable that is declared and defined and a variable that is only declared?": 0.4666666666666667, "What is Kubernetes ?": 0.28571428571428575, "How do you find the index of an item in a list?": 0.2608695652173913, "How can I find the maximum and minimum value in a list using Python?": 0.23999999999999996, "Write a Python program to find the maximum and minimum number from a given list.": 0.23076923076923075}, "avg_similarity_score": 0.1289493094329555} -{"instruction": "Write a Python function to find the number of items in a list that are not equal to a given value.", "input": "", "output": "def count_not_equal_to(numbers, value):\n return len([x for x in numbers if x != value])", "most_similar": {"Write a Python function to find the sum of all items in a list.": 0.6857142857142857, "Write a Python function to find the largest number in a dictionary.": 0.6060606060606061, "Write a program to find the smallest number in a list.": 0.5625, "Write a Python program to find the frequency of each word in a given string.": 0.5555555555555556, "Write a Python program to find the number of occurrences of a specified element in a given array of integers.": 0.5365853658536585, "Write a Python program to find the list of words that are longer than n from a given list of words.": 0.5238095238095238, "Write a Python program to find the most common words in a given text.": 0.5142857142857143, "Write a Python function to find the smallest number from a sequence of numbers.": 0.5142857142857143, "Write a Python function to find the maximum sum of a contiguous subsequence from a list of integers.": 0.5128205128205129, "Write a Python program to find the maximum and minimum number from a given list.": 0.5}, "avg_similarity_score": 0.24776865874814946} -{"instruction": "Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.", "input": "", "output": "def is_prime(num):\n if num > 1:\n for i in range(2, num):\n if (num % i) == 0:\n return False\n else:\n return True\n else:\n return False", "most_similar": {"Write a Python function to check if a given number is a prime number or not.": 0.6956521739130436, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.5964912280701755, "Write a Python function to find the number of items in a list that are not equal to a given value.": 0.3529411764705882, "Write a Python function to reverse a given list of integers.": 0.34146341463414637, "How to check quickly if a number is prime in C?": 0.34146341463414637, "Write a Python function to find the largest number in a dictionary.": 0.33333333333333337, "Write a Python function to find the smallest number from a sequence of numbers.": 0.3181818181818182, "Write a Python function to find all prime numbers up to the given number n.": 0.31111111111111117, "Write a Python function to find the maximum sum of a contiguous subsequence from a list of integers.": 0.2916666666666667, "What is the difference between a variable that is declared and defined and a variable that is only declared?": 0.2857142857142857}, "avg_similarity_score": 0.15550911978127024} -{"instruction": "Write a Python function to check if a given number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. For example, 6 has divisors 1, 2 and 3 (excluding the number itself), and 6 = 1 + 2 + 3. Similarly, 28 has divisors 1, 2, 4, 7, 14 and 28, and 28 = 1 + 2 + 4 + 7 + 14.", "input": "", "output": "def is_perfect(num):\n sum = 0\n for i in range(1, num):\n if num % i == 0:\n sum += i\n return sum == num", "most_similar": {"Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.4660194174757281, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.36, "Write a Python function to check if a given number is a prime number or not.": 0.33707865168539325, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.2795698924731183, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.26530612244897955, "Write a Python program to get a string made of the first 2 and the last 2 chars from a given a string. If the string length is less than 2, return instead of the empty string.": 0.2181818181818182, "Write a Python function to find the number of items in a list that are not equal to a given value.": 0.2127659574468085, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.2127659574468085, "Write a Python program to find the number of strings where the string length is 2 or more and the first and last character are same from a given list of strings.": 0.20952380952380953, "Write a python function that returns the sum of the elements of a list.": 0.20689655172413793}, "avg_similarity_score": 0.1105054853242042} -{"instruction": "Write a Python function to check if a given number is a Fibonacci number or not. The Fibonacci sequence is a sequence of numbers where each number is the sum of the two preceding numbers. The first two numbers are 0 and 1. The next 20 Fibonacci numbers are: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181.", "input": "", "output": "def is_fibonacci(num):\n a, b = 0, 1\n while a < num:\n if a == num:\n return True\n a, b = b, a + b\n return False", "most_similar": {"Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.40404040404040403, "Write a Python function to check if a given number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. For example, 6 has divisors 1, 2 and 3 (excluding the number itself), and 6 = 1 + 2 + 3. Similarly, 28 has divisors 1, 2, 4, 7, 14 and 28, and 28 = 1 + 2 + 4 + 7 + 14.": 0.39436619718309857, "Write a Python function to check if a given number is a prime number or not.": 0.3529411764705882, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.3333333333333333, "The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. That is,\n\nF(0) = 0, F(1) = 1\nF(n) = F(n - 1) + F(n - 2), for n > 1.\nGiven n, calculate F(n)": 0.3225806451612903, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.29213483146067415, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.2888888888888889, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.2553191489361702, "Write a Python function to find the smallest number from a sequence of numbers.": 0.24096385542168677, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.24096385542168677}, "avg_similarity_score": 0.12047166517451963} -{"instruction": "What is the output of this code?\n```\nx = 10\ndef func():\n x = 20\n print(x)\nfunc()\nprint(x)\n```", "input": "", "output": "The output of this code is: ```20\n10```", "most_similar": {"What is the output of the following code?\n```python\ndef func(x):\n return x + 1\n\ndef main():\n x = 1\n y = func(x)\n print(y)\n\nmain()\n```": 0.5581395348837209, "What is the output of the following code?\n```\npublic class Test {\n public static void main(String[] args) {\n int i = 1;\n while (i <= 5) {\n System.out.println(i);\n i++;\n }\n }\n}\n```": 0.2608695652173913, "What does this Python code do? ``` import random def montecarloPi(calcs): hits = 0 for i in range(calcs): x = random.random() y = random.random() if (x**2 + y**2) < 1: hits = hits + 1 return 4.0 * hits / calcs print(montecarloPi(10000)) ```": 0.23728813559322035, "What is the difference between a class and an object?": 0.21428571428571427, "What is the difference between a static and a dynamic method?": 0.20689655172413793, "What is the difference between an ingress and a persistent volume?": 0.20689655172413793, "What is the difference between a for loop and a while loop?": 0.2, "What is the difference between a list and a tuple in Python?": 0.2, "Solving the equation and find the value of X. Show your steps.": 0.2, "What is the difference between a replica set and a stateful set?": 0.2}, "avg_similarity_score": 0.0898023357890161} -{"instruction": "Answer the following math problem. You should write down the reasoning steps.\nRoger has 5 tennis balls. He buys 2 more cans of tennis balls. Each can has 3 tennis balls. How many tennis balls does he have now?", "input": "", "output": "Roger started with 5 balls. 2 cans of 3 tennis balls each is 6 tennis balls. 5 + 6 = 11. The answer is 11.", "most_similar": {"Answer the following math problem. You should write down the reasoning steps.": 0.47058823529411764, "Write a Python program to find the frequency of each word in a given string.": 0.14814814814814814, "Write a program to find the sum of all the multiples of 3 or 5 below 1000.": 0.14285714285714282, "Write a Python program to find the number of strings where the string length is 2 or more and the first and last character are same from a given list of strings.": 0.14084507042253522, "Write a function that takes a string and returns a new string with the first letter of each word capitalized.": 0.13559322033898302, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.13559322033898302, "Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.": 0.13114754098360654, "Solve the math problems. Intermediate steps are required.": 0.12765957446808512, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.125, "Solving the math word problem with linear algebra equations.": 0.125}, "avg_similarity_score": 0.07547974584819064} -{"instruction": "How to find the largest number in an array in Java?", "input": "", "output": "Here's a function that finds the largest number in an array: ```java public int findLargest(int[] array) { int largest = array[0]; for (int i = 1; i < array.length; i++) { if (array[i] > largest) { largest = array[i]; } } return largest; } ``` It works by: Starting with the first element in the array as the largest number Comparing each subsequent element to the current largest number Updating the largest number if the current element is larger than the current largest number Returning the largest number", "most_similar": {"How to find the largest prime factor of a given number?": 0.5454545454545454, "How do you find the largest number in a list using Python?": 0.5217391304347826, "Write a Python function to find the largest number in a dictionary.": 0.5217391304347826, "How to find the sum of all the elements in a list in python?": 0.4799999999999999, "Write a program to find the smallest number in a list.": 0.45454545454545453, "How do you find the index of an item in a list?": 0.43478260869565216, "Write a Python program to find the number of occurrences of a specified element in a given array of integers.": 0.3870967741935483, "How do you find the standard deviation of all items in a list in Python?": 0.3846153846153846, "Write a function to find the longest common prefix string amongst an array of strings.": 0.3846153846153846, "Write a C# program to find the sum of all the elements of an array.": 0.3846153846153846}, "avg_similarity_score": 0.17032019742348045} -{"instruction": "How do I create a new branch in git?", "input": "", "output": "To create a new branch in git, you use the ```git branch``` command. For example: ```git branch new-branch```", "most_similar": {"How do I output a string in C++ programming?": 0.5555555555555556, "How do I get the power of a number in python?": 0.5, "How can I make a button in HTML?": 0.47058823529411764, "How do you create a new list from two lists in Python by picking one element each?": 0.46153846153846156, "How do I incorporate CSS in my HTML page?": 0.4444444444444444, "How do you remove duplicates from a list in Python?": 0.4210526315789474, "How do you sort a list of strings in Python?": 0.4210526315789474, "How do you find the length of a string in Python?": 0.39999999999999997, "How do I find the first and last occurrence of a substring in a string in C++?": 0.3846153846153846, "How do you output all the contents of a list in Python?": 0.380952380952381}, "avg_similarity_score": 0.12691753269617012} -{"instruction": "How do I make a variable that is only declared?", "input": "", "output": "You can declare a variable without defining it by using the ```var``` keyword. For example, ```var myVariable``` will declare a variable named myVariable. You can then define it later by using the ```=``` operator. For example, ```myVariable = 10``` will define myVariable with a value of 10.", "most_similar": {"How can I make a button in HTML?": 0.4444444444444445, "How do I create a new branch in git?": 0.4210526315789474, "How do I output a string in C++ programming?": 0.4210526315789474, "What is the difference between a variable that is declared and defined and a variable that is only declared?": 0.41379310344827586, "How do I get the power of a number in python?": 0.380952380952381, "How to make a python program that will print the following pattern?\n```\n*\n**\n***\n****\n*****\n```": 0.3636363636363636, "How do I compile a go program on Linux to a windows executable?": 0.34782608695652173, "How do I incorporate CSS in my HTML page?": 0.3157894736842105, "How do I get the last element of an array?": 0.3, "How do you remove duplicates from a list in Python?": 0.3}, "avg_similarity_score": 0.12145502379433241} -{"instruction": "Write a Python function to check if a given number is a palindrome or not. A palindrome is a number that remains the same when its digits are reversed. For example, 121 is a palindrome but 112 is not.", "input": "", "output": "```python def is_palindrome(num):\n return str(num) == str(num)[::-1] ```", "most_similar": {"Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.6363636363636364, "Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.5797101449275363, "Write a Python function to check if a given number is a prime number or not.": 0.509090909090909, "Write a Python function to check if a given number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. For example, 6 has divisors 1, 2 and 3 (excluding the number itself), and 6 = 1 + 2 + 3. Similarly, 28 has divisors 1, 2, 4, 7, 14 and 28, and 28 = 1 + 2 + 4 + 7 + 14.": 0.3928571428571428, "Write a Python function to check if a given number is a Fibonacci number or not. The Fibonacci sequence is a sequence of numbers where each number is the sum of the two preceding numbers. The first two numbers are 0 and 1. The next 20 Fibonacci numbers are: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181.": 0.35185185185185186, "Write a Python function to find the number of items in a list that are not equal to a given value.": 0.3333333333333333, "Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. A palindrome string is a string that reads the same backward as forward.": 0.29333333333333333, "Write a Python program to find the number of strings where the string length is 2 or more and the first and last character are same from a given list of strings.": 0.28169014084507044, "Write a Python function to reverse a given list of integers.": 0.28, "Write a Python function to find the largest number in a dictionary.": 0.2745098039215686}, "avg_similarity_score": 0.14953977675910826} -{"instruction": "Write a Python function to check if a given number is a happy number or not. A happy number is defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are unhappy numbers.", "input": "", "output": "```python def is_happy(num):\n seen = set()\n while num != 1 and num not in seen:\n seen.add(num)\n num = sum([int(i) ** 2 for i in str(num)])\n return num == 1 ```", "most_similar": {"Write a Python function to check if a given number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. For example, 6 has divisors 1, 2 and 3 (excluding the number itself), and 6 = 1 + 2 + 3. Similarly, 28 has divisors 1, 2, 4, 7, 14 and 28, and 28 = 1 + 2 + 4 + 7 + 14.": 0.36809815950920244, "Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.35, "Write a Python function to check if a given number is a palindrome or not. A palindrome is a number that remains the same when its digits are reversed. For example, 121 is a palindrome but 112 is not.": 0.34108527131782945, "Write a Python function to check if a given number is a Fibonacci number or not. The Fibonacci sequence is a sequence of numbers where each number is the sum of the two preceding numbers. The first two numbers are 0 and 1. The next 20 Fibonacci numbers are: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181.": 0.33962264150943394, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.29059829059829057, "Write a Python function to check if a given number is a prime number or not.": 0.2830188679245283, "Write a Python function to find the number of items in a list that are not equal to a given value.": 0.21621621621621623, "Write a Python program that takes a list of numbers as input from the user, calculates the sum of all even numbers in the list, and returns the result. The program should check if the input is valid (i.e., if it's a list of numbers), and if it's not, it should return an error message. The program should also handle exceptions gracefully and return a user-friendly error message in case of any exceptions.": 0.20359281437125748, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.19819819819819817, "Write a Python function to find the sum of all items in a list.": 0.19230769230769232}, "avg_similarity_score": 0.109401363481271} -{"instruction": "Write a Python function to check if a given number is a Kaprekar number or not. In mathematics, a Kaprekar number for a given base is a non-negative integer, the representation of whose square in that base can be split into two parts that add up to the original number again. For example, 45 is a Kaprekar number, because 45\u00b2 = 2025 and 20+25 = 45.", "input": "", "output": "```python def is_kaprekar(num):\n num_str = str(num ** 2)\n for i in range(1, len(num_str)):\n part1 = int(num_str[:i])\n part2 = int(num_str[i:])\n if part1 + part2 == num:\n return True\n return False ```", "most_similar": {"Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.45833333333333326, "Write a Python function to check if a given number is a palindrome or not. A palindrome is a number that remains the same when its digits are reversed. For example, 121 is a palindrome but 112 is not.": 0.4380952380952381, "Write a Python function to check if a given number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. For example, 6 has divisors 1, 2 and 3 (excluding the number itself), and 6 = 1 + 2 + 3. Similarly, 28 has divisors 1, 2, 4, 7, 14 and 28, and 28 = 1 + 2 + 4 + 7 + 14.": 0.40287769784172656, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.3870967741935484, "Write a Python function to check if a given number is a prime number or not.": 0.36585365853658536, "Write a Python function to check if a given number is a Fibonacci number or not. The Fibonacci sequence is a sequence of numbers where each number is the sum of the two preceding numbers. The first two numbers are 0 and 1. The next 20 Fibonacci numbers are: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181.": 0.3555555555555555, "Write a Python function to check if a given number is a happy number or not. A happy number is defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are unhappy numbers.": 0.30769230769230765, "Write a Python function to find the number of items in a list that are not equal to a given value.": 0.2528735632183908, "Write a Python program to find the number of occurrences of a specified element in a given array of integers.": 0.23255813953488375, "Write a Python function to find the sum of all items in a list.": 0.225}, "avg_similarity_score": 0.1313373768835838} -{"instruction": "Write a Python function to check if a given number is a Harshad number or not. A Harshad number is a number that is divisible by the sum of its digits. For example, 42 is a Harshad number because it is divisible by 6 (the sum of its two digits 4 + 2).", "input": "", "output": "```python def is_harshad(num):\n return num % sum(int(i) for i in str(num)) == 0 ```", "most_similar": {"Write a Python function to check if a given number is a palindrome or not. A palindrome is a number that remains the same when its digits are reversed. For example, 121 is a palindrome but 112 is not.": 0.5934065934065933, "Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.5853658536585367, "Write a Python function to check if a given number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. For example, 6 has divisors 1, 2 and 3 (excluding the number itself), and 6 = 1 + 2 + 3. Similarly, 28 has divisors 1, 2, 4, 7, 14 and 28, and 28 = 1 + 2 + 4 + 7 + 14.": 0.4959999999999999, "Write a Python function to check if a given number is a Kaprekar number or not. In mathematics, a Kaprekar number for a given base is a non-negative integer, the representation of whose square in that base can be split into two parts that add up to the original number again. For example, 45 is a Kaprekar number, because 45\u00b2 = 2025 and 20+25 = 45.": 0.45762711864406785, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.45569620253164556, "Write a Python function to check if a given number is a prime number or not.": 0.44117647058823534, "Write a Python function to check if a given number is a Fibonacci number or not. The Fibonacci sequence is a sequence of numbers where each number is the sum of the two preceding numbers. The first two numbers are 0 and 1. The next 20 Fibonacci numbers are: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181.": 0.4132231404958678, "Write a Python function to check if a given number is a happy number or not. A happy number is defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are unhappy numbers.": 0.38028169014084506, "Write a python function that returns the sum of the elements of a list.": 0.30303030303030304, "Write a Python function to find the maximum sum of a contiguous subsequence from a list of integers.": 0.28571428571428575}, "avg_similarity_score": 0.1494918727840011} -{"instruction": "Write a Python function to check if a given number is a circular prime or not. A circular prime is a prime number that remains prime when each digit is rotated individually around the number (clockwise or counterclockwise). For example, 197 is a circular prime because 971 and 719 are both prime.", "input": "", "output": "```python def is_circular_prime(num):\n if num < 10:\n return True\n if num % 2 == 0:\n return False\n num_str = str(num)\n for i in range(len(num_str)):\n num_str = num_str[1:] + num_str[0]\n if int(num_str) not in primes:\n return False\n return True ```", "most_similar": {"Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.5609756097560975, "Write a Python function to check if a given number is a palindrome or not. A palindrome is a number that remains the same when its digits are reversed. For example, 121 is a palindrome but 112 is not.": 0.5494505494505495, "Write a Python function to check if a given number is a Harshad number or not. A Harshad number is a number that is divisible by the sum of its digits. For example, 42 is a Harshad number because it is divisible by 6 (the sum of its two digits 4 + 2).": 0.5, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.45569620253164556, "Write a Python function to check if a given number is a prime number or not.": 0.44117647058823534, "Write a Python function to check if a given number is a Kaprekar number or not. In mathematics, a Kaprekar number for a given base is a non-negative integer, the representation of whose square in that base can be split into two parts that add up to the original number again. For example, 45 is a Kaprekar number, because 45\u00b2 = 2025 and 20+25 = 45.": 0.4406779661016949, "Write a Python function to check if a given number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. For example, 6 has divisors 1, 2 and 3 (excluding the number itself), and 6 = 1 + 2 + 3. Similarly, 28 has divisors 1, 2, 4, 7, 14 and 28, and 28 = 1 + 2 + 4 + 7 + 14.": 0.384, "Write a Python function to check if a given number is a Fibonacci number or not. The Fibonacci sequence is a sequence of numbers where each number is the sum of the two preceding numbers. The first two numbers are 0 and 1. The next 20 Fibonacci numbers are: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181.": 0.34710743801652894, "Write a Python function to check if a given number is a happy number or not. A happy number is defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are unhappy numbers.": 0.30985915492957744, "Write a Python function to find the largest number in a dictionary.": 0.25}, "avg_similarity_score": 0.13409019075439896} -{"instruction": "Write a Python function to check if a given number is a Truncable prime or not. A Truncable prime is a prime number that remains prime when digits are removed from left or right side. For example, 3797 is a truncable prime because 3797, 797, 97 and 7 are all prime.", "input": "", "output": "```python def is_truncable_prime(num):\n if num < 10:\n return True\n if num % 2 == 0:\n return False\n num_str = str(num)\n for i in range(1, len(num_str)):\n if int(num_str[:-i]) not in primes:\n return False\n if int(num_str[i:]) not in primes:\n return False\n return True ```", "most_similar": {"Write a Python function to check if a given number is a circular prime or not. A circular prime is a prime number that remains prime when each digit is rotated individually around the number (clockwise or counterclockwise). For example, 197 is a circular prime because 971 and 719 are both prime.": 0.6796116504854369, "Write a Python function to check if a given number is a palindrome or not. A palindrome is a number that remains the same when its digits are reversed. For example, 121 is a palindrome but 112 is not.": 0.5999999999999999, "Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.5679012345679013, "Write a Python function to check if a given number is a Harshad number or not. A Harshad number is a number that is divisible by the sum of its digits. For example, 42 is a Harshad number because it is divisible by 6 (the sum of its two digits 4 + 2).": 0.4854368932038835, "Write a Python function to check if a given number is a prime number or not.": 0.44776119402985076, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.43589743589743585, "Write a Python function to check if a given number is a Kaprekar number or not. In mathematics, a Kaprekar number for a given base is a non-negative integer, the representation of whose square in that base can be split into two parts that add up to the original number again. For example, 45 is a Kaprekar number, because 45\u00b2 = 2025 and 20+25 = 45.": 0.41025641025641024, "Write a Python function to check if a given number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. For example, 6 has divisors 1, 2 and 3 (excluding the number itself), and 6 = 1 + 2 + 3. Similarly, 28 has divisors 1, 2, 4, 7, 14 and 28, and 28 = 1 + 2 + 4 + 7 + 14.": 0.3548387096774194, "Write a Python function to check if a given number is a Fibonacci number or not. The Fibonacci sequence is a sequence of numbers where each number is the sum of the two preceding numbers. The first two numbers are 0 and 1. The next 20 Fibonacci numbers are: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181.": 0.3333333333333333, "Write a Python function to check if a given number is a happy number or not. A happy number is defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are unhappy numbers.": 0.2978723404255319}, "avg_similarity_score": 0.12792601290928257} -{"instruction": "Write a Python function to check if a given number is a repdigit or not. A repdigit is a number that contains only one digit. For example, 11, 22, 3333, 44444444 are repdigits.", "input": "", "output": "```python def is_repdigit(num):\n return len(set(str(num))) == 1 ```", "most_similar": {"Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.6349206349206349, "Write a Python function to check if a given number is a palindrome or not. A palindrome is a number that remains the same when its digits are reversed. For example, 121 is a palindrome but 112 is not.": 0.5833333333333334, "Write a Python function to check if a given number is a prime number or not.": 0.5714285714285714, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.5666666666666667, "Write a Python function to check if a given number is a circular prime or not. A circular prime is a prime number that remains prime when each digit is rotated individually around the number (clockwise or counterclockwise). For example, 197 is a circular prime because 971 and 719 are both prime.": 0.5411764705882354, "Write a Python function to check if a given number is a Truncable prime or not. A Truncable prime is a prime number that remains prime when digits are removed from left or right side. For example, 3797 is a truncable prime because 3797, 797, 97 and 7 are all prime.": 0.5238095238095237, "Write a Python function to check if a given number is a Harshad number or not. A Harshad number is a number that is divisible by the sum of its digits. For example, 42 is a Harshad number because it is divisible by 6 (the sum of its two digits 4 + 2).": 0.4941176470588235, "Write a Python function to check if a given number is a Kaprekar number or not. In mathematics, a Kaprekar number for a given base is a non-negative integer, the representation of whose square in that base can be split into two parts that add up to the original number again. For example, 45 is a Kaprekar number, because 45\u00b2 = 2025 and 20+25 = 45.": 0.40404040404040403, "Write a Python function to check if a given number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. For example, 6 has divisors 1, 2 and 3 (excluding the number itself), and 6 = 1 + 2 + 3. Similarly, 28 has divisors 1, 2, 4, 7, 14 and 28, and 28 = 1 + 2 + 4 + 7 + 14.": 0.3773584905660377, "Write a Python function to check if a given number is a Fibonacci number or not. The Fibonacci sequence is a sequence of numbers where each number is the sum of the two preceding numbers. The first two numbers are 0 and 1. The next 20 Fibonacci numbers are: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181.": 0.3529411764705882}, "avg_similarity_score": 0.15533388532932102} -{"instruction": "Write a python code for a linked list", "input": "", "output": "```python class Node: def init(self, data): self.data = data self.next = None\n\nclass LinkedList: def init(self): self.head = None\n\ndef insert(self, data): new_node = Node(data) new_node.next = self.head self.head = new_node\n\ndef traverse(self): cur_node = self.head while cur_node: print(cur_node.data) cur_node = cur_node.next\n\ndef search(self, data): cur_node = self.head while cur_node: if cur_node.data == data: return True cur_node = cur_node.next return False\n\ndef delete(self, data): cur_node = self.head prev = None while cur_node: if cur_node.data == data: if prev is None: self.head = cur_node.next else: prev.next = cur_node.next return True cur_node = cur_node.next prev = cur_node ```", "most_similar": {"Write a python code for binary search": 0.6666666666666666, "Write a python code for queues using stack": 0.625, "Python code for a rotating square": 0.5714285714285715, "Write a Python function to reverse a given list of integers.": 0.5263157894736842, "Write a python function that sorts a list from large to small.": 0.5, "Write a python code to implement quick sort": 0.5, "Write python code to connect to a FTP server.": 0.47058823529411764, "Write a Python function to find the sum of all items in a list.": 0.45454545454545453, "Write a python function that returns the sum of the elements of a list.": 0.45454545454545453, "Write a Python program to find the maximum and minimum number from a given list.": 0.43478260869565216}, "avg_similarity_score": 0.19385461741596266} -{"instruction": "Write a python function that returns the number of words in a given string.", "input": "", "output": "def count_words(s):\n return len(s.split())", "most_similar": {"Write a function that takes a string and returns the number of vowels in the string.": 0.6666666666666666, "Write a python function that returns the sum of the elements of a list.": 0.6428571428571429, "Write a Python program to find the frequency of each word in a given string.": 0.6206896551724138, "Write a Python function to find the largest number in a dictionary.": 0.6153846153846153, "Write a Python function to find the sum of all items in a list.": 0.5714285714285714, "Write a Python program to find the most common words in a given text.": 0.5714285714285714, "Write a Python function to find the number of items in a list that are not equal to a given value.": 0.5714285714285714, "Write a Python program to find the number of occurrences of a specified element in a given array of integers.": 0.5294117647058824, "Write a function that takes a string as input and reverse only the vowels of a string.": 0.5161290322580646, "Write a Python function that takes a string and returns a new string with the words in sorted order and unique.": 0.5142857142857143}, "avg_similarity_score": 0.2593304797813718} -{"instruction": "What is the output of the following code?\n```python\ndef f(x):\n return x * 2\n\ndef g(x):\n return f(x) + 1\n\ndef h(x):\n return g(x) * 2\n\nprint(h(2))\n```", "input": "", "output": "The output of the code is 7. The function `h` calls the function `g` with the argument 2. The function `g` calls the function `f` with the argument 2. The function `f` returns 2 * 2 = 4. The function `g` returns 4 + 1 = 5. The function `h` returns 5 * 2 = 10. The function `print` prints the value 10.", "most_similar": {"What is the output of the following code?\n```python\ndef func(x):\n return x + 1\n\ndef main():\n x = 1\n y = func(x)\n print(y)\n\nmain()\n```": 0.631578947368421, "What is the output of this code?\n```\nx = 10\ndef func():\n x = 20\n print(x)\nfunc()\nprint(x)\n```": 0.44000000000000006, "What is the output of the following code?\n```\npublic class Test {\n public static void main(String[] args) {\n int i = 1;\n while (i <= 5) {\n System.out.println(i);\n i++;\n }\n }\n}\n```": 0.30000000000000004, "What does this Python code do? ``` import random def montecarloPi(calcs): hits = 0 for i in range(calcs): x = random.random() y = random.random() if (x**2 + y**2) < 1: hits = hits + 1 return 4.0 * hits / calcs print(montecarloPi(10000)) ```": 0.24657534246575344, "Find the bug in the following code piece: a = 1 while a == 1: b = input(\"what's your name ?\") print(\"Hi \",b, \" this is infinity loop !\")": 0.20689655172413793, "Translate the following code from python in Java.": 0.2, "I have the following python function: ```python def resize_images(images, res_x, res_y): resized_images = np.zeros((images.shape[0], res_x, res_y)) for n in range(len(images)): resized_images[n, :, :] = resize(images[n, :, :], resized_images.shape[1:], anti_aliasing=False) return resized_images ``` What does the function do?": 0.18823529411764706, "Translate the following code from python in Java.\ndef function(a : int, b : int, c : int):\n if a > b :\n print('You lost.')\n else :\n if c > a :\n print('Nice try.')\n else :\n print('You won.')": 0.1846153846153846, "The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. That is,\n\nF(0) = 0, F(1) = 1\nF(n) = F(n - 1) + F(n - 2), for n > 1.\nGiven n, calculate F(n)": 0.1839080459770115, "What is the difference between a list and a tuple in Python?": 0.18181818181818182}, "avg_similarity_score": 0.08982899392869134} -{"instruction": "Given a string s, return the number of palindromic substrings in it.", "input": "", "output": "class Solution:\n def countSubstrings(self, s: str) -> int:\n def expand(left: int, right: int) -> int:\n count = 0\n while left >= 0 and right < len(s) and s[left] == s[right]:\n count += 1\n left -= 1\n right += 1\n return count\n if len(s) < 2 or s == s[::-1]:\n return len(s)\n count = 0\n for i in range(len(s) - 1):\n count += expand(i, i + 1) + expand(i, i + 2)\n return count", "most_similar": {"Given a string s, return the longest palindromic substring in s.": 0.6956521739130435, "Given a string `s`, find the length of the longest substring without repeating characters.": 0.4615384615384615, "Write a function that takes a string and returns the number of vowels in the string.": 0.42857142857142855, "Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.": 0.4117647058823529, "Write a python function that returns the number of words in a given string.": 0.3846153846153846, "Given the `root` of a binary tree, return the inorder traversal of its nodes' values.": 0.3703703703703704, "Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s.": 0.358974358974359, "Write a program to find the smallest number in a list.": 0.34782608695652173, "Write a Python function to find the largest number in a dictionary.": 0.3333333333333333, "How can I get the number of days between two dates in python?": 0.32}, "avg_similarity_score": 0.1718185870605626} -{"instruction": "Write a Python program to find the frequency of the words from the sentence given.", "input": "", "output": "```python def word_freq(str):\n d = dict()\n for word in str.split():\n if word in d:\n d[word] += 1\n else:\n d[word] = 1\n return d\n\nprint(word_freq('I am a student. I study at SJSU.')) ```", "most_similar": {"Write a Python program to find the frequency of each word in a given string.": 0.6666666666666666, "Write a Python program to find the sum of the positive integers of a given range.": 0.6451612903225806, "Write a Python program to find the longest pallindrome substring from a given string.": 0.6206896551724138, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.6206896551724138, "Write a Python program to find the most common words in a given text.": 0.6206896551724138, "Write a Python program to find the list of words that are longer than n from a given list of words.": 0.611111111111111, "Write a Python program to find the maximum and minimum number from a given list.": 0.6, "Write a Python program to find the longest common prefix of a given list of strings.": 0.5806451612903225, "Write a Python program to find the sum of a non-negative integer.": 0.5714285714285715, "Write a Python program to find the unique common elements from two lists.": 0.5714285714285715}, "avg_similarity_score": 0.24089529159786294} -{"instruction": "What is the output of the following Python code? ```py def f(x): return x + 1 def g(x): return x * 2 print(g(f(3))) ```", "input": "", "output": "The output of the code is 8. The function f(x) returns x + 1. The function g(x) returns x * 2. The print statement prints the value of g(f(3)). The value of f(3) is 4. The value of g(4) is 8.", "most_similar": {"What is the output of the following code?\n```python\ndef f(x):\n return x * 2\n\ndef g(x):\n return f(x) + 1\n\ndef h(x):\n return g(x) * 2\n\nprint(h(2))\n```": 0.6896551724137931, "What is the output of the following code?\n```python\ndef func(x):\n return x + 1\n\ndef main():\n x = 1\n y = func(x)\n print(y)\n\nmain()\n```": 0.6666666666666666, "What is the output of this code?\n```\nx = 10\ndef func():\n x = 20\n print(x)\nfunc()\nprint(x)\n```": 0.5, "What is the output of the following code?\n```\npublic class Test {\n public static void main(String[] args) {\n int i = 1;\n while (i <= 5) {\n System.out.println(i);\n i++;\n }\n }\n}\n```": 0.3333333333333333, "What does this Python code do? ``` import random def montecarloPi(calcs): hits = 0 for i in range(calcs): x = random.random() y = random.random() if (x**2 + y**2) < 1: hits = hits + 1 return 4.0 * hits / calcs print(montecarloPi(10000)) ```": 0.26865671641791045, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.23529411764705882, "Suggest a completion for the following python code.": 0.23529411764705882, "Find the bug in the following code piece: a = 1 while a == 1: b = input(\"what's your name ?\") print(\"Hi \",b, \" this is infinity loop !\")": 0.23076923076923078, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.2173913043478261, "What is the difference between a list and a tuple in Python?": 0.21052631578947367}, "avg_similarity_score": 0.107170438594578} -{"instruction": "Write a Python function that takes a number as input and returns the square of that number.", "input": "", "output": "def square(number):\n return number * number\n\nresult = square(5)\nprint(result)", "most_similar": {"Write a Python function that takes a string as input and returns the string in reverse order.\n'Hello'": 0.6857142857142857, "Write a function that takes a string as input and reverse only the vowels of a string.": 0.6470588235294118, "Write a Python function that takes two numbers as input and returns their sum.": 0.6451612903225806, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.6190476190476191, "Write a function that takes a string and returns the number of vowels in the string.": 0.6060606060606061, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.5945945945945946, "Please write a Rust function that takes a u64 input and returns the largest prime number less than that value.": 0.5945945945945946, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.5789473684210527, "Write a function that takes a string and returns a new string with the first letter of each word capitalized.": 0.5405405405405405, "Write a Python function that takes a list and returns a new list with unique elements of the first list.": 0.5405405405405405}, "avg_similarity_score": 0.21872310381204538} -{"instruction": "Write a Python function that takes a number as input and returns the sum of all the numbers from 1 to that number that are divisible by 3 and 5.", "input": "", "output": "def sum_of_numbers_divisible_by_3_and_5(number):\n sum = 0\n for i in range(1, number + 1):\n if i % 3 == 0 and i % 5 == 0:\n sum += i\n return sum\n\nresult = sum_of_numbers_divisible_by_3_and_5(5)\nprint(result)", "most_similar": {"Write a Python function that takes a number as input and returns the square of that number.": 0.6808510638297872, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.588235294117647, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.5818181818181818, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.5199999999999999, "Write a Python function that takes a string as input and returns the string in reverse order.\n'Hello'": 0.5, "Write a Python function that takes two numbers as input and returns their sum.": 0.5, "Please write a Rust function that takes a u64 input and returns the largest prime number less than that value.": 0.48, "Write a function that takes a string and returns the number of vowels in the string.": 0.47826086956521735, "Write a function that takes a string as input and reverse only the vowels of a string.": 0.46808510638297873, "Write a python function that returns the sum of the elements of a list.": 0.4545454545454545}, "avg_similarity_score": 0.19097548810217577} -{"instruction": "Write a Python function to find the index of the first occurrence of a specified item in a list.", "input": "", "output": "def index_item(lst, item):\n return lst.index(item)", "most_similar": {"Write a Python function to find the sum of all items in a list.": 0.6666666666666667, "Write a Python program to find the number of occurrences of a specified element in a given array of integers.": 0.6153846153846154, "Write a python function that returns the sum of the elements of a list.": 0.6060606060606061, "Write a Python function to find the maximum sum of a contiguous subsequence from a list of integers.": 0.5945945945945946, "Write a Python function to find the largest number in a dictionary.": 0.5806451612903226, "Write a Python program to find the sum of the positive integers of a given range.": 0.5714285714285714, "Write a Python function to find the number of items in a list that are not equal to a given value.": 0.5500000000000002, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.5454545454545454, "Write a Python program to find the first non-repeated character in a string.": 0.5454545454545454, "Write a program to find the smallest number in a list.": 0.5333333333333333}, "avg_similarity_score": 0.2584643356803654} -{"instruction": "How do you find the number of occurrences of a given value in a list in Python?", "input": "", "output": "You can find the number of occurrences of a given value in a list in Python by using the count() method. For example: ``` list = [1, 2, 3, 4, 5] number_of_occurrences = list.count(3) print(number_of_occurrences) ``` This will print the following output: ``` 1 ```", "most_similar": {"How do you find the largest number in a list using Python?": 0.6896551724137931, "How do you find the standard deviation of all items in a list in Python?": 0.6875, "How do you find the length of a string in Python?": 0.6428571428571428, "How do you find the index of an item in a list?": 0.6206896551724139, "How do you output all the contents of a list in Python?": 0.6206896551724139, "How to find the sum of all the elements in a list in python?": 0.5806451612903226, "How do I find the first and last occurrence of a substring in a string in C++?": 0.5294117647058824, "How do you sort a list of strings in Python?": 0.5185185185185185, "How do you remove duplicates from a list in Python?": 0.5185185185185185, "How can I find the maximum and minimum value in a list using Python?": 0.5161290322580646}, "avg_similarity_score": 0.20486037126954834} -{"instruction": "How do I make a function that takes a string and returns a list of the words in the string?", "input": "", "output": "```python def split_string(string):\n return string.split()\n\nprint(split_string(\"This is a string\")) ```", "most_similar": {"Write a function that takes a string and returns the number of vowels in the string.": 0.6666666666666665, "Write a Python function that takes a string and returns a new string with the words in sorted order and unique.": 0.5853658536585366, "Write a Python function that takes a list and returns a new list with unique elements of the first list.": 0.55, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.5365853658536585, "Write a Python function that takes a string as input and returns the string in reverse order.\n'Hello'": 0.5263157894736842, "Write a function that takes a string and returns a new string with the first letter of each word capitalized.": 0.5, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.48888888888888893, "Write a function that takes a string as input and reverse only the vowels of a string.": 0.48648648648648646, "Write a python function that returns the number of words in a given string.": 0.47058823529411764, "Write a Python function that takes a number as input and returns the square of that number.": 0.4324324324324324}, "avg_similarity_score": 0.208386767995284} -{"instruction": "How to make a python program that will print the following pattern?\n```\n1\n1 2\n1 2 3\n1 2 3 4\n1 2 3 4 5\n```", "input": "", "output": "Here's a Python program that prints the pattern: ```py for i in range(1, 6): print(' '.join(str(j) for j in range(1, i + 1))) ``` Here's an example usage: ```py for i in range(1, 6): print(' '.join(str(j) for j in range(1, i + 1))) ``` This will output: ``` 1\n1 2\n1 2 3\n1 2 3 4\n1 2 3 4 5 ```", "most_similar": {"How to make a python program that will print the following pattern?\n```\n*\n**\n***\n****\n*****\n```": 0.6153846153846153, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.3829787234042553, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.34615384615384615, "Write a python script that prints the following pattern:\n```\n*\n**\n***\n****\n*****\n```": 0.3333333333333333, "Write a Python function to check if a given number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. For example, 6 has divisors 1, 2 and 3 (excluding the number itself), and 6 = 1 + 2 + 3. Similarly, 28 has divisors 1, 2, 4, 7, 14 and 28, and 28 = 1 + 2 + 4 + 7 + 14.": 0.3, "Generate a correct python program to fulfill the following purpose:": 0.2702702702702703, "Write a Python function that takes a number as input and returns the sum of all the numbers from 1 to that number that are divisible by 3 and 5.": 0.2456140350877193, "Write a program to find the sum of all the multiples of 3 or 5 below 1000.": 0.22727272727272727, "The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. That is,\n\nF(0) = 0, F(1) = 1\nF(n) = F(n - 1) + F(n - 2), for n > 1.\nGiven n, calculate F(n)": 0.21951219512195122, "Write a Python program to get a string made of the first 2 and the last 2 chars from a given a string. If the string length is less than 2, return instead of the empty string.": 0.21875}, "avg_similarity_score": 0.13119170686833287} -{"instruction": "How to make a python program that will print the following pattern?\n```\n1\n2 3\n4 5 6\n7 8 9 10\n11 12 13 14 15\n```", "input": "", "output": "Here's a Python program that prints the pattern: ```py for i in range(1, 6): print(' '.join(str(j) for j in range(i, i + 5))) ``` Here's an example usage: ```py for i in range(1, 6): print(' '.join(str(j) for j in range(i, i + 5))) ``` This will output: ``` 1\n2 3\n4 5 6\n7 8 9 10\n11 12 13 14 15 ```", "most_similar": {"How to make a python program that will print the following pattern?\n```\n1\n1 2\n1 2 3\n1 2 3 4\n1 2 3 4 5\n```": 0.6296296296296297, "How to make a python program that will print the following pattern?\n```\n*\n**\n***\n****\n*****\n```": 0.6153846153846153, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.3829787234042553, "Write a python script that prints the following pattern:\n```\n*\n**\n***\n****\n*****\n```": 0.3333333333333333, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.30769230769230765, "Generate a correct python program to fulfill the following purpose:": 0.2702702702702703, "Write a Python function that takes a number as input and returns the sum of all the numbers from 1 to that number that are divisible by 3 and 5.": 0.2456140350877193, "Write a program to find the sum of all the multiples of 3 or 5 below 1000.": 0.22727272727272727, "How do I make a variable that is only declared?": 0.21621621621621623, "How do I make a function that takes a string and returns a list of the words in the string?": 0.2127659574468085}, "avg_similarity_score": 0.1311464065144316} -{"instruction": "How to make a python program that will print the following pattern?\n```\n1\n2 3\n4 5 6\n7 8 9 10\n11 12 13 14 15\n16 17 18 19 20 21\n22 23 24 25 26 27 28\n29 30 31 32 33 34 35 36\n37 38 39 40 41 42 43 44 45\n46 47 48 49 50 51 52 53 54 55\n```", "input": "", "output": "Here's a Python program that prints the pattern: ```py for i in range(1, 11): print(' '.join(str(j) for j in range(i, i + 5))) ``` Here's an example usage: ```py for i in range(1, 11): print(' '.join(str(j) for j in range(i, i + 5))) ``` This will output: ``` 1\n2 3\n4 5 6\n7 8 9 10\n11 12 13 14 15\n16 17 18 19 20 21\n22 23 24 25 26 27 28\n29 30 31 32 33 34 35 36\n37 38 39 40 41 42 43 44 45\n46 47 48 49 50 51 52 53 54 55 ```", "most_similar": {"How to make a python program that will print the following pattern?\n```\n1\n2 3\n4 5 6\n7 8 9 10\n11 12 13 14 15\n```": 0.5744680851063829, "How to make a python program that will print the following pattern?\n```\n1\n1 2\n1 2 3\n1 2 3 4\n1 2 3 4 5\n```": 0.36170212765957455, "How to make a python program that will print the following pattern?\n```\n*\n**\n***\n****\n*****\n```": 0.30379746835443033, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.20689655172413793, "Write a Python function to check if a given number is a Fibonacci number or not. The Fibonacci sequence is a sequence of numbers where each number is the sum of the two preceding numbers. The first two numbers are 0 and 1. The next 20 Fibonacci numbers are: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181.": 0.17647058823529413, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.17391304347826086, "Make a python function that takes time segments and combine then if they overlap, like this: [[0, 10], [8, 20], [25, 30]] => [[0, 20], [25, 30]]": 0.17204301075268816, "Write a python script that prints the following pattern:\n```\n*\n**\n***\n****\n*****\n```": 0.15789473684210525, "Write a Python function to check if a given number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. For example, 6 has divisors 1, 2 and 3 (excluding the number itself), and 6 = 1 + 2 + 3. Similarly, 28 has divisors 1, 2, 4, 7, 14 and 28, and 28 = 1 + 2 + 4 + 7 + 14.": 0.15714285714285714, "Write a Python function that takes a number as input and returns the sum of all the numbers from 1 to that number that are divisible by 3 and 5.": 0.14432989690721648}, "avg_similarity_score": 0.07372725267874496} -{"instruction": "How do you create a variable in Python?", "input": "", "output": "You can create a variable in Python by using the assignment operator. For example: ``` x = 5 ``` This will create a variable named x with a value of 5.", "most_similar": {"How do you sort a list of strings in Python?": 0.6666666666666665, "How do you remove duplicates from a list in Python?": 0.6666666666666665, "How do you find the length of a string in Python?": 0.631578947368421, "How do you output all the contents of a list in Python?": 0.6, "How do I create a new branch in git?": 0.5882352941176471, "How do you create a new list from two lists in Python by picking one element each?": 0.56, "How do I get the power of a number in python?": 0.5263157894736842, "How do you find the standard deviation of all items in a list in Python?": 0.5217391304347827, "How do you find the largest number in a list using Python?": 0.5, "Create a calculator in the Python programming language": 0.5}, "avg_similarity_score": 0.16380909607410216} -{"instruction": "What is the output of the following code? ```py def add(a, b): return a + b print(add(1, 2)) print(add(b=2, a=1)) ```", "input": "", "output": "The output of the code is: ```py 3 3 ``` The first call to the add() function passes in 1 and 2 as the values for the a and b parameters. The second call to the add() function passes in 1 and 2 as the values for the b and a parameters. The order of the parameters does not matter because the function is using keyword arguments.", "most_similar": {"What is the output of the following Python code? ```py def f(x): return x + 1 def g(x): return x * 2 print(g(f(3))) ```": 0.5384615384615384, "What is the output of the following code?\n```python\ndef f(x):\n return x * 2\n\ndef g(x):\n return f(x) + 1\n\ndef h(x):\n return g(x) * 2\n\nprint(h(2))\n```": 0.4827586206896552, "What is the output of the following code?\n```python\ndef func(x):\n return x + 1\n\ndef main():\n x = 1\n y = func(x)\n print(y)\n\nmain()\n```": 0.47058823529411764, "What is the output of this code?\n```\nx = 10\ndef func():\n x = 20\n print(x)\nfunc()\nprint(x)\n```": 0.40909090909090906, "Find the bug in the following code piece: a = 1 while a == 1: b = input(\"what's your name ?\") print(\"Hi \",b, \" this is infinity loop !\")": 0.34615384615384615, "Translate the following code from python in Java.\ndef function(a : int, b : int, c : int):\n if a > b :\n print('You lost.')\n else :\n if c > a :\n print('Nice try.')\n else :\n print('You won.')": 0.3389830508474576, "What is the output of the following code?\n```\npublic class Test {\n public static void main(String[] args) {\n int i = 1;\n while (i <= 5) {\n System.out.println(i);\n i++;\n }\n }\n}\n```": 0.3333333333333333, "What is the difference between a static and a dynamic method?": 0.27027027027027023, "What is the difference between a list and a tuple in Python?": 0.2631578947368421, "What is the difference between a replica set and a stateful set?": 0.2631578947368421}, "avg_similarity_score": 0.12608443126584792} -{"instruction": "Given a list of numbers, find the sum of the numbers.", "input": "", "output": "def sum(numbers):\n total = 0\n for number in numbers:\n total += number\n return total", "most_similar": {"Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.5625, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.56, "Given a string `s`, find the length of the longest substring without repeating characters.": 0.4799999999999999, "Write a C# program to find the sum of all the elements of an array.": 0.4615384615384615, "Write a Python program to find the sum of the positive integers of a given range.": 0.4444444444444444, "Write a program to find the sum of all the multiples of 3 or 5 below 1000.": 0.42857142857142855, "I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.4242424242424242, "Write a Python program to find the sum of a non-negative integer.": 0.41666666666666663, "Write a Python function to find the smallest number from a sequence of numbers.": 0.4, "Write a Python function to find the sum of all items in a list.": 0.4}, "avg_similarity_score": 0.18866486924217038} -{"instruction": "What is the output of this code?\n```python\ndef f(x):\n x = 2 * x + 1\n return x\n\nx = 3\nz = f(x)\nprint(z)\n```", "input": "", "output": "The output is 7.", "most_similar": {"What is the output of the following code?\n```python\ndef f(x):\n return x * 2\n\ndef g(x):\n return f(x) + 1\n\ndef h(x):\n return g(x) * 2\n\nprint(h(2))\n```": 0.6428571428571429, "What is the output of the following code?\n```python\ndef func(x):\n return x + 1\n\ndef main():\n x = 1\n y = func(x)\n print(y)\n\nmain()\n```": 0.5714285714285714, "What is the output of the following Python code? ```py def f(x): return x + 1 def g(x): return x * 2 print(g(f(3))) ```": 0.5599999999999999, "What is the output of this code?\n```\nx = 10\ndef func():\n x = 20\n print(x)\nfunc()\nprint(x)\n```": 0.5238095238095238, "What is the output of the following code? ```py def add(a, b): return a + b print(add(1, 2)) print(add(b=2, a=1)) ```": 0.35999999999999993, "What does this Python code do? ``` import random def montecarloPi(calcs): hits = 0 for i in range(calcs): x = random.random() y = random.random() if (x**2 + y**2) < 1: hits = hits + 1 return 4.0 * hits / calcs print(montecarloPi(10000)) ```": 0.30769230769230765, "What is the output of the following code?\n```\npublic class Test {\n public static void main(String[] args) {\n int i = 1;\n while (i <= 5) {\n System.out.println(i);\n i++;\n }\n }\n}\n```": 0.2692307692307692, "What is the difference between a list and a tuple in Python?": 0.2222222222222222, "Translate the following code from python in Java.": 0.1875, "I have the following python function: ```python def resize_images(images, res_x, res_y): resized_images = np.zeros((images.shape[0], res_x, res_y)) for n in range(len(images)): resized_images[n, :, :] = resize(images[n, :, :], resized_images.shape[1:], anti_aliasing=False) return resized_images ``` What does the function do?": 0.18181818181818182}, "avg_similarity_score": 0.09885143002999439} -{"instruction": "Write a code to implement a binary search.", "input": "", "output": "```\ndef binary_search(arr, x):\n low = 0\n high = len(arr) - 1\n mid = 0\n\n while low <= high:\n mid = (high + low) // 2\n if arr[mid] < x:\n low = mid + 1\n elif arr[mid] > x:\n high = mid - 1\n else:\n return mid\n return -1\n```", "most_similar": {"Write a python code for binary search": 0.6666666666666666, "Write a python code to implement quick sort": 0.625, "Write a python code for a linked list": 0.5, "Write python code to connect to a FTP server.": 0.47058823529411764, "Write a program to find the smallest number in a list.": 0.4210526315789474, "Write a Python function to reverse a given list of integers.": 0.4210526315789474, "Write a Python function to find the largest number in a dictionary.": 0.4, "Write a script to output the mean of a list of integers.": 0.4, "write a code to get the current value of a Bitcoin in US dollars using the bitcoincharts API.": 0.3846153846153846, "Write a Python program to find the sum of a non-negative integer.": 0.380952380952381}, "avg_similarity_score": 0.1722591072886076} -{"instruction": "Write a Python program to find the Fibonacci series up to n numbers.", "input": "", "output": "def fibonacci(n):\n a, b = 0, 1\n while a < n:\n print(a, end=' ')\n a, b = b, a + b", "most_similar": {"Write a Python program to find the first Fibonacci number greater than four million.": 0.5925925925925927, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.5925925925925927, "Write a Python program to find the number of even and odd numbers from a series of numbers.": 0.5806451612903226, "Write a Python function to find all prime numbers up to the given number n.": 0.5714285714285715, "Write a Python program to find the first Fibonacci number with the first 1000 digits.": 0.5714285714285715, "Write a program to compute the sum of integers from k to n.": 0.5384615384615384, "Write a Python program to find the sum of a non-negative integer.": 0.5384615384615384, "Write a Python program to find the unique common elements from two lists.": 0.5384615384615384, "Write a Python program to find the longest pallindrome substring from a given string.": 0.5185185185185186, "Write a Python program to find the first non-repeated character in a string.": 0.5185185185185186}, "avg_similarity_score": 0.21192207139182487} -{"instruction": "Write a program that prints the numbers from 1 to 100. But for multiples of three print \"Fizz\" instead of the number and for the multiples of five print \"Buzz\". For numbers which are multiples of both three and five print \"FizzBuzz\".", "input": "", "output": "```python for i in range(1, 101):\n if i % 3 == 0 and i % 5 == 0:\n print('FizzBuzz')\n elif i % 3 == 0:\n print('Fizz')\n elif i % 5 == 0:\n print('Buzz')\n else:\n print(i) ```", "most_similar": {"Write a Python function that takes a number as input and returns the sum of all the numbers from 1 to that number that are divisible by 3 and 5.": 0.3055555555555555, "Write a Python program to find the number of even and odd numbers from a series of numbers.": 0.3, "Write a program to find the sum of all the multiples of 3 or 5 below 1000.": 0.27118644067796605, "Write a Python program to find the number of strings where the string length is 2 or more and the first and last character are same from a given list of strings.": 0.27027027027027023, "Write a Python program to find the number of occurrences of a specified element in a given array of integers.": 0.25806451612903225, "Write a Python program to find the list of words that are longer than n from a given list of words.": 0.25396825396825395, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.25396825396825395, "Write a Python function to find the smallest number from a sequence of numbers.": 0.25, "Write a python function that returns the sum of the elements of a list.": 0.25, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.25}, "avg_similarity_score": 0.13667599995508284} -{"instruction": "Write a Python function to check if a given number is an Armstrong number or not. An Armstrong number is a number that is equal to the sum of its own digits each raised to the power of the number of digits.", "input": "", "output": "def is_armstrong(num):\n sum = 0\n order = len(str(num))\n temp = num\n while temp > 0:\n digit = temp % 10\n sum += digit ** order\n temp //= 10\n return num == sum", "most_similar": {"Write a Python function to check if a given number is a Harshad number or not. A Harshad number is a number that is divisible by the sum of its digits. For example, 42 is a Harshad number because it is divisible by 6 (the sum of its two digits 4 + 2).": 0.5957446808510638, "Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.5555555555555556, "Write a Python function to check if a given number is a palindrome or not. A palindrome is a number that remains the same when its digits are reversed. For example, 121 is a palindrome but 112 is not.": 0.49382716049382713, "Write a Python function to check if a given number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. For example, 6 has divisors 1, 2 and 3 (excluding the number itself), and 6 = 1 + 2 + 3. Similarly, 28 has divisors 1, 2, 4, 7, 14 and 28, and 28 = 1 + 2 + 4 + 7 + 14.": 0.4869565217391304, "Write a Python function to check if a given number is a prime number or not.": 0.48275862068965514, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.463768115942029, "Write a Python function to check if a given number is a repdigit or not. A repdigit is a number that contains only one digit. For example, 11, 22, 3333, 44444444 are repdigits.": 0.4533333333333333, "Write a Python function to check if a given number is a circular prime or not. A circular prime is a prime number that remains prime when each digit is rotated individually around the number (clockwise or counterclockwise). For example, 197 is a circular prime because 971 and 719 are both prime.": 0.42553191489361697, "Write a Python function to check if a given number is a Fibonacci number or not. The Fibonacci sequence is a sequence of numbers where each number is the sum of the two preceding numbers. The first two numbers are 0 and 1. The next 20 Fibonacci numbers are: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181.": 0.41441441441441446, "Write a Python function to check if a given number is a Kaprekar number or not. In mathematics, a Kaprekar number for a given base is a non-negative integer, the representation of whose square in that base can be split into two parts that add up to the original number again. For example, 45 is a Kaprekar number, because 45\u00b2 = 2025 and 20+25 = 45.": 0.40740740740740733}, "avg_similarity_score": 0.17051644096523516} -{"instruction": "Write a Python function to check if a given number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence. The Fibonacci sequence is a sequence of numbers where each number is the sum of the two preceding numbers. The first two numbers in the sequence are 0 and 1.", "input": "", "output": "def is_fibonacci(num):\n a, b = 0, 1\n while a < num:\n if a == num:\n return True\n a, b = b, a + b\n return False", "most_similar": {"Write a Python function to check if a given number is a Fibonacci number or not. The Fibonacci sequence is a sequence of numbers where each number is the sum of the two preceding numbers. The first two numbers are 0 and 1. The next 20 Fibonacci numbers are: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181.": 0.6880000000000001, "Write a Python function to check if a given number is a Harshad number or not. A Harshad number is a number that is divisible by the sum of its digits. For example, 42 is a Harshad number because it is divisible by 6 (the sum of its two digits 4 + 2).": 0.537037037037037, "Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.5116279069767441, "Write a Python function to check if a given number is an Armstrong number or not. An Armstrong number is a number that is equal to the sum of its own digits each raised to the power of the number of digits.": 0.48979591836734687, "Write a Python function to check if a given number is a palindrome or not. A palindrome is a number that remains the same when its digits are reversed. For example, 121 is a palindrome but 112 is not.": 0.4631578947368421, "Write a Python function to check if a given number is a repdigit or not. A repdigit is a number that contains only one digit. For example, 11, 22, 3333, 44444444 are repdigits.": 0.4269662921348315, "Write a Python function to check if a given number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. For example, 6 has divisors 1, 2 and 3 (excluding the number itself), and 6 = 1 + 2 + 3. Similarly, 28 has divisors 1, 2, 4, 7, 14 and 28, and 28 = 1 + 2 + 4 + 7 + 14.": 0.41860465116279066, "Write a Python function to check if a given number is a prime number or not.": 0.41666666666666663, "Write a Python function to check if a given number is a happy number or not. A happy number is defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are unhappy numbers.": 0.41095890410958896, "Write a Python function to check if a given number is a Kaprekar number or not. In mathematics, a Kaprekar number for a given base is a non-negative integer, the representation of whose square in that base can be split into two parts that add up to the original number again. For example, 45 is a Kaprekar number, because 45\u00b2 = 2025 and 20+25 = 45.": 0.4098360655737705}, "avg_similarity_score": 0.16130332951824655} -{"instruction": "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.", "input": "", "output": "def is_kaprekar(num):\n square = num ** 2\n reverse = int(str(square)[::-1])\n return square - reverse == num", "most_similar": {"Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.6666666666666666, "Write a Python function to check if a given number is a palindrome or not. A palindrome is a number that remains the same when its digits are reversed. For example, 121 is a palindrome but 112 is not.": 0.6133333333333332, "Write a Python function to check if a given number is a Harshad number or not. A Harshad number is a number that is divisible by the sum of its digits. For example, 42 is a Harshad number because it is divisible by 6 (the sum of its two digits 4 + 2).": 0.5909090909090908, "Write a Python function to check if a given number is an Armstrong number or not. An Armstrong number is a number that is equal to the sum of its own digits each raised to the power of the number of digits.": 0.5897435897435898, "Write a Python function to check if a given number is a repdigit or not. A repdigit is a number that contains only one digit. For example, 11, 22, 3333, 44444444 are repdigits.": 0.5797101449275361, "Write a Python function to check if a given number is a prime number or not.": 0.5769230769230769, "Write a Python function to check if a given number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence. The Fibonacci sequence is a sequence of numbers where each number is the sum of the two preceding numbers. The first two numbers in the sequence are 0 and 1.": 0.5652173913043479, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.5396825396825397, "Write a Python function to check if a given number is a Kaprekar number or not. In mathematics, a Kaprekar number for a given base is a non-negative integer, the representation of whose square in that base can be split into two parts that add up to the original number again. For example, 45 is a Kaprekar number, because 45\u00b2 = 2025 and 20+25 = 45.": 0.5098039215686274, "Write a Python function to check if a given number is a circular prime or not. A circular prime is a prime number that remains prime when each digit is rotated individually around the number (clockwise or counterclockwise). For example, 197 is a circular prime because 971 and 719 are both prime.": 0.5}, "avg_similarity_score": 0.18653802253547358} -{"instruction": "Write a Python function to check if a given number is a Carmichael number or not. A Carmichael number is a composite number that satisfies the following conditions: The number must be composite i.e. greater than 1. The number must not be a prime number. If we take every number from 1 to n-1 (both included) and calculate the remainder when divided by the number, no number should have the same remainder when divided by the number, except 0 and the number itself.", "input": "", "output": "def is_carmichael(num):\n if num <= 1:\n return False\n if is_prime(num):\n return False\n for i in range(1, num):\n if pow(i, num - 1, num) != (i if i % num == 0 else 1):\n return False\n return True", "most_similar": {"Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.42975206611570255, "Write a Python function to check if a given number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence. The Fibonacci sequence is a sequence of numbers where each number is the sum of the two preceding numbers. The first two numbers in the sequence are 0 and 1.": 0.425531914893617, "Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.41739130434782606, "Write a Python function to check if a given number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. For example, 6 has divisors 1, 2 and 3 (excluding the number itself), and 6 = 1 + 2 + 3. Similarly, 28 has divisors 1, 2, 4, 7, 14 and 28, and 28 = 1 + 2 + 4 + 7 + 14.": 0.379746835443038, "Write a Python function to check if a given number is a Harshad number or not. A Harshad number is a number that is divisible by the sum of its digits. For example, 42 is a Harshad number because it is divisible by 6 (the sum of its two digits 4 + 2).": 0.3795620437956205, "Write a Python function to check if a given number is an Armstrong number or not. An Armstrong number is a number that is equal to the sum of its own digits each raised to the power of the number of digits.": 0.3779527559055118, "Write a Python function to check if a given number is a palindrome or not. A palindrome is a number that remains the same when its digits are reversed. For example, 121 is a palindrome but 112 is not.": 0.3548387096774194, "Write a Python function to check if a given number is a circular prime or not. A circular prime is a prime number that remains prime when each digit is rotated individually around the number (clockwise or counterclockwise). For example, 197 is a circular prime because 971 and 719 are both prime.": 0.35036496350364965, "Write a Python function to check if a given number is a Kaprekar number or not. In mathematics, a Kaprekar number for a given base is a non-negative integer, the representation of whose square in that base can be split into two parts that add up to the original number again. For example, 45 is a Kaprekar number, because 45\u00b2 = 2025 and 20+25 = 45.": 0.3443708609271523, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.3392857142857143}, "avg_similarity_score": 0.11608840977720812} -{"instruction": "Write a Python function to check if a given number is a Catalan number or not. A Catalan number is a number that occurs in the sequence of Catalan numbers. The sequence of Catalan numbers is generated by the following formula: Cn = (2n)! / (n+1)!n!", "input": "", "output": "def is_catalan(num):\n return num == math.factorial(2 * num) / (math.factorial(num + 1) * math.factorial(num))", "most_similar": {"Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.6315789473684211, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.6097560975609756, "Write a Python function to check if a given number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence. The Fibonacci sequence is a sequence of numbers where each number is the sum of the two preceding numbers. The first two numbers in the sequence are 0 and 1.": 0.5882352941176471, "Write a Python function to check if a given number is an Armstrong number or not. An Armstrong number is a number that is equal to the sum of its own digits each raised to the power of the number of digits.": 0.5454545454545454, "Write a Python function to check if a given number is a Harshad number or not. A Harshad number is a number that is divisible by the sum of its digits. For example, 42 is a Harshad number because it is divisible by 6 (the sum of its two digits 4 + 2).": 0.5306122448979592, "Write a Python function to check if a given number is a palindrome or not. A palindrome is a number that remains the same when its digits are reversed. For example, 121 is a palindrome but 112 is not.": 0.49411764705882355, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.4931506849315068, "Write a Python function to check if a given number is a prime number or not.": 0.48387096774193544, "Write a Python function to check if a given number is a repdigit or not. A repdigit is a number that contains only one digit. For example, 11, 22, 3333, 44444444 are repdigits.": 0.48101265822784817, "Write a Python function to check if a given number is a Fibonacci number or not. The Fibonacci sequence is a sequence of numbers where each number is the sum of the two preceding numbers. The first two numbers are 0 and 1. The next 20 Fibonacci numbers are: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181.": 0.43478260869565216}, "avg_similarity_score": 0.17357073363516354} -{"instruction": "Write a Python function to check if a given number is a Fermat number or not. A Fermat number is a number of the form 22n + 1, where n is a non-negative integer.", "input": "", "output": "def is_fermat(num):\n return num == 2 ** (2 ** num) + 1", "most_similar": {"Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.6571428571428571, "Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.65625, "Write a Python function to check if a given number is a Catalan number or not. A Catalan number is a number that occurs in the sequence of Catalan numbers. The sequence of Catalan numbers is generated by the following formula: Cn = (2n)! / (n+1)!n!": 0.6, "Write a Python function to check if a given number is a prime number or not.": 0.6, "Write a Python function to check if a given number is a palindrome or not. A palindrome is a number that remains the same when its digits are reversed. For example, 121 is a palindrome but 112 is not.": 0.5753424657534247, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.5573770491803278, "Write a Python function to check if a given number is a repdigit or not. A repdigit is a number that contains only one digit. For example, 11, 22, 3333, 44444444 are repdigits.": 0.5373134328358209, "Write a Python function to check if a given number is a Harshad number or not. A Harshad number is a number that is divisible by the sum of its digits. For example, 42 is a Harshad number because it is divisible by 6 (the sum of its two digits 4 + 2).": 0.5348837209302325, "Write a Python function to check if a given number is an Armstrong number or not. An Armstrong number is a number that is equal to the sum of its own digits each raised to the power of the number of digits.": 0.5263157894736842, "Write a Python function to check if a given number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence. The Fibonacci sequence is a sequence of numbers where each number is the sum of the two preceding numbers. The first two numbers in the sequence are 0 and 1.": 0.5111111111111111}, "avg_similarity_score": 0.18473884266837928} -{"instruction": "Write a Python function that returns the largest item in a list.", "input": "", "output": "def max_list(lst):\n return max(lst)", "most_similar": {"Write a python function that returns the sum of the elements of a list.": 0.6923076923076924, "Write a python function that returns the number of words in a given string.": 0.6923076923076924, "Write a Python function to find the largest number in a dictionary.": 0.6666666666666666, "Write a Python function to find the sum of all items in a list.": 0.6153846153846153, "Write a python function that sorts a list from large to small.": 0.5833333333333334, "Write a Python function to find the index of the first occurrence of a specified item in a list.": 0.5806451612903226, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.5454545454545454, "Write a Python function that takes a string as input and returns the string in reverse order.\n'Hello'": 0.5333333333333333, "Write a Python function to reverse a given list of integers.": 0.5217391304347826, "Write a program to find the smallest number in a list.": 0.5217391304347826}, "avg_similarity_score": 0.24717774696892217} -{"instruction": "Write a Python function that removes all occurrences of a specified item from a list.", "input": "", "output": "def remove_all_list(lst, item):\n while item in lst:\n lst.remove(item)", "most_similar": {"Write a Python function that returns the largest item in a list.": 0.5925925925925926, "Write a Python function to find the index of the first occurrence of a specified item in a list.": 0.5882352941176471, "Write a python function that returns the sum of the elements of a list.": 0.5517241379310344, "Write a Python function to find the maximum sum of a contiguous subsequence from a list of integers.": 0.5454545454545454, "Write a python function that sorts a list from large to small.": 0.5185185185185186, "Write a python function that returns the number of words in a given string.": 0.4827586206896552, "Write a Python function to find the sum of all items in a list.": 0.4827586206896552, "Write a Python function to reverse a given list of integers.": 0.4615384615384615, "Write a Python program to find the number of occurrences of a specified element in a given array of integers.": 0.4571428571428572, "Write a Python function that takes a list and returns a new list with unique elements of the first list.": 0.4571428571428572}, "avg_similarity_score": 0.19937168719309833} -{"instruction": "Write a Python function that returns a list containing only the items that are present in both lists.", "input": "", "output": "def intersection_list(lst1, lst2):\n return list(set(lst1) & set(lst2))", "most_similar": {"Write a Python function that returns the largest item in a list.": 0.5333333333333333, "Write a python function that returns the sum of the elements of a list.": 0.5, "Write a python function that returns the number of words in a given string.": 0.5, "Write a Python function that takes a list and returns a new list with unique elements of the first list.": 0.4736842105263158, "Write a python function that sorts a list from large to small.": 0.4666666666666666, "Write a Python function that takes a string and returns a new string with the words in sorted order and unique.": 0.4615384615384615, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.4615384615384615, "Write a Python function that takes a number as input and returns the square of that number.": 0.45714285714285713, "Write a Python function that takes a string as input and returns the string in reverse order.\n'Hello'": 0.4444444444444444, "Write a Python function to find the sum of all items in a list.": 0.43750000000000006}, "avg_similarity_score": 0.20221720950164035} -{"instruction": "How do I find the maximum value in an array?", "input": "", "output": "You can use the Math.max() function to find the maximum value in an array.\n\n```javascript const max = Math.max(...array); ```", "most_similar": {"How do I get the last element of an array?": 0.6, "How can I find the maximum and minimum value in a list using Python?": 0.5833333333333334, "How to find the largest number in an array in Java?": 0.5714285714285713, "How do you find the length of a string in Python?": 0.47619047619047616, "How do I get the power of a number in python?": 0.47619047619047616, "How do you find the index of an item in a list?": 0.45454545454545453, "How do you find the largest number in a list using Python?": 0.45454545454545453, "How do you find the number of occurrences of a given value in a list in Python?": 0.4444444444444445, "How do I find the first and last occurrence of a substring in a string in C++?": 0.4444444444444445, "How do I incorporate CSS in my HTML page?": 0.4210526315789474}, "avg_similarity_score": 0.14310136133301019} -{"instruction": "How do I find the standard deviation of all elements in an array?", "input": "", "output": "You can use the reduce() function to find the standard deviation of all elements in an array.\n\n```javascript const stdDev = Math.sqrt(array.reduce((a, b) => a + Math.pow(b - mean, 2), 0) / array.length); ```", "most_similar": {"How do I find the maximum value in an array?": 0.6956521739130435, "How do you find the standard deviation of all items in a list in Python?": 0.6428571428571429, "How do I get the last element of an array?": 0.608695652173913, "How to find the sum of all the elements in a list in python?": 0.5185185185185186, "Write a C# program to find the sum of all the elements of an array.": 0.5, "How to find the largest number in an array in Java?": 0.4999999999999999, "How do I get the power of a number in python?": 0.4999999999999999, "How do you find the length of a string in Python?": 0.4999999999999999, "How do you find the index of an item in a list?": 0.48000000000000004, "How do I find the first and last occurrence of a substring in a string in C++?": 0.4666666666666667}, "avg_similarity_score": 0.15619491183598827} -{"instruction": "How do I find the fibonacci number of a number?", "input": "", "output": "You can use the reduce() function to find the fibonacci number of a number.\n\n```javascript const fibonacci = array.reduce((a, b) => a + b, 0); ```", "most_similar": {"How do I get the power of a number in python?": 0.6666666666666666, "How to find the largest prime factor of a given number?": 0.5714285714285713, "How do you find the length of a string in Python?": 0.5714285714285713, "How do you find the index of an item in a list?": 0.5454545454545454, "How do you find the largest number in a list using Python?": 0.5454545454545454, "How do I find the standard deviation of all elements in an array?": 0.5217391304347826, "How do I find the first and last occurrence of a substring in a string in C++?": 0.5185185185185185, "How do you find the number of occurrences of a given value in a list in Python?": 0.5185185185185185, "How do I find the maximum value in an array?": 0.5, "How do I get the last element of an array?": 0.5}, "avg_similarity_score": 0.18752547544462655} -{"instruction": "How do I find the greatest common divisor of two numbers?", "input": "", "output": "You can use the reduce() function to find the greatest common divisor of two numbers.\n\n```javascript const gcd = array.reduce((a, b) => !b ? a : gcd(b, a % b), 0); ```", "most_similar": {"How do I find the fibonacci number of a number?": 0.5714285714285713, "How do I find the standard deviation of all elements in an array?": 0.4999999999999999, "How do I get the last element of an array?": 0.47619047619047616, "How do I find the maximum value in an array?": 0.47619047619047616, "How do I get the power of a number in python?": 0.45454545454545453, "How do you find the length of a string in Python?": 0.45454545454545453, "How do you find the index of an item in a list?": 0.43478260869565216, "How do I find the first and last occurrence of a substring in a string in C++?": 0.42857142857142855, "How can I get the number of days between two dates in python?": 0.41666666666666663, "How do you find the standard deviation of all items in a list in Python?": 0.3846153846153846}, "avg_similarity_score": 0.1430853055289402} -{"instruction": "How to get the current time in milliseconds in python?", "input": "", "output": "import time\ntime.time()", "most_similar": {"How can I get the current date and time in Python?": 0.6666666666666666, "How to get the last element of a list in Python?": 0.5714285714285713, "How to find the sum of all the elements in a list in python?": 0.5, "How to find the largest number in an array in Java?": 0.47619047619047616, "How do I get the power of a number in python?": 0.47619047619047616, "How can I get the first 1000 prime numbers in Python?": 0.47619047619047616, "How can I get the number of days between two dates in python?": 0.4347826086956522, "How do you find the standard deviation of all items in a list in Python?": 0.4, "How do you find the length of a string in Python?": 0.380952380952381, "How do you find the number of occurrences of a given value in a list in Python?": 0.37037037037037035}, "avg_similarity_score": 0.15193815533760638} -{"instruction": "How do I find the p-variance of all elements in a list?", "input": "", "output": "You can use the statistics module to find the p-variance of all elements in a list.\n\n```python import statistics statistics.pvariance([1, 2, 3]) ```", "most_similar": {"How do I find the standard deviation of all elements in an array?": 0.6923076923076923, "How to find the sum of all the elements in a list in python?": 0.6666666666666666, "How do you find the standard deviation of all items in a list in Python?": 0.6428571428571429, "How do you find the index of an item in a list?": 0.64, "How do I find the fibonacci number of a number?": 0.608695652173913, "How do you find the largest number in a list using Python?": 0.5599999999999999, "How do you find the number of occurrences of a given value in a list in Python?": 0.5333333333333333, "How do I find the first and last occurrence of a substring in a string in C++?": 0.5333333333333333, "How do I find the maximum value in an array?": 0.5217391304347826, "How can I find the maximum and minimum value in a list using Python?": 0.5185185185185186}, "avg_similarity_score": 0.19145334503807546} -{"instruction": "What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```", "input": "", "output": "The output of the code is ``` [1, 2, 3, 4, 5, 6] ```.", "most_similar": {"What is the output of the following code? ```py def add(a, b): return a + b print(add(1, 2)) print(add(b=2, a=1)) ```": 0.5531914893617021, "What is the output of the following Python code? ```py def f(x): return x + 1 def g(x): return x * 2 print(g(f(3))) ```": 0.4680851063829788, "What is the output of the following code?\n```python\ndef func(x):\n return x + 1\n\ndef main():\n x = 1\n y = func(x)\n print(y)\n\nmain()\n```": 0.43478260869565216, "What is the output of the following code?\n```python\ndef f(x):\n return x * 2\n\ndef g(x):\n return f(x) + 1\n\ndef h(x):\n return g(x) * 2\n\nprint(h(2))\n```": 0.4150943396226415, "What is the output of the following code?\n```\npublic class Test {\n public static void main(String[] args) {\n int i = 1;\n while (i <= 5) {\n System.out.println(i);\n i++;\n }\n }\n}\n```": 0.40816326530612246, "What is the output of this code?\n```python\ndef f(x):\n x = 2 * x + 1\n return x\n\nx = 3\nz = f(x)\nprint(z)\n```": 0.39999999999999997, "Find the bug in the following code piece: a = 1 while a == 1: b = input(\"what's your name ?\") print(\"Hi \",b, \" this is infinity loop !\")": 0.3829787234042554, "Translate the following code from python in Java.\ndef function(a : int, b : int, c : int):\n if a > b :\n print('You lost.')\n else :\n if c > a :\n print('Nice try.')\n else :\n print('You won.')": 0.37037037037037035, "What is the output of this code?\n```\nx = 10\ndef func():\n x = 20\n print(x)\nfunc()\nprint(x)\n```": 0.358974358974359, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.3414634146341463}, "avg_similarity_score": 0.14281243554843903} -{"instruction": "Write a script to output the factorial of an integer.", "input": "", "output": "def factorial(n):\n if n == 0 :\n return 1\n else :\n return n * factorial(n-1)", "most_similar": {"Write a script to output the mean of a list of integers.": 0.6363636363636365, "Write a script to output 'Hello World' in python": 0.5263157894736842, "Write a Python program to find the sum of a non-negative integer.": 0.5217391304347826, "Write a C# program to find the sum of all the elements of an array.": 0.48, "Write a program to compute the sum of integers from k to n.": 0.4347826086956522, "Write a python script that prints the following pattern:\n```\n*\n**\n***\n****\n*****\n```": 0.4210526315789474, "Write a Python function to find the smallest number from a sequence of numbers.": 0.41666666666666663, "Write a Python function to find the sum of all items in a list.": 0.41666666666666663, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.41666666666666663, "Write a Python program to find the frequency of each word in a given string.": 0.4}, "avg_similarity_score": 0.201543175096457} -{"instruction": "Write a script to output the nth fibonacci number.", "input": "", "output": "def fibonacci(n):\n if n == 0 :\n return 0\n elif n == 1 :\n return 1\n else :\n return fibonacci(n-1) + fibonacci(n-2)", "most_similar": {"Write a script to output the factorial of an integer.": 0.631578947368421, "Write a script to output the mean of a list of integers.": 0.5714285714285715, "Write a script to output 'Hello World' in python": 0.5555555555555556, "Write a Python program to find the first Fibonacci number greater than four million.": 0.5217391304347826, "Write a program to find the smallest number in a list.": 0.5, "Write a Python program to find the first Fibonacci number with the first 1000 digits.": 0.5, "Write a Python function to find the largest number in a dictionary.": 0.4761904761904762, "Write a Python program to find the Fibonacci series up to n numbers.": 0.4545454545454546, "Write a python script that prints the following pattern:\n```\n*\n**\n***\n****\n*****\n```": 0.4444444444444444, "Write a Python function to find the smallest number from a sequence of numbers.": 0.43478260869565216}, "avg_similarity_score": 0.1928825830632315} -{"instruction": "Given an array of integers, return indices of the two numbers such that they add up to a specific target.", "input": "", "output": "class Solution:\n def twoSum(self, nums: List[int], target: int) -> List[int]:\n d = {}\n for i, num in enumerate(nums):\n if target - num in d:\n return [d[target - num], i]\n else:\n d[num] = i", "most_similar": {"Given an array of integers `nums` and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order.": 0.5070422535211269, "Given a list of numbers, find the sum of the numbers.": 0.3225806451612903, "Given the `root` of a binary tree, return the inorder traversal of its nodes' values.": 0.2285714285714286, "Given an array of integers, find the first missing positive integer in linear time and constant space. In other words, find the lowest positive integer that does not exist in the array. The array can contain duplicates and negative numbers as well.": 0.22580645161290322, "Write a Python program to find the sum of the positive integers of a given range.": 0.22222222222222224, "Given an integer array nums, find the subarray with the largest sum, and return its sum.": 0.22222222222222224, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.2162162162162162, "Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s.": 0.2127659574468085, "Write a Python program to find the number of occurrences of a specified element in a given array of integers.": 0.20000000000000004, "Write a Python function to find the number of items in a list that are not equal to a given value.": 0.1951219512195122}, "avg_similarity_score": 0.11155862223974114} -{"instruction": "What is the difference between a relative and absolute path?", "input": "", "output": "A relative path is a path that starts from the current directory. An absolute path is a path that starts from the root directory. For example, the relative path to the file \u201c/home/user/file.txt\u201d is \u201cfile.txt\u201d. The absolute path to the file \u201c/home/user/file.txt\u201d is \u201c/home/user/file.txt\u201d.", "most_similar": {"What is the difference between a class and an object?": 0.7, "What is the difference between a static and a dynamic method?": 0.6666666666666666, "What is the difference between a list and a tuple in Python?": 0.6363636363636365, "What is the difference between a replica set and a stateful set?": 0.6363636363636365, "What is the difference between a for loop and a while loop?": 0.6363636363636365, "What is the difference between an ingress and a persistent volume?": 0.5714285714285713, "What is the difference between a variable that is declared and defined and a variable that is only declared?": 0.48275862068965514, "What is Kubernetes ?": 0.30769230769230765, "What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.25806451612903225, "What is the output of the following code? ```py def add(a, b): return a + b print(add(1, 2)) print(add(b=2, a=1)) ```": 0.2222222222222222}, "avg_similarity_score": 0.12919048551494822} -{"instruction": "Write a Python program to get the volume of a sphere with radius 6.", "input": "", "output": "```python import math radius = 6 volume = (4/3) * math.pi * radius**3 print(volume) ```", "most_similar": {"Write a Python program to find the sum of a non-negative integer.": 0.5925925925925927, "Write a Python program to find the frequency of each word in a given string.": 0.5517241379310344, "Write a Python program to find the sum of the positive integers of a given range.": 0.5333333333333333, "Write a Python program to find the longest common prefix of a given list of strings.": 0.5333333333333333, "Write a Python function to find the sum of all items in a list.": 0.5, "Write a Python program to find the first non-repeated character in a string.": 0.5, "Write a Python program to find the longest pallindrome substring from a given string.": 0.5, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.5, "Write a Python program to find the most common words in a given text.": 0.5, "Write a Python program to find the number of even and odd numbers from a series of numbers.": 0.5}, "avg_similarity_score": 0.23130849717282667} -{"instruction": "How can I sort a list of integers in Rust?", "input": "", "output": "You can use the sort method to sort a list of integers in Rust. Here's an example: ``` fn main() { let mut arr = [5, 2, 4, 1, 3]; arr.sort(); println!(\"{:?}\", arr); } ``` This code sorts the array arr in place using the sort method. The sort method sorts the slice in place and preserves the order of equal elements.", "most_similar": {"How do you sort a list of strings in Python?": 0.6, "How can I make a button in HTML?": 0.5555555555555556, "bubble sort list of int in python": 0.47058823529411764, "How can I get the number of days between two dates in python?": 0.4347826086956522, "How do I create a new branch in git?": 0.4210526315789474, "How do I output a string in C++ programming?": 0.4210526315789474, "How can I find the maximum and minimum value in a list using Python?": 0.41666666666666663, "How do you remove duplicates from a list in Python?": 0.4000000000000001, "How do I make a function that takes a string and returns a list of the words in the string?": 0.4, "How can I get the first 1000 prime numbers in Python?": 0.380952380952381}, "avg_similarity_score": 0.15508731726738526} -{"instruction": "I'm trying to use the following code to create a new column in a dataframe:\n```python\ndf['new_col'] = df['col_1'].apply(lambda x: x.split(' ')[0])\n```\nBut I'm getting the following error:\n```python\nAttributeError: 'float' object has no attribute 'split'\n```", "input": "", "output": "The error is caused by the fact that the `col_1` column contains float values. You can use the following code to create a new column that contains the first word from the `col_1` column: ```python df['new_col'] = df['col_1'].apply(lambda x: str(x).split(' ')[0]) ```", "most_similar": {"What is the output of the following code?\n```python\ndef func(x):\n return x + 1\n\ndef main():\n x = 1\n y = func(x)\n print(y)\n\nmain()\n```": 0.2028985507246377, "Create a calculator in the Python programming language": 0.1923076923076923, "How do I create a new branch in git?": 0.18867924528301888, "What is the output of the following code?\n```python\ndef f(x):\n return x * 2\n\ndef g(x):\n return f(x) + 1\n\ndef h(x):\n return g(x) * 2\n\nprint(h(2))\n```": 0.18421052631578946, "How do I get the power of a number in python?": 0.18181818181818182, "How to get the last element of a list in Python?": 0.18181818181818182, "How to make a python program that will print the following pattern?\n```\n*\n**\n***\n****\n*****\n```": 0.17857142857142858, "What is the output of this code?\n```python\ndef f(x):\n x = 2 * x + 1\n return x\n\nx = 3\nz = f(x)\nprint(z)\n```": 0.1764705882352941, "How to find the sum of all the elements in a list in python?": 0.17241379310344826, "How can I find the maximum and minimum value in a list using Python?": 0.17241379310344826}, "avg_similarity_score": 0.1058800110782541} -{"instruction": "What is the output of the following code?\n```python\ndef foo():\n print(\"foo\")\n\ndef bar():\n print(\"bar\")\n\ndef main():\n foo()\n bar()\n\nmain()\n```", "input": "", "output": "The output of the code is: ```bar foo```", "most_similar": {"What is the output of the following code?\n```python\ndef func(x):\n return x + 1\n\ndef main():\n x = 1\n y = func(x)\n print(y)\n\nmain()\n```": 0.5531914893617023, "What is the output of the following Python code? ```py def f(x): return x + 1 def g(x): return x * 2 print(g(f(3))) ```": 0.4583333333333333, "What is the output of the following code? ```py def add(a, b): return a + b print(add(1, 2)) print(add(b=2, a=1)) ```": 0.4583333333333333, "What is the output of this code?\n```\nx = 10\ndef func():\n x = 20\n print(x)\nfunc()\nprint(x)\n```": 0.45, "What is the output of the following code?\n```python\ndef f(x):\n return x * 2\n\ndef g(x):\n return f(x) + 1\n\ndef h(x):\n return g(x) * 2\n\nprint(h(2))\n```": 0.4444444444444444, "What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.4186046511627907, "What is the output of this code?\n```python\ndef f(x):\n x = 2 * x + 1\n return x\n\nx = 3\nz = f(x)\nprint(z)\n```": 0.3913043478260869, "What is the output of the following code?\n```\npublic class Test {\n public static void main(String[] args) {\n int i = 1;\n while (i <= 5) {\n System.out.println(i);\n i++;\n }\n }\n}\n```": 0.36000000000000004, "Translate the following code from python in Java.": 0.26666666666666666, "Translate the following code from python in Java.\ndef function(a : int, b : int, c : int):\n if a > b :\n print('You lost.')\n else :\n if c > a :\n print('Nice try.')\n else :\n print('You won.')": 0.2545454545454546}, "avg_similarity_score": 0.10945197526450416} -{"instruction": "How can I create a new column in a pandas dataframe that is the sum of two other columns?", "input": "", "output": "You can use the **assign** method to create a new column in a pandas dataframe that is the sum of two other columns. For example: ``` df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]}) df.assign(C=df.A + df.B) ```", "most_similar": {"How do I create a new branch in git?": 0.42857142857142855, "How can I get the number of days between two dates in python?": 0.37499999999999994, "How can I make a button in HTML?": 0.37037037037037035, "How can I sort a list of integers in Rust?": 0.3448275862068966, "How do I make a variable that is only declared?": 0.3448275862068966, "How do I find the greatest common divisor of two numbers?": 0.3333333333333333, "How can I find the maximum and minimum value in a list using Python?": 0.30303030303030304, "Write a python function that returns the sum of the elements of a list.": 0.30303030303030304, "Create a calculator in the Python programming language": 0.2962962962962963, "How do you create a variable in Python?": 0.2962962962962963}, "avg_similarity_score": 0.16652460278285736} -{"instruction": "Solve the math problems. Intermediate steps are required.\nA train running at the speed of 36 km/hr crosses a pole in 9 seconds. what is the length of the train?", "input": "", "output": "The speed 36 km/hr = 36 x 1000 / 3600 m/s = 10 m/s. \nThe length of the train = speed x time = 10 x 9 = 90 m.\nSo, the length of the train is 90 meters.", "most_similar": {"Solve the math problems. Intermediate steps are required.": 0.41025641025641024, "Using the comment as a guide, replace the \"TODO\" comment in the code with the proper code.": 0.25, "write a code to get the current value of a Bitcoin in US dollars using the bitcoincharts API.": 0.24489795918367346, "Given a list of numbers, find the sum of the numbers.": 0.23809523809523805, "Write a Python program to find the number of occurrences of a specified element in a given array of integers.": 0.23529411764705882, "Write a script to output the mean of a list of integers.": 0.2325581395348837, "Write a Python program to find the first repeated character of a given string where the index of first occurrence is smallest.": 0.22641509433962262, "Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.": 0.22641509433962262, "Write a python function that returns the sum of the elements of a list.": 0.2222222222222222, "Given a string `s`, find the length of the longest substring without repeating characters.": 0.2222222222222222}, "avg_similarity_score": 0.13282335314956178} -{"instruction": "What is the output of the following python code?\n```python\ndef function(a):\n if a > 0:\n print('Positive')\n else:\n print('Negative')\n\nfunction(0)\n```", "input": "", "output": "Negative", "most_similar": {"What is the output of the following code?\n```python\ndef foo():\n print(\"foo\")\n\ndef bar():\n print(\"bar\")\n\ndef main():\n foo()\n bar()\n\nmain()\n```": 0.5333333333333332, "What is the output of the following code? ```py def add(a, b): return a + b print(add(1, 2)) print(add(b=2, a=1)) ```": 0.5306122448979592, "What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.5, "What is the output of the following code?\n```python\ndef func(x):\n return x + 1\n\ndef main():\n x = 1\n y = func(x)\n print(y)\n\nmain()\n```": 0.4583333333333333, "What is the output of the following Python code? ```py def f(x): return x + 1 def g(x): return x * 2 print(g(f(3))) ```": 0.44897959183673475, "What is the output of this code?\n```\nx = 10\ndef func():\n x = 20\n print(x)\nfunc()\nprint(x)\n```": 0.4390243902439025, "Translate the following code from python in Java.\ndef function(a : int, b : int, c : int):\n if a > b :\n print('You lost.')\n else :\n if c > a :\n print('Nice try.')\n else :\n print('You won.')": 0.42857142857142855, "What is the output of the following code?\n```python\ndef f(x):\n return x * 2\n\ndef g(x):\n return f(x) + 1\n\ndef h(x):\n return g(x) * 2\n\nprint(h(2))\n```": 0.4, "What is the output of this code?\n```python\ndef f(x):\n x = 2 * x + 1\n return x\n\nx = 3\nz = f(x)\nprint(z)\n```": 0.3829787234042554, "What is the output of the following code?\n```\npublic class Test {\n public static void main(String[] args) {\n int i = 1;\n while (i <= 5) {\n System.out.println(i);\n i++;\n }\n }\n}\n```": 0.3137254901960784}, "avg_similarity_score": 0.1456078756052604} -{"instruction": "I have a list of numbers and I want to find the average of all the numbers.", "input": "", "output": "def average_numbers(numbers):\n return sum(numbers) / len(numbers)", "most_similar": {"I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.6666666666666667, "Given a list of numbers, find the sum of the numbers.": 0.6428571428571428, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.5263157894736842, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.45161290322580644, "Write a C# program to find the sum of all the elements of an array.": 0.43749999999999994, "Write a program to find the sum of all the multiples of 3 or 5 below 1000.": 0.4117647058823529, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.4117647058823529, "Write a Python function to find the smallest number from a sequence of numbers.": 0.3870967741935484, "Write a Python function to find the sum of all items in a list.": 0.3870967741935484, "How to find the sum of all the elements in a list in python?": 0.3870967741935484}, "avg_similarity_score": 0.19012631424956497} -{"instruction": "I'm trying to run a Python script on a remote server. I'm getting an error: \"ImportError: No module named 'requests'\". How can I fix this?", "input": "", "output": "You can install the requests module by running the following command: ``` pip install requests ```", "most_similar": {"I'm trying to use the following code to create a new column in a dataframe:\n```python\ndf['new_col'] = df['col_1'].apply(lambda x: x.split(' ')[0])\n```\nBut I'm getting the following error:\n```python\nAttributeError: 'float' object has no attribute 'split'\n```": 0.30985915492957744, "I have 2 EC2 machines on AWS, I'm having trouble making them communicate. How could I troubleshoot it?": 0.2608695652173913, "I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.24489795918367346, "Write me a python script, which reads data from a json file and saves the data in an appropriate data structure.": 0.20833333333333334, "How do I compile a go program on Linux to a windows executable?": 0.2, "Write a python code for a linked list": 0.17142857142857143, "How can I make a button in HTML?": 0.17142857142857143, "Write a python script that prints the following pattern:\n```\n*\n**\n***\n****\n*****\n```": 0.16666666666666666, "Write python code to connect to a FTP server.": 0.16666666666666666, "Write a script to output the factorial of an integer.": 0.16216216216216217}, "avg_similarity_score": 0.0978726524940433} -{"instruction": "How can I find the first repeated word in a string?", "input": "", "output": "You can use a set to keep track of the words you've seen so far. Here's an example: ```python def first_repeated_word(text):\n words = text.split()\n seen = set()\n for word in words:\n if word in seen:\n return word\n seen.add(word)\n return None ``` This function takes a string as input and returns the first repeated word in the string. It uses the split method to split the string into a list of words. It then iterates through the list of words and checks if the word is in the set of words seen so far. If it is, the function returns the word. Otherwise, it adds the word to the set of words seen so far. If the function reaches the end of the list of words without finding a repeated word, it returns None.", "most_similar": {"How do I find the first and last occurrence of a substring in a string in C++?": 0.5714285714285714, "How can I find the maximum and minimum value in a list using Python?": 0.56, "Write a Python program to find the first non-repeated character in a string.": 0.56, "How can I get the first 1000 prime numbers in Python?": 0.5454545454545454, "How do I find the p-variance of all elements in a list?": 0.4999999999999999, "How do I find the maximum value in an array?": 0.47619047619047616, "How do I find the fibonacci number of a number?": 0.47619047619047616, "Write a Python program to find the frequency of each word in a given string.": 0.4615384615384615, "How do you find the length of a string in Python?": 0.45454545454545453, "How can I get the current date and time in Python?": 0.45454545454545453}, "avg_similarity_score": 0.17138109838808468} -{"instruction": "What is a Docker container?", "input": "", "output": "A Docker container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another. A Docker container image is a lightweight, standalone, executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries and settings.", "most_similar": {"What is Kubernetes ?": 0.5, "What is the difference between a class and an object?": 0.4, "What is the difference between a relative and absolute path?": 0.4, "What is the difference between an ingress and a persistent volume?": 0.37499999999999994, "What is the difference between a static and a dynamic method?": 0.37499999999999994, "What is the difference between a list and a tuple in Python?": 0.35294117647058826, "What is the difference between a replica set and a stateful set?": 0.35294117647058826, "What is the difference between a for loop and a while loop?": 0.35294117647058826, "What is the difference between a variable that is declared and defined and a variable that is only declared?": 0.25, "What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.23076923076923073}, "avg_similarity_score": 0.09525321760480562} -{"instruction": "What is a Dockerfile?", "input": "", "output": "A Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image. Using docker build users can create an automated build that executes several command-line instructions in succession.", "most_similar": {"What is a Docker container?": 0.6666666666666665, "What is Kubernetes ?": 0.5714285714285715, "What is the difference between a relative and absolute path?": 0.4285714285714285, "What is the difference between a class and an object?": 0.4285714285714285, "What is the difference between a static and a dynamic method?": 0.39999999999999997, "What is the difference between an ingress and a persistent volume?": 0.39999999999999997, "What is the difference between a for loop and a while loop?": 0.375, "What is the difference between a list and a tuple in Python?": 0.375, "What is the difference between a replica set and a stateful set?": 0.375, "What is the difference between a variable that is declared and defined and a variable that is only declared?": 0.2608695652173913}, "avg_similarity_score": 0.10298507726533793} -{"instruction": "Given the `root` of a binary tree, return the inorder traversal of its nodes' values.\n# Definition for a binary tree node.\nclass TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right", "input": "", "output": "class Solution:\n def inorderTraversal(self, root: Optional[TreeNode]) -> List[int]:\n return self.inorderTraversal(root.left) + [root.val] + self.inorderTraversal(root.right) if root else []", "most_similar": {"Given the `root` of a binary tree, return the inorder traversal of its nodes' values.": 0.5357142857142857, "Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s.": 0.2058823529411765, "Given a string s, return the number of palindromic substrings in it.": 0.18867924528301888, "Write a python function that returns the sum of the elements of a list.": 0.18181818181818182, "Write a Python program to find the sum of the positive integers of a given range.": 0.17543859649122806, "Write a Python function to find the index of the first occurrence of a specified item in a list.": 0.16666666666666666, "Given an array of integers, return indices of the two numbers such that they add up to a specific target.": 0.16393442622950818, "Write a Python program to find the first repeated character of a given string where the index of first occurrence is smallest.": 0.15873015873015872, "What is the output of the following python code?\n```python\ndef function(a):\n if a > 0:\n print('Positive')\n else:\n print('Negative')\n\nfunction(0)\n```": 0.15625, "Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. A palindrome string is a string that reads the same backward as forward.": 0.15584415584415584}, "avg_similarity_score": 0.09270560924100404} -{"instruction": "Solving the math word problem with linear algebra equations.\nJenna is training hard to qualify for the National Games. She has a regular weekly routine, training for five hours a day on some days and 3 hours a day on the other days. She trains altogether 27 hours in a seven day week. On how many days does she train for five hours?", "input": "", "output": "Sol: Let x = the number of \"5 hour\" days, y = the number of \"3 hour\" days.\nWe know there are seven days in the week, so: x + y = 7.\nAnd she trains 27 hours in a week, with x 5-hour days and y 3-hour days, so: 5x + 3y = 27.\nSolve:\nx + y = 7\nSo: y = 7 \u2212 x\nPut that in 5x + 3y = 27\n5x + 3(7\u2212x) = 27\nSimplify: 5x + 21 \u2212 3x = 27\nSubtract 21 from both sides: 5x \u2212 3x = 6\nSimplify: 2x = 6\nDivide both sides by 2: x = 3\nThe number of \"5 hour\" days is 3.", "most_similar": {"Solving the math word problem with linear algebra equations.": 0.25, "Answer the following math problem. You should write down the reasoning steps.\nRoger has 5 tennis balls. He buys 2 more cans of tennis balls. Each can has 3 tennis balls. How many tennis balls does he have now?": 0.17647058823529413, "What is the difference between a list and a tuple in Python?": 0.16, "What is the difference between a for loop and a while loop?": 0.16, "Write a program that prints the numbers from 1 to 100. But for multiples of three print \"Fizz\" instead of the number and for the multiples of five print \"Buzz\". For numbers which are multiples of both three and five print \"FizzBuzz\".": 0.15238095238095237, "How do I make a function that takes a string and returns a list of the words in the string?": 0.14457831325301204, "Write a Python function that takes a string and returns a new string with the words in sorted order and unique.": 0.14285714285714285, "What is the difference between a static and a dynamic method?": 0.13513513513513514, "What is the difference between a replica set and a stateful set?": 0.13333333333333333, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.13333333333333333}, "avg_similarity_score": 0.08238317813020726} -{"instruction": "What is the output of the following code?\n```python\ndef foo():\n x = 1\n def bar():\n x = 2\n return x\n return bar()\nprint(foo())\n```", "input": "", "output": "2", "most_similar": {"What is the output of the following code?\n```python\ndef func(x):\n return x + 1\n\ndef main():\n x = 1\n y = func(x)\n print(y)\n\nmain()\n```": 0.6666666666666666, "What is the output of the following code?\n```python\ndef foo():\n print(\"foo\")\n\ndef bar():\n print(\"bar\")\n\ndef main():\n foo()\n bar()\n\nmain()\n```": 0.6666666666666666, "What is the output of the following Python code? ```py def f(x): return x + 1 def g(x): return x * 2 print(g(f(3))) ```": 0.6530612244897959, "What is the output of the following code?\n```python\ndef f(x):\n return x * 2\n\ndef g(x):\n return f(x) + 1\n\ndef h(x):\n return g(x) * 2\n\nprint(h(2))\n```": 0.6181818181818182, "What is the output of this code?\n```python\ndef f(x):\n x = 2 * x + 1\n return x\n\nx = 3\nz = f(x)\nprint(z)\n```": 0.5957446808510638, "What is the output of this code?\n```\nx = 10\ndef func():\n x = 20\n print(x)\nfunc()\nprint(x)\n```": 0.5365853658536586, "What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.5, "What is the output of the following code? ```py def add(a, b): return a + b print(add(1, 2)) print(add(b=2, a=1)) ```": 0.4897959183673469, "What is the output of the following python code?\n```python\ndef function(a):\n if a > 0:\n print('Positive')\n else:\n print('Negative')\n\nfunction(0)\n```": 0.4782608695652174, "What is the output of the following code?\n```\npublic class Test {\n public static void main(String[] args) {\n int i = 1;\n while (i <= 5) {\n System.out.println(i);\n i++;\n }\n }\n}\n```": 0.35294117647058826}, "avg_similarity_score": 0.12254360009315438} -{"instruction": "Write a Python function to check if a given number is a pandigital number or not. A pandigital number is a number that contains all the digits from 1 to n exactly once.", "input": "", "output": "def is_pandigital(num):\n digits = set()\n for i in str(num):\n if i in digits:\n return False\n else:\n digits.add(i)\n return len(digits) == 9", "most_similar": {"Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.6984126984126984, "Write a Python function to check if a given number is a Fermat number or not. A Fermat number is a number of the form 22n + 1, where n is a non-negative integer.": 0.6865671641791046, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.6376811594202899, "Write a Python function to check if a given number is a prime number or not.": 0.6122448979591837, "Write a Python function to check if a given number is a Catalan number or not. A Catalan number is a number that occurs in the sequence of Catalan numbers. The sequence of Catalan numbers is generated by the following formula: Cn = (2n)! / (n+1)!n!": 0.6075949367088608, "Write a Python function to check if a given number is a repdigit or not. A repdigit is a number that contains only one digit. For example, 11, 22, 3333, 44444444 are repdigits.": 0.6060606060606061, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.6, "Write a Python function to check if a given number is an Armstrong number or not. An Armstrong number is a number that is equal to the sum of its own digits each raised to the power of the number of digits.": 0.5866666666666667, "Write a Python function to check if a given number is a palindrome or not. A palindrome is a number that remains the same when its digits are reversed. For example, 121 is a palindrome but 112 is not.": 0.5833333333333334, "Write a Python function to check if a given number is a Harshad number or not. A Harshad number is a number that is divisible by the sum of its digits. For example, 42 is a Harshad number because it is divisible by 6 (the sum of its two digits 4 + 2).": 0.5411764705882354}, "avg_similarity_score": 0.1795639134353345} -{"instruction": "Write a function that takes an integer as input and returns the number of bits that are equal to 1 in the binary representation of that number. You can guarantee that input is non-negative.", "input": "", "output": "You can use the built-in function bin() to convert the number to binary and then count the number of 1s in the string.\n```\ndef count_bits(n):\n return bin(n).count('1')\n```", "most_similar": {"Write a Python function that takes a number as input and returns the square of that number.": 0.5, "Write a function that takes a string and returns the number of vowels in the string.": 0.47058823529411753, "Write a Python function that takes a number as input and returns the sum of all the numbers from 1 to that number that are divisible by 3 and 5.": 0.4615384615384615, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.43333333333333335, "Write a Python function that takes a string as input and returns the string in reverse order.\n'Hello'": 0.41509433962264153, "Please write a Rust function that takes a u64 input and returns the largest prime number less than that value.": 0.4, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.39285714285714285, "Write a function that takes a string as input and reverse only the vowels of a string.": 0.3846153846153846, "Write a python function that returns the number of words in a given string.": 0.36734693877551017, "Write a python function that returns the sum of the elements of a list.": 0.36734693877551017}, "avg_similarity_score": 0.16767806117894074} -{"instruction": "Write a Python program to find the average of a list using for loop.", "input": "", "output": "def average_of_list(list):\n sum = 0\n for i in list:\n sum += i\n return sum / len(list)", "most_similar": {"Write a Python program to find the longest common prefix of a given list of strings.": 0.6666666666666666, "Write a Python program to find the sum of a non-negative integer.": 0.6666666666666666, "Write a Python function to find the sum of all items in a list.": 0.6428571428571429, "Write a program to find the smallest number in a list.": 0.64, "Write a Python program to find the frequency of each word in a given string.": 0.6206896551724138, "Write a Python program to find the maximum and minimum number from a given list.": 0.6206896551724138, "Write a Python program to find the sum of the positive integers of a given range.": 0.6000000000000001, "Write a Python program to find the longest pallindrome substring from a given string.": 0.5714285714285714, "Write a Python program to find the most common words in a given text.": 0.5714285714285714, "Write a Python program to find the list of words that are longer than n from a given list of words.": 0.5714285714285714}, "avg_similarity_score": 0.2523459165591036} -{"instruction": "Using the comment as a guide, replace the \"TODO\" comment in the code with the proper code.\ndef greet_to(name):\n \"\"\"Print a greeting to the name provided.\"\"\"\n # TODO: assert name is a string\n print(\"Hello, \" + name + \"!\")", "input": "", "output": "def greet_to(name):\n \"\"\"Print a greeting to the name provided.\"\"\"\n # assert name is a string\n assert isinstance(name, str), \"name must be a string\"\n print(\"Hello, \" + name + \"!\")", "most_similar": {"Using the comment as a guide, replace the \"TODO\" comment in the code with the proper code.": 0.6296296296296297, "What is the output of the following python code?\n```python\ndef function(a):\n if a > 0:\n print('Positive')\n else:\n print('Negative')\n\nfunction(0)\n```": 0.23333333333333334, "Replace the token in the text with proper words that are consistent with the context. You can use multiple words for each token.": 0.22580645161290325, "Find the bug in the following code piece: a = 1 while a == 1: b = input(\"what's your name ?\") print(\"Hi \",b, \" this is infinity loop !\")": 0.22222222222222224, "What is the output of the following code? ```py def add(a, b): return a + b print(add(1, 2)) print(add(b=2, a=1)) ```": 0.22222222222222224, "Replace all the human names in the paragraph with .": 0.21276595744680854, "Write a Python function to find the number of items in a list that are not equal to a given value.": 0.20689655172413793, "What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.20689655172413793, "What is the output of the following code?\n```python\ndef foo():\n print(\"foo\")\n\ndef bar():\n print(\"bar\")\n\ndef main():\n foo()\n bar()\n\nmain()\n```": 0.20338983050847456, "Replace all the human names in the paragraph with .\nACM named Yoshua Bengio, Geoffrey Hinton, and Yann LeCun recipients of the 2018 ACM A.M. Turing Award for conceptual and engineering breakthroughs that have made deep neural networks a critical component of computing.": 0.19753086419753088}, "avg_similarity_score": 0.12649748148654003} -{"instruction": "Write a Python function that takes a number as input and returns its square, cube, square root, cube root, and the sum of its digits.", "input": "", "output": "def square_cube_square_root_cube_root_sum_digits(a):\n return a * a, a * a * a, a ** 0.5, a ** (1/3), sum(int(i) for i in str(a))\n\nresult = square_cube_square_root_cube_root_sum_digits(5)\nprint(result)", "most_similar": {"Write a Python function that takes a number as input and returns the square of that number.": 0.6666666666666666, "Write a Python function that takes two numbers as input and returns their sum.": 0.5641025641025641, "Write a Python function that takes a string as input and returns the string in reverse order.\n'Hello'": 0.5581395348837209, "Write a Python function that takes a number as input and returns the sum of all the numbers from 1 to that number that are divisible by 3 and 5.": 0.5454545454545454, "Write a function that takes a string as input and reverse only the vowels of a string.": 0.5238095238095238, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.5217391304347826, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.52, "Write a function that takes a string and returns the number of vowels in the string.": 0.48780487804878053, "Write a python function that returns the sum of the elements of a list.": 0.4615384615384615, "Write a Python function that takes a list and returns a new list with unique elements of the first list.": 0.4444444444444445}, "avg_similarity_score": 0.18002646497570768} -{"instruction": "Write a Python function to find the first repeated word in a given string, ignoring case and punctuation.", "input": "", "output": "def first_repeated_word_ignore_case_and_punctuation(string):\n words = string.split()\n for word in words:\n if words.count(word.lower().strip('.,?!')) > 1:\n return word\n return None", "most_similar": {"Write a Python program to find the first non-repeated character in a string.": 0.6875000000000001, "Write a Python program to find the frequency of each word in a given string.": 0.6666666666666666, "Write a Python function to find the largest number in a dictionary.": 0.6, "Write a Python function to find the sum of all items in a list.": 0.5625000000000001, "Write a Python program to find the longest pallindrome substring from a given string.": 0.5625000000000001, "Write a Python program to find the most common words in a given text.": 0.5625000000000001, "Write a python function that returns the number of words in a given string.": 0.5625000000000001, "How can I find the first repeated word in a string?": 0.5517241379310345, "Write a Python program to find the first repeated character of a given string where the index of first occurrence is smallest.": 0.55, "Write a Python function to find the index of the first occurrence of a specified item in a list.": 0.5405405405405405}, "avg_similarity_score": 0.23338229297342264} -{"instruction": "How can I make a program that will find the largest number in a list?", "input": "", "output": "def largest_number(list):\n return max(list)", "most_similar": {"Write a program to find the smallest number in a list.": 0.6153846153846153, "How do you find the largest number in a list using Python?": 0.5925925925925926, "How can I find the maximum and minimum value in a list using Python?": 0.5517241379310344, "How can I find the first repeated word in a string?": 0.5384615384615385, "How can I make a button in HTML?": 0.5217391304347827, "Write a Python function to find the largest number in a dictionary.": 0.5185185185185186, "Write a Python function that returns the largest item in a list.": 0.5185185185185186, "How to make a python program that will print the following pattern?\n```\n*\n**\n***\n****\n*****\n```": 0.5185185185185186, "How do I find the p-variance of all elements in a list?": 0.5, "How do I find the fibonacci number of a number?": 0.48}, "avg_similarity_score": 0.21845605904969695} -{"instruction": "How do I get the first element of a list?", "input": "", "output": "You can use the index operator to get the first element of a list. For example: ``` list = [1, 2, 3, 4, 5] print(list[0]) ``` This will print the following output: ``` 1 ```", "most_similar": {"How do I get the last element of an array?": 0.7, "How to get the last element of a list in Python?": 0.6666666666666666, "How do I get the power of a number in python?": 0.6666666666666666, "How do I find the p-variance of all elements in a list?": 0.608695652173913, "How do I find the fibonacci number of a number?": 0.6, "How do you output all the contents of a list in Python?": 0.5454545454545454, "How do you find the index of an item in a list?": 0.5454545454545454, "How do I find the first and last occurrence of a substring in a string in C++?": 0.5185185185185185, "How do you find the standard deviation of all items in a list in Python?": 0.48, "How do I find the greatest common divisor of two numbers?": 0.47619047619047616}, "avg_similarity_score": 0.1802678187103389} -{"instruction": "How do I create a new array from the values of two existing arrays in JavaScript?", "input": "", "output": "You can use the concat() method to create a new array from the values of two existing arrays.\n\n```javascript const new_array = old_array.concat(another_old_array); ```", "most_similar": {"How do I create a new branch in git?": 0.56, "How do you create a new list from two lists in Python by picking one element each?": 0.48484848484848486, "How can I create a new column in a pandas dataframe that is the sum of two other columns?": 0.45714285714285713, "How do I get the power of a number in python?": 0.4444444444444444, "How do I find the greatest common divisor of two numbers?": 0.4444444444444444, "How do you create a variable in Python?": 0.4166666666666667, "How can I get the number of days between two dates in python?": 0.41379310344827586, "How do I find the standard deviation of all elements in an array?": 0.41379310344827586, "How do I find the p-variance of all elements in a list?": 0.41379310344827586, "How do I output a string in C++ programming?": 0.39999999999999997}, "avg_similarity_score": 0.16931267085096774} -{"instruction": "How do I find the index of the first occurrence of a value in an array?", "input": "", "output": "You can use the indexOf() method to find the index of the first occurrence of a value in an array.\n\n```javascript const index = array.indexOf(value); ```", "most_similar": {"How do I find the maximum value in an array?": 0.6923076923076923, "How do I find the standard deviation of all elements in an array?": 0.6206896551724138, "How do I find the first and last occurrence of a substring in a string in C++?": 0.6060606060606061, "Write a Python function to find the index of the first occurrence of a specified item in a list.": 0.5714285714285714, "How do you find the number of occurrences of a given value in a list in Python?": 0.5454545454545455, "How do I get the last element of an array?": 0.5384615384615384, "How do I find the fibonacci number of a number?": 0.5384615384615384, "How do I get the first element of a list?": 0.5384615384615384, "How do I get the power of a number in python?": 0.5185185185185185, "How do you find the length of a string in Python?": 0.5185185185185185}, "avg_similarity_score": 0.19265162995873686} -{"instruction": "How do I find the first element that satisfies a condition in an array?", "input": "", "output": "You can use the find() method to find the first element that satisfies a condition in an array.\n\n```javascript const element = array.find(element => element > 10); ```", "most_similar": {"How do I find the index of the first occurrence of a value in an array?": 0.6666666666666666, "How do I find the maximum value in an array?": 0.6666666666666666, "How do I find the standard deviation of all elements in an array?": 0.5925925925925927, "How do I get the first element of a list?": 0.5833333333333334, "How do I get the last element of an array?": 0.5833333333333334, "How do I find the first and last occurrence of a substring in a string in C++?": 0.5161290322580646, "How do I find the fibonacci number of a number?": 0.5, "How can I find the first repeated word in a string?": 0.4799999999999999, "How do I get the power of a number in python?": 0.4799999999999999, "How do you find the length of a string in Python?": 0.4799999999999999}, "avg_similarity_score": 0.17290635833230522} -{"instruction": "Write a program to find the pearson correlation coefficient of two lists.", "input": "", "output": "def pearson_correlation_coefficient(list1, list2):\n mean1 = sum(list1) / len(list1)\n mean2 = sum(list2) / len(list2)\n cov = sum([(x1 - mean1) * (x2 - mean2) for x1, x2 in zip(list1, list2)]) / len(list1)\n std1 = sum([(x1 - mean1) ** 2 for x1 in list1]) / len(list1)\n std2 = sum([(x2 - mean2) ** 2 for x2 in list2]) / len(list2)\n return cov / (std1 * std2) ** 0.5", "most_similar": {"Write a Python function to find the correlation between two lists.": 0.6956521739130435, "Write a Python program to find the unique common elements from two lists.": 0.64, "Write a Python program to find the sum of a non-negative integer.": 0.5599999999999999, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.5384615384615384, "Write a Python program to find the average of a list using for loop.": 0.5384615384615384, "Write a program to find the smallest number in a list.": 0.5217391304347826, "Write a Python program to find the frequency of the words from the sentence given.": 0.5185185185185186, "Write a Python program to find the frequency of each word in a given string.": 0.5185185185185186, "Write a C# program to find the sum of all the elements of an array.": 0.5185185185185186, "Write a Python program to find the longest common prefix of a given list of strings.": 0.5}, "avg_similarity_score": 0.21325038199747204} -{"instruction": "How to find the maximum value in a list?", "input": "", "output": "You can use the built-in max function to find the maximum value in a list.\n\nFor example, to find the maximum value in the list [1, 2, 3, 4, 5]:\n\nmax([1, 2, 3, 4, 5])\n\nThis returns 5.", "most_similar": {"How can I find the maximum and minimum value in a list using Python?": 0.6956521739130435, "How do I find the maximum value in an array?": 0.631578947368421, "How to find the sum of all the elements in a list in python?": 0.6086956521739131, "Write a program to find the smallest number in a list.": 0.6, "How do you find the index of an item in a list?": 0.5714285714285715, "How do you find the largest number in a list using Python?": 0.5714285714285715, "How do I find the p-variance of all elements in a list?": 0.5454545454545455, "How do you find the number of occurrences of a given value in a list in Python?": 0.5384615384615384, "Write a Python function to find the sum of all items in a list.": 0.5217391304347826, "How do you find the standard deviation of all items in a list in Python?": 0.5}, "avg_similarity_score": 0.2071947021842101} -{"instruction": "How to find the frequency distribution of all values in a list?", "input": "", "output": "You can use the built-in statistics module to find the frequency distribution of all values in a list.\n\nFor example, to find the frequency distribution of all values in the list [1, 2, 3, 4, 5]:\n\nimport statistics\n\nstatistics.frequencies([1, 2, 3, 4, 5])\n\nThis returns {1: 1, 2: 1, 3: 1, 4: 1, 5: 1}.", "most_similar": {"How to find the sum of all the elements in a list in python?": 0.6923076923076924, "How to find the maximum value in a list?": 0.6666666666666666, "How do I find the p-variance of all elements in a list?": 0.64, "Write a Python function to find the sum of all items in a list.": 0.6153846153846153, "How do you find the standard deviation of all items in a list in Python?": 0.5925925925925926, "How do you find the index of an item in a list?": 0.5833333333333334, "How to find the largest prime factor of a given number?": 0.5217391304347826, "Write a program to find the smallest number in a list.": 0.5217391304347826, "How to get the last element of a list in Python?": 0.5217391304347826, "Write a Python program to find the frequency of each word in a given string.": 0.5185185185185186}, "avg_similarity_score": 0.21143622738779402} -{"instruction": "Write a function that returns the sum of two numbers.", "input": "", "output": "function sum(a, b) {\n return a + b;\n}", "most_similar": {"Write a python function that returns the sum of the elements of a list.": 0.6666666666666666, "Write a python function that returns the number of words in a given string.": 0.5833333333333334, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.5806451612903225, "Write a Python function that returns the largest item in a list.": 0.5454545454545454, "Write a function that takes a string and returns the number of vowels in the string.": 0.5384615384615384, "Write a Python function that takes a number as input and returns the square of that number.": 0.5185185185185185, "Write a Python function that takes two numbers as input and returns their sum.": 0.5, "Write a Python function to find the smallest number from a sequence of numbers.": 0.5, "Write a Python function to find the sum of all items in a list.": 0.5, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.5}, "avg_similarity_score": 0.2182553106515031} -{"instruction": "Write a python code to find the minimum value in a list.", "input": "", "output": "```python def min_num(list):\n return min(list) ```", "most_similar": {"Write a program to find the smallest number in a list.": 0.6956521739130435, "Write a Python function to find the sum of all items in a list.": 0.6923076923076924, "Write a Python function to find the largest number in a dictionary.": 0.6666666666666666, "How to find the maximum value in a list?": 0.6666666666666666, "Write a Python program to find the maximum and minimum number from a given list.": 0.6666666666666665, "Write a Python program to find the average of a list using for loop.": 0.6153846153846153, "Write a Python program to find the first non-repeated character in a string.": 0.6153846153846153, "Write a Python program to find the most common words in a given text.": 0.6153846153846153, "Write a python code for a linked list": 0.6, "Write a Python program to find the frequency of each word in a given string.": 0.5925925925925926}, "avg_similarity_score": 0.26391470732622263} -{"instruction": "I am trying to run the following code in Python: ```python def f(x): return x + 1 print(f(1)) ``` I get an error. What is the problem?", "input": "", "output": "The code you provided is not valid Python code. You need to indent the body of the function `f` to make it a valid function definition. Here is the corrected code: ```python def f(x): return x + 1 print(f(1)) ```", "most_similar": {"What is the output of the following Python code? ```py def f(x): return x + 1 def g(x): return x * 2 print(g(f(3))) ```": 0.4074074074074074, "What is the output of the following code?\n```python\ndef func(x):\n return x + 1\n\ndef main():\n x = 1\n y = func(x)\n print(y)\n\nmain()\n```": 0.3773584905660378, "What is the output of the following code?\n```python\ndef f(x):\n return x * 2\n\ndef g(x):\n return f(x) + 1\n\ndef h(x):\n return g(x) * 2\n\nprint(h(2))\n```": 0.3666666666666667, "What is the output of the following code?\n```python\ndef foo():\n x = 1\n def bar():\n x = 2\n return x\n return bar()\nprint(foo())\n```": 0.35294117647058826, "What is the output of this code?\n```python\ndef f(x):\n x = 2 * x + 1\n return x\n\nx = 3\nz = f(x)\nprint(z)\n```": 0.3461538461538462, "I'm trying to use the following code to create a new column in a dataframe:\n```python\ndf['new_col'] = df['col_1'].apply(lambda x: x.split(' ')[0])\n```\nBut I'm getting the following error:\n```python\nAttributeError: 'float' object has no attribute 'split'\n```": 0.33333333333333326, "What is the output of the following code? ```py def add(a, b): return a + b print(add(1, 2)) print(add(b=2, a=1)) ```": 0.29629629629629634, "I'm trying to run a Python script on a remote server. I'm getting an error: \"ImportError: No module named 'requests'\". How can I fix this?": 0.2909090909090909, "The following code I wrote in haskell ```hs factorial(1)=1 factorial(n)=n*(n-1)*factorial(n-2) ``` gives me an error when I try to run it. Is there anything I did wrong?": 0.2857142857142857, "I have the following python function: ```python def resize_images(images, res_x, res_y): resized_images = np.zeros((images.shape[0], res_x, res_y)) for n in range(len(images)): resized_images[n, :, :] = resize(images[n, :, :], resized_images.shape[1:], anti_aliasing=False) return resized_images ``` What does the function do?": 0.271604938271605}, "avg_similarity_score": 0.1257121382004565} -{"instruction": "How do I convert a string to a number in Python?", "input": "", "output": "You can use the int() function to convert a string to a number. For example: ```number = int(string)```", "most_similar": {"How do I get the power of a number in python?": 0.6363636363636364, "How do I output a string in C++ programming?": 0.6, "How do you find the length of a string in Python?": 0.5454545454545454, "How do you create a variable in Python?": 0.5263157894736842, "How do I create a new branch in git?": 0.5, "How do I compile a go program on Linux to a windows executable?": 0.4999999999999999, "How do I find the fibonacci number of a number?": 0.47619047619047616, "How do you sort a list of strings in Python?": 0.47619047619047616, "How do you remove duplicates from a list in Python?": 0.47619047619047616, "How to check quickly if a number is prime in C?": 0.45454545454545453}, "avg_similarity_score": 0.19795478491675395} -{"instruction": "Write a function that takes an array of numbers and returns the largest number in the array.", "input": "", "output": "function max(numbers) {\n let largest = numbers[0];\n for (let i = 1; i < numbers.length; i++) {\n if (numbers[i] > largest) {\n largest = numbers[i];\n }\n }\n return largest;\n}", "most_similar": {"Write a function that takes a string and returns the number of vowels in the string.": 0.6666666666666667, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.6486486486486486, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.6470588235294118, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.6315789473684211, "Write a Python function that returns the largest item in a list.": 0.5517241379310345, "Please write a Rust function that takes a u64 input and returns the largest prime number less than that value.": 0.5405405405405405, "Write a Python function that takes a number as input and returns the square of that number.": 0.5294117647058824, "Write a python function that returns the number of words in a given string.": 0.5161290322580646, "Write a Python function that takes two numbers as input and returns their sum.": 0.5161290322580646, "Write a Python function that takes a string as input and returns the string in reverse order.\n'Hello'": 0.5142857142857143}, "avg_similarity_score": 0.21348229932968477} -{"instruction": "I am trying to use the following code in python:\n```py\ndef function(a, b):\n if a > b:\n print('You lost.')\n else:\n if c > a:\n print('Nice try.')\n else:\n print('You won.')\n```\nBut I am getting an error. What is wrong with the code?", "input": "", "output": "The code you provided has a few issues. First, you are missing a colon after the function definition. Second, you are missing a parameter named c in the function definition. Third, you are missing a colon after the if statement. After making these changes, your code should look like this:\n```py\ndef function(a, b, c):\n if a > b:\n print('You lost.')\n else:\n if c > a:\n print('Nice try.')\n else:\n print('You won.')\n```", "most_similar": {"Translate the following code from python in Java.\ndef function(a : int, b : int, c : int):\n if a > b :\n print('You lost.')\n else :\n if c > a :\n print('Nice try.')\n else :\n print('You won.')": 0.6493506493506495, "I am trying to run the following code in Python: ```python def f(x): return x + 1 print(f(1)) ``` I get an error. What is the problem?": 0.4722222222222222, "What is the output of the following python code?\n```python\ndef function(a):\n if a > 0:\n print('Positive')\n else:\n print('Negative')\n\nfunction(0)\n```": 0.3582089552238806, "What is the output of the following code? ```py def add(a, b): return a + b print(add(1, 2)) print(add(b=2, a=1)) ```": 0.3142857142857143, "I'm trying to use the following code to create a new column in a dataframe:\n```python\ndf['new_col'] = df['col_1'].apply(lambda x: x.split(' ')[0])\n```\nBut I'm getting the following error:\n```python\nAttributeError: 'float' object has no attribute 'split'\n```": 0.29545454545454547, "What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.27692307692307694, "I'm trying to run a Python script on a remote server. I'm getting an error: \"ImportError: No module named 'requests'\". How can I fix this?": 0.2535211267605634, "Find the bug in the following code piece: a = 1 while a == 1: b = input(\"what's your name ?\") print(\"Hi \",b, \" this is infinity loop !\")": 0.2285714285714286, "What is the output of the following code?\n```python\ndef foo():\n print(\"foo\")\n\ndef bar():\n print(\"bar\")\n\ndef main():\n foo()\n bar()\n\nmain()\n```": 0.2121212121212121, "The following code I wrote in haskell ```hs factorial(1)=1 factorial(n)=n*(n-1)*factorial(n-2) ``` gives me an error when I try to run it. Is there anything I did wrong?": 0.20253164556962025}, "avg_similarity_score": 0.12063443159691585} -{"instruction": "Write a program to find the n-th ugly number.\nUgly numbers are positive numbers whose prime factors only include 2, 3, 5.", "input": "", "output": "```python def nthUglyNumber(n: int) -> int:\n ugly_numbers = [1]\n i2, i3, i5 = 0, 0, 0\n while len(ugly_numbers) < n:\n next_ugly_number = min(ugly_numbers[i2] * 2, ugly_numbers[i3] * 3, ugly_numbers[i5] * 5)\n ugly_numbers.append(next_ugly_number)\n if next_ugly_number == ugly_numbers[i2] * 2:\n i2 += 1\n if next_ugly_number == ugly_numbers[i3] * 3:\n i3 += 1\n if next_ugly_number == ugly_numbers[i5] * 5:\n i5 += 1\n return ugly_numbers[-1]\n\nprint(nthUglyNumber(10)) ```", "most_similar": {"Write a Python program to find the Fibonacci series up to n numbers.": 0.4444444444444444, "Write a Python program to find the number of even and odd numbers from a series of numbers.": 0.4390243902439025, "Write a program to find the smallest number in a list.": 0.411764705882353, "Write a program to find the sum of all the multiples of 3 or 5 below 1000.": 0.39999999999999997, "Write a Python function to find the smallest number from a sequence of numbers.": 0.3783783783783784, "Write a Python program to find the first Fibonacci number greater than four million.": 0.3783783783783784, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.3783783783783784, "Write a Python program to find the first Fibonacci number with the first 1000 digits.": 0.3684210526315789, "Write a Python program to find the maximum and minimum number from a given list.": 0.3684210526315789, "Write a Python program to find the sum of the positive integers of a given range.": 0.358974358974359}, "avg_similarity_score": 0.15561643594486232} -{"instruction": "What is the output of the following code?\n```\na = 1\nb = 2\nc = 3\nd = 4\ne = 5\nf = 6\ng = 7\nh = 8\ni = 9\nj = 10\nk = 11\nl = 12\nm = 13\nn = 14\no = 15\np = 16\nq = 17\nr = 18\ns = 19\nt = 20\nu = 21\nv = 22\nw = 23\nx = 24\ny = 25\nz = 26\n\nprint(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z)\n```", "input": "", "output": "The output of the code is: ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 ```", "most_similar": {"How to make a python program that will print the following pattern?\n```\n1\n2 3\n4 5 6\n7 8 9 10\n11 12 13 14 15\n16 17 18 19 20 21\n22 23 24 25 26 27 28\n29 30 31 32 33 34 35 36\n37 38 39 40 41 42 43 44 45\n46 47 48 49 50 51 52 53 54 55\n```": 0.36363636363636365, "What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.33333333333333326, "How to make a python program that will print the following pattern?\n```\n1\n2 3\n4 5 6\n7 8 9 10\n11 12 13 14 15\n```": 0.29824561403508776, "What is the output of the following code?\n```python\ndef f(x):\n return x * 2\n\ndef g(x):\n return f(x) + 1\n\ndef h(x):\n return g(x) * 2\n\nprint(h(2))\n```": 0.2352941176470588, "What is the output of the following code?\n```python\ndef func(x):\n return x + 1\n\ndef main():\n x = 1\n y = func(x)\n print(y)\n\nmain()\n```": 0.23214285714285718, "What is the output of the following code? ```py def add(a, b): return a + b print(add(1, 2)) print(add(b=2, a=1)) ```": 0.23008849557522124, "What is the output of the following Python code? ```py def f(x): return x + 1 def g(x): return x * 2 print(g(f(3))) ```": 0.23008849557522124, "What is the output of the following code?\n```python\ndef foo():\n x = 1\n def bar():\n x = 2\n return x\n return bar()\nprint(foo())\n```": 0.2181818181818182, "What is the output of this code?\n```python\ndef f(x):\n x = 2 * x + 1\n return x\n\nx = 3\nz = f(x)\nprint(z)\n```": 0.2162162162162162, "What is the output of this code?\n```\nx = 10\ndef func():\n x = 20\n print(x)\nfunc()\nprint(x)\n```": 0.20952380952380958}, "avg_similarity_score": 0.06554483894103966} -{"instruction": "How do I make a dropdown menu?", "input": "", "output": "A dropdown menu is a menu that appears when the user clicks on a button or link. The menu can contain links to other pages, forms, or other content. The menu can be made with HTML and CSS, or with JavaScript.\n\nHere is an example of a dropdown menu made with HTML and CSS:\n\n\n\n\n\n \n\n\n
\n \n
\n Home\n About\n Contact\n
\n
\n\n\n\n\n", "most_similar": {"How do I make a variable that is only declared?": 0.588235294117647, "How can I make a button in HTML?": 0.5333333333333333, "How do I output a string in C++ programming?": 0.5, "How do I create a new branch in git?": 0.5, "How do I get the first element of a list?": 0.47058823529411764, "How do I find the fibonacci number of a number?": 0.47058823529411764, "How do I get the power of a number in python?": 0.4444444444444444, "How do I convert a string to a number in Python?": 0.4444444444444444, "How do I compile a go program on Linux to a windows executable?": 0.4, "How do I find the p-variance of all elements in a list?": 0.4}, "avg_similarity_score": 0.11872167078818564} -{"instruction": "Generate a correct python program to fulfill the following purpose:\nCount the occurrence of an element x in a list y.", "input": "", "output": "def count_x(x, y):\n count = 0\n for i in range(y):\n if i == x:\n count += 1\n return count", "most_similar": {"Generate a correct python program to fulfill the following purpose:": 0.6451612903225806, "Write a Python function to find the index of the first occurrence of a specified item in a list.": 0.5, "Write a Python function to find the sum of all items in a list.": 0.4571428571428571, "Write a Python program to find the average of a list using for loop.": 0.4571428571428571, "Write a Python program to find the frequency of each word in a given string.": 0.4444444444444444, "Write a Python program to find the number of occurrences of a specified element in a given array of integers.": 0.4390243902439024, "Write a program to find the smallest number in a list.": 0.43749999999999994, "Write a Python program to find the longest common prefix of a given list of strings.": 0.4324324324324324, "Write a Python program to find the sum of the positive integers of a given range.": 0.4324324324324324, "Write a python code to find the minimum value in a list.": 0.4242424242424242}, "avg_similarity_score": 0.1970273260869334} -{"instruction": "Write a python code for a stack using an array", "input": "", "output": "You can implement a stack using an array like this: ```python class Stack: def init(self): self.items = [] def push(self, item): self.items.append(item) def pop(self): if not self.items: return None return self.items.pop() ``` This implementation uses a list to store the items in the stack. The push() method adds a new item to the end of the list, and the pop() method removes the last item from the list and returns it.", "most_similar": {"Write a python code for a linked list": 0.6666666666666665, "Write a python code for queues using stack": 0.6666666666666665, "Write a python code for binary search": 0.588235294117647, "Python code for a rotating square": 0.5, "Write a python code to find the minimum value in a list.": 0.45454545454545453, "Write a python code to implement quick sort": 0.4444444444444445, "Write a code to implement a binary search.": 0.4444444444444445, "Write python code to connect to a FTP server.": 0.4210526315789474, "Write a Python program to find the average of a list using for loop.": 0.41666666666666663, "Write a Python program to find the first pythagorean triplet for which a + b + c = 1000.": 0.38461538461538464}, "avg_similarity_score": 0.179701592653907} -{"instruction": "Write a python code for a queue using a dictionary", "input": "", "output": "You can implement a queue using a dictionary like this: ```python class Queue: def init(self): self.items = {} self.count = 0 def enqueue(self, item): self.items[self.count] = item self.count += 1 def dequeue(self): if not self.count: return None self.count -= 1 return self.items.pop(self.count) ``` This implementation uses a dictionary to store the items in the queue. The enqueue() method adds a new item to the dictionary with a key equal to the count, and the dequeue() method removes the item with the lowest key and returns it.", "most_similar": {"Write a python code for a stack using an array": 0.7, "Write a python code for a linked list": 0.6666666666666665, "Write a python code for queues using stack": 0.6666666666666665, "Write a python code for binary search": 0.588235294117647, "Python code for a rotating square": 0.5, "Write a Python function to find the largest number in a dictionary.": 0.45454545454545453, "Write a python code to find the minimum value in a list.": 0.45454545454545453, "Write a code to implement a binary search.": 0.4444444444444445, "Write a python code to implement quick sort": 0.4444444444444445, "Write python code to connect to a FTP server.": 0.4210526315789474}, "avg_similarity_score": 0.1778791347703155} -{"instruction": "Write a Python program to find the sum of three given numbers, if the values are equal then return three times of their sum.", "input": "", "output": "def sum_three(a, b, c):\n if a == b and b == c:\n return 3 * (a + b + c)\n return a + b + c", "most_similar": {"Write a Python program to find the sum of the positive integers of a given range.": 0.5499999999999999, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.5263157894736842, "Write a C# program to find the sum of all the elements of an array.": 0.5128205128205129, "Write a Python program to find the longest common prefix of a given list of strings.": 0.5, "Write a program to find the sum of all the multiples of 3 or 5 below 1000.": 0.48780487804878053, "Write a Python program to find the sum of a non-negative integer.": 0.48648648648648646, "Write a Python program to find the first repeated character of a given string where the index of first occurrence is smallest.": 0.4782608695652174, "Write a Python program to find the number of even and odd numbers from a series of numbers.": 0.4761904761904762, "Write a Python program to find the frequency of each word in a given string.": 0.4615384615384615, "Write a Python program to find the frequency of the words from the sentence given.": 0.4615384615384615}, "avg_similarity_score": 0.19878658145213937} -{"instruction": "Write a Python function to check if a number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its proper positive divisors.", "input": "", "output": "def is_perfect(num):\n sum = 0\n for i in range(1, num):\n if num % i == 0:\n sum += i\n return sum == num", "most_similar": {"Write a Python function to check if a given number is an Armstrong number or not. An Armstrong number is a number that is equal to the sum of its own digits each raised to the power of the number of digits.": 0.64, "Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.6349206349206349, "Write a Python function to check if a given number is a pandigital number or not. A pandigital number is a number that contains all the digits from 1 to n exactly once.": 0.6060606060606061, "Write a Python function to check if a given number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. For example, 6 has divisors 1, 2 and 3 (excluding the number itself), and 6 = 1 + 2 + 3. Similarly, 28 has divisors 1, 2, 4, 7, 14 and 28, and 28 = 1 + 2 + 4 + 7 + 14.": 0.6037735849056604, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.5797101449275361, "Write a Python function to check if a given number is a prime number or not.": 0.5714285714285714, "Write a Python function to check if a given number is a Fermat number or not. A Fermat number is a number of the form 22n + 1, where n is a non-negative integer.": 0.5671641791044776, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.5666666666666667, "Write a Python function to check if a given number is a Harshad number or not. A Harshad number is a number that is divisible by the sum of its digits. For example, 42 is a Harshad number because it is divisible by 6 (the sum of its two digits 4 + 2).": 0.5647058823529413, "Write a Python function to check if a given number is a Catalan number or not. A Catalan number is a number that occurs in the sequence of Catalan numbers. The sequence of Catalan numbers is generated by the following formula: Cn = (2n)! / (n+1)!n!": 0.5316455696202532}, "avg_similarity_score": 0.18344171461270806} -{"instruction": "Write a Python function to check if a number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence.", "input": "", "output": "def is_fibonacci(num):\n a, b = 0, 1\n while a < num:\n a, b = b, a + b\n if a == num:\n return True\n return False", "most_similar": {"Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.6909090909090909, "Write a Python function to check if a given number is a pandigital number or not. A pandigital number is a number that contains all the digits from 1 to n exactly once.": 0.689655172413793, "Write a Python function to check if a given number is a prime number or not.": 0.6829268292682927, "Write a Python function to check if a given number is a Fermat number or not. A Fermat number is a number of the form 22n + 1, where n is a non-negative integer.": 0.6779661016949153, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.6557377049180328, "Write a Python function to check if a number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its proper positive divisors.": 0.6551724137931034, "Write a Python function to check if a given number is a Catalan number or not. A Catalan number is a number that occurs in the sequence of Catalan numbers. The sequence of Catalan numbers is generated by the following formula: Cn = (2n)! / (n+1)!n!": 0.619718309859155, "Write a Python function to check if a given number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence. The Fibonacci sequence is a sequence of numbers where each number is the sum of the two preceding numbers. The first two numbers in the sequence are 0 and 1.": 0.617283950617284, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.6153846153846153, "Write a Python function to check if a given number is a repdigit or not. A repdigit is a number that contains only one digit. For example, 11, 22, 3333, 44444444 are repdigits.": 0.5862068965517241}, "avg_similarity_score": 0.1989054870701812} -{"instruction": "Write a Python function to check if a number is a Truncatable number or not. A Truncatable number is a number where the number formed by the first n digits is divisible by n for every n.", "input": "", "output": "def is_truncatable(num):\n num = str(num)\n for i in range(1, len(num)):\n if int(num[:i]) % i != 0:\n return False\n if int(num[i:]) % (len(num) - i) != 0:\n return False\n return True", "most_similar": {"Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.6567164179104478, "Write a Python function to check if a number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence.": 0.6451612903225806, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.6301369863013699, "Write a Python function to check if a given number is a pandigital number or not. A pandigital number is a number that contains all the digits from 1 to n exactly once.": 0.6285714285714286, "Write a Python function to check if a given number is a Fermat number or not. A Fermat number is a number of the form 22n + 1, where n is a non-negative integer.": 0.619718309859155, "Write a Python function to check if a given number is a Catalan number or not. A Catalan number is a number that occurs in the sequence of Catalan numbers. The sequence of Catalan numbers is generated by the following formula: Cn = (2n)! / (n+1)!n!": 0.6024096385542168, "Write a Python function to check if a given number is a Harshad number or not. A Harshad number is a number that is divisible by the sum of its digits. For example, 42 is a Harshad number because it is divisible by 6 (the sum of its two digits 4 + 2).": 0.5617977528089887, "Write a Python function to check if a number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its proper positive divisors.": 0.5428571428571428, "Write a Python function to check if a given number is a prime number or not.": 0.5283018867924528, "Write a Python function to check if a given number is a palindrome or not. A palindrome is a number that remains the same when its digits are reversed. For example, 121 is a palindrome but 112 is not.": 0.5263157894736842}, "avg_similarity_score": 0.17040241672283032} -{"instruction": "How do I make a list of all the prime numbers up to a certain number?", "input": "", "output": "Here's a simple implementation of the Sieve of Eratosthenes in Python: ```py def sieve(n):\n prime = [True] * (n + 1)\n p = 2\n while p * p <= n:\n if prime[p]:\n for i in range(p * p, n + 1, p):\n prime[i] = False\n p += 1\n return [p for p in range(2, n + 1) if prime[p]] ```", "most_similar": {"How do I convert a string to a number in Python?": 0.5185185185185185, "How do I find the fibonacci number of a number?": 0.4615384615384615, "Write a Python function to find all prime numbers up to the given number n.": 0.45161290322580644, "How do I make a function that takes a string and returns a list of the words in the string?": 0.4444444444444445, "How do I get the power of a number in python?": 0.4444444444444444, "How do I make a dropdown menu?": 0.43478260869565216, "I have a list of numbers and I want to find the average of all the numbers.": 0.42424242424242425, "How do I find the p-variance of all elements in a list?": 0.41379310344827586, "How do I compile a go program on Linux to a windows executable?": 0.41379310344827586, "How can I make a program that will find the largest number in a list?": 0.38709677419354843}, "avg_similarity_score": 0.1828160815430354} -{"instruction": "Write a Python function to check if a given string is a pangram or not. A pangram is a sentence containing every letter of the English alphabet at least once.", "input": "", "output": "def is_pangram(string):\n return set(string.lower()) == set(string.lower().replace(' ', ''))", "most_similar": {"Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.5964912280701755, "Write a Python function to check if a number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence.": 0.5818181818181818, "Write a Python function to check if a given number is a pandigital number or not. A pandigital number is a number that contains all the digits from 1 to n exactly once.": 0.5714285714285713, "Write a Python function to check if a given number is a prime number or not.": 0.5652173913043479, "Write a Python function to check if a given number is a Fermat number or not. A Fermat number is a number of the form 22n + 1, where n is a non-negative integer.": 0.5625, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.5454545454545454, "Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.5333333333333333, "Write a Python function to check if a number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its proper positive divisors.": 0.507936507936508, "Write a Python function to check if a given number is a repdigit or not. A repdigit is a number that contains only one digit. For example, 11, 22, 3333, 44444444 are repdigits.": 0.507936507936508, "Write a Python function to check if a given number is a palindrome or not. A palindrome is a number that remains the same when its digits are reversed. For example, 121 is a palindrome but 112 is not.": 0.4927536231884058}, "avg_similarity_score": 0.18057662365151247} -{"instruction": "Write a python code to find the area of a circle.", "input": "", "output": "import math\n\ndef circle_area(radius):\n return math.pi * radius ** 2", "most_similar": {"Write a python code to find the minimum value in a list.": 0.6956521739130435, "Write a Python program to find the sum of a non-negative integer.": 0.6666666666666667, "Write a Python function to find the sum of all items in a list.": 0.64, "Write a Python program to find the average of a list using for loop.": 0.64, "Write a Python program to find the frequency of each word in a given string.": 0.6153846153846153, "Write a Python function to find the largest number in a dictionary.": 0.6086956521739131, "Write a Python program to find the sum of the positive integers of a given range.": 0.5925925925925926, "Write a Python program to find the longest common prefix of a given list of strings.": 0.5925925925925926, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.56, "Write a Python program to find the most common words in a given text.": 0.56}, "avg_similarity_score": 0.2654691333234402} -{"instruction": "Write a Python function to calculate the factorial of a number.", "input": "", "output": "def factorial(n):\n if n == 0:\n return 1\n else:\n return n * factorial(n-1)", "most_similar": {"Write a Python function to find the sum of all items in a list.": 0.64, "Write a python code to find the area of a circle.": 0.6363636363636364, "Write a Python function to find the largest number in a dictionary.": 0.6086956521739131, "Write a Python program to find the sum of a non-negative integer.": 0.5833333333333334, "Write a script to output the factorial of an integer.": 0.5714285714285713, "Write a python function that returns the number of words in a given string.": 0.56, "Write a Python program to get the volume of a sphere with radius 6.": 0.56, "Write a Python function to find the smallest number from a sequence of numbers.": 0.56, "Write a Python program to find the average of a list using for loop.": 0.56, "Write a python function that returns the sum of the elements of a list.": 0.56}, "avg_similarity_score": 0.2625514662399751} -{"instruction": "Write a Python function to calculate the greatest common divisor (GCD) of two positive integers.", "input": "", "output": "def gcd(a, b):\n while b:\n a, b = b, a % b\n return a", "most_similar": {"Write a Python function to calculate the factorial of a number.": 0.6153846153846153, "Write a Python function to find the correlation between two lists.": 0.5384615384615385, "Write a Python function to reverse a given list of integers.": 0.5384615384615385, "Write a Python program to find the sum of the positive integers of a given range.": 0.5161290322580646, "Write a Python program to find the unique common elements from two lists.": 0.5, "Write a Python function to find the maximum sum of a contiguous subsequence from a list of integers.": 0.4848484848484848, "Write a Python function to find the sum of all items in a list.": 0.4827586206896552, "Write a Python function to find the smallest number from a sequence of numbers.": 0.4827586206896552, "Write a function that returns the sum of two numbers.": 0.48, "Write a function to find the longest common prefix string amongst an array of strings.": 0.4666666666666667}, "avg_similarity_score": 0.20887074646169496} -{"instruction": "Write a Python function to calculate the sum of two given integers. However, if the sum is between 15 to 20 it should return 20.", "input": "", "output": "def sum_num(a, b):\n if 15 <= a + b <= 20:\n return 20\n else:\n return a + b", "most_similar": {"Write a Python function to calculate the greatest common divisor (GCD) of two positive integers.": 0.5, "Write a Python program to find the sum of three given numbers, if the values are equal then return three times of their sum.": 0.4489795918367347, "Write a Python function to calculate the factorial of a number.": 0.4444444444444444, "Write a program to compute the sum of integers from k to n.": 0.4210526315789474, "Write a Python function to find the maximum sum of a contiguous subsequence from a list of integers.": 0.41860465116279066, "Write a python function that returns the sum of the elements of a list.": 0.41025641025641024, "Write a Python function to find the sum of all items in a list.": 0.41025641025641024, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.41025641025641024, "Write a function that returns the sum of two numbers.": 0.4, "Write a Python program to find the sum of the positive integers of a given range.": 0.39024390243902435}, "avg_similarity_score": 0.1897247559614363} -{"instruction": "Write a Python function that returns the number of items that are present in the first list but not in the second list.", "input": "", "output": "def difference_count(lst1, lst2):\n return len(set(lst1) - set(lst2))", "most_similar": {"Write a Python function that returns a list containing only the items that are present in both lists.": 0.5853658536585366, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.5454545454545454, "Write a python function that returns the number of words in a given string.": 0.5405405405405405, "Write a python function that returns the sum of the elements of a list.": 0.5405405405405405, "Write a Python function that returns the largest item in a list.": 0.5142857142857143, "Write a function that takes a string and returns the number of vowels in the string.": 0.5128205128205128, "Write a Python function to find the number of items in a list that are not equal to a given value.": 0.5, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.4999999999999999, "Write a Python function to find the sum of all items in a list.": 0.4864864864864865, "Write a Python function to find the index of the first occurrence of a specified item in a list.": 0.47619047619047616}, "avg_similarity_score": 0.21438246003483777} -{"instruction": "Write a program to find the n-th ugly number.", "input": "", "output": "def nth_ugly_number(n):\n ugly_numbers = [1]\n i2 = i3 = i5 = 0\n while len(ugly_numbers) < n:\n next_ugly_number = min(ugly_numbers[i2] * 2, ugly_numbers[i3] * 3, ugly_numbers[i5] * 5)\n ugly_numbers.append(next_ugly_number)\n if next_ugly_number == ugly_numbers[i2] * 2:\n i2 += 1\n if next_ugly_number == ugly_numbers[i3] * 3:\n i3 += 1\n if next_ugly_number == ugly_numbers[i5] * 5:\n i5 += 1\n return ugly_numbers[-1]", "most_similar": {"Write a program to find the smallest number in a list.": 0.6666666666666666, "Write a Python program to find the Fibonacci series up to n numbers.": 0.608695652173913, "Write a program to find the n-th ugly number.\nUgly numbers are positive numbers whose prime factors only include 2, 3, 5.": 0.6060606060606061, "Write a Python program to find the first Fibonacci number greater than four million.": 0.5833333333333334, "Write a Python program to find the maximum and minimum number from a given list.": 0.56, "Write a Python program to find the first Fibonacci number with the first 1000 digits.": 0.56, "Write a Python function to find the largest number in a dictionary.": 0.5454545454545454, "Write a program to find the pearson correlation coefficient of two lists.": 0.5454545454545454, "Write a script to output the nth fibonacci number.": 0.5263157894736842, "Write a program to compute the sum of integers from k to n.": 0.5217391304347826}, "avg_similarity_score": 0.21547919121363374} -{"instruction": "Write Python code to solve this leetcode problem.\nProblem: You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.\n\nYou may assume the two numbers do not contain any leading zero, except the number 0 itself.", "input": "", "output": "class Solution(object):\n def addTwoNumbers(self, l1, l2):\n \"\"\"\n :type l1: ListNode\n :type l2: ListNode\n :rtype: ListNode\n \"\"\"\n carry = 0\n root = n = ListNode(0)\n while l1 or l2 or carry:\n v1 = v2 = 0\n if l1:\n v1 = l1.val\n l1 = l1.next\n if l2:\n v2 = l2.val\n l2 = l2.next\n carry, val = divmod(v1+v2+carry, 10)\n n.next = ListNode(val)\n n = n.next\n return root.next", "most_similar": {"Write a Python function to check if a given number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence. The Fibonacci sequence is a sequence of numbers where each number is the sum of the two preceding numbers. The first two numbers in the sequence are 0 and 1.": 0.24390243902439024, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.22727272727272727, "Write a Python function to check if a given number is a Fibonacci number or not. The Fibonacci sequence is a sequence of numbers where each number is the sum of the two preceding numbers. The first two numbers are 0 and 1. The next 20 Fibonacci numbers are: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181.": 0.22058823529411764, "Write a Python program to find the first appearance of the substring 'not' and 'poor' from a given string, if 'not' follows the 'poor', replace the whole 'not'...'poor' substring with 'good'. Return the resulting string.": 0.21359223300970875, "Write Python code to solve this leetcode problem.": 0.21333333333333335, "Given an array of integers `nums` and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order.": 0.20338983050847456, "Write a python code to find the minimum value in a list.": 0.20253164556962025, "Write a Python program to find the number of strings where the string length is 2 or more and the first and last character are same from a given list of strings.": 0.20202020202020202, "Write a Python function that returns the number of items that are present in the first list but not in the second list.": 0.2, "Write a Python program to find the sum of three given numbers, if the values are equal then return three times of their sum.": 0.19780219780219782}, "avg_similarity_score": 0.11318712720208424} -{"instruction": "Write a function that returns the number of times a given string occurs in a given text as its substring.", "input": "", "output": "def count_substring(string, sub_string):\n count = 0\n for i in range(len(string)):\n if string[i:].startswith(sub_string):\n count += 1\n return count", "most_similar": {"Write a python function that returns the number of words in a given string.": 0.6470588235294117, "Write a Python function that returns the largest item in a list.": 0.5, "write a java function that implements gray code and returns the next sequence code after a given code in a given direction of rotation": 0.5, "Write a function that takes a string and returns the number of vowels in the string.": 0.5, "Write a python function that returns the sum of the elements of a list.": 0.47058823529411764, "Write a function that returns the sum of two numbers.": 0.4666666666666667, "Write a Python program to find the number of occurrences of a specified element in a given array of integers.": 0.45, "Write a Python function to find the number of items in a list that are not equal to a given value.": 0.4390243902439024, "Write a Python function to find the largest number in a dictionary.": 0.4375, "Write a function that takes an array of numbers and returns the largest number in the array.": 0.4324324324324324}, "avg_similarity_score": 0.212965904521432} -{"instruction": "Write a function that takes a list of numbers and returns a list of the same numbers, but with the first and last elements swapped.", "input": "", "output": "def swap_first_last(lst):\n if len(lst) <= 1:\n return lst\n return lst[-1:] + lst[1:-1] + lst[:1]", "most_similar": {"Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.6521739130434783, "Write a Python function that takes a list and returns a new list with unique elements of the first list.": 0.6222222222222222, "Write a function that takes a string and returns a new string with the first letter of each word capitalized.": 0.5333333333333332, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.5333333333333332, "How do I make a function that takes a string and returns a list of the words in the string?": 0.5333333333333332, "Write a function that takes an array of numbers and returns the largest number in the array.": 0.5238095238095238, "Write a Python function that takes a string and returns a new string with the words in sorted order and unique.": 0.5217391304347826, "Write a function that takes a string and returns the number of vowels in the string.": 0.48780487804878053, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.48, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.4761904761904762}, "avg_similarity_score": 0.18719184460102078} -{"instruction": "Write a function that takes in a string of one or more words, and returns the same string, but with all words sorted lengthwise.", "input": "", "output": "def solution(s):\n return ' '.join(sorted(s.split(' '), key=len))", "most_similar": {"Write a Python function that takes a string and returns a new string with the words in sorted order and unique.": 0.5777777777777778, "Write a function that takes in a string of one or more words, and returns the same string, but with all five or more letter words reversed (Just like the name of this Kata). Strings passed in will consist of only letters and spaces. Spaces will be included only when more than one word is present.": 0.55, "Write a function that takes a string and returns the number of vowels in the string.": 0.5499999999999999, "Write a function that takes a list of numbers and returns a list of the same numbers, but with the first and last elements swapped.": 0.5306122448979592, "Write a Python function that takes a string as input and returns the string in reverse order.\n'Hello'": 0.5238095238095238, "Write a function that takes a string and returns a new string with the first letter of each word capitalized.": 0.5, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.4888888888888889, "Write a function that takes a string as input and reverse only the vowels of a string.": 0.48780487804878053, "How do I make a function that takes a string and returns a list of the words in the string?": 0.45454545454545453, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.45454545454545453}, "avg_similarity_score": 0.17099514010285075} -{"instruction": "Write a Python function to check if a number is a strong number or not. A strong number is a number whose sum of factorial of digits is equal to the original number. For example, 145 is strong number since 1! + 4! + 5! = 1 + 24 + 120 = 145.", "input": "", "output": "def is_strong_number(num):\n sum = 0\n # return false if the number\n # is negative\n if num < 0:\n return False\n\n # find the sum of all\n # divisors of the number\n while num > 0:\n r = num % 10\n sum = sum + factorial(r)\n num = num // 10\n\n # if the sum is equal to the number,\n # then the number is a strong number\n if sum == num:\n return True\n return False", "most_similar": {"Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.5783132530120482, "Write a Python function to check if a number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence.": 0.5555555555555557, "Write a Python function to check if a number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its proper positive divisors.": 0.55, "Write a Python function to check if a given number is a Harshad number or not. A Harshad number is a number that is divisible by the sum of its digits. For example, 42 is a Harshad number because it is divisible by 6 (the sum of its two digits 4 + 2).": 0.5454545454545454, "Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.5454545454545453, "Write a Python function to check if a given number is a Fermat number or not. A Fermat number is a number of the form 22n + 1, where n is a non-negative integer.": 0.54320987654321, "Write a Python function to check if a given number is a pandigital number or not. A pandigital number is a number that contains all the digits from 1 to n exactly once.": 0.5249999999999999, "Write a Python function to check if a number is a Truncatable number or not. A Truncatable number is a number where the number formed by the first n digits is divisible by n for every n.": 0.5238095238095238, "Write a Python function to check if a given number is an Armstrong number or not. An Armstrong number is a number that is equal to the sum of its own digits each raised to the power of the number of digits.": 0.5168539325842697, "Write a Python function to check if a given number is a Catalan number or not. A Catalan number is a number that occurs in the sequence of Catalan numbers. The sequence of Catalan numbers is generated by the following formula: Cn = (2n)! / (n+1)!n!": 0.5161290322580645}, "avg_similarity_score": 0.15555881308226954} -{"instruction": "Write a Python function to check if a number is a Smith number or not. A Smith number is a composite number, whose sum of digits is equal to the sum of digits of its prime factors. For example, 42 is a Smith number, since its prime factors are 2 and 21, and 2 + 2 + 1 = 2 + 4 + 2 = 8.", "input": "", "output": "def is_smith_number(num):\n sum = 0\n # return false if the number\n # is negative\n if num < 0:\n return False\n\n # find the sum of all\n # divisors of the number\n while num > 0:\n r = num % 10\n sum = sum + r\n num = num // 10\n\n # if the sum is equal to the number,\n # then the number is a Smith number\n if (num % sum) == 0:\n return True\n return False", "most_similar": {"Write a Python function to check if a number is a strong number or not. A strong number is a number whose sum of factorial of digits is equal to the original number. For example, 145 is strong number since 1! + 4! + 5! = 1 + 24 + 120 = 145.": 0.6355140186915887, "Write a Python function to check if a given number is a Harshad number or not. A Harshad number is a number that is divisible by the sum of its digits. For example, 42 is a Harshad number because it is divisible by 6 (the sum of its two digits 4 + 2).": 0.5892857142857143, "Write a Python function to check if a number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its proper positive divisors.": 0.5376344086021506, "Write a Python function to check if a given number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. For example, 6 has divisors 1, 2 and 3 (excluding the number itself), and 6 = 1 + 2 + 3. Similarly, 28 has divisors 1, 2, 4, 7, 14 and 28, and 28 = 1 + 2 + 4 + 7 + 14.": 0.5263157894736842, "Write a Python function to check if a given number is an Armstrong number or not. An Armstrong number is a number that is equal to the sum of its own digits each raised to the power of the number of digits.": 0.5098039215686274, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.5, "Write a Python function to check if a given number is a Fermat number or not. A Fermat number is a number of the form 22n + 1, where n is a non-negative integer.": 0.4893617021276596, "Write a Python function to check if a given number is a pandigital number or not. A pandigital number is a number that contains all the digits from 1 to n exactly once.": 0.47311827956989244, "Write a Python function to check if a number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence.": 0.47058823529411764, "Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.4666666666666667}, "avg_similarity_score": 0.14990436118341596} -{"instruction": "Write a Python function to check if a number is a Truncable Harshad number or not. A Truncable Harshad number is a Harshad number which remains a Harshad number even after removing one or more digits from left or right side. For example, 1801 is a Truncable Harshad number, since 1801, 801, 01, 1 are all Harshad numbers.", "input": "", "output": "def is_truncable_harshad_number(num):\n # return false if the number\n # is negative\n if num < 0:\n return False\n\n # check if the number is Harshad\n if not is_harshad_number(num):\n return False\n\n # check if the number is truncable\n while num > 0:\n r = num % 10\n num = num // 10\n if not is_harshad_number(num):\n return False\n return True", "most_similar": {"Write a Python function to check if a given number is a Truncable prime or not. A Truncable prime is a prime number that remains prime when digits are removed from left or right side. For example, 3797 is a truncable prime because 3797, 797, 97 and 7 are all prime.": 0.6055045871559633, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.5106382978723404, "Write a Python function to check if a given number is a Harshad number or not. A Harshad number is a number that is divisible by the sum of its digits. For example, 42 is a Harshad number because it is divisible by 6 (the sum of its two digits 4 + 2).": 0.509090909090909, "Write a Python function to check if a number is a strong number or not. A strong number is a number whose sum of factorial of digits is equal to the original number. For example, 145 is strong number since 1! + 4! + 5! = 1 + 24 + 120 = 145.": 0.49523809523809526, "Write a Python function to check if a given number is a pandigital number or not. A pandigital number is a number that contains all the digits from 1 to n exactly once.": 0.48351648351648346, "Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.47727272727272735, "Write a Python function to check if a given number is a palindrome or not. A palindrome is a number that remains the same when its digits are reversed. For example, 121 is a palindrome but 112 is not.": 0.4742268041237114, "Write a Python function to check if a number is a Truncatable number or not. A Truncatable number is a number where the number formed by the first n digits is divisible by n for every n.": 0.4631578947368421, "Write a Python function to check if a given number is a repdigit or not. A repdigit is a number that contains only one digit. For example, 11, 22, 3333, 44444444 are repdigits.": 0.4615384615384615, "Write a Python function to check if a number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence.": 0.45783132530120474}, "avg_similarity_score": 0.12264889997021299} -{"instruction": "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a positive integer that after being repeatedly summed and subtracted by its digits, eventually reaches 1.", "input": "", "output": "def is_kaprekar(num):\n digits = len(str(num))\n while num != 1:\n num = sum(int(i) ** digits for i in str(num)) - num\n return num == 1", "most_similar": {"Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.6666666666666666, "Write a Python function to check if a number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its proper positive divisors.": 0.6376811594202899, "Write a Python function to check if a given number is a pandigital number or not. A pandigital number is a number that contains all the digits from 1 to n exactly once.": 0.6376811594202899, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.6111111111111112, "Write a Python function to check if a number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence.": 0.5901639344262295, "Write a Python function to check if a given number is a prime number or not.": 0.5769230769230769, "Write a Python function to check if a given number is a Fermat number or not. A Fermat number is a number of the form 22n + 1, where n is a non-negative integer.": 0.5714285714285715, "Write a Python function to check if a number is a Truncatable number or not. A Truncatable number is a number where the number formed by the first n digits is divisible by n for every n.": 0.547945205479452, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.5396825396825397, "Write a Python function to check if a given number is a Catalan number or not. A Catalan number is a number that occurs in the sequence of Catalan numbers. The sequence of Catalan numbers is generated by the following formula: Cn = (2n)! / (n+1)!n!": 0.5365853658536586}, "avg_similarity_score": 0.16663317704381286} -{"instruction": "Write a Python function to check if a given number is a circular prime or not. A circular prime is a prime number that remains a prime when the digits are rotated.", "input": "", "output": "def is_circular(num):\n for i in range(len(str(num))):\n if not is_prime(int(str(num)[i:] + str(num)[:i])):\n return False\n return True", "most_similar": {"Write a Python function to check if a given number is a circular prime or not. A circular prime is a prime number that remains prime when each digit is rotated individually around the number (clockwise or counterclockwise). For example, 197 is a circular prime because 971 and 719 are both prime.": 0.6904761904761905, "Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.6774193548387096, "Write a Python function to check if a given number is a Truncable prime or not. A Truncable prime is a prime number that remains prime when digits are removed from left or right side. For example, 3797 is a truncable prime because 3797, 797, 97 and 7 are all prime.": 0.6506024096385543, "Write a Python function to check if a given number is a palindrome or not. A palindrome is a number that remains the same when its digits are reversed. For example, 121 is a palindrome but 112 is not.": 0.6478873239436619, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.6470588235294118, "Write a Python function to check if a given number is a pandigital number or not. A pandigital number is a number that contains all the digits from 1 to n exactly once.": 0.6461538461538462, "Write a Python function to check if a number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence.": 0.631578947368421, "Write a Python function to check if a given number is a prime number or not.": 0.625, "Write a Python function to check if a given number is a repdigit or not. A repdigit is a number that contains only one digit. For example, 11, 22, 3333, 44444444 are repdigits.": 0.6153846153846154, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.6101694915254238}, "avg_similarity_score": 0.1884485573629014} -{"instruction": "Write a Python function to check if a given number is a repdigit or not. A repdigit is a positive integer that consists of a single digit repeated one or more times.", "input": "", "output": "def is_repdigit(num):\n return len(set(str(num))) == 1", "most_similar": {"Write a Python function to check if a given number is a repdigit or not. A repdigit is a number that contains only one digit. For example, 11, 22, 3333, 44444444 are repdigits.": 0.6461538461538462, "Write a Python function to check if a number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its proper positive divisors.": 0.6153846153846154, "Write a Python function to check if a given number is a circular prime or not. A circular prime is a prime number that remains a prime when the digits are rotated.": 0.59375, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a positive integer that after being repeatedly summed and subtracted by its digits, eventually reaches 1.": 0.5882352941176471, "Write a Python function to check if a given number is a prime number or not.": 0.5833333333333334, "Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.5806451612903225, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.5762711864406779, "Write a Python function to check if a given number is a Fermat number or not. A Fermat number is a number of the form 22n + 1, where n is a non-negative integer.": 0.5757575757575757, "Write a Python function to check if a number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence.": 0.5614035087719298, "Write a Python function to check if a given number is a pandigital number or not. A pandigital number is a number that contains all the digits from 1 to n exactly once.": 0.5538461538461538}, "avg_similarity_score": 0.1838708639920321} -{"instruction": "How do I push a tag to remote in git?", "input": "", "output": "To push a tag to remote in git, you use the ```git push``` command. For example: ```git push origin new-tag```", "most_similar": {"How do I create a new branch in git?": 0.631578947368421, "How do I convert a string to a number in Python?": 0.5714285714285713, "How do I output a string in C++ programming?": 0.5263157894736842, "How do I get the power of a number in python?": 0.47619047619047616, "How do I make a dropdown menu?": 0.47058823529411764, "How can I make a button in HTML?": 0.4444444444444445, "How do you create a variable in Python?": 0.4444444444444445, "How do I compile a go program on Linux to a windows executable?": 0.4347826086956522, "How do I incorporate CSS in my HTML page?": 0.4210526315789474, "How do I find the first element that satisfies a condition in an array?": 0.41666666666666663}, "avg_similarity_score": 0.15326540909636957} -{"instruction": "What is the difference between a variable that is:\n1. Immutable\n2. Mutable", "input": "", "output": "Immutable objects are objects whose state cannot be modified after they are created. Mutable objects are objects whose state can be modified after they are created.", "most_similar": {"What is the difference between a variable that is declared and defined and a variable that is only declared?": 0.5625, "What is the difference between a relative and absolute path?": 0.5217391304347826, "What is the difference between a class and an object?": 0.5217391304347826, "What is the difference between a static and a dynamic method?": 0.4999999999999999, "What is the difference between an ingress and a persistent volume?": 0.4999999999999999, "What is the difference between a replica set and a stateful set?": 0.48000000000000004, "What is the difference between a for loop and a while loop?": 0.48000000000000004, "What is the difference between a list and a tuple in Python?": 0.48000000000000004, "What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.35294117647058826, "What is a Dockerfile?": 0.3529411764705882}, "avg_similarity_score": 0.13373554316778952} -{"instruction": "What is the value of the following expression?\n10 + 2 * 3 / 4", "input": "", "output": "10 + 2 * 3 / 4 = 10 + 6 / 4 = 10 + 1.5 = 11.5", "most_similar": {"What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.5454545454545454, "What is the output of the following Python code? ```py def f(x): return x + 1 def g(x): return x * 2 print(g(f(3))) ```": 0.42105263157894735, "What is the output of the following code?\n```python\ndef foo():\n x = 1\n def bar():\n x = 2\n return x\n return bar()\nprint(foo())\n```": 0.4, "What is the output of the following code? ```py def add(a, b): return a + b print(add(1, 2)) print(add(b=2, a=1)) ```": 0.3684210526315789, "What is the output of the following code?\n```python\ndef foo():\n print(\"foo\")\n\ndef bar():\n print(\"bar\")\n\ndef main():\n foo()\n bar()\n\nmain()\n```": 0.3529411764705882, "What is the output of the following python code?\n```python\ndef function(a):\n if a > 0:\n print('Positive')\n else:\n print('Negative')\n\nfunction(0)\n```": 0.3428571428571428, "What is the output of this code?\n```\nx = 10\ndef func():\n x = 20\n print(x)\nfunc()\nprint(x)\n```": 0.33333333333333337, "What is the output of this code?\n```python\ndef f(x):\n x = 2 * x + 1\n return x\n\nx = 3\nz = f(x)\nprint(z)\n```": 0.3333333333333333, "What is the output of the following code?\n```python\ndef func(x):\n return x + 1\n\ndef main():\n x = 1\n y = func(x)\n print(y)\n\nmain()\n```": 0.32432432432432434, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.32432432432432434}, "avg_similarity_score": 0.129356185868323} -{"instruction": "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number whose square when divided into two parts, one part being the original number and the other part being the remaining part, add up to the original number.", "input": "", "output": "def is_kaprekar(num):\n square = num ** 2\n left = square // 10 ** len(str(num))\n right = square % 10 ** len(str(num))\n return num == left + right", "most_similar": {"Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.611764705882353, "Write a Python function to check if a given number is a Kaprekar number or not. In mathematics, a Kaprekar number for a given base is a non-negative integer, the representation of whose square in that base can be split into two parts that add up to the original number again. For example, 45 is a Kaprekar number, because 45\u00b2 = 2025 and 20+25 = 45.": 0.5565217391304348, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a positive integer that after being repeatedly summed and subtracted by its digits, eventually reaches 1.": 0.5411764705882353, "Write a Python function to check if a number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence.": 0.5405405405405406, "Write a Python function to check if a given number is a pandigital number or not. A pandigital number is a number that contains all the digits from 1 to n exactly once.": 0.5365853658536586, "Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.5316455696202531, "Write a Python function to check if a number is a Truncatable number or not. A Truncatable number is a number where the number formed by the first n digits is divisible by n for every n.": 0.5116279069767442, "Write a Python function to check if a given number is a Fermat number or not. A Fermat number is a number of the form 22n + 1, where n is a non-negative integer.": 0.5060240963855421, "Write a Python function to check if a number is a strong number or not. A strong number is a number whose sum of factorial of digits is equal to the original number. For example, 145 is strong number since 1! + 4! + 5! = 1 + 24 + 120 = 145.": 0.5, "Write a Python function to check if a given number is a circular prime or not. A circular prime is a prime number that remains a prime when the digits are rotated.": 0.4938271604938272}, "avg_similarity_score": 0.1568810767821861} -{"instruction": "Write a Python function to check if a given number is a Truncable Prime or not. A Truncable Prime is a prime number which remains a prime number even if we truncate one or more digits from left or right side.", "input": "", "output": "def is_truncable_prime(num):\n if not is_prime(num):\n return False\n for i in range(1, len(str(num))):\n if not is_prime(int(str(num)[i:])) or not is_prime(int(str(num)[:-i])):\n return False\n return True", "most_similar": {"Write a Python function to check if a given number is a circular prime or not. A circular prime is a prime number that remains a prime when the digits are rotated.": 0.684931506849315, "Write a Python function to check if a given number is a Truncable prime or not. A Truncable prime is a prime number that remains prime when digits are removed from left or right side. For example, 3797 is a truncable prime because 3797, 797, 97 and 7 are all prime.": 0.6739130434782609, "Write a Python function to check if a number is a Truncable Harshad number or not. A Truncable Harshad number is a Harshad number which remains a Harshad number even after removing one or more digits from left or right side. For example, 1801 is a Truncable Harshad number, since 1801, 801, 01, 1 are all Harshad numbers.": 0.6666666666666667, "Write a Python function to check if a given number is a repdigit or not. A repdigit is a positive integer that consists of a single digit repeated one or more times.": 0.5753424657534246, "Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.5633802816901409, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.5454545454545454, "Write a Python function to check if a given number is a pandigital number or not. A pandigital number is a number that contains all the digits from 1 to n exactly once.": 0.5405405405405406, "Write a Python function to check if a given number is a circular prime or not. A circular prime is a prime number that remains prime when each digit is rotated individually around the number (clockwise or counterclockwise). For example, 197 is a circular prime because 971 and 719 are both prime.": 0.5376344086021505, "Write a Python function to check if a given number is a prime number or not.": 0.5263157894736842, "Write a Python function to check if a number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence.": 0.5151515151515151}, "avg_similarity_score": 0.15128083759660763} -{"instruction": "Write a Python function to check if a given number is a Ugly number or not. An Ugly number is a number whose prime factors are only 2, 3 or 5.", "input": "", "output": "def is_ugly(num):\n if num <= 0:\n return False\n while num % 2 == 0:\n num //= 2\n while num % 3 == 0:\n num //= 3\n while num % 5 == 0:\n num //= 5\n return num == 1", "most_similar": {"Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.6557377049180327, "Write a Python function to check if a number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence.": 0.6428571428571428, "Write a Python function to check if a given number is a prime number or not.": 0.6382978723404255, "Write a Python function to check if a given number is a circular prime or not. A circular prime is a prime number that remains a prime when the digits are rotated.": 0.6031746031746031, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.5970149253731343, "Write a Python function to check if a given number is a pandigital number or not. A pandigital number is a number that contains all the digits from 1 to n exactly once.": 0.59375, "Write a Python function to check if a given number is a Fermat number or not. A Fermat number is a number of the form 22n + 1, where n is a non-negative integer.": 0.5846153846153845, "Write a Python function to check if a given number is a repdigit or not. A repdigit is a number that contains only one digit. For example, 11, 22, 3333, 44444444 are repdigits.": 0.5625, "Write a Python function to check if a given number is a repdigit or not. A repdigit is a positive integer that consists of a single digit repeated one or more times.": 0.5396825396825397, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a positive integer that after being repeatedly summed and subtracted by its digits, eventually reaches 1.": 0.537313432835821}, "avg_similarity_score": 0.18390257047681569} -{"instruction": "Write a Python function to check if a given number is a Heptagonal number or not. A Heptagonal number is a number that can be expressed as n(5n-3)/2 where n is an integer.", "input": "", "output": "def is_heptagonal(num):\n return (math.sqrt(24 * num + 1) + 1) % 6 == 0", "most_similar": {"Write a Python function to check if a given number is a Fermat number or not. A Fermat number is a number of the form 22n + 1, where n is a non-negative integer.": 0.6857142857142857, "Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.6666666666666666, "Write a Python function to check if a given number is a pandigital number or not. A pandigital number is a number that contains all the digits from 1 to n exactly once.": 0.6376811594202899, "Write a Python function to check if a number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence.": 0.6229508196721312, "Write a Python function to check if a number is a Truncatable number or not. A Truncatable number is a number where the number formed by the first n digits is divisible by n for every n.": 0.6027397260273972, "Write a Python function to check if a given number is a Ugly number or not. An Ugly number is a number whose prime factors are only 2, 3 or 5.": 0.5970149253731343, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.5833333333333334, "Write a Python function to check if a number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its proper positive divisors.": 0.5797101449275361, "Write a Python function to check if a given number is a prime number or not.": 0.5769230769230769, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.5714285714285715}, "avg_similarity_score": 0.17586866336451087} -{"instruction": "Write a Python function to check if a number is a Disarium number or not. A Disarium number is a number where the sum of its digits powered with their respective positions is equal to the number itself.", "input": "", "output": "def is_disarium_number(num):\n sum = 0\n for i in range(1, len(str(num)) + 1):\n sum += pow(int(str(num)[-i]), i)\n return num == sum", "most_similar": {"Write a Python function to check if a number is a strong number or not. A strong number is a number whose sum of factorial of digits is equal to the original number. For example, 145 is strong number since 1! + 4! + 5! = 1 + 24 + 120 = 145.": 0.6352941176470589, "Write a Python function to check if a number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence.": 0.6349206349206348, "Write a Python function to check if a given number is an Armstrong number or not. An Armstrong number is a number that is equal to the sum of its own digits each raised to the power of the number of digits.": 0.625, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.6216216216216216, "Write a Python function to check if a given number is a pandigital number or not. A pandigital number is a number that contains all the digits from 1 to n exactly once.": 0.619718309859155, "Write a Python function to check if a number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its proper positive divisors.": 0.619718309859155, "Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.6176470588235295, "Write a Python function to check if a number is a Truncatable number or not. A Truncatable number is a number where the number formed by the first n digits is divisible by n for every n.": 0.6133333333333333, "Write a Python function to check if a given number is a Fermat number or not. A Fermat number is a number of the form 22n + 1, where n is a non-negative integer.": 0.5833333333333334, "Write a Python function to check if a given number is a Harshad number or not. A Harshad number is a number that is divisible by the sum of its digits. For example, 42 is a Harshad number because it is divisible by 6 (the sum of its two digits 4 + 2).": 0.5777777777777778}, "avg_similarity_score": 0.19496859870891428} -{"instruction": "Write a Python function to check if a number is a Truncable Primes or not. A Truncable Primes number is a number which can be repeatedly truncated from left or right side and each time a Truncable Primes is obtained, then the number is called Truncable Primes.", "input": "", "output": "def is_truncable_primes(num):\n while num > 0:\n if not is_prime(num):\n return False\n num = num // 10\n return True", "most_similar": {"Write a Python function to check if a given number is a Truncable Prime or not. A Truncable Prime is a prime number which remains a prime number even if we truncate one or more digits from left or right side.": 0.5681818181818181, "Write a Python function to check if a number is a Truncable Harshad number or not. A Truncable Harshad number is a Harshad number which remains a Harshad number even after removing one or more digits from left or right side. For example, 1801 is a Truncable Harshad number, since 1801, 801, 01, 1 are all Harshad numbers.": 0.5523809523809523, "Write a Python function to check if a given number is a Truncable prime or not. A Truncable prime is a prime number that remains prime when digits are removed from left or right side. For example, 3797 is a truncable prime because 3797, 797, 97 and 7 are all prime.": 0.5306122448979591, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.5301204819277109, "Write a Python function to check if a number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence.": 0.5277777777777778, "Write a Python function to check if a given number is a Heptagonal number or not. A Heptagonal number is a number that can be expressed as n(5n-3)/2 where n is an integer.": 0.5060240963855422, "Write a Python function to check if a number is a Truncatable number or not. A Truncatable number is a number where the number formed by the first n digits is divisible by n for every n.": 0.5, "Write a Python function to check if a number is a Disarium number or not. A Disarium number is a number where the sum of its digits powered with their respective positions is equal to the number itself.": 0.49411764705882355, "Write a Python function to check if a given number is a Fermat number or not. A Fermat number is a number of the form 22n + 1, where n is a non-negative integer.": 0.49382716049382713, "Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.49350649350649345}, "avg_similarity_score": 0.15788958278513648} -{"instruction": "Write a Python function that returns a list of numbers in a specified range.", "input": "", "output": "def list_range(start, stop):\n return list(range(start, stop))", "most_similar": {"Write a python function that returns the number of words in a given string.": 0.6428571428571429, "Write a Python function that returns the largest item in a list.": 0.6153846153846153, "Write a function that returns the sum of two numbers.": 0.5833333333333334, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.5714285714285714, "Write a python function that returns the sum of the elements of a list.": 0.5714285714285714, "Write a Python function that returns a list containing only the items that are present in both lists.": 0.5625000000000001, "Write a Python function to reverse a given list of integers.": 0.56, "Write a Python function that removes all occurrences of a specified item from a list.": 0.5517241379310344, "Write a python function that sorts a list from large to small.": 0.5384615384615384, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.5294117647058824}, "avg_similarity_score": 0.22677217797560353} -{"instruction": "Write a Python function that returns a specified number of elements in a list from a specified index.", "input": "", "output": "def list_slice(lst, start, end):\n return lst[start:end]", "most_similar": {"Write a Python function that returns a list of numbers in a specified range.": 0.6875000000000001, "Write a python function that returns the sum of the elements of a list.": 0.6250000000000001, "Write a python function that returns the number of words in a given string.": 0.6250000000000001, "Write a Python function that returns the largest item in a list.": 0.6, "Write a Python function that removes all occurrences of a specified item from a list.": 0.5454545454545454, "Write a python function that sorts a list from large to small.": 0.5333333333333333, "Write a Python function to find the number of items in a list that are not equal to a given value.": 0.5128205128205129, "Write a Python function to find the sum of all items in a list.": 0.5, "Write a Python function that returns the number of items that are present in the first list but not in the second list.": 0.4878048780487805, "Write a Python function to find the index of the first occurrence of a specified item in a list.": 0.4864864864864865}, "avg_similarity_score": 0.21939249729850419} -{"instruction": "Write a Python function that removes the first item from a list and returns it.", "input": "", "output": "def pop_list(lst):\n return lst.pop(0)", "most_similar": {"Write a Python function that removes all occurrences of a specified item from a list.": 0.6666666666666666, "Write a Python function that returns the largest item in a list.": 0.6666666666666665, "Write a python function that returns the sum of the elements of a list.": 0.5517241379310344, "Write a Python function to find the index of the first occurrence of a specified item in a list.": 0.5294117647058824, "Write a python function that sorts a list from large to small.": 0.5185185185185186, "Write a Python function that takes a list and returns a new list with unique elements of the first list.": 0.5142857142857143, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.5142857142857143, "Write a Python function that takes a number as input and returns the square of that number.": 0.5, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.5, "Write a Python function that takes a string as input and returns the string in reverse order.\n'Hello'": 0.4848484848484848}, "avg_similarity_score": 0.22630826717542143} -{"instruction": "How to find the number of days between two dates?", "input": "", "output": "You can use the built-in datetime module to find the number of days between two dates.\n\nFor example, to find the number of days between 2019-01-01 and 2019-01-10:\n\nimport datetime\n\ndate1 = datetime.date(2019, 1, 1)\ndate2 = datetime.date(2019, 1, 10)\n\nprint(date2 - date1)\n\nThis prints 9 days, 0:00:00.", "most_similar": {"How can I get the number of days between two dates in python?": 0.6956521739130435, "How do I find the fibonacci number of a number?": 0.5, "How do I find the greatest common divisor of two numbers?": 0.47619047619047616, "How to find the largest number in an array in Java?": 0.47619047619047616, "Write a Python function to find the correlation between two lists.": 0.47619047619047616, "How to find the largest prime factor of a given number?": 0.47619047619047616, "How to find the frequency distribution of all values in a list?": 0.45454545454545453, "Write a program to find the pearson correlation coefficient of two lists.": 0.45454545454545453, "Write me a function in C++ to find the distance between two points": 0.4347826086956522, "How to find the maximum value in a list?": 0.4210526315789474}, "avg_similarity_score": 0.17158527658770398} -{"instruction": "What is a persistent volume ?", "input": "", "output": "A PersistentVolume (PV) is a piece of storage in the cluster that has been provisioned by an administrator or dynamically provisioned using Storage Classes. It is a piece of storage in the cluster that has been provisioned by an administrator or dynamically provisioned using Storage Classes. It is a piece of storage in the cluster that has been provisioned by an administrator or dynamically provisioned using Storage Classes.", "most_similar": {"What is a Dockerfile?": 0.6666666666666665, "What is the difference between an ingress and a persistent volume?": 0.625, "What is a Docker container?": 0.6, "What is Kubernetes ?": 0.5, "What is the difference between a relative and absolute path?": 0.4, "What is the difference between a class and an object?": 0.4, "What is the difference between a static and a dynamic method?": 0.37499999999999994, "What is the difference between a list and a tuple in Python?": 0.35294117647058826, "What is the difference between a for loop and a while loop?": 0.35294117647058826, "What is the difference between a replica set and a stateful set?": 0.35294117647058826}, "avg_similarity_score": 0.10134708279386914} -{"instruction": "What is a stateful set ?", "input": "", "output": "Manages the deployment and scaling of a set of Pods, and provides guarantees about the ordering and uniqueness of these Pods. When you use a StatefulSet, you need to consider the order of Pod creation, deletion, and updates. Unlike a Deployment, a StatefulSet maintains a sticky identity for each of their Pods. These pods are created from the same spec, but are not interchangeable: each has a persistent identifier that it maintains across any rescheduling. If you want to use storage volumes to provide persistence for your workload, you can use a StatefulSet as part of the solution. However, a StatefulSet does not provide any guarantees on pod scheduling, such as co-location.", "most_similar": {"What is a Dockerfile?": 0.6666666666666665, "What is a persistent volume ?": 0.6, "What is a Docker container?": 0.6, "What is the difference between a replica set and a stateful set?": 0.5882352941176471, "What is Kubernetes ?": 0.5, "What is the difference between a relative and absolute path?": 0.4, "What is the difference between a class and an object?": 0.4, "What is the difference between a static and a dynamic method?": 0.37499999999999994, "What is the difference between an ingress and a persistent volume?": 0.37499999999999994, "What is the difference between a list and a tuple in Python?": 0.35294117647058826}, "avg_similarity_score": 0.10263373976190872} -{"instruction": "What is a cron job ?", "input": "", "output": "A CronJob creates Jobs on a repeating schedule. It is intended to be used to schedule jobs that are not expected to terminate (for example, a batch job). CronJobs are useful for creating periodic and recurring tasks, like running backups or sending emails. CronJobs can also schedule individual tasks for a specific time, such as scheduling a Job for when your cluster is likely to be idle. CronJobs are intended as replacements for the now-deprecated kubernetes.io/v1beta1 CronJob API.", "most_similar": {"What is a Dockerfile?": 0.6666666666666665, "What is a stateful set ?": 0.6, "What is a persistent volume ?": 0.6, "What is a Docker container?": 0.6, "What is Kubernetes ?": 0.5, "What is the difference between a class and an object?": 0.4, "What is the difference between a relative and absolute path?": 0.4, "What is the difference between an ingress and a persistent volume?": 0.37499999999999994, "What is the difference between a static and a dynamic method?": 0.37499999999999994, "What is the difference between a list and a tuple in Python?": 0.35294117647058826}, "avg_similarity_score": 0.10345906528241362} -{"instruction": "I want to find the average of all the numbers in a list.", "input": "", "output": "def average_numbers(numbers):\n return sum(numbers) / len(numbers)", "most_similar": {"I have a list of numbers and I want to find the average of all the numbers.": 0.6666666666666667, "How to find the sum of all the elements in a list in python?": 0.6666666666666666, "How to find the frequency distribution of all values in a list?": 0.64, "How do I find the p-variance of all elements in a list?": 0.6153846153846154, "Write a Python function to find the sum of all items in a list.": 0.5925925925925927, "How to find the maximum value in a list?": 0.5454545454545455, "Write a Python program to find the average of a list using for loop.": 0.5185185185185186, "How do you find the standard deviation of all items in a list in Python?": 0.5, "Write a Python function to find the index of the first occurrence of a specified item in a list.": 0.5, "Write a program to find the smallest number in a list.": 0.4999999999999999}, "avg_similarity_score": 0.2136174681441785} -{"instruction": "Write a Python function to check if a given number is a Sphenic number or not. A Sphenic number is a number whose proper divisors (excluding the number itself) are all the same.", "input": "", "output": "def is_sphenic(num):\n sum = 0\n temp = num\n while temp > 1:\n for i in range(2, temp):\n if temp % i == 0:\n sum += i\n temp //= i\n break\n return sum == num", "most_similar": {"Write a Python function to check if a number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence.": 0.689655172413793, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.6666666666666666, "Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.6666666666666666, "Write a Python function to check if a given number is a pandigital number or not. A pandigital number is a number that contains all the digits from 1 to n exactly once.": 0.6666666666666666, "Write a Python function to check if a given number is a Ugly number or not. An Ugly number is a number whose prime factors are only 2, 3 or 5.": 0.65625, "Write a Python function to check if a number is a Truncatable number or not. A Truncatable number is a number where the number formed by the first n digits is divisible by n for every n.": 0.6285714285714286, "Write a Python function to check if a given number is a Fermat number or not. A Fermat number is a number of the form 22n + 1, where n is a non-negative integer.": 0.6268656716417911, "Write a Python function to check if a number is a Disarium number or not. A Disarium number is a number where the sum of its digits powered with their respective positions is equal to the number itself.": 0.619718309859155, "Write a Python function to check if a given number is a circular prime or not. A circular prime is a prime number that remains a prime when the digits are rotated.": 0.6153846153846154, "Write a Python function to check if a given number is a prime number or not.": 0.6122448979591837}, "avg_similarity_score": 0.20026951355399167} -{"instruction": "I have a list of numbers, how do I find the second largest number?", "input": "", "output": "You can use the sort() method to sort the list in ascending order and then return the second element.\n\n```python numbers = [1, 5, 2, 4, 3] numbers.sort() print(numbers[1]) ```", "most_similar": {"I have a list of numbers and I want to find the average of all the numbers.": 0.5806451612903226, "I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.5555555555555556, "How do I find the fibonacci number of a number?": 0.5, "Given a list of numbers, find the sum of the numbers.": 0.4799999999999999, "How do you find the largest number in a list using Python?": 0.4615384615384615, "How do I find the maximum value in an array?": 0.41666666666666663, "How can I make a program that will find the largest number in a list?": 0.4137931034482759, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.4117647058823529, "How to find the largest number in an array in Java?": 0.4, "How to find the largest prime factor of a given number?": 0.4}, "avg_similarity_score": 0.16942744223064538} -{"instruction": "Write a Python function to check if a number is a Sphenic number or not. A Sphenic number is a number that can be decomposed into a product of two prime numbers.", "input": "", "output": "def is_sphenic(num):\n for i in range(2, num):\n if num % i == 0:\n if is_prime(i) and is_prime(num // i):\n return True\n return False", "most_similar": {"Write a Python function to check if a number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence.": 0.6666666666666666, "Write a Python function to check if a given number is a Heptagonal number or not. A Heptagonal number is a number that can be expressed as n(5n-3)/2 where n is an integer.": 0.6470588235294118, "Write a Python function to check if a given number is a Sphenic number or not. A Sphenic number is a number whose proper divisors (excluding the number itself) are all the same.": 0.6461538461538462, "Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.6451612903225806, "Write a Python function to check if a given number is a circular prime or not. A circular prime is a prime number that remains a prime when the digits are rotated.": 0.625, "Write a Python function to check if a given number is a pandigital number or not. A pandigital number is a number that contains all the digits from 1 to n exactly once.": 0.6153846153846154, "Write a Python function to check if a number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its proper positive divisors.": 0.6153846153846154, "Write a Python function to check if a given number is a Fermat number or not. A Fermat number is a number of the form 22n + 1, where n is a non-negative integer.": 0.6060606060606061, "Write a Python function to check if a given number is a Ugly number or not. An Ugly number is a number whose prime factors are only 2, 3 or 5.": 0.6031746031746031, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.5882352941176471}, "avg_similarity_score": 0.19619537597572326} -{"instruction": "I have the following code: ```python def get_max_value(list): max_value = list[0] for i in range(1, len(list)): if list[i] > max_value: max_value = list[i] return max_value ``` What does the function do?", "input": "", "output": "The function takes in a list as an input and returns the maximum value in the list. Here is an in-depth look: ```python # It takes in a list as an input and returns the maximum value in the list. def get_max_value(list): # It sets the first element of the list as the maximum value. max_value = list[0] # It iterates over the list starting from the second element. for i in range(1, len(list)): # If the current element is greater than the maximum value, it updates the maximum value. if list[i] > max_value: max_value = list[i] # Finally, it returns the maximum value. return max_value ```", "most_similar": {"I have the following python function: ```python def resize_images(images, res_x, res_y): resized_images = np.zeros((images.shape[0], res_x, res_y)) for n in range(len(images)): resized_images[n, :, :] = resize(images[n, :, :], resized_images.shape[1:], anti_aliasing=False) return resized_images ``` What does the function do?": 0.3695652173913044, "I am trying to run the following code in Python: ```python def f(x): return x + 1 print(f(1)) ``` I get an error. What is the problem?": 0.29850746268656714, "I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.2622950819672131, "I am trying to use the following code in python:\n```py\ndef function(a, b):\n if a > b:\n print('You lost.')\n else:\n if c > a:\n print('Nice try.')\n else:\n print('You won.')\n```\nBut I am getting an error. What is wrong with the code?": 0.24096385542168672, "What is the output of the following python code?\n```python\ndef function(a):\n if a > 0:\n print('Positive')\n else:\n print('Negative')\n\nfunction(0)\n```": 0.22580645161290322, "What is the output of the following code?\n```python\ndef foo():\n x = 1\n def bar():\n x = 2\n return x\n return bar()\nprint(foo())\n```": 0.22580645161290322, "What does this Python code do? ``` import random def montecarloPi(calcs): hits = 0 for i in range(calcs): x = random.random() y = random.random() if (x**2 + y**2) < 1: hits = hits + 1 return 4.0 * hits / calcs print(montecarloPi(10000)) ```": 0.225, "The following code I wrote in haskell ```hs factorial(1)=1 factorial(n)=n*(n-1)*factorial(n-2) ``` gives me an error when I try to run it. Is there anything I did wrong?": 0.2162162162162162, "Translate the following code from python in Java.": 0.21276595744680848, "What is the output of the following code?\n```\npublic class Test {\n public static void main(String[] args) {\n int i = 1;\n while (i <= 5) {\n System.out.println(i);\n i++;\n }\n }\n}\n```": 0.208955223880597}, "avg_similarity_score": 0.0923815407525071} -{"instruction": "Write a Python function to check if a number is a Truncable number or not. A Truncable number is a number where the number generated by truncating the leftmost and rightmost digits of the number is a prime number. For example, 137 is a Truncable number, since 137, 37 and 7 are all prime numbers.", "input": "", "output": "def is_truncable_number(num):\n # return false if the number\n # is negative\n if num < 0:\n return False\n\n # find the sum of all\n # divisors of the number\n while num > 0:\n r = num % 10\n sum = sum + r\n num = num // 10\n\n # if the sum is equal to the number,\n # then the number is a Kaprekar number\n if (num % sum) == 0:\n return True\n return False", "most_similar": {"Write a Python function to check if a number is a Truncatable number or not. A Truncatable number is a number where the number formed by the first n digits is divisible by n for every n.": 0.5869565217391305, "Write a Python function to check if a number is a Truncable Harshad number or not. A Truncable Harshad number is a Harshad number which remains a Harshad number even after removing one or more digits from left or right side. For example, 1801 is a Truncable Harshad number, since 1801, 801, 01, 1 are all Harshad numbers.": 0.584070796460177, "Write a Python function to check if a given number is a Truncable prime or not. A Truncable prime is a prime number that remains prime when digits are removed from left or right side. For example, 3797 is a truncable prime because 3797, 797, 97 and 7 are all prime.": 0.5660377358490566, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.5494505494505494, "Write a Python function to check if a number is a strong number or not. A strong number is a number whose sum of factorial of digits is equal to the original number. For example, 145 is strong number since 1! + 4! + 5! = 1 + 24 + 120 = 145.": 0.5294117647058822, "Write a Python function to check if a given number is a Sphenic number or not. A Sphenic number is a number whose proper divisors (excluding the number itself) are all the same.": 0.5227272727272727, "Write a Python function to check if a number is a Smith number or not. A Smith number is a composite number, whose sum of digits is equal to the sum of digits of its prime factors. For example, 42 is a Smith number, since its prime factors are 2 and 21, and 2 + 2 + 1 = 2 + 4 + 2 = 8.": 0.5217391304347826, "Write a Python function to check if a given number is a Fermat number or not. A Fermat number is a number of the form 22n + 1, where n is a non-negative integer.": 0.5168539325842696, "Write a Python function to check if a number is a Disarium number or not. A Disarium number is a number where the sum of its digits powered with their respective positions is equal to the number itself.": 0.5161290322580645, "Write a Python function to check if a number is a Sphenic number or not. A Sphenic number is a number that can be decomposed into a product of two prime numbers.": 0.5057471264367817}, "avg_similarity_score": 0.1726040961391841} -{"instruction": "Write a Python function to find the first non-pallindrome string in a given list.", "input": "", "output": "def first_non_pallindrome_string(list):\n for string in list:\n if string != string[::-1]:\n return string\n return", "most_similar": {"Write a Python program to find the first non-repeated character in a string.": 0.689655172413793, "Write a Python function to find the sum of all items in a list.": 0.689655172413793, "Write a Python function to find the first repeated word in a given string, ignoring case and punctuation.": 0.6666666666666666, "Write a Python function to find the largest number in a dictionary.": 0.6666666666666665, "Write a python code to find the minimum value in a list.": 0.6666666666666665, "Write a Python function to find the index of the first occurrence of a specified item in a list.": 0.6470588235294117, "Write a Python program to find the longest pallindrome substring from a given string.": 0.6206896551724138, "Write a Python program to find the most common words in a given text.": 0.6206896551724138, "Write a Python function to reverse a given list of integers.": 0.6153846153846153, "Write a program to find the smallest number in a list.": 0.6153846153846153}, "avg_similarity_score": 0.2606221805738764} -{"instruction": "Write an SQL query to select all columns from a table named 'employees' where the age is greater than 30 and the salary is greater than 10000 or the name is 'John' and the age is less than 40.", "input": "", "output": "SELECT * FROM employees WHERE (age > 30 AND salary > 10000) OR (name = 'John' AND age < 40);", "most_similar": {"Write an SQL query to select all columns from a table named 'employees' where the age is greater than 30.": 0.6779661016949152, "Write a Python program to get a string made of the first 2 and the last 2 chars from a given a string. If the string length is less than 2, return instead of the empty string.": 0.2631578947368421, "Parse the natural language query into a SQL query that can be executed on the table.\nWhat are the name and budget of the departments with average instructor salary greater than the overall average?\nGiven two tables: instructor, department.": 0.2564102564102564, "Write a Python program to find the number of strings where the string length is 2 or more and the first and last character are same from a given list of strings.": 0.22535211267605634, "Write a Python function to check if a given number is a Fermat number or not. A Fermat number is a number of the form 22n + 1, where n is a non-negative integer.": 0.2191780821917808, "Write a Python function to check if a number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence.": 0.21875, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.21333333333333332, "Write a Python function to check if a number is a Truncable number or not. A Truncable number is a number where the number generated by truncating the leftmost and rightmost digits of the number is a prime number. For example, 137 is a Truncable number, since 137, 37 and 7 are all prime numbers.": 0.2127659574468085, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.21212121212121213, "Write a Python function to check if a number is a Truncatable number or not. A Truncatable number is a number where the number formed by the first n digits is divisible by n for every n.": 0.21052631578947367}, "avg_similarity_score": 0.11507511326571149} -{"instruction": "What is the difference between a pod and a horizontal pod autoscaler?", "input": "", "output": "A pod is a group of one or more containers, with shared storage/network, and a specification for how to run the containers. A horizontal pod autoscaler is a resource that controls a pod. The horizontal pod autoscaler in turn controls how many pods are running.", "most_similar": {"What is the difference between a static and a dynamic method?": 0.6956521739130435, "What is the difference between a list and a tuple in Python?": 0.6666666666666666, "What is the difference between a for loop and a while loop?": 0.6666666666666666, "What is the difference between a replica set and a stateful set?": 0.6666666666666666, "What is the difference between a class and an object?": 0.6363636363636365, "What is the difference between a relative and absolute path?": 0.6363636363636365, "What is the difference between an ingress and a persistent volume?": 0.6086956521739131, "What is the difference between a variable that is declared and defined and a variable that is only declared?": 0.5161290322580646, "What is the difference between a variable that is:\n1. Immutable\n2. Mutable": 0.48000000000000004, "What is a Dockerfile?": 0.375}, "avg_similarity_score": 0.14003206042502178} -{"instruction": "What is the difference between a deep copy and a shallow copy?", "input": "", "output": "A shallow copy is a copy of the reference to the object. A deep copy is a copy of the object.", "most_similar": {"What is the difference between a static and a dynamic method?": 0.6956521739130435, "What is the difference between a pod and a horizontal pod autoscaler?": 0.6666666666666666, "What is the difference between a for loop and a while loop?": 0.6666666666666666, "What is the difference between a replica set and a stateful set?": 0.6666666666666666, "What is the difference between a list and a tuple in Python?": 0.6666666666666666, "What is the difference between a relative and absolute path?": 0.6363636363636365, "What is the difference between a class and an object?": 0.6363636363636365, "What is the difference between an ingress and a persistent volume?": 0.6086956521739131, "What is the difference between a variable that is declared and defined and a variable that is only declared?": 0.5161290322580646, "What is the difference between a variable that is:\n1. Immutable\n2. Mutable": 0.48000000000000004}, "avg_similarity_score": 0.1417092406996767} -{"instruction": "How to find the standard deviation of a list?", "input": "", "output": "The statistics module contains a function called stdev() that returns the standard deviation of a list. The syntax for the stdev() looks like this: ``` import statistics a = [1, 2, 3, 4, 5] # a is the list. b = statistics.stdev(a) # b is the standard deviation of a. print(b) # The output would be 1.4142135623730951. ```", "most_similar": {"How do you find the standard deviation of all items in a list in Python?": 0.6666666666666667, "How to find the maximum value in a list?": 0.6666666666666666, "How to find the frequency distribution of all values in a list?": 0.6666666666666666, "How to find the sum of all the elements in a list in python?": 0.6086956521739131, "How to get the last element of a list in Python?": 0.6, "How to find the largest prime factor of a given number?": 0.6, "How do you find the index of an item in a list?": 0.5714285714285715, "I want to find the average of all the numbers in a list.": 0.5454545454545455, "How do I find the p-variance of all elements in a list?": 0.5454545454545455, "How do I find the standard deviation of all elements in an array?": 0.5454545454545455}, "avg_similarity_score": 0.20959325563298445} -{"instruction": "How do I print a list in Python?", "input": "", "output": "You can use the print() function to print a list.\n\n```python my_list = [1, 2, 3, 4, 5] print(my_list) ```", "most_similar": {"How do you sort a list of strings in Python?": 0.6666666666666665, "How do you remove duplicates from a list in Python?": 0.6666666666666665, "How do I get the power of a number in python?": 0.631578947368421, "How do I convert a string to a number in Python?": 0.631578947368421, "How do you create a variable in Python?": 0.625, "How do you output all the contents of a list in Python?": 0.6, "How do I output a string in C++ programming?": 0.5882352941176471, "How do I create a new branch in git?": 0.5882352941176471, "How do I push a tag to remote in git?": 0.5555555555555556, "How can I sort a list of integers in Rust?": 0.5555555555555556}, "avg_similarity_score": 0.17618278479391478} -{"instruction": "Given an array of integers nums, write a method that returns the \"pivot\" index of this array.", "input": "", "output": "class Solution:\n def pivotIndex(self, nums: List[int]) -> int:\n if not nums:\n return -1\n left_sum = 0\n right_sum = sum(nums) - nums[0]\n for i in range(len(nums)):\n if left_sum == right_sum:\n return i\n left_sum += nums[i]\n if i < len(nums) - 1:\n right_sum -= nums[i + 1]\n return -1", "most_similar": {"Write a function that returns the sum of two numbers.": 0.4444444444444445, "Write a python function that returns the number of words in a given string.": 0.3870967741935484, "Write a python function that returns the sum of the elements of a list.": 0.3870967741935484, "Write a function that takes a string and returns the number of vowels in the string.": 0.3636363636363636, "write a c++ program that calculates the perimeter of a square": 0.35714285714285715, "Write a function that takes an array of numbers and returns the largest number in the array.": 0.35294117647058826, "Write a Python function that takes a number as input and returns the square of that number.": 0.35294117647058826, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.35294117647058826, "Write a Python function that returns the largest item in a list.": 0.3448275862068966, "Given an array of integers, return indices of the two numbers such that they add up to a specific target.": 0.3243243243243243}, "avg_similarity_score": 0.1616470283931598} -{"instruction": "Write a Python program to find the difference between a specified number and 13, if the number is greater than 13 return double the absolute difference.", "input": "", "output": "def difference(num):\n diff = abs(num - 13)\n if num > 13:\n return diff * 2\n else:\n return diff\n\nprint(difference(17))", "most_similar": {"Write a Python program to find the first Fibonacci number greater than four million.": 0.5, "Write a Python program to find the frequency of the words from the sentence given.": 0.43902439024390244, "Write a Python program to find the maximum and minimum number from a given list.": 0.43902439024390244, "Write a Python program to find the first Fibonacci number with the first 1000 digits.": 0.43902439024390244, "Write a Python program to find the first repeated character of a given string where the index of first occurrence is smallest.": 0.41666666666666663, "Write a Python program to get a string made of the first 2 and the last 2 chars from a given a string. If the string length is less than 2, return instead of the empty string.": 0.41269841269841273, "Write a Python program to find the sum of a non-negative integer.": 0.4102564102564103, "Write a Python program to find the number of even and odd numbers from a series of numbers.": 0.40909090909090906, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.4, "Write a Python program to find the first non-repeated character in a string.": 0.4}, "avg_similarity_score": 0.20844038990784916} -{"instruction": "Write a Python function that takes a list of numbers as input and returns the sum of all the numbers in the list that are greater than 5 and less than 10, and are even, and are not divisible by 3.", "input": "", "output": "def sum_numbers_greater_than_5_less_than_10_even_not_divisible_by_3(numbers):\n return sum(i for i in numbers if i > 5 and i < 10 and i % 2 == 0 and i % 3 != 0)\n\nresult = sum_numbers_greater_than_5_less_than_10_even_not_divisible_by_3([1, 2, 3, 4, 5])\nprint(result)", "most_similar": {"Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.6774193548387097, "Write a Python function that takes a number as input and returns the sum of all the numbers from 1 to that number that are divisible by 3 and 5.": 0.6197183098591549, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.5757575757575758, "Write a function that takes a list of numbers and returns a list of the same numbers, but with the first and last elements swapped.": 0.48484848484848486, "Write a Python function that takes a number as input and returns the square of that number.": 0.48275862068965514, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.4590163934426229, "Write a Python function that takes a string as input and returns the string in reverse order.\n'Hello'": 0.44067796610169496, "Write a Python function that takes two numbers as input and returns their sum.": 0.4363636363636364, "Write a Python function that takes a list and returns a new list with unique elements of the first list.": 0.42622950819672134, "Write a Python function that takes a number as input and returns its square, cube, square root, cube root, and the sum of its digits.": 0.42424242424242425}, "avg_similarity_score": 0.1768248003207247} -{"instruction": "How do I create a text field in HTML?", "input": "", "output": "A text field is a clickable element that can be used to input text. Here is an example of a text field.\n\n\n\n\n\n \n\n\n

HTML Forms

\n

What is your name?

\n\n
\n
\n
\n
\n

\n \n
\n\n\n", "most_similar": {"How do I create a new branch in git?": 0.6666666666666666, "How do I print a list in Python?": 0.5882352941176471, "How do you create a variable in Python?": 0.5882352941176471, "How can I make a button in HTML?": 0.5882352941176471, "How do I incorporate CSS in my HTML page?": 0.5555555555555556, "How do I output a string in C++ programming?": 0.5555555555555556, "How do I push a tag to remote in git?": 0.5263157894736842, "How do I make a dropdown menu?": 0.5, "How do I get the power of a number in python?": 0.5, "How do I convert a string to a number in Python?": 0.5}, "avg_similarity_score": 0.13488290677079412} -{"instruction": "How do I find the sum of the first 1000 prime numbers in C++?", "input": "", "output": "Here's a C++ program that finds the sum of the first 1000 prime numbers: ``` c++ #include using namespace std; int main() { int sum = 0; for (int i = 2; i < 1000; i++) { bool isPrime = true; for (int j = 2; j < i; j++) { if (i % j == 0) { isPrime = false; break; } } if (isPrime) { sum += i; } } cout << sum; return 0; } ```", "most_similar": {"Write a Python program to find the sum of the first 1000 prime numbers.": 0.6428571428571429, "How can I get the first 1000 prime numbers in Python?": 0.64, "How do I find the index of the first occurrence of a value in an array?": 0.6000000000000001, "How do I find the greatest common divisor of two numbers?": 0.56, "How do I find the standard deviation of all elements in an array?": 0.5185185185185186, "How do I find the p-variance of all elements in a list?": 0.5185185185185186, "I want to find the average of all the numbers in a list.": 0.5185185185185186, "How do I find the first and last occurrence of a substring in a string in C++?": 0.5161290322580646, "How to find the sum of all the elements in a list in python?": 0.5, "How do I find the first element that satisfies a condition in an array?": 0.5}, "avg_similarity_score": 0.18048073375581458} -{"instruction": "How to find the nth prime number in C?", "input": "", "output": "```c #include int main() { int n, i, j, flag; printf(\"Enter a positive integer: \"); scanf(\"%d\", &n); printf(\"First %d prime numbers are :\\n\", n); for (i = 2; n > 0; ++i) { flag = 0; for (j = 2; j <= i / 2; ++j) { if (i % j == 0) { flag = 1; break; } } if (flag == 0) { printf(\"%d\\n\", i); --n; } } return 0; } ```", "most_similar": {"How to find the largest number in an array in Java?": 0.6, "How to find the largest prime factor of a given number?": 0.6, "How to find the maximum value in a list?": 0.5555555555555556, "How to find the number of days between two dates?": 0.5263157894736842, "How do I find the sum of the first 1000 prime numbers in C++?": 0.5217391304347826, "Write a program to find the smallest number in a list.": 0.5, "How to check quickly if a number is prime in C?": 0.5, "How to find the frequency distribution of all values in a list?": 0.4761904761904762, "How do you find the largest number in a list using Python?": 0.4761904761904762, "Write a Python function to find the largest number in a dictionary.": 0.4761904761904762}, "avg_similarity_score": 0.17633924162827558} -{"instruction": "Write a Python program to find the first pallindromic string from a given string where the length is three or more.", "input": "", "output": "def first_pallindromic_string_length_three(str):\n for i in range(len(str)-2):\n if str[i:i+3] == str[i:i+3][::-1]:\n return str[i:i+3]\n return None", "most_similar": {"Write a Python program to find the first repeated character of a given string where the index of first occurrence is smallest.": 0.6511627906976744, "Write a Python program to find the longest pallindrome substring from a given string.": 0.6285714285714286, "Write a Python program to find the first non-repeated character in a string.": 0.5714285714285714, "Write a Python program to find the frequency of each word in a given string.": 0.5555555555555556, "Write a Python program to find the maximum and minimum number from a given list.": 0.5555555555555556, "Write a Python function to find the first non-pallindrome string in a given list.": 0.5555555555555556, "Write a Python program to find the most common words in a given text.": 0.5142857142857143, "Write a Python function to find the first repeated word in a given string, ignoring case and punctuation.": 0.5128205128205129, "Write a Python program to find the frequency of the words from the sentence given.": 0.5, "Write a Python program to find the first Fibonacci number with the first 1000 digits.": 0.5}, "avg_similarity_score": 0.2220118665835247} -{"instruction": "Write a script to output 'Hello World' in python\nYou are given an array `prices` where `prices[i]` is the price of a given stock on the i^th day. You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. Return the maximum profit you can achieve from this transaction. If you cannot achieve any profit, return 0.", "input": "", "output": "class Solution:\n def maxProfit(self, prices: List[int]) -> int:\n min_price = float('inf')\n max_profit = 0\n for i in range(len(prices)):\n if prices[i] < min_price:\n min_price = prices[i]\n elif prices[i] - min_price > max_profit:\n max_profit = prices[i] - min_price\n \n return max_profit", "most_similar": {"Write a script to output 'Hello World' in python": 0.21428571428571425, "Write Python code to solve this leetcode problem.\nProblem: You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.\n\nYou may assume the two numbers do not contain any leading zero, except the number 0 itself.": 0.2112676056338028, "Write a Python function to check if a given number is a pandigital number or not. A pandigital number is a number that contains all the digits from 1 to n exactly once.": 0.2037037037037037, "Write a function that takes an integer as input and returns the number of bits that are equal to 1 in the binary representation of that number. You can guarantee that input is non-negative.": 0.19999999999999998, "Write a Python program to find the first appearance of the substring 'not' and 'poor' from a given string, if 'not' follows the 'poor', replace the whole 'not'...'poor' substring with 'good'. Return the resulting string.": 0.19819819819819823, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.19607843137254902, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number whose square when divided into two parts, one part being the original number and the other part being the remaining part, add up to the original number.": 0.1935483870967742, "Given an array of integers `nums` and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order.": 0.19047619047619052, "Given an array of integers, find the first missing positive integer in linear time and constant space. In other words, find the lowest positive integer that does not exist in the array. The array can contain duplicates and negative numbers as well.": 0.18803418803418803, "Write a Python function to check if a given number is an Armstrong number or not. An Armstrong number is a number that is equal to the sum of its own digits each raised to the power of the number of digits.": 0.18803418803418803}, "avg_similarity_score": 0.11875180716105575} -{"instruction": "Fill in the in the html document with a propoer text. You should take the html tag into consideration. You output should be the completed html document.\n\n\n <mask> \n\n\u02dc South Korea on Monday announced sweeping\ntax reforms, including income and\ncorporate tax cuts to boost growth by\nstimulating sluggish private\nconsumption and business investment.\n\n", "input": "", "output": "\n\n South Korea Announces Tax Reforms To\nBoost Economic Growth \n\n\u02dc South Korea on Monday announced sweeping\ntax reforms, including income and\ncorporate tax cuts to boost growth by\nstimulating sluggish private\nconsumption and business investment.\n\n", "most_similar": {"Fill in the in the html document with a propoer text. You should take the html tag into consideration. You output should be the completed html document.": 0.6222222222222222, "Replace the token in the text with proper words that are consistent with the context. You can use multiple words for each token.": 0.1839080459770115, "Write a Python function that takes a number as input and returns the sum of all the numbers from 1 to that number that are divisible by 3 and 5.": 0.13043478260869568, "Using the comment as a guide, replace the \"TODO\" comment in the code with the proper code.": 0.12658227848101267, "Write a Python function to check if a given number is a Carmichael number or not. A Carmichael number is a composite number that satisfies the following conditions: The number must be composite i.e. greater than 1. The number must not be a prime number. If we take every number from 1 to n-1 (both included) and calculate the remainder when divided by the number, no number should have the same remainder when divided by the number, except 0 and the number itself.": 0.12244897959183675, "You are given a list of numbers. You need to find the number of pairs of indices (i, j) such that the difference between nums[i] and nums[j] is at most t and i < j.": 0.12244897959183673, "Using the comment as a guide, replace the \"TODO\" comment in the code with the proper code.\ndef greet_to(name):\n \"\"\"Print a greeting to the name provided.\"\"\"\n # TODO: assert name is a string\n print(\"Hello, \" + name + \"!\")": 0.12121212121212119, "Write a Python function to check if a given number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence. The Fibonacci sequence is a sequence of numbers where each number is the sum of the two preceding numbers. The first two numbers in the sequence are 0 and 1.": 0.11864406779661016, "Write a script to output 'Hello World' in python\nYou are given an array `prices` where `prices[i]` is the price of a given stock on the i^th day. You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. Return the maximum profit you can achieve from this transaction. If you cannot achieve any profit, return 0.": 0.11678832116788321, "Given an array of integers, find the first missing positive integer in linear time and constant space. In other words, find the lowest positive integer that does not exist in the array. The array can contain duplicates and negative numbers as well.": 0.11538461538461538}, "avg_similarity_score": 0.06582967869934751} -{"instruction": "Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of the first 10 ugly numbers. Note that 1 is typically treated as an ugly number.", "input": "", "output": "class Solution:\n def nthUglyNumber(self, n: int) -> int:\n ugly = [1]\n i2, i3, i5 = 0, 0, 0\n while len(ugly) < n:\n ugly.append(min(ugly[i2] * 2, ugly[i3] * 3, ugly[i5] * 5))\n if ugly[-1] == ugly[i2] * 2:\n i2 += 1\n if ugly[-1] == ugly[i3] * 3:\n i3 += 1\n if ugly[-1] == ugly[i5] * 5:\n i5 += 1\n return ugly[-1]", "most_similar": {"Write a program to find the n-th ugly number.\nUgly numbers are positive numbers whose prime factors only include 2, 3, 5.": 0.5974025974025974, "How to make a python program that will print the following pattern?\n```\n1\n2 3\n4 5 6\n7 8 9 10\n11 12 13 14 15\n```": 0.3209876543209876, "Write a program to find the n-th ugly number.": 0.3125, "Write a Python function to check if a given number is a Ugly number or not. An Ugly number is a number whose prime factors are only 2, 3 or 5.": 0.30588235294117644, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.2941176470588235, "Write a Python program to find the number of even and odd numbers from a series of numbers.": 0.2777777777777778, "Write a Python function to find the smallest number from a sequence of numbers.": 0.2647058823529412, "Write a Python program to find the first repeated character of a given string where the index of first occurrence is smallest.": 0.2631578947368421, "Write a Python program to find the first Fibonacci number with the first 1000 digits.": 0.2608695652173913, "Write a C# program to find the sum of all the elements of an array.": 0.2608695652173913}, "avg_similarity_score": 0.13091859873897135} -{"instruction": "How to find the sum of all numbers in an array?", "input": "", "output": "```javascript const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9]; const sum = numbers.reduce((a, b) => a + b, 0); ```", "most_similar": {"How do I find the standard deviation of all elements in an array?": 0.6666666666666667, "How to find the sum of all the elements in a list in python?": 0.64, "How to find the largest number in an array in Java?": 0.6363636363636364, "Write a C# program to find the sum of all the elements of an array.": 0.6153846153846153, "How to find the frequency distribution of all values in a list?": 0.6086956521739131, "I want to find the average of all the numbers in a list.": 0.5833333333333334, "How do I find the maximum value in an array?": 0.5714285714285713, "How do I find the sum of the first 1000 prime numbers in C++?": 0.56, "Write a Python function to find the sum of all items in a list.": 0.56, "How do I find the index of the first occurrence of a value in an array?": 0.5185185185185185}, "avg_similarity_score": 0.19626926770540057} -{"instruction": "What is the output of the following code?\n```\na = 1\nb = 2\nc = 3\nif a > b:\n print(\"a is greater than b\")\nelif a > c:\n print(\"a is greater than c\")\nelse:\n print(\"a is not greater than b or c\")\n```", "input": "", "output": "a is not greater than b or c", "most_similar": {"What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.5396825396825397, "What is the output of the following code? ```py def add(a, b): return a + b print(add(1, 2)) print(add(b=2, a=1)) ```": 0.4411764705882353, "What is the output of the following python code?\n```python\ndef function(a):\n if a > 0:\n print('Positive')\n else:\n print('Negative')\n\nfunction(0)\n```": 0.4307692307692308, "Translate the following code from python in Java.\ndef function(a : int, b : int, c : int):\n if a > b :\n print('You lost.')\n else :\n if c > a :\n print('Nice try.')\n else :\n print('You won.')": 0.3733333333333333, "What is the output of the following code?\n```python\ndef foo():\n x = 1\n def bar():\n x = 2\n return x\n return bar()\nprint(foo())\n```": 0.3384615384615384, "I am trying to use the following code in python:\n```py\ndef function(a, b):\n if a > b:\n print('You lost.')\n else:\n if c > a:\n print('Nice try.')\n else:\n print('You won.')\n```\nBut I am getting an error. What is wrong with the code?": 0.3255813953488372, "Find the bug in the following code piece: a = 1 while a == 1: b = input(\"what's your name ?\") print(\"Hi \",b, \" this is infinity loop !\")": 0.3235294117647059, "What is the output of the following Python code? ```py def f(x): return x + 1 def g(x): return x * 2 print(g(f(3))) ```": 0.3235294117647059, "What is the output of the following code?\n```python\ndef foo():\n print(\"foo\")\n\ndef bar():\n print(\"bar\")\n\ndef main():\n foo()\n bar()\n\nmain()\n```": 0.31249999999999994, "What is the output of the following code?\n```python\ndef func(x):\n return x + 1\n\ndef main():\n x = 1\n y = func(x)\n print(y)\n\nmain()\n```": 0.2985074626865672}, "avg_similarity_score": 0.11945797494798983} -{"instruction": "How can I find the index of an item in an array in c++?", "input": "", "output": "You can use the find() function to find the index of an item in an array.\n\n```c++ int myints[] = {10,20,30,40}; std::vector myvector (myints, myints+4); std::vector::iterator it = std::find (myvector.begin(), myvector.end(), 30); if (it != myvector.end()) std::cout << \"Element found in myvector: \" << *it << '\\n'; else std::cout << \"Element not found in myvector\\n\"; ```", "most_similar": {"How do you find the index of an item in a list?": 0.6153846153846153, "How can I iterate through each item in an array in a random order using c++?": 0.6000000000000001, "How do I find the index of the first occurrence of a value in an array?": 0.6000000000000001, "How do I find the standard deviation of all elements in an array?": 0.5925925925925927, "How do I find the maximum value in an array?": 0.5833333333333334, "How to find the largest number in an array in Java?": 0.56, "How to find the sum of all numbers in an array?": 0.56, "How do I find the first and last occurrence of a substring in a string in C++?": 0.5161290322580646, "How do I find the first element that satisfies a condition in an array?": 0.5, "How do I find the sum of the first 1000 prime numbers in C++?": 0.5}, "avg_similarity_score": 0.15776471494008004} -{"instruction": "Write a Python function to check if a given number is a prime number or not. A prime number is a positive integer that has exactly two distinct divisors: 1 and the number itself. For example, 2 is a prime number because it is only divisible by 1 and 2. Similarly, 3 is a prime number because it is only divisible by 1 and 3.", "input": "", "output": "def is_prime(num):\n if num <= 1:\n return False\n for i in range(2, num):\n if num % i == 0:\n return False\n return True", "most_similar": {"Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.5894736842105264, "Write a Python function to check if a given number is a Harshad number or not. A Harshad number is a number that is divisible by the sum of its digits. For example, 42 is a Harshad number because it is divisible by 6 (the sum of its two digits 4 + 2).": 0.5470085470085471, "Write a Python function to check if a given number is a circular prime or not. A circular prime is a prime number that remains prime when each digit is rotated individually around the number (clockwise or counterclockwise). For example, 197 is a circular prime because 971 and 719 are both prime.": 0.5128205128205129, "Write a Python function to check if a given number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. For example, 6 has divisors 1, 2 and 3 (excluding the number itself), and 6 = 1 + 2 + 3. Similarly, 28 has divisors 1, 2, 4, 7, 14 and 28, and 28 = 1 + 2 + 4 + 7 + 14.": 0.5072463768115941, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a positive integer that after being repeatedly summed and subtracted by its digits, eventually reaches 1.": 0.49504950495049505, "Write a Python function to check if a number is a Truncable number or not. A Truncable number is a number where the number generated by truncating the leftmost and rightmost digits of the number is a prime number. For example, 137 is a Truncable number, since 137, 37 and 7 are all prime numbers.": 0.48333333333333334, "Write a Python function to check if a given number is a Truncable prime or not. A Truncable prime is a prime number that remains prime when digits are removed from left or right side. For example, 3797 is a truncable prime because 3797, 797, 97 and 7 are all prime.": 0.4827586206896552, "Write a Python function to check if a given number is a Ugly number or not. An Ugly number is a number whose prime factors are only 2, 3 or 5.": 0.47916666666666663, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.47524752475247534, "Write a Python function to check if a given number is a circular prime or not. A circular prime is a prime number that remains a prime when the digits are rotated.": 0.4742268041237114}, "avg_similarity_score": 0.15139017134315497} -{"instruction": "Write a program to find the maximum of three numbers.", "input": "", "output": "def max_of_three(x, y, z):\n if x > y and x > z:\n return x\n elif y > x and y > z:\n return y\n else:\n return z", "most_similar": {"Write a Python program to find the sum of the first 1000 prime numbers.": 0.6666666666666666, "Write a program to find the pearson correlation coefficient of two lists.": 0.6363636363636365, "Write a Python program to find the Fibonacci series up to n numbers.": 0.608695652173913, "Write a Python program to find the sum of a non-negative integer.": 0.608695652173913, "Write a program to find the n-th ugly number.": 0.6, "Write a Python program to find the average of a list using for loop.": 0.5833333333333334, "Write a Python function to find the smallest number from a sequence of numbers.": 0.5833333333333334, "Write a Python program to find the number of even and odd numbers from a series of numbers.": 0.5714285714285714, "Write a python code to find the area of a circle.": 0.5714285714285713, "Write a program to find the smallest number in a list.": 0.5714285714285713}, "avg_similarity_score": 0.23390044442953736} -{"instruction": "What is the output of the following code? ```py def add_five(x): x += 5 return x print(add_five(2)) ```", "input": "", "output": "The output is 7.", "most_similar": {"What is the output of the following Python code? ```py def f(x): return x + 1 def g(x): return x * 2 print(g(f(3))) ```": 0.6382978723404256, "What is the output of the following code? ```py def add(a, b): return a + b print(add(1, 2)) print(add(b=2, a=1)) ```": 0.6382978723404256, "What is the output of the following code?\n```python\ndef foo():\n x = 1\n def bar():\n x = 2\n return x\n return bar()\nprint(foo())\n```": 0.6363636363636365, "What is the output of the following code?\n```python\ndef f(x):\n return x * 2\n\ndef g(x):\n return f(x) + 1\n\ndef h(x):\n return g(x) * 2\n\nprint(h(2))\n```": 0.5660377358490566, "What is the output of the following code?\n```python\ndef func(x):\n return x + 1\n\ndef main():\n x = 1\n y = func(x)\n print(y)\n\nmain()\n```": 0.5652173913043478, "What is the output of this code?\n```python\ndef f(x):\n x = 2 * x + 1\n return x\n\nx = 3\nz = f(x)\nprint(z)\n```": 0.5333333333333333, "What is the output of this code?\n```\nx = 10\ndef func():\n x = 20\n print(x)\nfunc()\nprint(x)\n```": 0.5128205128205129, "What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.47619047619047616, "What is the output of the following code?\n```python\ndef foo():\n print(\"foo\")\n\ndef bar():\n print(\"bar\")\n\ndef main():\n foo()\n bar()\n\nmain()\n```": 0.46511627906976744, "What is the output of the following python code?\n```python\ndef function(a):\n if a > 0:\n print('Positive')\n else:\n print('Negative')\n\nfunction(0)\n```": 0.4545454545454545}, "avg_similarity_score": 0.11633963646232964} -{"instruction": "Write a Python function to check if a given number is a Sphenic number or not. A Sphenic number is a number whose prime factorization only contains 3, 5, and 7. For example, 105 is a Sphenic number because it is divisible by 3, 5, and 7.", "input": "", "output": "```python def is_sphenic_number(num):\n for factor in range(2, num):\n while num % factor == 0:\n if factor not in [3, 5, 7]:\n return False\n num //= factor\n return True ```", "most_similar": {"Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.6233766233766233, "Write a Python function to check if a given number is a Ugly number or not. An Ugly number is a number whose prime factors are only 2, 3 or 5.": 0.6153846153846153, "Write a Python function to check if a given number is a Harshad number or not. A Harshad number is a number that is divisible by the sum of its digits. For example, 42 is a Harshad number because it is divisible by 6 (the sum of its two digits 4 + 2).": 0.6060606060606061, "Write a Python function to check if a given number is a Sphenic number or not. A Sphenic number is a number whose proper divisors (excluding the number itself) are all the same.": 0.5999999999999999, "Write a Python function to check if a given number is a prime number or not. A prime number is a positive integer that has exactly two distinct divisors: 1 and the number itself. For example, 2 is a prime number because it is only divisible by 1 and 2. Similarly, 3 is a prime number because it is only divisible by 1 and 3.": 0.5714285714285714, "Write a Python function to check if a number is a Sphenic number or not. A Sphenic number is a number that can be decomposed into a product of two prime numbers.": 0.5569620253164557, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.5542168674698795, "Write a Python function to check if a number is a Truncatable number or not. A Truncatable number is a number where the number formed by the first n digits is divisible by n for every n.": 0.5476190476190476, "Write a Python function to check if a given number is a Fermat number or not. A Fermat number is a number of the form 22n + 1, where n is a non-negative integer.": 0.54320987654321, "Write a Python function to check if a given number is a palindrome or not. A palindrome is a number that remains the same when its digits are reversed. For example, 121 is a palindrome but 112 is not.": 0.5348837209302325}, "avg_similarity_score": 0.15891372627692285} -{"instruction": "You are given a list of numbers. You need to find the median of the list.", "input": "", "output": "The median is the middle number of a list. If the list has an even number of elements, then there is no single middle value; the median is then defined to be the mean of the two middle values.\n\nFor example, the median of [2, 4, 1, 5, 3] is 3, the median of [2, 4, 1, 5, 3, 6] is (3 + 4) / 2 = 3.5.\n\nYou can use the following code to find the median of a list.\n\n```python\ndef median(lst):\n sortedLst = sorted(lst)\n lstLen = len(lst)\n index = (lstLen - 1) // 2\n if (lstLen % 2):\n return sortedLst[index]\n else:\n return (sortedLst[index] + sortedLst[index + 1]) / 2.0\n```", "most_similar": {"Given a list of numbers, find the sum of the numbers.": 0.6666666666666666, "I have a list of numbers and I want to find the average of all the numbers.": 0.5454545454545455, "You are given a list of numbers. You need to find the number of pairs of indices (i, j) such that the difference between nums[i] and nums[j] is at most t and i < j.": 0.5384615384615385, "I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.47368421052631576, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.4324324324324324, "I want to find the average of all the numbers in a list.": 0.41379310344827586, "I have a list of numbers, how do I find the second largest number?": 0.39999999999999997, "How to find the sum of all the elements in a list in python?": 0.39999999999999997, "Given a string `s`, find the length of the longest substring without repeating characters.": 0.39999999999999997, "Write a Python function to find the sum of all items in a list.": 0.39999999999999997}, "avg_similarity_score": 0.18835004339953934} -{"instruction": "Write a Python function to check if a given number is a Automorphic number or not. An Automorphic number is a number whose square \"ends\" in the same digits as the number itself.", "input": "", "output": "def is_automorphic(num):\n return num == int(str(num * num)[-len(str(num)):])", "most_similar": {"Write a Python function to check if a given number is a Sphenic number or not. A Sphenic number is a number whose proper divisors (excluding the number itself) are all the same.": 0.696969696969697, "Write a Python function to check if a number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence.": 0.689655172413793, "Write a Python function to check if a given number is a Ugly number or not. An Ugly number is a number whose prime factors are only 2, 3 or 5.": 0.65625, "Write a Python function to check if a number is a Disarium number or not. A Disarium number is a number where the sum of its digits powered with their respective positions is equal to the number itself.": 0.6478873239436619, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.6376811594202899, "Write a Python function to check if a given number is a pandigital number or not. A pandigital number is a number that contains all the digits from 1 to n exactly once.": 0.6363636363636364, "Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.6349206349206349, "Write a Python function to check if a given number is an Armstrong number or not. An Armstrong number is a number that is equal to the sum of its own digits each raised to the power of the number of digits.": 0.6133333333333334, "Write a Python function to check if a given number is a prime number or not.": 0.6122448979591837, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.6}, "avg_similarity_score": 0.2044094172661038} -{"instruction": "Write a Python function to check if a given number is a Truncable number or not. A Truncable number is a number where the number generated by truncating it from left or right is also a number.", "input": "", "output": "def is_truncable(num):\n while num:\n if int(num) ** 2 < num:\n return False\n num = str(num)[1:]\n return True", "most_similar": {"Write a Python function to check if a number is a Truncable number or not. A Truncable number is a number where the number generated by truncating the leftmost and rightmost digits of the number is a prime number. For example, 137 is a Truncable number, since 137, 37 and 7 are all prime numbers.": 0.6521739130434782, "Write a Python function to check if a number is a Truncatable number or not. A Truncatable number is a number where the number formed by the first n digits is divisible by n for every n.": 0.6486486486486487, "Write a Python function to check if a given number is a Fermat number or not. A Fermat number is a number of the form 22n + 1, where n is a non-negative integer.": 0.6478873239436619, "Write a Python function to check if a number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence.": 0.6451612903225806, "Write a Python function to check if a given number is a Truncable Prime or not. A Truncable Prime is a prime number which remains a prime number even if we truncate one or more digits from left or right side.": 0.6410256410256411, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.6301369863013699, "Write a Python function to check if a given number is a Sphenic number or not. A Sphenic number is a number whose proper divisors (excluding the number itself) are all the same.": 0.6285714285714286, "Write a Python function to check if a given number is a pandigital number or not. A pandigital number is a number that contains all the digits from 1 to n exactly once.": 0.6285714285714286, "Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.626865671641791, "Write a Python function to check if a number is a Truncable Primes or not. A Truncable Primes number is a number which can be repeatedly truncated from left or right side and each time a Truncable Primes is obtained, then the number is called Truncable Primes.": 0.6190476190476191}, "avg_similarity_score": 0.19461064297745448} -{"instruction": "Given a string, return the number of vowels used in the text.", "input": "", "output": "def get_num_vowels(text):\n vowels = set('aeiou')\n return sum(map(lambda c: c in vowels, text))", "most_similar": {"Given a string s, return the number of palindromic substrings in it.": 0.6666666666666666, "Write a function that takes a string and returns the number of vowels in the string.": 0.5714285714285715, "Given a string s, return the longest palindromic substring in s.": 0.5217391304347826, "Given a string `s`, find the length of the longest substring without repeating characters.": 0.4615384615384615, "Given a list of numbers, find the sum of the numbers.": 0.43478260869565216, "Write a python function that returns the number of words in a given string.": 0.3846153846153846, "Write a function that returns the number of times a given string occurs in a given text as its substring.": 0.37499999999999994, "Given the `root` of a binary tree, return the inorder traversal of its nodes' values.": 0.3703703703703704, "Can you provide a shell script that displays the total number of lines in all '*.txt' files in the current directory?": 0.36363636363636365, "You are given a list of numbers. You need to find the median of the list.": 0.35714285714285715}, "avg_similarity_score": 0.1888263275151548} -{"instruction": "Write a Python function to check whether a passed string is palindrome or not.", "input": "", "output": "def is_palindrome(string):\n return string == string[::-1]", "most_similar": {"Write a Python function to check if a given number is a prime number or not.": 0.6666666666666666, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.5365853658536585, "Write a Python function to check if a number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence.": 0.5128205128205129, "Write a Python function to check if a given string is a pangram or not. A pangram is a sentence containing every letter of the English alphabet at least once.": 0.5, "Write a Python function to reverse a given list of integers.": 0.4799999999999999, "Write a Python function to calculate the factorial of a number.": 0.4799999999999999, "Write a Python function to find the largest number in a dictionary.": 0.4615384615384615, "Write a Python program to find the first pallindromic string from a given string where the length is three or more.": 0.4571428571428571, "Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.4545454545454545, "Write a Python function to check if a given number is a Ugly number or not. An Ugly number is a number whose prime factors are only 2, 3 or 5.": 0.4444444444444444}, "avg_similarity_score": 0.2055943651023386} -{"instruction": "How do you add a link to a web page?", "input": "", "output": "You can add a link to a web page by using the anchor tag. For example: ``` Click here ``` This will create a link to the URL https://www.example.com with the text \"Click here\".", "most_similar": {"How do I convert a string to a number in Python?": 0.47619047619047616, "How do you create a variable in Python?": 0.4444444444444445, "How do I compile a go program on Linux to a windows executable?": 0.4347826086956522, "How do I push a tag to remote in git?": 0.4000000000000001, "How do you remove duplicates from a list in Python?": 0.4000000000000001, "How do you sort a list of strings in Python?": 0.4000000000000001, "How do I make a list of all the prime numbers up to a certain number?": 0.38461538461538464, "How do you find the length of a string in Python?": 0.380952380952381, "How do you find the number of occurrences of a given value in a list in Python?": 0.37037037037037035, "How do you find the largest number in a list using Python?": 0.3636363636363636}, "avg_similarity_score": 0.15156093998411763} -{"instruction": "What is the output of the following C# code?\n```\nint x = 1;\nint y = 2;\nint z = 3;\n\nif (x < y)\n{\n if (y < z)\n {\n Console.WriteLine(\"y is the median\");\n }\n else\n {\n Console.WriteLine(\"x is the median\");\n }\n}\nelse\n{\n if (x < z)\n {\n Console.WriteLine(\"x is the median\");\n }\n else\n {\n Console.WriteLine(\"z is the median\");\n }\n}\n```", "input": "", "output": "x is the median", "most_similar": {"What is the output of this code?\n```python\ndef f(x):\n x = 2 * x + 1\n return x\n\nx = 3\nz = f(x)\nprint(z)\n```": 0.358974358974359, "What is the output of the following code?\n```\na = 1\nb = 2\nc = 3\nif a > b:\n print(\"a is greater than b\")\nelif a > c:\n print(\"a is greater than c\")\nelse:\n print(\"a is not greater than b or c\")\n```": 0.3333333333333333, "What is the output of the following code?\n```python\ndef func(x):\n return x + 1\n\ndef main():\n x = 1\n y = func(x)\n print(y)\n\nmain()\n```": 0.3291139240506329, "What is the output of the following code?\n```python\ndef f(x):\n return x * 2\n\ndef g(x):\n return f(x) + 1\n\ndef h(x):\n return g(x) * 2\n\nprint(h(2))\n```": 0.3255813953488372, "What is the output of the following code?\n```python\ndef foo():\n x = 1\n def bar():\n x = 2\n return x\n return bar()\nprint(foo())\n```": 0.3116883116883117, "What is the output of the following Python code? ```py def f(x): return x + 1 def g(x): return x * 2 print(g(f(3))) ```": 0.3, "What is the output of the following code? ```py def add_five(x): x += 5 return x print(add_five(2)) ```": 0.2933333333333333, "What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.2933333333333333, "What is the output of this code?\n```\nx = 10\ndef func():\n x = 20\n print(x)\nfunc()\nprint(x)\n```": 0.2777777777777778, "What is the output of the following python code?\n```python\ndef function(a):\n if a > 0:\n print('Positive')\n else:\n print('Negative')\n\nfunction(0)\n```": 0.2597402597402597}, "avg_similarity_score": 0.07988713556675425} -{"instruction": "Write a Python function to check if a given number is a Sphenic number or not. A Sphenic number is a composite number where the sum of its proper divisors is equal to the sum of its distinct prime factors. For example, 220 is a Sphenic number because its proper divisors are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110, and the sum of its distinct prime factors is 2 + 2 + 5 = 9.", "input": "", "output": "```python def is_sphenic(num):\n sum1 = sum([i for i in range(1, num) if num % i == 0])\n sum2 = sum(set([i for i in range(1, num) if num % i == 0]))\n return sum1 == sum2 ```", "most_similar": {"Write a Python function to check if a number is a Smith number or not. A Smith number is a composite number, whose sum of digits is equal to the sum of digits of its prime factors. For example, 42 is a Smith number, since its prime factors are 2 and 21, and 2 + 2 + 1 = 2 + 4 + 2 = 8.": 0.6277372262773723, "Write a Python function to check if a given number is a Harshad number or not. A Harshad number is a number that is divisible by the sum of its digits. For example, 42 is a Harshad number because it is divisible by 6 (the sum of its two digits 4 + 2).": 0.5581395348837209, "Write a Python function to check if a given number is a Sphenic number or not. A Sphenic number is a number whose prime factorization only contains 3, 5, and 7. For example, 105 is a Sphenic number because it is divisible by 3, 5, and 7.": 0.5161290322580645, "Write a Python function to check if a number is a strong number or not. A strong number is a number whose sum of factorial of digits is equal to the original number. For example, 145 is strong number since 1! + 4! + 5! = 1 + 24 + 120 = 145.": 0.5161290322580645, "Write a Python function to check if a given number is a Sphenic number or not. A Sphenic number is a number whose proper divisors (excluding the number itself) are all the same.": 0.509090909090909, "Write a Python function to check if a number is a Disarium number or not. A Disarium number is a number where the sum of its digits powered with their respective positions is equal to the number itself.": 0.5043478260869565, "Write a Python function to check if a number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its proper positive divisors.": 0.49090909090909085, "Write a Python function to check if a given number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. For example, 6 has divisors 1, 2 and 3 (excluding the number itself), and 6 = 1 + 2 + 3. Similarly, 28 has divisors 1, 2, 4, 7, 14 and 28, and 28 = 1 + 2 + 4 + 7 + 14.": 0.48000000000000004, "Write a Python function to check if a number is a Truncable number or not. A Truncable number is a number where the number generated by truncating the leftmost and rightmost digits of the number is a prime number. For example, 137 is a Truncable number, since 137, 37 and 7 are all prime numbers.": 0.46969696969696967, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.46017699115044247}, "avg_similarity_score": 0.14999977251649643} -{"instruction": "Write a Python function to check if a given number is a Neon number or not. A Neon number is a number where the sum of digits of square of the number is equal to the number itself. For example, 9 is a Neon number because 92 = 81 and 8 + 1 = 9.", "input": "", "output": "```python def is_neon(num):\n return num == sum([int(i) for i in str(num ** 2)]) ```", "most_similar": {"Write a Python function to check if a number is a Disarium number or not. A Disarium number is a number where the sum of its digits powered with their respective positions is equal to the number itself.": 0.6666666666666666, "Write a Python function to check if a number is a strong number or not. A strong number is a number whose sum of factorial of digits is equal to the original number. For example, 145 is strong number since 1! + 4! + 5! = 1 + 24 + 120 = 145.": 0.6464646464646464, "Write a Python function to check if a number is a Truncable number or not. A Truncable number is a number where the number generated by truncating the leftmost and rightmost digits of the number is a prime number. For example, 137 is a Truncable number, since 137, 37 and 7 are all prime numbers.": 0.616822429906542, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.6136363636363638, "Write a Python function to check if a number is a Smith number or not. A Smith number is a composite number, whose sum of digits is equal to the sum of digits of its prime factors. For example, 42 is a Smith number, since its prime factors are 2 and 21, and 2 + 2 + 1 = 2 + 4 + 2 = 8.": 0.5892857142857143, "Write a Python function to check if a given number is a Truncable number or not. A Truncable number is a number where the number generated by truncating it from left or right is also a number.": 0.5842696629213484, "Write a Python function to check if a given number is a Harshad number or not. A Harshad number is a number that is divisible by the sum of its digits. For example, 42 is a Harshad number because it is divisible by 6 (the sum of its two digits 4 + 2).": 0.5769230769230769, "Write a Python function to check if a given number is a Automorphic number or not. An Automorphic number is a number whose square \"ends\" in the same digits as the number itself.": 0.5647058823529413, "Write a Python function to check if a given number is a Fermat number or not. A Fermat number is a number of the form 22n + 1, where n is a non-negative integer.": 0.558139534883721, "Write a Python function to check if a given number is a Sphenic number or not. A Sphenic number is a composite number where the sum of its proper divisors is equal to the sum of its distinct prime factors. For example, 220 is a Sphenic number because its proper divisors are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110, and the sum of its distinct prime factors is 2 + 2 + 5 = 9.": 0.5581395348837209}, "avg_similarity_score": 0.18699468237161962} -{"instruction": "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number whose square when divided into two parts and then added gives the original number. For example, 297 is a Kaprekar number because 2972 = 592 + 247 and 592 + 247 = 297.", "input": "", "output": "```python def is_kaprekar(num):\n square = num ** 2\n num_str = str(square)\n l = len(num_str)\n sum1 = int(num_str[:l // 2])\n sum2 = int(num_str[l // 2:])\n return sum1 + sum2 == num ```", "most_similar": {"Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number whose square when divided into two parts, one part being the original number and the other part being the remaining part, add up to the original number.": 0.66, "Write a Python function to check if a given number is a Kaprekar number or not. In mathematics, a Kaprekar number for a given base is a non-negative integer, the representation of whose square in that base can be split into two parts that add up to the original number again. For example, 45 is a Kaprekar number, because 45\u00b2 = 2025 and 20+25 = 45.": 0.6324786324786323, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.5977011494252873, "Write a Python function to check if a given number is a Sphenic number or not. A Sphenic number is a number whose prime factorization only contains 3, 5, and 7. For example, 105 is a Sphenic number because it is divisible by 3, 5, and 7.": 0.5918367346938775, "Write a Python function to check if a given number is a Neon number or not. A Neon number is a number where the sum of digits of square of the number is equal to the number itself. For example, 9 is a Neon number because 92 = 81 and 8 + 1 = 9.": 0.5825242718446602, "Write a Python function to check if a given number is a Truncable number or not. A Truncable number is a number where the number generated by truncating it from left or right is also a number.": 0.5681818181818181, "Write a Python function to check if a number is a strong number or not. A strong number is a number whose sum of factorial of digits is equal to the original number. For example, 145 is strong number since 1! + 4! + 5! = 1 + 24 + 120 = 145.": 0.5510204081632654, "Write a Python function to check if a given number is a Sphenic number or not. A Sphenic number is a number whose proper divisors (excluding the number itself) are all the same.": 0.5476190476190477, "Write a Python function to check if a given number is a Automorphic number or not. An Automorphic number is a number whose square \"ends\" in the same digits as the number itself.": 0.5476190476190477, "Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.54320987654321}, "avg_similarity_score": 0.16736441001694033} -{"instruction": "How can I convert a list of strings to a list of integers?", "input": "", "output": "You can use the **map** function to convert a list of strings to a list of integers. For example: ``` l = ['1', '2', '3'] l = list(map(int, l)) ``` In this example, l is the list of strings. The map function is used to convert each string in the list to an integer. The result is stored in the l variable.", "most_similar": {"How can I sort a list of integers in Rust?": 0.608695652173913, "Write a Python function to reverse a given list of integers.": 0.4999999999999999, "How do I convert a string to a number in Python?": 0.4999999999999999, "How do I make a list of all the prime numbers up to a certain number?": 0.4827586206896552, "Write a script to output the mean of a list of integers.": 0.48000000000000004, "How do I get the first element of a list?": 0.4347826086956522, "How do you sort a list of strings in Python?": 0.4347826086956522, "How can I make a program that will find the largest number in a list?": 0.42857142857142855, "I have a list of numbers and I want to find the average of all the numbers.": 0.4000000000000001, "Write a Python function to find the maximum sum of a contiguous subsequence from a list of integers.": 0.3870967741935484}, "avg_similarity_score": 0.17732045998059978} -{"instruction": "What is the difference between `git pull` and `git fetch` ?", "input": "", "output": "`git pull` is a combination of `git fetch` and `git merge`. `git fetch` downloads the latest changes from the remote repository, but does not merge them into the local repository. `git pull` downloads the latest changes from the remote repository and merges them into the local repository.", "most_similar": {"What is the difference between a class and an object?": 0.6, "What is the difference between a relative and absolute path?": 0.6, "What is the difference between an ingress and a persistent volume?": 0.5714285714285713, "What is the difference between a static and a dynamic method?": 0.5714285714285713, "What is the difference between a list and a tuple in Python?": 0.5454545454545454, "What is the difference between a pod and a horizontal pod autoscaler?": 0.5454545454545454, "What is the difference between a deep copy and a shallow copy?": 0.5454545454545454, "What is the difference between a for loop and a while loop?": 0.5454545454545454, "What is the difference between a replica set and a stateful set?": 0.5454545454545454, "What is the difference between a variable that is:\n1. Immutable\n2. Mutable": 0.4347826086956522}, "avg_similarity_score": 0.0962200768060611} -{"instruction": "I am trying to write a function that takes a list of numbers and returns the sum of the numbers. I wrote the following code in Python:\n```py def sum(lst):\n total = 0\n for i in lst:\n total += i\n return total\n```", "input": "", "output": "Your code is correct, but you should not use the name `sum` for your function, as it conflicts with the built-in `sum` function in Python. To fix this, you can rename your function to `sum_list` or `sum_numbers` to avoid the conflict.", "most_similar": {"Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.5483870967741935, "Write a function that takes a list of numbers and returns a list of the same numbers, but with the first and last elements swapped.": 0.4545454545454546, "Write a Python function that takes a list of numbers as input and returns the sum of all the numbers in the list that are greater than 5 and less than 10, and are even, and are not divisible by 3.": 0.4146341463414634, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.3939393939393939, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.39344262295081966, "Write a function that takes a string and returns the number of vowels in the string.": 0.38596491228070173, "Write a function that takes an array of numbers and returns the largest number in the array.": 0.3793103448275862, "Write a Python function that takes a number as input and returns the sum of all the numbers from 1 to that number that are divisible by 3 and 5.": 0.36619718309859156, "Write a Python function that takes a list and returns a new list with unique elements of the first list.": 0.36065573770491804, "How do I make a function that takes a string and returns a list of the words in the string?": 0.36065573770491804}, "avg_similarity_score": 0.17020749611500782} -{"instruction": "Write a Python function to check if a given number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence. The Fibonacci sequence is defined by the recurrence relation: F(n) = F(n-1) + F(n-2) with seed values F(0) = 0 and F(1) = 1.", "input": "", "output": "def is_fibonacci(num):\n a, b = 0, 1\n while a <= num:\n if a == num:\n return True\n a, b = b, a + b\n return False", "most_similar": {"Write a Python function to check if a number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence.": 0.641025641025641, "Write a Python function to check if a given number is a Catalan number or not. A Catalan number is a number that occurs in the sequence of Catalan numbers. The sequence of Catalan numbers is generated by the following formula: Cn = (2n)! / (n+1)!n!": 0.6262626262626263, "Write a Python function to check if a given number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence. The Fibonacci sequence is a sequence of numbers where each number is the sum of the two preceding numbers. The first two numbers in the sequence are 0 and 1.": 0.6238532110091742, "Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.5783132530120482, "Write a Python function to check if a number is a Truncatable number or not. A Truncatable number is a number where the number formed by the first n digits is divisible by n for every n.": 0.5555555555555556, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.5393258426966292, "Write a Python function to check if a given number is a pandigital number or not. A pandigital number is a number that contains all the digits from 1 to n exactly once.": 0.5348837209302327, "Write a Python function to check if a given number is a Fermat number or not. A Fermat number is a number of the form 22n + 1, where n is a non-negative integer.": 0.5287356321839081, "Write a Python function to check if a given number is a Sphenic number or not. A Sphenic number is a number whose proper divisors (excluding the number itself) are all the same.": 0.5116279069767442, "Write a Python function to check if a given number is a Automorphic number or not. An Automorphic number is a number whose square \"ends\" in the same digits as the number itself.": 0.5116279069767442}, "avg_similarity_score": 0.16732581615929248} -{"instruction": "How do I check if a string contains a substring?", "input": "", "output": "You can use the in keyword to check if a string contains a substring. Here's an example: ``` string = \"Hello, World!\" print(\"Hello\" in string) ``` This will print the following output: ``` True ```", "most_similar": {"How do I convert a string to a number in Python?": 0.5714285714285713, "How do I output a string in C++ programming?": 0.5263157894736842, "How do I make a dropdown menu?": 0.47058823529411764, "How do I print a list in Python?": 0.4444444444444445, "How do I compile a go program on Linux to a windows executable?": 0.4347826086956522, "How do I create a new branch in git?": 0.4210526315789474, "How do I create a text field in HTML?": 0.4210526315789474, "How do I push a tag to remote in git?": 0.4000000000000001, "How do I make a variable that is only declared?": 0.4000000000000001, "How do I find the fibonacci number of a number?": 0.4000000000000001}, "avg_similarity_score": 0.14534738182387633} -{"instruction": "How do I find the index of the last occurrence of a substring in a string, starting at a particular index?", "input": "", "output": "You can use the rfind() method to find the index of the last occurrence of a substring in a string, starting at a particular index. Here's an example: ``` string = \"Hello, World!\" print(string.rfind(\"o\", 0, 5)) ``` This will print the following output: ``` 4 ```", "most_similar": {"How do I find the first and last occurrence of a substring in a string in C++?": 0.6842105263157895, "How do I find the index of the first occurrence of a value in an array?": 0.6486486486486486, "Write a Python function to find the index of the first occurrence of a specified item in a list.": 0.5, "How do you find the index of an item in a list?": 0.4848484848484849, "How do you find the number of occurrences of a given value in a list in Python?": 0.4736842105263158, "How do I find the p-variance of all elements in a list?": 0.47058823529411764, "How do I find the sum of the first 1000 prime numbers in C++?": 0.4571428571428571, "How do I find the fibonacci number of a number?": 0.45161290322580644, "How can I find the first repeated word in a string?": 0.43749999999999994, "How do I get the power of a number in python?": 0.43749999999999994}, "avg_similarity_score": 0.17858286483873542} -{"instruction": "How do I replace all occurrences of a substring in a string with another string?", "input": "", "output": "You can use the replace() method to replace all occurrences of a substring in a string with another string. Here's an example: ``` string = \"Hello, World!\" print(string.replace(\"World\", \"there\")) ``` This will print the following output: ``` Hello, there! ```", "most_similar": {"How do I find the first and last occurrence of a substring in a string in C++?": 0.5625, "How do I find the index of the last occurrence of a substring in a string, starting at a particular index?": 0.5, "How do I get the power of a number in python?": 0.4615384615384615, "How do you output all the contents of a list in Python?": 0.4444444444444445, "How do you find the number of occurrences of a given value in a list in Python?": 0.43749999999999994, "How do I print a list in Python?": 0.43478260869565216, "How do I find the p-variance of all elements in a list?": 0.42857142857142855, "How do I create a text field in HTML?": 0.4166666666666667, "How do I output a string in C++ programming?": 0.4166666666666667, "How do I create a new branch in git?": 0.4166666666666667}, "avg_similarity_score": 0.15109556851893638} -{"instruction": "Write a Python function that returns the sum of all numbers in a list that are divisible by 3.", "input": "", "output": "def sum_divisible_by_three(lst):\n return sum(x for x in lst if x % 3 == 0)", "most_similar": {"Write a Python function to find the sum of all items in a list.": 0.6666666666666667, "Write a python function that returns the sum of the elements of a list.": 0.6666666666666667, "Write a Python function that takes a number as input and returns the sum of all the numbers from 1 to that number that are divisible by 3 and 5.": 0.653061224489796, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.6500000000000001, "Write a Python function that returns the largest item in a list.": 0.6451612903225806, "Write a function that returns the sum of two numbers.": 0.6206896551724138, "Write a Python function that returns a list of numbers in a specified range.": 0.6060606060606061, "Write a python function that returns the number of words in a given string.": 0.6060606060606061, "Write a Python function that takes a list of numbers as input and returns the sum of all the numbers in the list that are greater than 5 and less than 10, and are even, and are not divisible by 3.": 0.6, "Write a Python function to find the number of items in a list that are not equal to a given value.": 0.5500000000000002}, "avg_similarity_score": 0.23856234739234108} -{"instruction": "Write a Python function that takes a number as a parameter and returns \"Fizz\" for multiples of 3, \"Buzz\" for multiples of 5 and \"FizzBuzz\" for multiples of 3 and 5.", "input": "", "output": "def fizz_buzz(num):\n if num % 3 == 0 and num % 5 == 0:\n return \"FizzBuzz\"\n elif num % 3 == 0:\n return \"Fizz\"\n elif num % 5 == 0:\n return \"Buzz\"\n else:\n return num", "most_similar": {"Write a Python function that takes a number as input and returns the square of that number.": 0.5, "Write a Python function that takes a number as input and returns the sum of all the numbers from 1 to that number that are divisible by 3 and 5.": 0.4918032786885246, "Write a Python function that takes a number as input and returns its square, cube, square root, cube root, and the sum of its digits.": 0.46428571428571425, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.46428571428571425, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.43137254901960786, "Write a Python function that takes a string as input and returns the string in reverse order.\n'Hello'": 0.40816326530612246, "Write a Python function that takes two numbers as input and returns their sum.": 0.4, "Write a Python function that takes a list and returns a new list with unique elements of the first list.": 0.39215686274509803, "Write a Python function that takes a list of numbers as input and returns the sum of all the numbers in the list that are greater than 5 and less than 10, and are even, and are not divisible by 3.": 0.3888888888888889, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.3846153846153846}, "avg_similarity_score": 0.15578911197122713} -{"instruction": "Write a python code snippet to print the following text.\nHello World!", "input": "", "output": "print('Hello World!')", "most_similar": {"Write a python code to find the area of a circle.": 0.5217391304347826, "Write a python code to find the minimum value in a list.": 0.5, "Write a python code to implement quick sort": 0.5, "Write a JavaScript code snippet to show an alert message with the text \"Welcome to my website!\".": 0.4827586206896552, "Write a script to output 'Hello World' in python": 0.4761904761904762, "Write a python script that prints the following pattern:\n```\n*\n**\n***\n****\n*****\n```": 0.4761904761904762, "Write a Python program to find the most common words in a given text.": 0.4615384615384615, "Generate a correct python program to fulfill the following purpose:": 0.45454545454545453, "Write a Python function to find the correlation between two lists.": 0.43478260869565216, "Write a Python function to calculate the factorial of a number.": 0.43478260869565216}, "avg_similarity_score": 0.19306597283371418} -{"instruction": "Given an array of integers, find the pair of adjacent elements that has the largest product and return that product.", "input": "", "output": "```python def adjacentElementsProduct(inputArray):\n max_product = inputArray[0] * inputArray[1]\n for i in range(1, len(inputArray) - 1):\n product = inputArray[i] * inputArray[i + 1]\n if product > max_product:\n max_product = product\n return max_product ```", "most_similar": {"Given an integer array nums, find the subarray with the largest sum, and return its sum.": 0.5, "Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product.": 0.4285714285714286, "Given an array of integers, return indices of the two numbers such that they add up to a specific target.": 0.4000000000000001, "Given a list of numbers, find the sum of the numbers.": 0.3870967741935483, "Given an array of integers nums, write a method that returns the \"pivot\" index of this array.": 0.37837837837837834, "You are given a list of numbers. You need to find the median of the list.": 0.33333333333333326, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.3243243243243243, "Given an array of integers, find the first missing positive integer in linear time and constant space. In other words, find the lowest positive integer that does not exist in the array. The array can contain duplicates and negative numbers as well.": 0.3225806451612903, "Given a string `s`, find the length of the longest substring without repeating characters.": 0.2941176470588235, "You are given a list of numbers. You need to find the number of pairs of indices (i, j) such that the difference between nums[i] and nums[j] is at most t and i < j.": 0.2857142857142857}, "avg_similarity_score": 0.12495819047684628} -{"instruction": "I am trying to use the following code to create a list of numbers from 1 to 100. But it is not working. Can you help me fix it? ```python numbers = [] for i in range(1, 100): numbers.append(i) ```", "input": "", "output": "You can use the following code to create a list of numbers from 1 to 100: ```python numbers = [] for i in range(1, 101): numbers.append(i) ``` The `range()` function takes two arguments, the start and end of the range. In your code, you have specified the start as 1 and the end as 100, which means that the range will be from 1 to 99. To include 100 in the range, you need to specify the end as 101.", "most_similar": {"I am trying to write a function that takes a list of numbers and returns the sum of the numbers. I wrote the following code in Python:\n```py def sum(lst):\n total = 0\n for i in lst:\n total += i\n return total\n```": 0.3209876543209877, "I'm trying to use the following code to create a new column in a dataframe:\n```python\ndf['new_col'] = df['col_1'].apply(lambda x: x.split(' ')[0])\n```\nBut I'm getting the following error:\n```python\nAttributeError: 'float' object has no attribute 'split'\n```": 0.30952380952380953, "I am trying to run the following code in Python: ```python def f(x): return x + 1 print(f(1)) ``` I get an error. What is the problem?": 0.2941176470588235, "I have the following code: ```python def get_max_value(list): max_value = list[0] for i in range(1, len(list)): if list[i] > max_value: max_value = list[i] return max_value ``` What does the function do?": 0.27848101265822783, "I am trying to use the following code in python:\n```py\ndef function(a, b):\n if a > b:\n print('You lost.')\n else:\n if c > a:\n print('Nice try.')\n else:\n print('You won.')\n```\nBut I am getting an error. What is wrong with the code?": 0.2619047619047619, "I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.25806451612903225, "Translate the following code from python in Java.": 0.24999999999999997, "I have a list of numbers and I want to find the average of all the numbers.": 0.2456140350877193, "I want to find the average of all the numbers in a list.": 0.22641509433962265, "Write a Python function that returns a list of numbers in a specified range.": 0.2222222222222222}, "avg_similarity_score": 0.12554708399562797} -{"instruction": "Write a Python function to check if a given number is a Keith number or not. A Keith number is a number which is one less than a perfect square.", "input": "", "output": "```python def is_keith_number(num):\n return (math.sqrt(num + 1)).is_integer() ```", "most_similar": {"Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.7, "Write a Python function to check if a number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence.": 0.6909090909090909, "Write a Python function to check if a given number is a Fermat number or not. A Fermat number is a number of the form 22n + 1, where n is a non-negative integer.": 0.6875, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.6666666666666666, "Write a Python function to check if a given number is a Truncable number or not. A Truncable number is a number where the number generated by truncating it from left or right is also a number.": 0.6567164179104478, "Write a Python function to check if a given number is a prime number or not.": 0.6521739130434783, "Write a Python function to check if a number is a Sphenic number or not. A Sphenic number is a number that can be decomposed into a product of two prime numbers.": 0.6451612903225806, "Write a Python function to check if a given number is a Heptagonal number or not. A Heptagonal number is a number that can be expressed as n(5n-3)/2 where n is an integer.": 0.6363636363636365, "Write a Python function to check if a given number is a Sphenic number or not. A Sphenic number is a number whose proper divisors (excluding the number itself) are all the same.": 0.6349206349206349, "Write a Python function to check if a given number is a Automorphic number or not. An Automorphic number is a number whose square \"ends\" in the same digits as the number itself.": 0.6349206349206349}, "avg_similarity_score": 0.19377837013822374} -{"instruction": "How do you remove an item at a given index from a list using Python?", "input": "", "output": "There are several ways to remove an item at a given index from a list using Python. One of the most common ways is using the pop() function: ``` list = [1, 2, 3, 4, 5] list.pop(2) print(list) ``` Another way is to use a for loop: ``` list = [1, 2, 3, 4, 5] del list[2] print(list) ``` Finally, you can also use the list.sort() method: ``` list = [1, 2, 3, 4, 5] list.sort() print(list[-1]) ```", "most_similar": {"How do you remove duplicates from a list in Python?": 0.64, "How do you find the largest number in a list using Python?": 0.5185185185185186, "How do you find the index of an item in a list?": 0.5185185185185186, "How do you find the number of occurrences of a given value in a list in Python?": 0.5, "How do you sort a list of strings in Python?": 0.48, "How do you output all the contents of a list in Python?": 0.4444444444444445, "How do I print a list in Python?": 0.43478260869565216, "How do you create a variable in Python?": 0.43478260869565216, "How do you find the standard deviation of all items in a list in Python?": 0.4000000000000001, "How do you add a link to a web page?": 0.4}, "avg_similarity_score": 0.1415686421098659} -{"instruction": "Given a string s, return the number of palindromic substrings in it. A string is a palindrome when it reads the same backward as forward. A substring is a contiguous sequence of characters within the string.", "input": "", "output": "class Solution:\n def countSubstrings(self, s: str) -> int:\n def expand(left, right):\n while left >= 0 and right < len(s) and s[left] == s[right]:\n left -= 1\n right += 1\n return right - left - 1\n count = 0\n for i in range(len(s)):\n count += expand(i, i) + expand(i, i + 1)\n return count", "most_similar": {"Given a string s, return the number of palindromic substrings in it.": 0.5, "Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. A palindrome string is a string that reads the same backward as forward.": 0.4444444444444444, "Given a string, return the number of vowels used in the text.": 0.375, "Given a string `s`, find the length of the longest substring without repeating characters.": 0.36, "Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s.": 0.3492063492063492, "Given a string s, return the longest palindromic substring in s.": 0.3404255319148936, "Write a function that returns the number of times a given string occurs in a given text as its substring.": 0.32142857142857145, "Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.": 0.31034482758620685, "Write a function that takes a string and returns the number of vowels in the string.": 0.30769230769230765, "Write a Python function to check if a given string is a pangram or not. A pangram is a sentence containing every letter of the English alphabet at least once.": 0.303030303030303}, "avg_similarity_score": 0.15354288503505648} -{"instruction": "I have this function: ```python def match_rows(x, y, data, index): index_match = [] for i in range(len(data)): if data[i][x] == data[i][y]: index_match.append(i) return index[index_match] ``` What does the function do?", "input": "", "output": "Hmm, let me see. I think the function is used to find the rows in a 2D array, where the values in columns `x` and `y` are identical. It takes in two integers `x` and `y` and the 2D array `data` as inputs and returns a list of indices of rows in `data` where the values in columns `x` and `y` are identical. Here is an in-depth look: ```python # It takes in two integers `x` and `y` and the 2D array `data` as inputs and returns a list of indices of rows in `data` where the values in columns `x` and `y` are identical. def match_rows(x, y, data, index): # It creates an empty list index_match. index_match = [] # It iterates over the length of `data` and for each row, if the value at column `x` is equal to the value at column `y` of the same row, it appends the index of that row to the list index_match. for i in range(len(data)): if data[i][x] == data[i][y]: index_match.append(i) # It returns the list of indices `index_match` of rows in `data` where the values in columns `x` and `y` are identical. return index[index_match] ```", "most_similar": {"I have the following code: ```python def get_max_value(list): max_value = list[0] for i in range(1, len(list)): if list[i] > max_value: max_value = list[i] return max_value ``` What does the function do?": 0.45569620253164556, "I have the following python function: ```python def resize_images(images, res_x, res_y): resized_images = np.zeros((images.shape[0], res_x, res_y)) for n in range(len(images)): resized_images[n, :, :] = resize(images[n, :, :], resized_images.shape[1:], anti_aliasing=False) return resized_images ``` What does the function do?": 0.3655913978494624, "What does this Python code do? ``` import random def montecarloPi(calcs): hits = 0 for i in range(calcs): x = random.random() y = random.random() if (x**2 + y**2) < 1: hits = hits + 1 return 4.0 * hits / calcs print(montecarloPi(10000)) ```": 0.271604938271605, "I am trying to run the following code in Python: ```python def f(x): return x + 1 print(f(1)) ``` I get an error. What is the problem?": 0.23529411764705882, "I am trying to write a function that takes a list of numbers and returns the sum of the numbers. I wrote the following code in Python:\n```py def sum(lst):\n total = 0\n for i in lst:\n total += i\n return total\n```": 0.22222222222222224, "I am trying to use the following code to create a list of numbers from 1 to 100. But it is not working. Can you help me fix it? ```python numbers = [] for i in range(1, 100): numbers.append(i) ```": 0.20000000000000004, "I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.19354838709677416, "def _process(self, data): X = data[1] + \" \" + data[2] Y = pd.get_dummies(data[0], prefix=\"y\").astype(np.float32) return X, Y, len(data) I have a bug `Failed to convert a NumPy array to a Tensor (Unsupported object type float).`. Can you show me where is the problem and how to fix it?": 0.1894736842105263, "What is the output of this code?\n```python\ndef f(x):\n x = 2 * x + 1\n return x\n\nx = 3\nz = f(x)\nprint(z)\n```": 0.18749999999999997, "What is the output of the following code?\n```python\ndef func(x):\n return x + 1\n\ndef main():\n x = 1\n y = func(x)\n print(y)\n\nmain()\n```": 0.1846153846153846}, "avg_similarity_score": 0.07349130728810158} -{"instruction": "I have this python code: ```python def make_dict(df): d = dict(zip(df.columns, df.values[0])) return d ``` What does the function do?", "input": "", "output": "Hmm, let me see. I think the function is used to convert a pandas DataFrame to a dictionary. It takes in a DataFrame `df` as an input and returns the dictionary. Here is an in-depth look: ```python # It takes in a pandas DataFrame `df` as an input and returns the dictionary. def make_dict(df): # It creates a dictionary d using the zip function with keys from the column names of df and values from the first row of values in df. d = dict(zip(df.columns, df.values[0])) # It returns the dictionary. return d ```", "most_similar": {"I have the following code: ```python def get_max_value(list): max_value = list[0] for i in range(1, len(list)): if list[i] > max_value: max_value = list[i] return max_value ``` What does the function do?": 0.37500000000000006, "I have this function: ```python def match_rows(x, y, data, index): index_match = [] for i in range(len(data)): if data[i][x] == data[i][y]: index_match.append(i) return index[index_match] ``` What does the function do?": 0.3384615384615385, "I have the following python function: ```python def resize_images(images, res_x, res_y): resized_images = np.zeros((images.shape[0], res_x, res_y)) for n in range(len(images)): resized_images[n, :, :] = resize(images[n, :, :], resized_images.shape[1:], anti_aliasing=False) return resized_images ``` What does the function do?": 0.3076923076923077, "I am trying to run the following code in Python: ```python def f(x): return x + 1 print(f(1)) ``` I get an error. What is the problem?": 0.2641509433962264, "What is the output of the following python code?\n```python\ndef function(a):\n if a > 0:\n print('Positive')\n else:\n print('Negative')\n\nfunction(0)\n```": 0.24999999999999994, "What is the output of this code?\n```python\ndef f(x):\n x = 2 * x + 1\n return x\n\nx = 3\nz = f(x)\nprint(z)\n```": 0.20408163265306126, "I'm trying to use the following code to create a new column in a dataframe:\n```python\ndf['new_col'] = df['col_1'].apply(lambda x: x.split(' ')[0])\n```\nBut I'm getting the following error:\n```python\nAttributeError: 'float' object has no attribute 'split'\n```": 0.2028985507246377, "I am trying to write a function that takes a list of numbers and returns the sum of the numbers. I wrote the following code in Python:\n```py def sum(lst):\n total = 0\n for i in lst:\n total += i\n return total\n```": 0.1818181818181818, "What does this Python code do? ``` import random def montecarloPi(calcs): hits = 0 for i in range(calcs): x = random.random() y = random.random() if (x**2 + y**2) < 1: hits = hits + 1 return 4.0 * hits / calcs print(montecarloPi(10000)) ```": 0.1818181818181818, "I am trying to use the following code in python:\n```py\ndef function(a, b):\n if a > b:\n print('You lost.')\n else:\n if c > a:\n print('Nice try.')\n else:\n print('You won.')\n```\nBut I am getting an error. What is wrong with the code?": 0.17391304347826086}, "avg_similarity_score": 0.08323474166800147} -{"instruction": "Write me a python function that takes two arrays as input, and return the element-wise sum of the two arrays as a new array.", "input": "", "output": "def element_wise_sum(x, y):\n\treturn [sum(p) for p in zip(x, y)]", "most_similar": {"Write a Python function that takes two numbers as input and returns their sum.": 0.5641025641025641, "Write a function that takes a string as input and reverse only the vowels of a string.": 0.5238095238095238, "Write a Python function that takes a number as input and returns the square of that number.": 0.5238095238095238, "Write a python function that returns the sum of the elements of a list.": 0.5128205128205129, "Write a Python function that takes a number as input and returns its square, cube, square root, cube root, and the sum of its digits.": 0.48, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.48, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.4782608695652174, "Write a Python function that takes a number as input and returns the sum of all the numbers from 1 to that number that are divisible by 3 and 5.": 0.4727272727272728, "Write a Python function that takes a string as input and returns the string in reverse order.\n'Hello'": 0.46511627906976744, "Write a function that returns the sum of two numbers.": 0.45714285714285713}, "avg_similarity_score": 0.1967618099592941} -{"instruction": "I have this function: ```python def second_largest_even(nums): # If the length of the list is less than 2, then return -1. if len(nums) < 2: return -1 # Return the second largest even element. second_largest = -1 for num in nums: if num % 2 == 0: if second_largest < num: second_largest = num if second_largest >= num: return second_largest return second_largest ``` What does the function do?", "input": "", "output": "Hmm, let me see. I think the function is used to find the second largest even number in a list. It takes in a list of integers `nums` as an input and returns the second largest even number in the list, or -1 if the list contains less than two even numbers. Here is an in-depth look: ```python # It takes in a list of integers `nums` as an input and returns the second largest even number in the list, or -1 if the list contains less than two even numbers. def second_largest_even(nums): # If the length of the list is less than 2, then return -1. if len(nums) < 2: return -1 # It creates a variable second_largest and sets it to -1 for num in nums: # If the number is even, then check if the variable second_largest is less than the number. if num % 2 == 0: if second_largest < num: # If it is less, then set the variable second_largest to the number. second_largest = num # If the variable second_largest is greater than or equal to the number, then the variable second_largest remains as it is. if second_largest >= num: pass # Finally, return the variable second_largest. return second_largest ```", "most_similar": {"I have this function: ```python def match_rows(x, y, data, index): index_match = [] for i in range(len(data)): if data[i][x] == data[i][y]: index_match.append(i) return index[index_match] ``` What does the function do?": 0.2777777777777778, "I have the following code: ```python def get_max_value(list): max_value = list[0] for i in range(1, len(list)): if list[i] > max_value: max_value = list[i] return max_value ``` What does the function do?": 0.26168224299065423, "I have this python code: ```python def make_dict(df): d = dict(zip(df.columns, df.values[0])) return d ``` What does the function do?": 0.25806451612903225, "I have the following python function: ```python def resize_images(images, res_x, res_y): resized_images = np.zeros((images.shape[0], res_x, res_y)) for n in range(len(images)): resized_images[n, :, :] = resize(images[n, :, :], resized_images.shape[1:], anti_aliasing=False) return resized_images ``` What does the function do?": 0.21487603305785125, "Write a Python program to get a string made of the first 2 and the last 2 chars from a given a string. If the string length is less than 2, return instead of the empty string.": 0.19047619047619047, "What is the output of the following code?\n```python\ndef f(x):\n return x * 2\n\ndef g(x):\n return f(x) + 1\n\ndef h(x):\n return g(x) * 2\n\nprint(h(2))\n```": 0.18000000000000002, "How to make a python program that will print the following pattern?\n```\n1\n1 2\n1 2 3\n1 2 3 4\n1 2 3 4 5\n```": 0.16842105263157892, "I am trying to run the following code in Python: ```python def f(x): return x + 1 print(f(1)) ``` I get an error. What is the problem?": 0.16666666666666666, "What does this Python code do? ``` import random def montecarloPi(calcs): hits = 0 for i in range(calcs): x = random.random() y = random.random() if (x**2 + y**2) < 1: hits = hits + 1 return 4.0 * hits / calcs print(montecarloPi(10000)) ```": 0.1651376146788991, "I am trying to write a function that takes a list of numbers and returns the sum of the numbers. I wrote the following code in Python:\n```py def sum(lst):\n total = 0\n for i in lst:\n total += i\n return total\n```": 0.1651376146788991}, "avg_similarity_score": 0.08430321033936841} -{"instruction": "What is the result of the following C program? ```c #include \nint main()\n{\n int a = 2;\n int b = 3;\n int c = 4;\n int d = 5;\n printf(\"%d\\n\", a++ + ++b + c++ + ++d);\n printf(\"%d %d %d %d\\n\", a, b, c, d);\n return 0;\n}\n ```", "input": "", "output": "The answer is: 14 3 5 5", "most_similar": {"What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.4477611940298507, "What is the output of the following code?\n```\na = 1\nb = 2\nc = 3\nif a > b:\n print(\"a is greater than b\")\nelif a > c:\n print(\"a is greater than c\")\nelse:\n print(\"a is not greater than b or c\")\n```": 0.34090909090909094, "What is the value of the following expression?\n10 + 2 * 3 / 4": 0.3103448275862069, "What is the output of the following code? ```py def add(a, b): return a + b print(add(1, 2)) print(add(b=2, a=1)) ```": 0.3055555555555556, "Translate the following code from python in Java.\ndef function(a : int, b : int, c : int):\n if a > b :\n print('You lost.')\n else :\n if c > a :\n print('Nice try.')\n else :\n print('You won.')": 0.3037974683544304, "What is the output of the following python code?\n```python\ndef function(a):\n if a > 0:\n print('Positive')\n else:\n print('Negative')\n\nfunction(0)\n```": 0.2608695652173913, "What is the output of the following code?\n```\na = 1\nb = 2\nc = 3\nd = 4\ne = 5\nf = 6\ng = 7\nh = 8\ni = 9\nj = 10\nk = 11\nl = 12\nm = 13\nn = 14\no = 15\np = 16\nq = 17\nr = 18\ns = 19\nt = 20\nu = 21\nv = 22\nw = 23\nx = 24\ny = 25\nz = 26\n\nprint(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z)\n```": 0.25563909774436094, "What is the output of the following code?\n```\npublic class Test {\n public static void main(String[] args) {\n int i = 1;\n while (i <= 5) {\n System.out.println(i);\n i++;\n }\n }\n}\n```": 0.24324324324324326, "What is the output of the following C# code?\n```\nint x = 1;\nint y = 2;\nint z = 3;\n\nif (x < y)\n{\n if (y < z)\n {\n Console.WriteLine(\"y is the median\");\n }\n else\n {\n Console.WriteLine(\"x is the median\");\n }\n}\nelse\n{\n if (x < z)\n {\n Console.WriteLine(\"x is the median\");\n }\n else\n {\n Console.WriteLine(\"z is the median\");\n }\n}\n```": 0.24, "What is the output of the following code? ```py def add_five(x): x += 5 return x print(add_five(2)) ```": 0.2388059701492537}, "avg_similarity_score": 0.0945911302231918} -{"instruction": "Write a python function that adds a new key to a dictionary and returns the value of the key.", "input": "", "output": "def add_new_key_to_dict(d, k, v):\n\td[k] = v\n\treturn d[k]", "most_similar": {"Write a function that takes a string and returns the number of vowels in the string.": 0.5714285714285714, "Write a Python function that takes a number as input and returns the square of that number.": 0.5555555555555555, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.5500000000000002, "Write a python function that returns the sum of the elements of a list.": 0.5454545454545454, "Write a Python function that takes a list and returns a new list with unique elements of the first list.": 0.5128205128205129, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.5, "Write a Python function that takes a string as input and returns the string in reverse order.\n'Hello'": 0.4864864864864865, "Write a python function that returns the number of words in a given string.": 0.48484848484848486, "Write a function that returns the sum of two numbers.": 0.48275862068965514, "Write a Python function that removes the first item from a list and returns it.": 0.47058823529411764}, "avg_similarity_score": 0.2282594970100778} -{"instruction": "Write me a python function that returns the sum of all even numbers in an array of integers.", "input": "", "output": "def sum_even_numbers(lst):\n\treturn sum(x for x in lst if x % 2 == 0)", "most_similar": {"Write a Python function that returns the sum of all numbers in a list that are divisible by 3.": 0.6486486486486486, "Write a function that returns the sum of two numbers.": 0.6428571428571429, "Write a python function that returns the sum of the elements of a list.": 0.6250000000000001, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.6153846153846153, "Write a Python function that returns a list of numbers in a specified range.": 0.5625000000000001, "Write a Python function to find the sum of all items in a list.": 0.5625000000000001, "Write a python function that returns the number of words in a given string.": 0.5625000000000001, "How to find the sum of all numbers in an array?": 0.5517241379310345, "Write a Python function that returns the largest item in a list.": 0.5333333333333333, "Write a Python function to find the maximum sum of a contiguous subsequence from a list of integers.": 0.5}, "avg_similarity_score": 0.222447057007779} -{"instruction": "What does the following python code do?\n```python def sum_divisible_by_three(lst):\n\treturn sum(x for x in lst if x % 3 == 0)\n ```", "input": "", "output": "It returns the sum of all numbers in a list that are divisible by 3.", "most_similar": {"What is the output of the following Python code? ```py def f(x): return x + 1 def g(x): return x * 2 print(g(f(3))) ```": 0.4313725490196078, "What is the output of the following code?\n```python\ndef func(x):\n return x + 1\n\ndef main():\n x = 1\n y = func(x)\n print(y)\n\nmain()\n```": 0.4000000000000001, "What is the output of the following code?\n```python\ndef foo():\n x = 1\n def bar():\n x = 2\n return x\n return bar()\nprint(foo())\n```": 0.37499999999999994, "What is the output of the following python code?\n```python\ndef function(a):\n if a > 0:\n print('Positive')\n else:\n print('Negative')\n\nfunction(0)\n```": 0.37499999999999994, "What is the output of this code?\n```python\ndef f(x):\n x = 2 * x + 1\n return x\n\nx = 3\nz = f(x)\nprint(z)\n```": 0.3673469387755102, "What is the output of the following code?\n```python\ndef f(x):\n return x * 2\n\ndef g(x):\n return f(x) + 1\n\ndef h(x):\n return g(x) * 2\n\nprint(h(2))\n```": 0.3508771929824561, "What is the output of the following code? ```py def add_five(x): x += 5 return x print(add_five(2)) ```": 0.34782608695652173, "What does this Python code do? ``` import random def montecarloPi(calcs): hits = 0 for i in range(calcs): x = random.random() y = random.random() if (x**2 + y**2) < 1: hits = hits + 1 return 4.0 * hits / calcs print(montecarloPi(10000)) ```": 0.33333333333333337, "What is the output of this code?\n```\nx = 10\ndef func():\n x = 20\n print(x)\nfunc()\nprint(x)\n```": 0.32558139534883723, "Translate the following code from python in Java.": 0.30303030303030304}, "avg_similarity_score": 0.1008671345226946} -{"instruction": "What does the following python code do?\n```python def is_prime(num):\n\t# Return false if the number is negative\n\tif num < 0:\n\t\treturn False\n\n\t# Check if the number is prime\n\tif not is_harshad_number(num):\n\t\treturn False\n\n\t# Check if the number is truncable\n\twhile num > 0:\n\t\tr = num % 10\n\t\tnum = num // 10\n\t\tif not is_harshad_number(num):\n\t\t\treturn False\n\treturn True\n ```", "input": "", "output": "It checks if a number is a Truncable Harshad number or not. A Truncable Harshad number is a Harshad number which remains a Harshad number even after removing one or more digits from left or right side. For example, 1801 is a Truncable Harshad number, since 1801, 801, 01, 1 are all Harshad numbers.", "most_similar": {"I have this function: ```python def second_largest_even(nums): # If the length of the list is less than 2, then return -1. if len(nums) < 2: return -1 # Return the second largest even element. second_largest = -1 for num in nums: if num % 2 == 0: if second_largest < num: second_largest = num if second_largest >= num: return second_largest return second_largest ``` What does the function do?": 0.27480916030534347, "What does the following python code do?\n```python def sum_divisible_by_three(lst):\n\treturn sum(x for x in lst if x % 3 == 0)\n ```": 0.2727272727272727, "Write a Python function to check if a given number is a Truncable number or not. A Truncable number is a number where the number generated by truncating it from left or right is also a number.": 0.24, "What is the output of the following python code?\n```python\ndef function(a):\n if a > 0:\n print('Positive')\n else:\n print('Negative')\n\nfunction(0)\n```": 0.23255813953488372, "Write a Python function to check if a number is a Truncable Harshad number or not. A Truncable Harshad number is a Harshad number which remains a Harshad number even after removing one or more digits from left or right side. For example, 1801 is a Truncable Harshad number, since 1801, 801, 01, 1 are all Harshad numbers.": 0.23140495867768596, "Write a Python function to check if a given number is a Neon number or not. A Neon number is a number where the sum of digits of square of the number is equal to the number itself. For example, 9 is a Neon number because 92 = 81 and 8 + 1 = 9.": 0.22608695652173913, "Write a Python function to check if a given number is a Harshad number or not. A Harshad number is a number that is divisible by the sum of its digits. For example, 42 is a Harshad number because it is divisible by 6 (the sum of its two digits 4 + 2).": 0.22608695652173913, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.22222222222222224, "Write a Python function to check if a number is a Truncable number or not. A Truncable number is a number where the number generated by truncating the leftmost and rightmost digits of the number is a prime number. For example, 137 is a Truncable number, since 137, 37 and 7 are all prime numbers.": 0.22033898305084743, "Write a Python function to check if a number is a Truncatable number or not. A Truncatable number is a number where the number formed by the first n digits is divisible by n for every n.": 0.22}, "avg_similarity_score": 0.08803739705450707} -{"instruction": "Given a string s, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.", "input": "", "output": "class Solution:\n def isPalindrome(self, s: str) -> bool:\n l = [ch.lower() for ch in s if ch.isalnum()]\n return l == l[::-1]", "most_similar": {"Given a string s, return the number of palindromic substrings in it.": 0.3448275862068966, "Given a string s, return the number of palindromic substrings in it. A string is a palindrome when it reads the same backward as forward. A substring is a contiguous sequence of characters within the string.": 0.33962264150943394, "Given a string `s`, find the length of the longest substring without repeating characters.": 0.3225806451612903, "Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s.": 0.3181818181818182, "Given a string s, return the longest palindromic substring in s.": 0.2857142857142857, "Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. A palindrome string is a string that reads the same backward as forward.": 0.2641509433962264, "Write a Python function to check whether a passed string is palindrome or not.": 0.2580645161290323, "Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.": 0.25641025641025644, "Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.25531914893617025, "Write a Python function to check if a given number is a prime number or not.": 0.24242424242424243}, "avg_similarity_score": 0.10804536396532508} -{"instruction": "A zero-indexed array A consisting of N different integers is given. The array contains all integers in the range [0, N - 1].\n\nSeveral copies of the array A are created, and in every copy exactly one element is changed. The elements are changed in the following way:\n\nin the first copy, the element at index 0 is changed to 0;\nin the second copy, the element at index 1 is changed to 1;\nin the third copy, the element at index 2 is changed to 2;\n...\nin the N-1 copy, the element at index N - 1 is changed to N - 1.\nThe changes are applied in the same order as the described: first the element at index 0 is changed, then the element at index 1 is changed, and so on.\n\nReturn the number of the copy, in which the maximum number of changes is applied.", "input": "", "output": "def solution(A):\n count = 0\n for index, val in enumerate(A):\n if val == index:\n count += 1\n return count", "most_similar": {"Write a Python function to check if a given number is a Carmichael number or not. A Carmichael number is a composite number that satisfies the following conditions: The number must be composite i.e. greater than 1. The number must not be a prime number. If we take every number from 1 to n-1 (both included) and calculate the remainder when divided by the number, no number should have the same remainder when divided by the number, except 0 and the number itself.": 0.18884120171673824, "Write a Python function to check if a given number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence. The Fibonacci sequence is a sequence of numbers where each number is the sum of the two preceding numbers. The first two numbers in the sequence are 0 and 1.": 0.16666666666666669, "Write a Python function to check if a given number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence. The Fibonacci sequence is defined by the recurrence relation: F(n) = F(n-1) + F(n-2) with seed values F(0) = 0 and F(1) = 1.": 0.1592039800995025, "The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. That is,\n\nF(0) = 0, F(1) = 1\nF(n) = F(n - 1) + F(n - 2), for n > 1.\nGiven n, calculate F(n)": 0.15763546798029557, "Write a Python function to check if a given number is a happy number or not. A happy number is defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are unhappy numbers.": 0.15126050420168066, "Write a Python program that takes a list of numbers as input from the user, calculates the sum of all even numbers in the list, and returns the result. The program should check if the input is valid (i.e., if it's a list of numbers), and if it's not, it should return an error message. The program should also handle exceptions gracefully and return a user-friendly error message in case of any exceptions.": 0.1511111111111111, "What is the output of the following C# code?\n```\nint x = 1;\nint y = 2;\nint z = 3;\n\nif (x < y)\n{\n if (y < z)\n {\n Console.WriteLine(\"y is the median\");\n }\n else\n {\n Console.WriteLine(\"x is the median\");\n }\n}\nelse\n{\n if (x < z)\n {\n Console.WriteLine(\"x is the median\");\n }\n else\n {\n Console.WriteLine(\"z is the median\");\n }\n}\n```": 0.14851485148514854, "Write a Python function to check if a given number is a Fibonacci number or not. The Fibonacci sequence is a sequence of numbers where each number is the sum of the two preceding numbers. The first two numbers are 0 and 1. The next 20 Fibonacci numbers are: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181.": 0.14746543778801843, "Write a Python function to check if a given number is an Armstrong number or not. An Armstrong number is a number that is equal to the sum of its own digits each raised to the power of the number of digits.": 0.1473684210526316, "Write a Python function to check if a given number is a Sphenic number or not. A Sphenic number is a composite number where the sum of its proper divisors is equal to the sum of its distinct prime factors. For example, 220 is a Sphenic number because its proper divisors are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110, and the sum of its distinct prime factors is 2 + 2 + 5 = 9.": 0.14222222222222222}, "avg_similarity_score": 0.067812239742251} -{"instruction": "Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.", "input": "", "output": "class Solution:\n def fourSum(self, nums: List[int], target: int) -> List[List[int]]:\n results = []\n nums.sort()\n for i in range(len(nums) - 3):\n if i > 0 and nums[i] == nums[i - 1]:\n continue\n for j in range(i + 1, len(nums) - 2):\n if j > i + 1 and nums[j] == nums[j - 1]:\n continue\n left, right = j + 1, len(nums) - 1\n while left < right:\n s = nums[i] + nums[j] + nums[left] + nums[right]\n if s == target:\n results.append([nums[i], nums[j], nums[left], nums[right]])\n left, right = left + 1, right - 1\n while left < right and nums[left] == nums[left - 1]:\n left += 1\n while left < right and nums[right] == nums[right + 1]:\n right -= 1\n elif s > target:\n right -= 1\n else:\n left += 1\n return results", "most_similar": {"Given an array of integers, find the first missing positive integer in linear time and constant space. In other words, find the lowest positive integer that does not exist in the array. The array can contain duplicates and negative numbers as well.": 0.3132530120481927, "Given an array of integers nums, write a method that returns the \"pivot\" index of this array.": 0.3103448275862069, "Given an array of integers `nums` and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order.": 0.30434782608695654, "Given an array of integers, return indices of the two numbers such that they add up to a specific target.": 0.29508196721311475, "Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product.": 0.28571428571428575, "Given an integer array nums, find the subarray with the largest sum, and return its sum.": 0.28070175438596495, "Given an array of integers, find the pair of adjacent elements that has the largest product and return that product.": 0.26229508196721313, "Write a function that takes an array of numbers and returns the largest number in the array.": 0.24137931034482757, "Given a list of numbers, find the sum of the numbers.": 0.23076923076923073, "What is the result of the following C program? ```c #include \nint main()\n{\n int a = 2;\n int b = 3;\n int c = 4;\n int d = 5;\n printf(\"%d\\n\", a++ + ++b + c++ + ++d);\n printf(\"%d %d %d %d\\n\", a, b, c, d);\n return 0;\n}\n ```": 0.22988505747126436}, "avg_similarity_score": 0.11776123160066893} -{"instruction": "Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n).", "input": "", "output": "class Solution:\n def thirdMax(self, nums: List[int]) -> int:\n n = float('-inf')\n first = float('-inf')\n second = float('-inf')\n\n for num in nums:\n if num > n:\n n, second, first = num, n, second\n elif num == n:\n pass\n elif num > second:\n second, first = num, second\n elif num == second:\n pass\n elif num > first:\n first = num\n\n return first if n != float('-inf') else n", "most_similar": {"Given a string s, return the number of palindromic substrings in it.": 0.31818181818181823, "Given a string, return the number of vowels used in the text.": 0.31818181818181823, "Given an array of integers, find the first missing positive integer in linear time and constant space. In other words, find the lowest positive integer that does not exist in the array. The array can contain duplicates and negative numbers as well.": 0.2972972972972973, "Given an array of integers nums, write a method that returns the \"pivot\" index of this array.": 0.2857142857142857, "Write a function that takes an array of numbers and returns the largest number in the array.": 0.2857142857142857, "Given a string s, return the number of palindromic substrings in it. A string is a palindrome when it reads the same backward as forward. A substring is a contiguous sequence of characters within the string.": 0.2647058823529412, "I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.25925925925925924, "Write a Python program to find the difference between a specified number and 13, if the number is greater than 13 return double the absolute difference.": 0.2413793103448276, "Given an array of integers `nums` and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order.": 0.24096385542168675, "How to find the largest number in an array in Java?": 0.2325581395348837}, "avg_similarity_score": 0.1232113942372417} -{"instruction": "Given a string S, check if the letters can be rearranged so that two characters that are adjacent to each other are not the same.\n\nIf possible, output any possible result. If not possible, return the empty string.", "input": "", "output": "class Solution:\n def reorganizeString(self, S: str) -> str:\n count = collections.Counter(S)\n # the most number of each char\n most, _ = count.most_common()[0]\n if most > (len(S) + 1) // 2:\n return \"\"\n # first char of the result\n ans = [char for char, num in count.items() for _ in range(num)]\n ans.sort(key=lambda x: (-count[x], x))\n i = 1\n for j in range(0, len(ans) - 1, 2):\n # the most number of each char must be even\n if i >= len(ans) or ans[i] == ans[j]:\n return \"\"\n ans[j + 1], ans[i] = ans[i], ans[j + 1]\n i += 2\n return \"\".join(ans)", "most_similar": {"Given an array of integers `nums` and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order.": 0.24719101123595505, "Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s.": 0.24615384615384617, "Given a string s, return the longest palindromic substring in s.": 0.24489795918367344, "Write a Python program to find the first appearance of the substring 'not' and 'poor' from a given string, if 'not' follows the 'poor', replace the whole 'not'...'poor' substring with 'good'. Return the resulting string.": 0.24324324324324326, "Given a string s, return the number of palindromic substrings in it. A string is a palindrome when it reads the same backward as forward. A substring is a contiguous sequence of characters within the string.": 0.24324324324324326, "Write a Python program to get a string made of the first 2 and the last 2 chars from a given a string. If the string length is less than 2, return instead of the empty string.": 0.23999999999999996, "Given a string s, return the number of palindromic substrings in it.": 0.23999999999999996, "Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.": 0.23333333333333334, "Given a string `s`, find the length of the longest substring without repeating characters.": 0.23076923076923078, "Write a Python function that returns the number of items that are present in the first list but not in the second list.": 0.22950819672131145}, "avg_similarity_score": 0.10868844095802628} -{"instruction": "You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins, return -1.", "input": "", "output": "class Solution:\n def coinChange(self, coins: List[int], amount: int) -> int:\n dp = [float('inf')] * (amount + 1)\n dp[0] = 0\n for coin in coins:\n for x in range(coin, amount + 1):\n dp[x] = min(dp[x], dp[x - coin] + 1)\n return -1 if dp[amount] == float('inf') else dp[amount]", "most_similar": {"You are given a list of numbers. You need to find the median of the list.": 0.3076923076923077, "You are given a list of numbers. You need to find the number of pairs of indices (i, j) such that the difference between nums[i] and nums[j] is at most t and i < j.": 0.2588235294117647, "Write a Python function to find the number of items in a list that are not equal to a given value.": 0.2571428571428572, "Write a Python function to calculate the sum of two given integers. However, if the sum is between 15 to 20 it should return 20.": 0.24324324324324326, "Write a function that takes an integer as input and returns the number of bits that are equal to 1 in the binary representation of that number. You can guarantee that input is non-negative.": 0.23809523809523808, "Write a Python program to find the number of occurrences of a specified element in a given array of integers.": 0.23188405797101447, "Write a Python function that takes a number as input and returns the sum of all the numbers from 1 to that number that are divisible by 3 and 5.": 0.22784810126582278, "Write a script to output 'Hello World' in python\nYou are given an array `prices` where `prices[i]` is the price of a given stock on the i^th day. You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. Return the maximum profit you can achieve from this transaction. If you cannot achieve any profit, return 0.": 0.22580645161290322, "Write a program to compute the sum of integers from k to n.": 0.2258064516129032, "Write a Python function that returns the number of items that are present in the first list but not in the second list.": 0.22222222222222224}, "avg_similarity_score": 0.1251724763626998} -{"instruction": "Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.\n\nThe function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2.", "input": "", "output": "class Solution:\n def twoSum(self, numbers: List[int], target: int) -> List[int]:\n l, r = 0, len(numbers) - 1\n while l < r:\n s = numbers[l] + numbers[r]\n if s == target:\n return [l + 1, r + 1]\n elif s < target:\n l += 1\n else:\n r -= 1\n return []", "most_similar": {"Given an array of integers, return indices of the two numbers such that they add up to a specific target.": 0.5142857142857143, "Given an array of integers `nums` and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order.": 0.37623762376237624, "Given an array of integers, find the pair of adjacent elements that has the largest product and return that product.": 0.28571428571428575, "Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.": 0.2857142857142857, "Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n).": 0.24390243902439027, "Given an array of integers, find the first missing positive integer in linear time and constant space. In other words, find the lowest positive integer that does not exist in the array. The array can contain duplicates and negative numbers as well.": 0.2391304347826087, "Given an array of integers nums, write a method that returns the \"pivot\" index of this array.": 0.23880597014925375, "Given a list of numbers, find the sum of the numbers.": 0.22950819672131148, "Write a Python function to check if a given number is a Kaprekar number or not. In mathematics, a Kaprekar number for a given base is a non-negative integer, the representation of whose square in that base can be split into two parts that add up to the original number again. For example, 45 is a Kaprekar number, because 45\u00b2 = 2025 and 20+25 = 45.": 0.22413793103448273, "You are given a list of numbers. You need to find the median of the list.": 0.21212121212121213}, "avg_similarity_score": 0.11121727867368264} -{"instruction": "Write a program to find the maximum value in an array", "input": "", "output": "def get_max(arr):\n max_value = 0\n for i in arr:\n if i > max_value:\n max_value = i\n return max_value", "most_similar": {"How do I find the maximum value in an array?": 0.6666666666666666, "Write a program to find the maximum of three numbers.": 0.6666666666666666, "Write a program to find the smallest number in a list.": 0.6363636363636364, "Write a C# program to find the sum of all the elements of an array.": 0.6153846153846153, "Write a python code to find the minimum value in a list.": 0.6086956521739131, "How to find the maximum value in a list?": 0.6, "Write a program to find the n-th ugly number.": 0.5714285714285713, "Write a Python program to find the most common words in a given text.": 0.56, "Write a Python program to find the first non-repeated character in a string.": 0.56, "How to find the largest number in an array in Java?": 0.5454545454545454}, "avg_similarity_score": 0.21981306769068223} -{"instruction": "Write a function that takes an integer minutes and converts it to hours and minutes.", "input": "", "output": "def time_converter(minutes):\n hours = minutes // 60\n minutes = minutes % 60\n return '{:02d} hours {:02d} minutes'.format(hours, minutes)", "most_similar": {"Write a function that takes an array of numbers and returns the largest number in the array.": 0.43749999999999994, "Write a Python function that takes two numbers as input and returns their sum.": 0.4137931034482759, "Write a Python function that removes the first item from a list and returns it.": 0.4000000000000001, "Write a Python function that takes a string and returns a new string with the words in sorted order and unique.": 0.3888888888888889, "Write a function that takes a string and returns the number of vowels in the string.": 0.38709677419354843, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.37500000000000006, "Write a function that takes a string as input and reverse only the vowels of a string.": 0.37500000000000006, "Write a Python function that takes a number as input and returns the square of that number.": 0.37500000000000006, "Write a python function that sorts a list from large to small.": 0.3703703703703704, "Write a Python function that takes a string as input and returns the string in reverse order.\n'Hello'": 0.3636363636363636}, "avg_similarity_score": 0.14890654710288662} -{"instruction": "Write a function that takes a positive integer n and returns the next biggest number with the same number of 1 bits. For example, given the number 6 (0110 in binary), the function should return 9 (1001).", "input": "", "output": "def next_number(n):\n m = n | (n - 1)\n m += 1\n return m", "most_similar": {"Write a function that takes a string and returns the number of vowels in the string.": 0.49056603773584906, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.4482758620689656, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.4193548387096775, "Write a Python function that takes a number as input and returns the square of that number.": 0.40740740740740744, "Write a function that takes an array of numbers and returns the largest number in the array.": 0.40740740740740744, "Write a function that takes an integer as input and returns the number of bits that are equal to 1 in the binary representation of that number. You can guarantee that input is non-negative.": 0.3888888888888889, "Write a Python function that takes a list and returns a new list with unique elements of the first list.": 0.38596491228070173, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.38596491228070173, "Write a function that takes a string and returns a new string with the first letter of each word capitalized.": 0.38596491228070173, "How do I make a function that takes a string and returns a list of the words in the string?": 0.38596491228070173}, "avg_similarity_score": 0.16683107809664335} -{"instruction": "Write a Python function that returns true if a string contains any space character.", "input": "", "output": "def has_space(text):\n return ' ' in text", "most_similar": {"Write a python function that returns the number of words in a given string.": 0.5714285714285714, "Write a Python function that returns the largest item in a list.": 0.5384615384615384, "Write a python function that returns the sum of the elements of a list.": 0.5, "Write a Python function that returns a list of numbers in a specified range.": 0.5, "Write a python function that sorts a list from large to small.": 0.4615384615384615, "Write a Python function that takes a string and returns a new string with the words in sorted order and unique.": 0.4571428571428571, "Write a Python function that takes a string as input and returns the string in reverse order.\n'Hello'": 0.43750000000000006, "Write a Python function that returns a specified number of elements in a list from a specified index.": 0.43750000000000006, "Write a Python function that returns a list containing only the items that are present in both lists.": 0.43750000000000006, "Write a Python function that takes two numbers as input and returns their sum.": 0.42857142857142855}, "avg_similarity_score": 0.17838981059804793} -{"instruction": "Write a Python function that returns True if the specified list and the specified value are not empty.", "input": "", "output": "def non_empty(values, value):\n return values and value", "most_similar": {"Write a Python function that returns the largest item in a list.": 0.5333333333333333, "Write a Python function that returns true if a string contains any space character.": 0.5, "Write a Python function that returns a list containing only the items that are present in both lists.": 0.5, "Write a Python function that returns a list of numbers in a specified range.": 0.5, "Write a Python function that returns a specified number of elements in a list from a specified index.": 0.5, "Write a python function that returns the sum of the elements of a list.": 0.5, "Write a Python function that returns the sum of all numbers in a list that are divisible by 3.": 0.4864864864864865, "Write a Python function that removes the first item from a list and returns it.": 0.4848484848484848, "Write a Python function that returns the number of items that are present in the first list but not in the second list.": 0.4390243902439025, "Write a python function that returns the number of words in a given string.": 0.43750000000000006}, "avg_similarity_score": 0.19475527842108187} -{"instruction": "How to extract all of the unique words from a string?", "input": "", "output": "Here is a python program that extracts all of the unique words from a string: ``` python string = \"The sky is blue.\" unique_words = set(string.split()) print(\"Unique words in the string:\") print(unique_words) ``` This program uses the str.split() method to split the string into words. It uses the set() function to get all the unique words.", "most_similar": {"How to find the sum of all the elements in a list in python?": 0.4, "Write a Python program to find the longest pallindrome substring from a given string.": 0.4, "How to find the maximum value in a list?": 0.39999999999999997, "How to find the standard deviation of a list?": 0.39999999999999997, "Write a Python program to find the frequency of the words from the sentence given.": 0.3846153846153846, "How do I replace all occurrences of a substring in a string with another string?": 0.3846153846153846, "How can I find the first repeated word in a string?": 0.36363636363636365, "How to find the largest prime factor of a given number?": 0.36363636363636365, "How to get the last element of a list in Python?": 0.36363636363636365, "How do you find the length of a string in Python?": 0.36363636363636365}, "avg_similarity_score": 0.16114312117968574} -{"instruction": "Given a binary array, find the maximum number of consecutive 1s in this array.", "input": "", "output": "class Solution:\n def findMaxConsecutiveOnes(self, nums: List[int]) -> int:\n max_ones = 0\n current_ones = 0\n for i in range(len(nums)):\n if nums[i] == 1:\n current_ones += 1\n else:\n max_ones = max(max_ones, current_ones)\n current_ones = 0\n\n return max(max_ones, current_ones)", "most_similar": {"Write a program to find the maximum value in an array": 0.4799999999999999, "Given a string, return the number of vowels used in the text.": 0.4615384615384615, "Given a string s, return the number of palindromic substrings in it.": 0.4615384615384615, "How do I find the maximum value in an array?": 0.41666666666666663, "Write a program to find the maximum of three numbers.": 0.41666666666666663, "Write a Python program to find the number of occurrences of a specified element in a given array of integers.": 0.4117647058823529, "How to find the largest number in an array in Java?": 0.4, "How to find the sum of all numbers in an array?": 0.4, "Given a list of numbers, find the sum of the numbers.": 0.4, "Write a program to find the smallest number in a list.": 0.4}, "avg_similarity_score": 0.17844256075198917} -{"instruction": "How do you count the number of items in a list?", "input": "", "output": "There are two ways of counting the number of items in a list.\n\nThe len() Function\nThe len() function is used to get the length of a list. For example, the code below counts the number of items in the list: ``` python names = ['Jane', 'James', 'Robert', 'Michael'] print(len(names)) # Prints 4 ```\n\nThe count() Method\nThe count() method is used to count the number of items in a list that match the given value. For example, the code below counts the number of names in the list: ``` python names = ['Jane', 'James', 'Robert', 'Michael'] print(names.count('Jane')) # Prints 1 ```", "most_similar": {"How do you find the index of an item in a list?": 0.6956521739130435, "How do you find the largest number in a list using Python?": 0.6956521739130435, "How do you find the standard deviation of all items in a list in Python?": 0.6923076923076923, "How do you find the number of occurrences of a given value in a list in Python?": 0.6428571428571428, "How do you output all the contents of a list in Python?": 0.6086956521739131, "How do I find the p-variance of all elements in a list?": 0.5833333333333334, "How do I find the fibonacci number of a number?": 0.5714285714285713, "How do I get the first element of a list?": 0.5714285714285713, "How do you find the length of a string in Python?": 0.5454545454545454, "How to find the frequency distribution of all values in a list?": 0.5217391304347826}, "avg_similarity_score": 0.18803706919213073} -{"instruction": "How to capitalize a string in Python?", "input": "", "output": "Here are two ways of capitalizing a string in Python.\n\nUsing the capitalize() Method\nThe capitalize() method capitalizes the first letter of the given string and makes the rest lowercase. For example, the code below capitalizes the first letter in the string: ``` python name = \"james\" print(name.capitalize()) # Prints \"James\" ```\n\nUsing the title() Method\nThe title() method capitalizes the first letter of each word in the given string. For example, the code below capitalizes the first letter in each word: ``` python name = \"james bond\" print(name.title()) # Prints \"James Bond\" ```", "most_similar": {"How to get the last element of a list in Python?": 0.5555555555555556, "How do you find the length of a string in Python?": 0.5555555555555556, "How do I convert a string to a number in Python?": 0.5555555555555556, "How do you create a variable in Python?": 0.5333333333333333, "How do I print a list in Python?": 0.5333333333333333, "How do I output a string in C++ programming?": 0.5, "How to find the sum of all the elements in a list in python?": 0.4761904761904762, "How do you sort a list of strings in Python?": 0.47058823529411764, "How do you remove duplicates from a list in Python?": 0.47058823529411764, "How to get the current time in milliseconds in python?": 0.47058823529411764}, "avg_similarity_score": 0.16375971509856305} -{"instruction": "How do you check if a value is present in a list?", "input": "", "output": "There are several ways to check if a value is present in a list. One of the most common ways is using the in operator. For example, the code below checks if 'apple' is present in the list: ``` python fruits = ['banana', 'apple', 'mango', 'orange'] print('apple' in fruits) # Prints True ```\n\nYou can also use the count() method. If the value is present, it returns the number of occurrences. Otherwise, it returns 0. For example, the code below checks if 'apple' is present in the list: ``` python fruits = ['banana', 'apple', 'mango', 'orange'] print(fruits.count('apple')) # Prints 1 ```", "most_similar": {"How do you find the number of occurrences of a given value in a list in Python?": 0.5517241379310345, "How do I check if a string contains a substring?": 0.5454545454545454, "How do you count the number of items in a list?": 0.5217391304347826, "How to check quickly if a number is prime in C?": 0.5217391304347826, "How do you create a variable in Python?": 0.5, "How do you find the largest number in a list using Python?": 0.5, "How do you find the index of an item in a list?": 0.5, "How to find the maximum value in a list?": 0.4761904761904762, "How do you remove duplicates from a list in Python?": 0.45454545454545453, "How do you add a link to a web page?": 0.45454545454545453}, "avg_similarity_score": 0.168974404640771} -{"instruction": "Can you tell me how to sort a dictionary by value in Python?", "input": "", "output": "You can use the built-in dict method items to convert a dictionary to a list of tuples where the first item in each tuple is the key and the second item is the value.\n\nFor example, this dictionary:\n\nd = {'a': 3, 'b': 2, 'c': 1}\nwill become this list:\n\n[('a', 3), ('b', 2), ('c', 1)]\nNext, you can use the built-in sorted function to sort the list of tuples by the second item in each tuple.\n\nThen, you can use the built-in dict function to convert the sorted list of tuples back to a dictionary.\n\nThis is the complete code:\n\nd = {'a': 3, 'b': 2, 'c': 1}\n\nsorted_d = dict(sorted(d.items(), key=lambda x: x[1]))\n\nprint(sorted_d)", "most_similar": {"How to capitalize a string in Python?": 0.5, "How do you sort a list of strings in Python?": 0.4347826086956522, "How to get the last element of a list in Python?": 0.41666666666666663, "How do I convert a string to a number in Python?": 0.41666666666666663, "How do you create a variable in Python?": 0.380952380952381, "How do I print a list in Python?": 0.380952380952381, "How to find the sum of all the elements in a list in python?": 0.3703703703703704, "How to find the maximum value in a list?": 0.3636363636363637, "How to get the current time in milliseconds in python?": 0.34782608695652173, "How do you remove duplicates from a list in Python?": 0.34782608695652173}, "avg_similarity_score": 0.13110258403857905} -{"instruction": "How to split a string into a list?", "input": "", "output": "You can use the built-in str method split to split a string into a list.\n\nFor example, this string:\n\ntxt = \"This is a text\"\nwill become this list:\n\n[\"This\", \"is\", \"a\", \"text\"]\nTo make it a list of words, you can add the space character as a separator to the split function:\n\ntxt = \"This is a text\"\n\nwords = txt.split(\" \")\n\nprint(words)", "most_similar": {"How to capitalize a string in Python?": 0.5333333333333333, "How to find the standard deviation of a list?": 0.47058823529411764, "How to find the maximum value in a list?": 0.47058823529411764, "How do I check if a string contains a substring?": 0.4444444444444445, "How do I convert a string to a number in Python?": 0.4210526315789474, "How to extract all of the unique words from a string?": 0.4210526315789474, "How to get the last element of a list in Python?": 0.4210526315789474, "How do you check if a value is present in a list?": 0.4, "How to find the frequency distribution of all values in a list?": 0.4, "How can I convert a list of strings to a list of integers?": 0.380952380952381}, "avg_similarity_score": 0.15284164571860512} -{"instruction": "I need a simple C++ program to find the factorial of a number.", "input": "", "output": "int factorial(int n) {\n if (n == 0)\n return 1;\n return n * factorial(n - 1);\n}", "most_similar": {"Write a Python function to calculate the factorial of a number.": 0.5833333333333334, "Write a Python program to find the sum of a non-negative integer.": 0.5384615384615384, "How do I find the fibonacci number of a number?": 0.5217391304347826, "Write a program to find the n-th ugly number.": 0.5217391304347826, "Write a program to find the maximum of three numbers.": 0.5217391304347826, "Write a Python program to find the average of a list using for loop.": 0.5185185185185186, "Write a Python program to find the frequency of each word in a given string.": 0.5, "Write a C# program to find the sum of all the elements of an array.": 0.5, "write a c++ program that calculates the perimeter of a square": 0.4999999999999999, "Write a python code to find the area of a circle.": 0.4999999999999999}, "avg_similarity_score": 0.21445865827665128} -{"instruction": "Write a Python function that takes two lists and returns True if they have at least one common member.", "input": "", "output": "You can use the built-in list function set to convert a list to a set and check if the set intersection is empty.\n\nIf the intersection is empty, the lists have no common members. Otherwise, the lists have at least one common member.\n\nHere is the code:\n\ndef common_member(lst1, lst2):\n return bool(set(lst1) & set(lst2))\n\nresult = common_member([1, 2, 3], [4, 5, 6])\n\nprint(result)", "most_similar": {"Write a Python function that takes two numbers as input and returns their sum.": 0.5454545454545454, "Write a Python function that returns true if a string contains any space character.": 0.48484848484848486, "Write a Python function that takes a number as input and returns the square of that number.": 0.4444444444444444, "Write a Python function that takes a string as input and returns the string in reverse order.\n'Hello'": 0.43243243243243246, "Write a Python function that returns True if the specified list and the specified value are not empty.": 0.43243243243243246, "Write a Python function that removes the first item from a list and returns it.": 0.4117647058823529, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.41025641025641024, "Write a Python function that takes a list and returns a new list with unique elements of the first list.": 0.41025641025641024, "Write a Python function that takes a string and returns a new string with the words in sorted order and unique.": 0.4, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.4}, "avg_similarity_score": 0.1490424177296219} -{"instruction": "What is a list comprehension?", "input": "", "output": "A list comprehension is a compact way of creating a list.\n\nFor example, this list:\n\nlst = []\n\nfor i in range(10):\n lst.append(i)\nwill become this list:\n\nlst = [i for i in range(10)]", "most_similar": {"What is a Dockerfile?": 0.6666666666666665, "What is a cron job ?": 0.6, "What is a stateful set ?": 0.6, "What is a persistent volume ?": 0.6, "What is a Docker container?": 0.6, "What is Kubernetes ?": 0.5, "What is the difference between a list and a tuple in Python?": 0.47058823529411764, "What is the difference between a relative and absolute path?": 0.4, "What is the difference between a class and an object?": 0.4, "What is the difference between a static and a dynamic method?": 0.37499999999999994}, "avg_similarity_score": 0.12111277954990346} -{"instruction": "Convert this list into a list of sets: [[1, 2, 3], [4, 5, 6], [7, 8, 9]]", "input": "", "output": "Use the built-in list function set to convert a list to a set:\n\nlst = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]\n\nprint([set(s) for s in lst])", "most_similar": {"How to make a python program that will print the following pattern?\n```\n1\n2 3\n4 5 6\n7 8 9 10\n11 12 13 14 15\n```": 0.45454545454545453, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.4324324324324324, "What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.36842105263157887, "How can I convert a list of strings to a list of integers?": 0.33333333333333337, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.3333333333333333, "What is the value of the following expression?\n10 + 2 * 3 / 4": 0.27586206896551724, "How to make a python program that will print the following pattern?\n```\n1\n1 2\n1 2 3\n1 2 3 4\n1 2 3 4 5\n```": 0.27272727272727276, "Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of the first 10 ugly numbers. Note that 1 is typically treated as an ugly number.": 0.2535211267605634, "How to split a string into a list?": 0.24, "How to make a python program that will print the following pattern?\n```\n1\n2 3\n4 5 6\n7 8 9 10\n11 12 13 14 15\n16 17 18 19 20 21\n22 23 24 25 26 27 28\n29 30 31 32 33 34 35 36\n37 38 39 40 41 42 43 44 45\n46 47 48 49 50 51 52 53 54 55\n```": 0.23809523809523808}, "avg_similarity_score": 0.09631574671483219} -{"instruction": "What are the different methods to remove an element from a list in Python?", "input": "", "output": "You can use either the built-in list function remove or the del statement.\n\nFor example, this list:\n\nlst = [1, 2, 3, 4, 5]\nwill become this list:\n\n[1, 2, 3, 5]\n\nHere is the code using the built-in list function remove:\n\nlst = [1, 2, 3, 4, 5]\n\nlst.remove(4)\n\nprint(lst)\n\nHere is the code using the del statement:\n\nlst = [1, 2, 3, 4, 5]\n\ndel lst[3]\n\nprint(lst)", "most_similar": {"How do you remove duplicates from a list in Python?": 0.5, "How to get the last element of a list in Python?": 0.4799999999999999, "What is the difference between a list and a tuple in Python?": 0.4615384615384615, "How do you remove an item at a given index from a list using Python?": 0.4137931034482759, "How do you output all the contents of a list in Python?": 0.3846153846153846, "How to capitalize a string in Python?": 0.38095238095238093, "How do I print a list in Python?": 0.36363636363636365, "How to find the sum of all the elements in a list in python?": 0.35714285714285715, "How do you find the standard deviation of all items in a list in Python?": 0.3448275862068965, "How do you sort a list of strings in Python?": 0.3333333333333333}, "avg_similarity_score": 0.14970863713216398} -{"instruction": "Write a function that reverses a given string.", "input": "", "output": "def reverse_string(s):\n return s[::-1]", "most_similar": {"Write a python function that returns the number of words in a given string.": 0.6363636363636364, "Write a Python function that returns true if a string contains any space character.": 0.5454545454545454, "Write a Python function to reverse a given list of integers.": 0.5263157894736842, "Write a function that takes a string and returns the number of vowels in the string.": 0.5, "Write a python function that sorts a list from large to small.": 0.5, "Write a Python function that returns the largest item in a list.": 0.5, "Write a function that returns the number of times a given string occurs in a given text as its substring.": 0.4999999999999999, "Write a function that takes a string as input and reverse only the vowels of a string.": 0.48, "Write a Python function to find the first repeated word in a given string, ignoring case and punctuation.": 0.46153846153846156, "Write a Python function that takes a string as input and returns the string in reverse order.\n'Hello'": 0.46153846153846156}, "avg_similarity_score": 0.1822723800901746} -{"instruction": "If you have an array of numbers and you want to get the average of all the numbers, what is the shortest code to do it?", "input": "", "output": "if you have a list of numbers, you can calculate the mean with a one-liner: ```python import statistics list_of_nums = [2, 4, 6, 8, 10] mean = statistics.mean(list_of_nums) ```", "most_similar": {"I have a list of numbers and I want to find the average of all the numbers.": 0.558139534883721, "I want to find the average of all the numbers in a list.": 0.4102564102564103, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.3829787234042554, "You are given a list of numbers. You need to find the median of the list.": 0.380952380952381, "I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.37500000000000006, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.372093023255814, "Write a function that takes an array of numbers and returns the largest number in the array.": 0.3255813953488372, "Given a list of numbers, find the sum of the numbers.": 0.3243243243243243, "Given an array of integers, return indices of the two numbers such that they add up to a specific target.": 0.3043478260869565, "You are given a list of numbers. You need to find the number of pairs of indices (i, j) such that the difference between nums[i] and nums[j] is at most t and i < j.": 0.2903225806451613}, "avg_similarity_score": 0.1350260247228418} -{"instruction": "Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.", "input": "", "output": "```python def removeDuplicates(nums): i = 0 for n in nums: if i == 0 or n > nums[i-1]: nums[i] = n i += 1 return i ```", "most_similar": {"Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.": 0.3181818181818182, "Given an integer array nums, find the subarray with the largest sum, and return its sum.": 0.3157894736842105, "Given a string, return the number of vowels used in the text.": 0.29411764705882354, "Given an array of integers, find the pair of adjacent elements that has the largest product and return that product.": 0.28571428571428564, "Given a binary array, find the maximum number of consecutive 1s in this array.": 0.2777777777777778, "Given an array of integers `nums` and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order.": 0.273972602739726, "Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n).": 0.25925925925925924, "Given an array of integers nums, write a method that returns the \"pivot\" index of this array.": 0.25641025641025644, "Write a function that takes an array of numbers and returns the largest number in the array.": 0.25641025641025644, "Write me a python function that takes two arrays as input, and return the element-wise sum of the two arrays as a new array.": 0.2553191489361702}, "avg_similarity_score": 0.12901297087186173} -{"instruction": "I have the following code in python: ```python b = sorted(a, key=lambda x: (x[0], x[1]), reverse=True) ``` What does it do?", "input": "", "output": "The above code sorts the list `a` by using the `lambda` function. The `lambda` function sorts the list in the reverse order based on the first and second elements in the sublists in `a`. For example: ```python a = [[1, 2], [3, 4], [4, 3], [4, 2]] b = sorted(a, key=lambda x: (x[0], x[1]), reverse=True) print(b) # Output: [[4, 3], [4, 2], [3, 4], [1, 2]] ```", "most_similar": {"I am trying to run the following code in Python: ```python def f(x): return x + 1 print(f(1)) ``` I get an error. What is the problem?": 0.4230769230769231, "I have the following code: ```python def get_max_value(list): max_value = list[0] for i in range(1, len(list)): if list[i] > max_value: max_value = list[i] return max_value ``` What does the function do?": 0.34920634920634913, "I have the following python function: ```python def resize_images(images, res_x, res_y): resized_images = np.zeros((images.shape[0], res_x, res_y)) for n in range(len(images)): resized_images[n, :, :] = resize(images[n, :, :], resized_images.shape[1:], anti_aliasing=False) return resized_images ``` What does the function do?": 0.33766233766233766, "I have this python code: ```python def make_dict(df): d = dict(zip(df.columns, df.values[0])) return d ``` What does the function do?": 0.32653061224489793, "What is the output of the following code?\n```python\ndef func(x):\n return x + 1\n\ndef main():\n x = 1\n y = func(x)\n print(y)\n\nmain()\n```": 0.32653061224489793, "What is the output of the following code?\n```python\ndef foo():\n x = 1\n def bar():\n x = 2\n return x\n return bar()\nprint(foo())\n```": 0.2978723404255319, "I'm trying to use the following code to create a new column in a dataframe:\n```python\ndf['new_col'] = df['col_1'].apply(lambda x: x.split(' ')[0])\n```\nBut I'm getting the following error:\n```python\nAttributeError: 'float' object has no attribute 'split'\n```": 0.29411764705882354, "What is the output of this code?\n```python\ndef f(x):\n x = 2 * x + 1\n return x\n\nx = 3\nz = f(x)\nprint(z)\n```": 0.2916666666666667, "What is the output of the following code?\n```python\ndef f(x):\n return x * 2\n\ndef g(x):\n return f(x) + 1\n\ndef h(x):\n return g(x) * 2\n\nprint(h(2))\n```": 0.28571428571428575, "What does the following python code do?\n```python def sum_divisible_by_three(lst):\n\treturn sum(x for x in lst if x % 3 == 0)\n ```": 0.2857142857142857}, "avg_similarity_score": 0.1130054540570486} -{"instruction": "How to sort the list by second element in each sublist", "input": "", "output": "You can use the `sorted()` function with a `key` to sort a list by the second element in each sublist. For example: ```python my_list = [[\"John\", 1, \"A\"], [\"Betty\", 2, \"C\"], [\"Harry\", 1, \"B\"], [\"Donald\", 3, \"D\"] my_list = sorted(my_list, key=lambda x: x[1]) print(my_list) # Output: [['Harry', 1, 'B'], ['John', 1, 'A'], ['Betty', 2, 'C'], ['Donald', 3, 'D']] ```", "most_similar": {"How to get the last element of a list in Python?": 0.45454545454545453, "Can you tell me how to sort a dictionary by value in Python?": 0.41666666666666663, "How to find the sum of all the elements in a list in python?": 0.4, "How to find the maximum value in a list?": 0.39999999999999997, "How to find the nth prime number in C?": 0.39999999999999997, "How to find the standard deviation of a list?": 0.39999999999999997, "How do you sort a list of strings in Python?": 0.380952380952381, "How can I sort a list of integers in Rust?": 0.380952380952381, "How to get the current time in milliseconds in python?": 0.380952380952381, "How to find the largest number in an array in Java?": 0.36363636363636365}, "avg_similarity_score": 0.13499126263648462} -{"instruction": "Given the following code, what does it print? ```python import requests url = \"https://example.com\" r = requests.get(url) if r.status_code != 200: print(\"error\") else: print(r.text) ```", "input": "", "output": "Given the above code, the output is: `error` Here is an explanation of what the code does: 1. We import the `requests` module. 2. We define the `url` variable as `https://example.com`. 3. We create a `GET` request to the URL defined in the `url` variable using the `requests.get()` function. 4. We define a conditional statement to check if the request status code is not equal to 200, and if so, print the string `error`. 5. If the condition is not met, then we print the request text. 6. Because `https://example.com` returns a status code of 200, the output is `error`.", "most_similar": {"What is the output of the following python code?\n```python\ndef function(a):\n if a > 0:\n print('Positive')\n else:\n print('Negative')\n\nfunction(0)\n```": 0.30188679245283023, "Translate the following code from python in Java.\ndef function(a : int, b : int, c : int):\n if a > b :\n print('You lost.')\n else :\n if c > a :\n print('Nice try.')\n else :\n print('You won.')": 0.253968253968254, "What is the output of the following code?\n```python\ndef foo():\n print(\"foo\")\n\ndef bar():\n print(\"bar\")\n\ndef main():\n foo()\n bar()\n\nmain()\n```": 0.23076923076923075, "I have the following code in python: ```python b = sorted(a, key=lambda x: (x[0], x[1]), reverse=True) ``` What does it do?": 0.22222222222222224, "I am trying to use the following code in python:\n```py\ndef function(a, b):\n if a > b:\n print('You lost.')\n else:\n if c > a:\n print('Nice try.')\n else:\n print('You won.')\n```\nBut I am getting an error. What is wrong with the code?": 0.21621621621621623, "Suggest a completion for the following python code.": 0.2105263157894737, "Translate the following code from python in Java.": 0.2105263157894737, "I am trying to run the following code in Python: ```python def f(x): return x + 1 print(f(1)) ``` I get an error. What is the problem?": 0.20689655172413796, "What is the output of the following code?\n```\na = 1\nb = 2\nc = 3\nif a > b:\n print(\"a is greater than b\")\nelif a > c:\n print(\"a is greater than c\")\nelse:\n print(\"a is not greater than b or c\")\n```": 0.19444444444444445, "Write a python code snippet to print the following text.\nHello World!": 0.19047619047619044}, "avg_similarity_score": 0.06697467821998714} -{"instruction": "I have a list of strings, how do I convert them to numbers?", "input": "", "output": "You can use the `list` function to convert a list of strings to a list of numbers. For example: ```python my_list = ['1', '2', '3'] my_list = list(map(int, my_list)) print(my_list) # Output: [1, 2, 3] ```", "most_similar": {"I have a list of numbers, how do I find the second largest number?": 0.5925925925925927, "I have a list of numbers and I want to find the average of all the numbers.": 0.5333333333333333, "How can I convert a list of strings to a list of integers?": 0.46153846153846156, "How do I convert a string to a number in Python?": 0.41666666666666663, "I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.39999999999999997, "How do you sort a list of strings in Python?": 0.34782608695652173, "How do I push a tag to remote in git?": 0.34782608695652173, "How can I sort a list of integers in Rust?": 0.34782608695652173, "How do I make a list of all the prime numbers up to a certain number?": 0.3448275862068966, "Given a list of numbers, find the sum of the numbers.": 0.33333333333333337}, "avg_similarity_score": 0.1345063693116417} -{"instruction": "I need to sum all the values in the following list: `[1,2,3,4,5,6,7,8,9]`.", "input": "", "output": "You can use the `sum()` function to sum all the values in a list. For example: ```python my_list = [1, 2, 3, 4, 5, 6, 7, 8, 9] total = sum(my_list) print(total) # Output: 45 ```", "most_similar": {"Convert this list into a list of sets: [[1, 2, 3], [4, 5, 6], [7, 8, 9]]": 0.5405405405405405, "How to make a python program that will print the following pattern?\n```\n1\n2 3\n4 5 6\n7 8 9 10\n11 12 13 14 15\n```": 0.5106382978723405, "What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.4390243902439024, "What is the value of the following expression?\n10 + 2 * 3 / 4": 0.37499999999999994, "I want to find the average of all the numbers in a list.": 0.3636363636363637, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.35555555555555557, "How to find the sum of all the elements in a list in python?": 0.3529411764705882, "How to make a python program that will print the following pattern?\n```\n1\n1 2\n1 2 3\n1 2 3 4\n1 2 3 4 5\n```": 0.3404255319148936, "Write a program to find the sum of all the multiples of 3 or 5 below 1000.": 0.3243243243243243, "How to find the frequency distribution of all values in a list?": 0.3125}, "avg_similarity_score": 0.1326561984748076} -{"instruction": "Can I convert a dictionary to a JSON string?", "input": "", "output": "Yes, you can. You can use the `json.dumps()` function to convert a dictionary to a JSON string. For example: ```python import json my_dict = {\"name\": \"John\", \"age\": 30, \"city\": \"New York\"} my_json = json.dumps(my_dict) print(my_json) # Output: {\"name\": \"John\", \"age\": 30, \"city\": \"New York\"} ```", "most_similar": {"How can I convert a list of strings to a list of integers?": 0.5454545454545455, "How do I convert a string to a number in Python?": 0.5, "How can I find the first repeated word in a string?": 0.39999999999999997, "How to capitalize a string in Python?": 0.375, "How do I compile a go program on Linux to a windows executable?": 0.3636363636363637, "I need a simple C++ program to find the factorial of a number.": 0.3636363636363637, "How to split a string into a list?": 0.35294117647058826, "How can I make a button in HTML?": 0.35294117647058826, "Write a code to implement a binary search.": 0.35294117647058826, "Write a function that reverses a given string.": 0.35294117647058826}, "avg_similarity_score": 0.1470297981618134} -{"instruction": "What is the python code to print hello world?", "input": "", "output": "```python print(\"Hello world\") ```", "most_similar": {"Write a python code snippet to print the following text.\nHello World!": 0.5714285714285715, "What is the difference between a list and a tuple in Python?": 0.380952380952381, "What is the output of the following python code?\n```python\ndef function(a):\n if a > 0:\n print('Positive')\n else:\n print('Negative')\n\nfunction(0)\n```": 0.37500000000000006, "What is the output of this code?\n```\nx = 10\ndef func():\n x = 20\n print(x)\nfunc()\nprint(x)\n```": 0.3703703703703704, "Suggest a completion for the following python code.": 0.35294117647058826, "Write a python code to implement quick sort": 0.35294117647058826, "Write Python code to generate N Tribonacci numbers": 0.35294117647058826, "Write Python code to solve this leetcode problem.": 0.35294117647058826, "What is the output of the following Python code? ```py def f(x): return x + 1 def g(x): return x * 2 print(g(f(3))) ```": 0.3428571428571429, "What is Kubernetes ?": 0.3333333333333333}, "avg_similarity_score": 0.1252109967174952} -{"instruction": "Write a code snippet to list the directories in the current directory.", "input": "", "output": "import os\nimport pandas as pd\n\npd.DataFrame(sorted(os.listdir(os.curdir)))", "most_similar": {"Write a python code snippet to print the following text.\nHello World!": 0.5, "Write a python code to find the minimum value in a list.": 0.5, "write a code to get the current value of a Bitcoin in US dollars using the bitcoincharts API.": 0.4666666666666666, "Write a program to find the smallest number in a list.": 0.43478260869565216, "Write a python code to find the area of a circle.": 0.43478260869565216, "Write a program to find the maximum value in an array": 0.43478260869565216, "Write a script in JavaScript for printing the current date and time.": 0.4166666666666667, "Write a Python function to find the largest number in a dictionary.": 0.4166666666666667, "Write a JavaScript code snippet to show an alert message with the text \"Welcome to my website!\".": 0.41379310344827586, "Write a python code for a linked list": 0.4}, "avg_similarity_score": 0.19944688117488413} -{"instruction": "Describe the in a sentence.\n is a type of food often served as a side dish or snack at picnics and other informal gatherings.", "input": "", "output": "Crackers are a type of food often served as a side dish or snack at picnics and other informal gatherings.", "most_similar": {"Given a string s, return the number of palindromic substrings in it. A string is a palindrome when it reads the same backward as forward. A substring is a contiguous sequence of characters within the string.": 0.22580645161290322, "How can I create a new column in a pandas dataframe that is the sum of two other columns?": 0.2222222222222222, "Write a Python function to check if a given number is a repdigit or not. A repdigit is a positive integer that consists of a single digit repeated one or more times.": 0.20689655172413793, "Write a function that takes in a string of one or more words, and returns the same string, but with all words sorted lengthwise.": 0.2, "Write a Python function that returns a list of numbers in a specified range.": 0.2, "Write a function that takes a list of numbers and returns a list of the same numbers, but with the first and last elements swapped.": 0.19607843137254902, "Write a Python function to check if a given number is a prime number or not.": 0.1904761904761905, "Write a function that takes a string as input and reverse only the vowels of a string.": 0.186046511627907, "Write a Python function that takes a number as input and returns the square of that number.": 0.186046511627907, "Given a string s, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.": 0.186046511627907}, "avg_similarity_score": 0.1141872823520209} -{"instruction": "Given a list of strings, find the longest string in the list. You can use the len function to find the length of a string.", "input": "", "output": "def find_longest(arr):\n longest = \"\"\n for i in arr:\n if len(longest) < len(i):\n longest = i\n return longest", "most_similar": {"You are given a list of numbers. You need to find the median of the list.": 0.43902439024390244, "Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.": 0.4255319148936171, "Given a list of numbers, find the sum of the numbers.": 0.3888888888888889, "How do you find the length of a string in Python?": 0.3888888888888889, "I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.3829787234042554, "Given a string `s`, find the length of the longest substring without repeating characters.": 0.358974358974359, "Write a Python function to find the sum of all items in a list.": 0.358974358974359, "Write a Python program to find the frequency of each word in a given string.": 0.35000000000000003, "Write a python code to find the area of a circle.": 0.3333333333333333, "Write a Python function to calculate the factorial of a number.": 0.3333333333333333}, "avg_similarity_score": 0.17773824361309068} -{"instruction": "Fill in the in the python code. The output should be a list of 10 random integers between 0 and 100.\n\n```python import random def ten_random_numbers(): ```", "input": "", "output": "import random def ten_random_numbers():\n return [random.randint(0, 100) for _ in range(10)]", "most_similar": {"Fill in the in the html document with a propoer text. You should take the html tag into consideration. You output should be the completed html document.": 0.3448275862068965, "Write a Python function to find the maximum sum of a contiguous subsequence from a list of integers.": 0.25, "Write a Python function to reverse a given list of integers.": 0.2439024390243902, "Fill in the in the html document with a propoer text. You should take the html tag into consideration. You output should be the completed html document.\n\n\n <mask> \n\n\u02dc South Korea on Monday announced sweeping\ntax reforms, including income and\ncorporate tax cuts to boost growth by\nstimulating sluggish private\nconsumption and business investment.\n\n": 0.23913043478260868, "Write a python code to find the minimum value in a list.": 0.23809523809523808, "Write a script to output the mean of a list of integers.": 0.23809523809523808, "What is the difference between a list and a tuple in Python?": 0.23809523809523808, "How do you find the largest number in a list using Python?": 0.23809523809523808, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.23529411764705882, "I am trying to use the following code to create a list of numbers from 1 to 100. But it is not working. Can you help me fix it? ```python numbers = [] for i in range(1, 100): numbers.append(i) ```": 0.2285714285714286}, "avg_similarity_score": 0.1271472984405963} -{"instruction": "If the statement is false, then correct the statement. Otherwise, leave the statement as it is. You can leave the statement as it is without any change.\nA hydrogen bomb is more powerful than a nuclear bomb.", "input": "", "output": "A hydrogen bomb is more powerful than a nuclear bomb.", "most_similar": {"Given a string s, return the number of palindromic substrings in it. A string is a palindrome when it reads the same backward as forward. A substring is a contiguous sequence of characters within the string.": 0.2191780821917808, "Write an SQL query to select all columns from a table named 'employees' where the age is greater than 30 and the salary is greater than 10000 or the name is 'John' and the age is less than 40.": 0.21052631578947367, "Write a Python function to check if a given number is a Keith number or not. A Keith number is a number which is one less than a perfect square.": 0.208955223880597, "What is the output of the following code?\n```\na = 1\nb = 2\nc = 3\nif a > b:\n print(\"a is greater than b\")\nelif a > c:\n print(\"a is greater than c\")\nelse:\n print(\"a is not greater than b or c\")\n```": 0.20253164556962025, "Write a Python function to check if a number is a Truncable number or not. A Truncable number is a number where the number generated by truncating the leftmost and rightmost digits of the number is a prime number. For example, 137 is a Truncable number, since 137, 37 and 7 are all prime numbers.": 0.1956521739130435, "Given a list of strings, find the longest string in the list. You can use the len function to find the length of a string.": 0.1935483870967742, "If you have an array of numbers and you want to get the average of all the numbers, what is the shortest code to do it?": 0.19047619047619047, "Using the comment as a guide, replace the \"TODO\" comment in the code with the proper code.\ndef greet_to(name):\n \"\"\"Print a greeting to the name provided.\"\"\"\n # TODO: assert name is a string\n print(\"Hello, \" + name + \"!\")": 0.18918918918918917, "Write a Python function to check if a given number is a Truncable number or not. A Truncable number is a number where the number generated by truncating it from left or right is also a number.": 0.18918918918918917, "Write a Python function to check if a given number is a palindrome or not. A palindrome is a number that remains the same when its digits are reversed. For example, 121 is a palindrome but 112 is not.": 0.1842105263157895}, "avg_similarity_score": 0.09188109375340081} -{"instruction": "The output should be a list of all the prime numbers between 1 and 100.", "input": "", "output": "```python import math\n\ndef get_prime_numbers(num):\n \"\"\"\n Return a list of all prime numbers from 1 to given number.\n >>> get_prime_numbers(100)\n [1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]\n \"\"\"\n prime_numbers = []\n for i in range(2, num + 1):\n if all(i % j != 0 for j in range(2, int(math.sqrt(i)) + 1)):\n prime_numbers.append(i)\n return prime_numbers\n```", "most_similar": {"How do I make a list of all the prime numbers up to a certain number?": 0.45161290322580644, "Fill in the in the python code. The output should be a list of 10 random integers between 0 and 100.\n\n```python import random def ten_random_numbers(): ```": 0.4444444444444444, "Given a list of numbers, find the sum of the numbers.": 0.3846153846153846, "I have a list of numbers and I want to find the average of all the numbers.": 0.37500000000000006, "I want to find the average of all the numbers in a list.": 0.3571428571428571, "How do I find the sum of the first 1000 prime numbers in C++?": 0.3448275862068965, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.3448275862068965, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.3333333333333333, "Write a Python function that takes a number as input and returns the sum of all the numbers from 1 to that number that are divisible by 3 and 5.": 0.31111111111111117, "How to find the sum of all numbers in an array?": 0.30769230769230765}, "avg_similarity_score": 0.15536252236526976} -{"instruction": "Given a list of numbers, find the largest number in the list.", "input": "", "output": "```python def max_number(numbers):\n \"\"\"\n Return the largest number in a given list.\n >>> max_number([1, 2, 3, 4, 5])\n 5\n >>> max_number([1, 3, 10, 2, 5])\n 10\n \"\"\"\n return max(numbers)\n```", "most_similar": {"Given a list of numbers, find the sum of the numbers.": 0.6956521739130435, "You are given a list of numbers. You need to find the median of the list.": 0.6428571428571429, "I have a list of numbers, how do I find the second largest number?": 0.6153846153846153, "I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.5882352941176471, "Write a function that takes an array of numbers and returns the largest number in the array.": 0.5517241379310345, "Write a program to find the smallest number in a list.": 0.5217391304347826, "How can I make a program that will find the largest number in a list?": 0.5185185185185186, "Write a Python function to find the largest number in a dictionary.": 0.5, "How do you find the largest number in a list using Python?": 0.5, "Given a string, return the number of vowels used in the text.": 0.5}, "avg_similarity_score": 0.20249234069322442} -{"instruction": "Write a python function that returns a value from a list, selected at random.", "input": "", "output": "def get_random(my_list):\n import random\n x = random.randint(0, len(my_list)-1)\n return my_list[x]", "most_similar": {"Write a Python function that removes all occurrences of a specified item from a list.": 0.6206896551724138, "Write a Python function that returns the largest item in a list.": 0.6153846153846153, "Write a Python function that returns a list of numbers in a specified range.": 0.5714285714285714, "Write a python function that returns the sum of the elements of a list.": 0.5714285714285714, "Write a Python function that returns a specified number of elements in a list from a specified index.": 0.5625000000000001, "Write a Python function that removes the first item from a list and returns it.": 0.5517241379310344, "Write a python function that sorts a list from large to small.": 0.5384615384615384, "Write a Python function that returns a list containing only the items that are present in both lists.": 0.5, "Write a Python function to find the maximum sum of a contiguous subsequence from a list of integers.": 0.5, "Write a python function that returns the number of words in a given string.": 0.5}, "avg_similarity_score": 0.18875538930408678} -{"instruction": "What are the drawbacks of using this python code? ``` py def get_random_index(my_list): return random.randint(0, len(my_list)-1) ```", "input": "", "output": "This function will not work if the list has a length of 0. This will cause an error. This could be fixed by using an if statement to check the length of the list.", "most_similar": {"What is the output of the following Python code? ```py def f(x): return x + 1 def g(x): return x * 2 print(g(f(3))) ```": 0.35999999999999993, "What is the output of the following code? ```py def add(a, b): return a + b print(add(1, 2)) print(add(b=2, a=1)) ```": 0.32, "What is the output of the following code? ```py def add_five(x): x += 5 return x print(add_five(2)) ```": 0.3111111111111111, "What is the output of the following python code?\n```python\ndef function(a):\n if a > 0:\n print('Positive')\n else:\n print('Negative')\n\nfunction(0)\n```": 0.2978723404255319, "What is the output of this code?\n```python\ndef f(x):\n x = 2 * x + 1\n return x\n\nx = 3\nz = f(x)\nprint(z)\n```": 0.2916666666666667, "What is the output of this code?\n```\nx = 10\ndef func():\n x = 20\n print(x)\nfunc()\nprint(x)\n```": 0.28571428571428575, "What is the output of the following code?\n```python\ndef func(x):\n return x + 1\n\ndef main():\n x = 1\n y = func(x)\n print(y)\n\nmain()\n```": 0.2857142857142857, "What does the following python code do?\n```python def sum_divisible_by_three(lst):\n\treturn sum(x for x in lst if x % 3 == 0)\n ```": 0.2857142857142857, "What is the output of the following code?\n```python\ndef foo():\n x = 1\n def bar():\n x = 2\n return x\n return bar()\nprint(foo())\n```": 0.2553191489361702, "I have the following code: ```python def get_max_value(list): max_value = list[0] for i in range(1, len(list)): if list[i] > max_value: max_value = list[i] return max_value ``` What does the function do?": 0.25396825396825395}, "avg_similarity_score": 0.09618258181609862} -{"instruction": "What is the output of the following code? ```py def a(): print(\"a\") b = a def c(): print(\"c\") b() ```", "input": "", "output": "The output of the code is: ```py a ``` The first line of code defines the function a(). The second line of code defines the variable b to equal the function a(). The third line of code defines the function c(). The fourth line of code calls the function b(), which is the function a().", "most_similar": {"What is the output of the following code? ```py def add(a, b): return a + b print(add(1, 2)) print(add(b=2, a=1)) ```": 0.6521739130434783, "What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.6341463414634146, "What is the output of the following code?\n```python\ndef foo():\n print(\"foo\")\n\ndef bar():\n print(\"bar\")\n\ndef main():\n foo()\n bar()\n\nmain()\n```": 0.5714285714285713, "What is the output of the following python code?\n```python\ndef function(a):\n if a > 0:\n print('Positive')\n else:\n print('Negative')\n\nfunction(0)\n```": 0.5581395348837209, "What is the output of the following code?\n```\na = 1\nb = 2\nc = 3\nif a > b:\n print(\"a is greater than b\")\nelif a > c:\n print(\"a is greater than c\")\nelse:\n print(\"a is not greater than b or c\")\n```": 0.5483870967741935, "What is the output of the following code? ```py def add_five(x): x += 5 return x print(add_five(2)) ```": 0.5365853658536585, "What is the output of the following Python code? ```py def f(x): return x + 1 def g(x): return x * 2 print(g(f(3))) ```": 0.5217391304347826, "What is the output of the following code?\n```python\ndef foo():\n x = 1\n def bar():\n x = 2\n return x\n return bar()\nprint(foo())\n```": 0.5116279069767442, "What is the output of the following code?\n```python\ndef func(x):\n return x + 1\n\ndef main():\n x = 1\n y = func(x)\n print(y)\n\nmain()\n```": 0.48888888888888893, "What is the output of this code?\n```\nx = 10\ndef func():\n x = 20\n print(x)\nfunc()\nprint(x)\n```": 0.4736842105263158}, "avg_similarity_score": 0.1510179552427934} -{"instruction": "How to make this code work? ```py def foo(): print('foo') def bar(function): function() bar(foo) ```", "input": "", "output": "The foo() function will be called after the bar() function is called. To fix the code, move the bar(foo) function call to the end of the code: ```py def foo(): print('foo') def bar(function): function() bar(foo) foo() ```", "most_similar": {"What is the output of the following code?\n```python\ndef foo():\n print(\"foo\")\n\ndef bar():\n print(\"bar\")\n\ndef main():\n foo()\n bar()\n\nmain()\n```": 0.46153846153846156, "What is the output of the following code?\n```python\ndef foo():\n x = 1\n def bar():\n x = 2\n return x\n return bar()\nprint(foo())\n```": 0.35, "How to make a python program that will print the following pattern?\n```\n*\n**\n***\n****\n*****\n```": 0.27586206896551724, "What is the output of the following code? ```py def a(): print(\"a\") b = a def c(): print(\"c\") b() ```": 0.27027027027027023, "What is the output of this code?\n```\nx = 10\ndef func():\n x = 20\n print(x)\nfunc()\nprint(x)\n```": 0.22857142857142856, "What is the output of the following code? ```py def add_five(x): x += 5 return x print(add_five(2)) ```": 0.21052631578947367, "What is the output of the following python code?\n```python\ndef function(a):\n if a > 0:\n print('Positive')\n else:\n print('Negative')\n\nfunction(0)\n```": 0.19999999999999998, "What is the output of this code?\n```python\ndef f(x):\n x = 2 * x + 1\n return x\n\nx = 3\nz = f(x)\nprint(z)\n```": 0.19512195121951217, "What are the drawbacks of using this python code? ``` py def get_random_index(my_list): return random.randint(0, len(my_list)-1) ```": 0.19512195121951217, "Add comments in the given function to make the code more readable for humans.": 0.1935483870967742}, "avg_similarity_score": 0.06281731358822124} -{"instruction": "If we have a string \"Hello, world!\", what will be the output of this code? ```py def echo(text): print(text) echo(\"Hello, world!\") ```", "input": "", "output": "The output of the code is: ```py Hello, world! ``` The code defines the function echo(), which takes one parameter called text. The echo() function prints the value of the text parameter. The code then calls the echo() function with the string \"Hello, world!\" as an argument.", "most_similar": {"What is the output of this code?\n```\nx = 10\ndef func():\n x = 20\n print(x)\nfunc()\nprint(x)\n```": 0.380952380952381, "What is the python code to print hello world?": 0.36363636363636365, "What is the output of the following code? ```py def a(): print(\"a\") b = a def c(): print(\"c\") b() ```": 0.3636363636363636, "What is the output of the following code? ```py def add_five(x): x += 5 return x print(add_five(2)) ```": 0.35555555555555557, "Write a python code snippet to print the following text.\nHello World!": 0.3333333333333333, "What is the output of this code?\n```python\ndef f(x):\n x = 2 * x + 1\n return x\n\nx = 3\nz = f(x)\nprint(z)\n```": 0.3333333333333333, "What is the output of the following Python code? ```py def f(x): return x + 1 def g(x): return x * 2 print(g(f(3))) ```": 0.32, "What is the output of the following code? ```py def add(a, b): return a + b print(add(1, 2)) print(add(b=2, a=1)) ```": 0.32, "What is the output of the following code?\n```python\ndef foo():\n print(\"foo\")\n\ndef bar():\n print(\"bar\")\n\ndef main():\n foo()\n bar()\n\nmain()\n```": 0.30434782608695654, "What is the output of the following code?\n```python\ndef foo():\n x = 1\n def bar():\n x = 2\n return x\n return bar()\nprint(foo())\n```": 0.2978723404255319}, "avg_similarity_score": 0.11716947836085352} -{"instruction": "Given a C# program that contains an error, how do you compile the program and show the error?", "input": "", "output": "You can compile a C# program and show the error by running the following command: ```csc Program.cs```", "most_similar": {"write a c++ program that calculates the perimeter of a square": 0.3448275862068966, "Write a C# program to find the sum of all the elements of an array.": 0.303030303030303, "Write a simple C# program that prints \"Hello, World!\".": 0.2962962962962963, "Write a simple C++ program that prints \"Hello, World!\".": 0.2962962962962963, "You are given a list of numbers. You need to find the median of the list.": 0.29411764705882354, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.28571428571428575, "Write a function that takes an array of numbers and returns the largest number in the array.": 0.28571428571428575, "Write a Python function that returns True if the specified list and the specified value are not empty.": 0.2777777777777778, "Given a list of numbers, find the sum of the numbers.": 0.27586206896551724, "How do you count the number of items in a list?": 0.27586206896551724}, "avg_similarity_score": 0.14861680318398024} -{"instruction": "What is the output of the following code? ```py a = 5 b = 15 print(\"a / b is\", a / b) print(\"a % b is\", a % b) print(\"a // b is\", a // b) ```", "input": "", "output": "The output of the code is: ```py a / b is 0 a % b is 5 a // b is 0 ``` The code sets the variables a and b to the values 5 and 15, respectively. The first print statement prints the value of a divided by b, which is 0. The second print statement prints the value of a modulo b, which is 5. The third print statement prints the value of a divided by b, which is 0.", "most_similar": {"What is the output of the following code? ```py def a(): print(\"a\") b = a def c(): print(\"c\") b() ```": 0.6274509803921569, "What is the output of the following code? ```py def add(a, b): return a + b print(add(1, 2)) print(add(b=2, a=1)) ```": 0.5964912280701755, "What is the output of the following code?\n```\na = 1\nb = 2\nc = 3\nif a > b:\n print(\"a is greater than b\")\nelif a > c:\n print(\"a is greater than c\")\nelse:\n print(\"a is not greater than b or c\")\n```": 0.5753424657534247, "What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.5, "What is the output of the following python code?\n```python\ndef function(a):\n if a > 0:\n print('Positive')\n else:\n print('Negative')\n\nfunction(0)\n```": 0.4444444444444444, "What is the output of the following code? ```py def add_five(x): x += 5 return x print(add_five(2)) ```": 0.4230769230769231, "What is the output of the following code?\n```python\ndef foo():\n print(\"foo\")\n\ndef bar():\n print(\"bar\")\n\ndef main():\n foo()\n bar()\n\nmain()\n```": 0.3773584905660377, "What is the output of the following Python code? ```py def f(x): return x + 1 def g(x): return x * 2 print(g(f(3))) ```": 0.3508771929824561, "Find the bug in the following code piece: a = 1 while a == 1: b = input(\"what's your name ?\") print(\"Hi \",b, \" this is infinity loop !\")": 0.3508771929824561, "What is the output of the following code?\n```python\ndef foo():\n x = 1\n def bar():\n x = 2\n return x\n return bar()\nprint(foo())\n```": 0.33333333333333337}, "avg_similarity_score": 0.13438200426139976} -{"instruction": "What is the output of the following code? ```py def print_odds(n): for i in range(n): if i % 2 == 0: print(i) print_odds(10) ```", "input": "", "output": "The output of the code is: ```py 0 2 4 6 8 ``` The code defines the function print_odds(), which takes one argument called n. The function prints all of the numbers from 0 to n, excluding the even numbers. The function is then called with the argument 10.", "most_similar": {"What is the output of the following python code?\n```python\ndef function(a):\n if a > 0:\n print('Positive')\n else:\n print('Negative')\n\nfunction(0)\n```": 0.52, "What is the output of the following code? ```py def a(): print(\"a\") b = a def c(): print(\"c\") b() ```": 0.5106382978723405, "What is the output of the following code? ```py def add_five(x): x += 5 return x print(add_five(2)) ```": 0.5, "What is the output of the following code? ```py def add(a, b): return a + b print(add(1, 2)) print(add(b=2, a=1)) ```": 0.49056603773584906, "What is the output of the following Python code? ```py def f(x): return x + 1 def g(x): return x * 2 print(g(f(3))) ```": 0.4528301886792453, "What is the output of the following code?\n```python\ndef foo():\n print(\"foo\")\n\ndef bar():\n print(\"bar\")\n\ndef main():\n foo()\n bar()\n\nmain()\n```": 0.44897959183673464, "What is the output of the following code?\n```python\ndef foo():\n x = 1\n def bar():\n x = 2\n return x\n return bar()\nprint(foo())\n```": 0.44000000000000006, "What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.4166666666666667, "What is the output of the following code? ```py a = 5 b = 15 print(\"a / b is\", a / b) print(\"a % b is\", a % b) print(\"a // b is\", a // b) ```": 0.41379310344827586, "What is the output of this code?\n```\nx = 10\ndef func():\n x = 20\n print(x)\nfunc()\nprint(x)\n```": 0.4}, "avg_similarity_score": 0.12586437616717236} -{"instruction": "What will be the output of the following code? ```py a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] b = a[2:8:2] c = a[:8:2] d = a[2:] e = a[:8] f = a[::] g = a[2:8:3] h = a[2:8:2] print(b) print(c) print(d) print(e) print(f) print(g) print(h) ```", "input": "", "output": "The output of the code is: ```py [3, 5, 7] [1, 3, 5, 7] [3, 4, 5, 6, 7, 8, 9, 10] [1, 2, 3, 4, 5, 6, 7, 8] [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] [3, 6, 9] [3, 5, 7] ``` The code sets the variable a to the list [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]. The code then sets several variables to slices of the list a. For example, the code sets the variable b to the values [3, 5, 7], which are the values in the list a from index 2 to index 8 in steps of 2. The variable c is set to the values [1, 3, 5, 7], which are the values in the list a from index 0 to index 8 in steps of 2. The variable d is set to the values [3, 4, 5, 6, 7, 8, 9, 10], which are the values in the list a from index 2 to the end of the list in steps of 1. The variable e is set to the values [1, 2, 3, 4, 5, 6, 7, 8], which are the values in the list a from index 0 to index 8 in steps of 1. The variable f is set to the values [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], which are the values in the list a from index 0 to the end of the list in steps of 1. The variable g is set to the values [3, 6, 9], which are the values in the list a from index 2 to index 8 in steps of 3. The variable h is set to the values [3, 5, 7], which are the values in the list a from index 2 to index 8 in steps of 2.", "most_similar": {"What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.4578313253012048, "What is the output of the following code? ```py a = 5 b = 15 print(\"a / b is\", a / b) print(\"a % b is\", a % b) print(\"a // b is\", a // b) ```": 0.3870967741935484, "What is the output of the following code?\n```\na = 1\nb = 2\nc = 3\nif a > b:\n print(\"a is greater than b\")\nelif a > c:\n print(\"a is greater than c\")\nelse:\n print(\"a is not greater than b or c\")\n```": 0.36538461538461536, "What is the output of the following code?\n```\na = 1\nb = 2\nc = 3\nd = 4\ne = 5\nf = 6\ng = 7\nh = 8\ni = 9\nj = 10\nk = 11\nl = 12\nm = 13\nn = 14\no = 15\np = 16\nq = 17\nr = 18\ns = 19\nt = 20\nu = 21\nv = 22\nw = 23\nx = 24\ny = 25\nz = 26\n\nprint(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z)\n```": 0.3489932885906041, "What is the output of the following code? ```py def a(): print(\"a\") b = a def c(): print(\"c\") b() ```": 0.3414634146341463, "What is the output of the following code? ```py def add(a, b): return a + b print(add(1, 2)) print(add(b=2, a=1)) ```": 0.3181818181818182, "What is the result of the following C program? ```c #include \nint main()\n{\n int a = 2;\n int b = 3;\n int c = 4;\n int d = 5;\n printf(\"%d\\n\", a++ + ++b + c++ + ++d);\n printf(\"%d %d %d %d\\n\", a, b, c, d);\n return 0;\n}\n ```": 0.3148148148148148, "What is the output of the following Python code? ```py def f(x): return x + 1 def g(x): return x * 2 print(g(f(3))) ```": 0.29545454545454547, "I need to sum all the values in the following list: `[1,2,3,4,5,6,7,8,9]`.": 0.2926829268292683, "How to make a python program that will print the following pattern?\n```\n1\n2 3\n4 5 6\n7 8 9 10\n11 12 13 14 15\n```": 0.29213483146067415}, "avg_similarity_score": 0.0858438070889923} -{"instruction": "What is the purpose of a hash table?", "input": "", "output": "A hash table is a data structure that stores key-value pairs. The table uses a hash function to compute an index into an array of buckets or slots, from which the desired value can be found.", "most_similar": {"What is a Dockerfile?": 0.5, "What is a cron job ?": 0.4615384615384615, "What is a Docker container?": 0.4615384615384615, "What is a list comprehension?": 0.4615384615384615, "What is a persistent volume ?": 0.4615384615384615, "What is a stateful set ?": 0.4615384615384615, "What is the difference between a relative and absolute path?": 0.4444444444444445, "What is the difference between a class and an object?": 0.4444444444444445, "What is the difference between an ingress and a persistent volume?": 0.4210526315789474, "What is the difference between a static and a dynamic method?": 0.4210526315789474}, "avg_similarity_score": 0.15439401915380657} -{"instruction": "What are the major differences between the Array and List data structures?", "input": "", "output": "The major differences between the Array and List data structures are as follows:\n\n1. An array is a static data structure while a list is a dynamic data structure.\n2. An array is a continuous memory location while a list is a linked list.\n3. An array can be declared with a specific size while a list can grow and shrink dynamically.", "most_similar": {"What is the difference between `git pull` and `git fetch` ?": 0.3636363636363636, "What is the difference between a relative and absolute path?": 0.3636363636363636, "What is the difference between a class and an object?": 0.3636363636363636, "What is the difference between an ingress and a persistent volume?": 0.34782608695652173, "What is the difference between a static and a dynamic method?": 0.34782608695652173, "What is the difference between a pod and a horizontal pod autoscaler?": 0.3333333333333333, "What is the difference between a replica set and a stateful set?": 0.3333333333333333, "What is the difference between a for loop and a while loop?": 0.3333333333333333, "What is the difference between a deep copy and a shallow copy?": 0.3333333333333333, "What is the difference between a list and a tuple in Python?": 0.3333333333333333}, "avg_similarity_score": 0.10525513117402706} -{"instruction": "What is the difference between a binary search tree and a red-black tree?", "input": "", "output": "A binary search tree is a binary tree where every node's value is greater than the values in all the nodes in that node's left subtree and less than the values in all the nodes in that node's right subtree. A red-black tree is a binary search tree where every node is marked as either red or black.", "most_similar": {"What is the difference between a static and a dynamic method?": 0.64, "What is the difference between a for loop and a while loop?": 0.6153846153846153, "What is the difference between a list and a tuple in Python?": 0.6153846153846153, "What is the difference between a deep copy and a shallow copy?": 0.6153846153846153, "What is the difference between a pod and a horizontal pod autoscaler?": 0.6153846153846153, "What is the difference between a replica set and a stateful set?": 0.6153846153846153, "What is the difference between a class and an object?": 0.5833333333333334, "What is the difference between a relative and absolute path?": 0.5833333333333334, "What is the difference between an ingress and a persistent volume?": 0.56, "What is the difference between `git pull` and `git fetch` ?": 0.5}, "avg_similarity_score": 0.13338303404336704} -{"instruction": "Write a C# program that creates a new string from a given string by removing all vowels.", "input": "", "output": "using System;\nclass Program\n{\n static void Main(string[] args)\n {\n string input = \"This is a test.\";\n Console.WriteLine(\"Original string: \" + input);\n string output = RemoveVowels(input);\n Console.WriteLine(\"Without vowels: \" + output);\n }\n static string RemoveVowels(string input)\n {\n char[] vowels = { 'a', 'e', 'i', 'o', 'u' };\n return new string(input.ToCharArray()\n .Where(c => !vowels.Contains(c))\n .ToArray());\n }\n}", "most_similar": {"Write a function that reverses a given string.": 0.48, "Write a Python program to find the longest pallindrome substring from a given string.": 0.45161290322580644, "Write a Python program to get a string from a given string where all occurrences of its first char have been changed to '$', except the first char itself.": 0.4444444444444445, "write a c++ program that calculates the perimeter of a square": 0.42857142857142855, "Write a Python program to find the first pallindromic string from a given string where the length is three or more.": 0.42105263157894735, "Write a function that takes a string as input and reverse only the vowels of a string.": 0.4117647058823529, "Write a python function that returns the number of words in a given string.": 0.3870967741935484, "Write a python function that returns a value from a list, selected at random.": 0.3870967741935484, "Write a simple C++ program that prints \"Hello, World!\".": 0.3846153846153846, "Write a simple C# program that prints \"Hello, World!\".": 0.3846153846153846}, "avg_similarity_score": 0.14691689024704022} -{"instruction": "Write a C program that shows the use of the function strtok().", "input": "", "output": "#include \n#include \nint main()\n{\n char str[80], *pch;\n char *delim = \".,:; \";\n int i = 0;\n printf(\"Enter the string: \");\n gets(str);\n pch = strtok(str, delim);\n while (pch != NULL)\n {\n printf(\"%s\\n\", pch);\n pch = strtok(NULL, delim);\n i++;\n }\n printf(\"Number of words: %d\\n\", i);\n return 0;\n}", "most_similar": {"write a c++ program that calculates the perimeter of a square": 0.6086956521739131, "Write a C# program to find the sum of all the elements of an array.": 0.5185185185185186, "Write a simple C++ program that prints \"Hello, World!\".": 0.4761904761904762, "Write a simple C# program that prints \"Hello, World!\".": 0.4761904761904762, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.4615384615384615, "Write a python function that returns the sum of the elements of a list.": 0.4615384615384615, "Write a program to find the maximum of three numbers.": 0.45454545454545453, "Write a function that returns the sum of two numbers.": 0.45454545454545453, "Write a Python program to find the frequency of the words from the sentence given.": 0.4444444444444445, "Write a Python program to find the sum of the positive integers of a given range.": 0.42857142857142855}, "avg_similarity_score": 0.19276814423915048} -{"instruction": "Write a C program that takes a character from user and displays the ASCII value of the character.", "input": "", "output": "#include \nint main()\n{\n char c;\n int i;\n printf(\"Enter a character: \");\n scanf(\"%c\", &c);\n i = (int)c;\n printf(\"The ASCII value of %c is %d.\", c, i);\n return 0;\n}", "most_similar": {"Write a C program that shows the use of the function strtok().": 0.5333333333333333, "Write a function that takes a string and returns the number of vowels in the string.": 0.5294117647058824, "Write a python function that adds a new key to a dictionary and returns the value of the key.": 0.4864864864864865, "write a c++ program that calculates the perimeter of a square": 0.4827586206896552, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.4615384615384615, "Write a Python function that takes a number as input and returns the square of that number.": 0.45714285714285713, "Write a function that takes a string as input and reverse only the vowels of a string.": 0.45714285714285713, "Write a C# program to find the sum of all the elements of an array.": 0.42424242424242425, "Please write a Rust function that takes a u64 input and returns the largest prime number less than that value.": 0.4210526315789474, "Write a Python function that takes a list and returns a new list with unique elements of the first list.": 0.4210526315789474}, "avg_similarity_score": 0.1858782952291731} -{"instruction": "Write a program in C to insert an element at the beginning of the linked list.", "input": "", "output": "#include \n#include \n#include \nstruct node\n{\n int data;\n struct node *link;\n};\nstruct node *start = NULL;\nvoid insert_at_end();\nvoid display();\nint main()\n{\n int choice;\n while (1)\n {\n printf(\"1.Insert an element at the beginning of the linked list\\n\");\n printf(\"2.Display\\n\");\n printf(\"3.Exit\\n\");\n printf(\"Enter your choice: \");\n scanf(\"%d\", &choice);\n switch (choice)\n {\n case 1:\n insert_at_beginning();\n break;\n case 2:\n display();\n break;\n case 3:\n exit(1);\n default:\n printf(\"Wrong choice.\\n\");\n }\n }\n return 0;\n}\nvoid insert_at_beginning()\n{\n struct node *temp, *ptr;\n int item;\n temp = (struct node *)malloc(sizeof(struct node));\n if (temp == NULL)\n {\n printf(\"Out of memory.\\n\");\n return;\n }\n printf(\"Enter value: \");\n scanf(\"%d\", &item);\n temp->data = item;\n temp->link = NULL;\n if (start == NULL)\n {\n start = temp;\n }\n else\n {\n ptr = start;\n start = temp;\n start->link = ptr;\n }\n}\nvoid display()\n{\n struct node *ptr;\n if (start == NULL)\n {\n printf(\"List is empty.\\n\");\n return;\n }\n ptr = start;\n while (ptr != NULL)\n {\n printf(\"%d\\n\", ptr->data);\n ptr = ptr->link;\n }\n}", "most_similar": {"Write a Python program to find the average of a list using for loop.": 0.4666666666666667, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.4666666666666667, "Write a program to find the maximum of three numbers.": 0.4615384615384615, "Write a C# program to find the sum of all the elements of an array.": 0.45161290322580644, "Write a Python program to find the frequency of the words from the sentence given.": 0.45161290322580644, "Write a program to find the smallest number in a list.": 0.4444444444444444, "Write a Python program to find the sum of the positive integers of a given range.": 0.4375, "Write a Python program to find the longest common prefix of a given list of strings.": 0.4375, "Write a program to find the pearson correlation coefficient of two lists.": 0.42857142857142855, "Write a script to output the mean of a list of integers.": 0.42857142857142855}, "avg_similarity_score": 0.19546553129285135} -{"instruction": "What does the HTML tag `

` do?", "input": "", "output": "The HTML

element represents a paragraph of text. Paragraphs are usually represented in visual media as blocks of text separated from adjacent blocks by blank lines and/or first-line indentation, but HTML paragraphs can be any structural grouping of related content, such as images or form fields.", "most_similar": {"What is the purpose of a hash table?": 0.26666666666666666, "What is the python code to print hello world?": 0.25, "I have this python code: ```python def make_dict(df): d = dict(zip(df.columns, df.values[0])) return d ``` What does the function do?": 0.25, "What does the following python code do?\n```python def sum_divisible_by_three(lst):\n\treturn sum(x for x in lst if x % 3 == 0)\n ```": 0.25, "What is the difference between a class and an object?": 0.23529411764705882, "What is the difference between `git pull` and `git fetch` ?": 0.23529411764705882, "What is the difference between a relative and absolute path?": 0.23529411764705882, "What is the difference between an ingress and a persistent volume?": 0.2222222222222222, "What is the difference between a static and a dynamic method?": 0.2222222222222222, "Identify the pos tag of the word in the given sentence.": 0.2222222222222222}, "avg_similarity_score": 0.08053140223215564} -{"instruction": "How can I rotate an element in CSS?", "input": "", "output": "In CSS, transform: rotate(15deg); will rotate the element by 15 degrees. However, it's important to note that this will not work in IE8 and below. You will need a JavaScript or jQuery solution for IE8 and below.", "most_similar": {"How can I make a button in HTML?": 0.5, "How can I find the index of an item in an array in c++?": 0.45454545454545453, "How can I sort a list of integers in Rust?": 0.4444444444444445, "How can I get the current date and time in Python?": 0.4210526315789474, "How can I get the first 1000 prime numbers in Python?": 0.4210526315789474, "How can I find the first repeated word in a string?": 0.4210526315789474, "How can I iterate through each item in an array in a random order using c++?": 0.4166666666666667, "How can I get the number of days between two dates in python?": 0.380952380952381, "How do I print a list in Python?": 0.375, "How can I find the maximum and minimum value in a list using Python?": 0.36363636363636365}, "avg_similarity_score": 0.07650405317840725} -{"instruction": "What does `if` do?", "input": "", "output": "The if statement in Python is used to test whether a given statement is true or false. It allows you to make decisions in your Python program based on the values and conditions of the variables.", "most_similar": {"What does the HTML tag `

` do?": 0.5454545454545454, "What is Kubernetes ?": 0.28571428571428575, "What is a Dockerfile?": 0.25, "What is a list comprehension?": 0.22222222222222224, "What is a persistent volume ?": 0.22222222222222224, "What is a stateful set ?": 0.22222222222222224, "What is a Docker container?": 0.22222222222222224, "What is a cron job ?": 0.22222222222222224, "I have the following code in python: ```python b = sorted(a, key=lambda x: (x[0], x[1]), reverse=True) ``` What does it do?": 0.21428571428571427, "I have this python code: ```python def make_dict(df): d = dict(zip(df.columns, df.values[0])) return d ``` What does the function do?": 0.20689655172413793}, "avg_similarity_score": 0.041060764999284176} -{"instruction": "What does the CSS style `float: left;` do?", "input": "", "output": "If the float property is set to the left value, the selected element will be placed to the left of its container.", "most_similar": {"What does the HTML tag `

` do?": 0.5333333333333333, "What does `if` do?": 0.5, "What is the purpose of a hash table?": 0.25, "I have this python code: ```python def make_dict(df): d = dict(zip(df.columns, df.values[0])) return d ``` What does the function do?": 0.24242424242424243, "What does the following python code do?\n```python def sum_divisible_by_three(lst):\n\treturn sum(x for x in lst if x % 3 == 0)\n ```": 0.24242424242424243, "What is the python code to print hello world?": 0.23529411764705882, "What is the difference between a class and an object?": 0.22222222222222224, "What is the difference between a relative and absolute path?": 0.22222222222222224, "What is the difference between `git pull` and `git fetch` ?": 0.22222222222222224, "What is the difference between a static and a dynamic method?": 0.2105263157894737}, "avg_similarity_score": 0.07779722083198042} -{"instruction": "Can you give me an example of a computer vision task?", "input": "", "output": "Yes! Here are some computer vision tasks:\n- Image classification: Classify images according to their content.\n- Object detection: Localize and identify multiple objects in a single image.\n- Image segmentation: Identify and segment different parts of an image.\n- Scene understanding: Understand the contextual relationships between objects in a scene.", "most_similar": {"Can you tell me how to sort a dictionary by value in Python?": 0.33333333333333337, "How do you count the number of items in a list?": 0.2727272727272727, "How do you find the length of a string in Python?": 0.2727272727272727, "How do you output all the contents of a list in Python?": 0.2608695652173913, "How do you find the index of an item in a list?": 0.2608695652173913, "Could you please write me Rust code that takes ownership of an array of integers and sorts them in ascending order?": 0.25, "How can I convert a list of strings to a list of integers?": 0.24999999999999994, "How do you find the standard deviation of all items in a list in Python?": 0.23076923076923075, "How do you remove an item at a given index from a list using Python?": 0.23076923076923075, "How can I iterate through each item in an array in a random order using c++?": 0.2222222222222222}, "avg_similarity_score": 0.09058590536924419} -{"instruction": "What does the function `print()` do?", "input": "", "output": "The print function prints the value of the given argument(s).", "most_similar": {"What does the HTML tag `

` do?": 0.6153846153846153, "What does `if` do?": 0.6, "What does the CSS style `float: left;` do?": 0.5714285714285715, "What is the python code to print hello world?": 0.4, "I have this python code: ```python def make_dict(df): d = dict(zip(df.columns, df.values[0])) return d ``` What does the function do?": 0.3225806451612903, "What is the purpose of a hash table?": 0.28571428571428575, "What is the output of the following python code?\n```python\ndef function(a):\n if a > 0:\n print('Positive')\n else:\n print('Negative')\n\nfunction(0)\n```": 0.27586206896551724, "What does the following python code do?\n```python def sum_divisible_by_three(lst):\n\treturn sum(x for x in lst if x % 3 == 0)\n ```": 0.25806451612903225, "What is the output of this code?\n```\nx = 10\ndef func():\n x = 20\n print(x)\nfunc()\nprint(x)\n```": 0.25, "What is the difference between `git pull` and `git fetch` ?": 0.25}, "avg_similarity_score": 0.09591273945277633} -{"instruction": "Write a python program to check if the number is prime.", "input": "", "output": "This is the code to check if a number is prime in Python: ```python def is_prime(num): if num == 1: return False for i in range(2, num): if num % i == 0: return False return True print(is_prime(9)) # Prints False ```", "most_similar": {"Write a Python function to check if a given number is a prime number or not.": 0.6666666666666666, "Write a program to find the n-th ugly number.": 0.5714285714285713, "Write a Python program to find the first Fibonacci number greater than four million.": 0.56, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.56, "How to check quickly if a number is prime in C?": 0.5454545454545454, "Write a Python function to calculate the factorial of a number.": 0.5454545454545454, "Write a program to find the smallest number in a list.": 0.5454545454545454, "Write a Python program to find the maximum and minimum number from a given list.": 0.5384615384615385, "Write a Python program to find the first Fibonacci number with the first 1000 digits.": 0.5384615384615385, "Write a Python function to find the largest number in a dictionary.": 0.5217391304347826}, "avg_similarity_score": 0.22184276376705886} -{"instruction": "Sort the following list of tuples by their second item and then by their first item: ```[(4, 0), (0, 3), (0, 2), (2, 6), (3, 4), (5, 2), (1, 6)]```", "input": "", "output": "Here is the code that sorts the list of tuples by their second item and then by their first item: ```python x = [(4, 0), (0, 3), (0, 2), (2, 6), (3, 4), (5, 2), (1, 6)] x.sort(key=lambda x: (x[1], x[0])) print(x) # Prints [(0, 2), (0, 3), (4, 0), (3, 4), (2, 6), (5, 2), (1, 6)] ```", "most_similar": {"I need to sum all the values in the following list: `[1,2,3,4,5,6,7,8,9]`.": 0.32, "Convert this list into a list of sets: [[1, 2, 3], [4, 5, 6], [7, 8, 9]]": 0.2978723404255319, "How to make a python program that will print the following pattern?\n```\n1\n1 2\n1 2 3\n1 2 3 4\n1 2 3 4 5\n```": 0.28070175438596495, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.28, "What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.27450980392156865, "How to make a python program that will print the following pattern?\n```\n1\n2 3\n4 5 6\n7 8 9 10\n11 12 13 14 15\n```": 0.2456140350877193, "How to sort the list by second element in each sublist": 0.2439024390243902, "What is the value of the following expression?\n10 + 2 * 3 / 4": 0.23809523809523808, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.1818181818181818, "What does the following python code do?\n```python def sum_divisible_by_three(lst):\n\treturn sum(x for x in lst if x % 3 == 0)\n ```": 0.1818181818181818}, "avg_similarity_score": 0.07975369712100049} -{"instruction": "What is the output of the code below?\n\n```python import math print(math.sqrt(16))```", "input": "", "output": "The output is 4.", "most_similar": {"What is the output of the following code?\n```python\ndef foo():\n print(\"foo\")\n\ndef bar():\n print(\"bar\")\n\ndef main():\n foo()\n bar()\n\nmain()\n```": 0.4864864864864865, "What is the output of the following python code?\n```python\ndef function(a):\n if a > 0:\n print('Positive')\n else:\n print('Negative')\n\nfunction(0)\n```": 0.47368421052631576, "What is the output of the following code?\n```python\ndef foo():\n x = 1\n def bar():\n x = 2\n return x\n return bar()\nprint(foo())\n```": 0.47368421052631576, "What is the output of the following code? ```py def a(): print(\"a\") b = a def c(): print(\"c\") b() ```": 0.4571428571428572, "What is the output of the following code?\n```python\ndef func(x):\n return x + 1\n\ndef main():\n x = 1\n y = func(x)\n print(y)\n\nmain()\n```": 0.45, "What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.4444444444444444, "What is the output of the following code? ```py def add_five(x): x += 5 return x print(add_five(2)) ```": 0.4444444444444444, "What is the output of this code?\n```\nx = 10\ndef func():\n x = 20\n print(x)\nfunc()\nprint(x)\n```": 0.42424242424242425, "What is the python code to print hello world?": 0.4166666666666667, "What is the output of this code?\n```python\ndef f(x):\n x = 2 * x + 1\n return x\n\nx = 3\nz = f(x)\nprint(z)\n```": 0.4102564102564102}, "avg_similarity_score": 0.1297887068447699} -{"instruction": "Write a function to check if a number is divisible by 7 or 5 and not 3.", "input": "", "output": "Here is the code to check if a number is divisible by 7 or 5 and not 3: ```python def divisible_7_5_not_3(num): if (num % 7 == 0 or num % 5 == 0) and num % 3 != 0: return True else: return False ```", "most_similar": {"Write a Python function to check if a given number is a prime number or not.": 0.6666666666666667, "Write a Python function to check whether a passed string is palindrome or not.": 0.5806451612903226, "Write a Python function to check if a number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence.": 0.5238095238095238, "Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.5106382978723405, "Write a python program to check if the number is prime.": 0.5, "Write a Python function to check if a given number is a Ugly number or not. An Ugly number is a number whose prime factors are only 2, 3 or 5.": 0.5, "Write a Python function to check if a given number is a Keith number or not. A Keith number is a number which is one less than a perfect square.": 0.46808510638297873, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.45454545454545453, "Write a Python function to check if a given number is a Heptagonal number or not. A Heptagonal number is a number that can be expressed as n(5n-3)/2 where n is an integer.": 0.45283018867924524, "Write a Python function to check if a given number is a circular prime or not. A circular prime is a prime number that remains a prime when the digits are rotated.": 0.4489795918367347}, "avg_similarity_score": 0.18017864745062934} -{"instruction": "Return the first non-repeating character in a string.", "input": "", "output": "Here is the code that returns the first non-repeating character in a string: ```python def first_not_repeating_char(string): for char in string: if string.count(char) == 1: return char return '' ```", "most_similar": {"Write a Python program to find the first non-repeated character in a string.": 0.6086956521739131, "How can I find the first repeated word in a string?": 0.5, "Write a Python function to find the first non-pallindrome string in a given list.": 0.4166666666666667, "How do I find the first and last occurrence of a substring in a string in C++?": 0.3846153846153846, "Write a Python function to find the first repeated word in a given string, ignoring case and punctuation.": 0.3703703703703704, "Write a python function that returns the number of words in a given string.": 0.34782608695652173, "Write a Python program to find the frequency of each word in a given string.": 0.33333333333333337, "How to find the maximum value in a list?": 0.3333333333333333, "Write a Python program to find the first repeated character of a given string where the index of first occurrence is smallest.": 0.3225806451612903, "How do I get the first element of a list?": 0.3157894736842105}, "avg_similarity_score": 0.13113989248595406} -{"instruction": "Write a Python program to add a key to a dictionary.", "input": "", "output": "This is the Python program to add a key to a dictionary: ```python dict = {'name': 'John', 'age': 23} dict['phone'] = 987654321 print(dict) # Prints {'name': 'John', 'age': 23, 'phone': 987654321} ```", "most_similar": {"Write a python code for a queue using a dictionary": 0.5714285714285713, "Write a python function that adds a new key to a dictionary and returns the value of the key.": 0.5333333333333333, "Write a Python function to find the largest number in a dictionary.": 0.5217391304347826, "Write python code to connect to a FTP server.": 0.5, "Write a Python program to find the sum of a non-negative integer.": 0.4999999999999999, "Write a Python program to find the Fibonacci series up to n numbers.": 0.4999999999999999, "Write a Python program to find the first non-repeated character in a string.": 0.4799999999999999, "Write a Python program to find the longest pallindrome substring from a given string.": 0.4799999999999999, "Write a Python program to find the average of a list using for loop.": 0.4799999999999999, "Write a Python program to find the most common words in a given text.": 0.4799999999999999}, "avg_similarity_score": 0.19010552444068324} -{"instruction": "What is the output of the code below?\n\n```python x = [1, 2, 3, 4, 5] x = x[1:-1] print(x)```", "input": "", "output": "The output is [2, 3, 4].", "most_similar": {"What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.6190476190476191, "What is the output of the following code?\n```python\ndef foo():\n x = 1\n def bar():\n x = 2\n return x\n return bar()\nprint(foo())\n```": 0.5909090909090909, "What is the output of the following code?\n```python\ndef func(x):\n return x + 1\n\ndef main():\n x = 1\n y = func(x)\n print(y)\n\nmain()\n```": 0.5652173913043478, "What is the output of this code?\n```\nx = 10\ndef func():\n x = 20\n print(x)\nfunc()\nprint(x)\n```": 0.5641025641025642, "What is the output of the code below?\n\n```python import math print(math.sqrt(16))```": 0.5555555555555556, "What is the output of this code?\n```python\ndef f(x):\n x = 2 * x + 1\n return x\n\nx = 3\nz = f(x)\nprint(z)\n```": 0.5333333333333333, "What is the output of the following code?\n```python\ndef f(x):\n return x * 2\n\ndef g(x):\n return f(x) + 1\n\ndef h(x):\n return g(x) * 2\n\nprint(h(2))\n```": 0.5283018867924528, "What is the output of the following code? ```py def add_five(x): x += 5 return x print(add_five(2)) ```": 0.5238095238095238, "What is the output of the following Python code? ```py def f(x): return x + 1 def g(x): return x * 2 print(g(f(3))) ```": 0.5106382978723405, "What is the value of the following expression?\n10 + 2 * 3 / 4": 0.4848484848484849}, "avg_similarity_score": 0.1280586997493398} -{"instruction": "Write a Python program to create a dictionary from a string.", "input": "", "output": "This is the Python program to create a dictionary from a string: ```python string = \"Hello, I'm a Python developer\" dict = {} for word in string.split(): if word not in dict: dict[word] = 1 else: dict[word] = dict[word] + 1 print(dict) # Prints {'Hello,': 1, \"I'm\": 1, 'a': 1, 'Python': 1, 'developer': 1} ```", "most_similar": {"Write a Python program to find the longest pallindrome substring from a given string.": 0.64, "Write a Python program to add a key to a dictionary.": 0.6363636363636364, "Write a Python program to find the first non-repeated character in a string.": 0.56, "Write a Python program to find the frequency of each word in a given string.": 0.5384615384615385, "Write a Python program to find the maximum and minimum number from a given list.": 0.5384615384615385, "Write a Python function to find the largest number in a dictionary.": 0.5217391304347826, "Write a Python program to find the first pallindromic string from a given string where the length is three or more.": 0.5, "Write a C# program that creates a new string from a given string by removing all vowels.": 0.5, "Write a Python program to find the unique common elements from two lists.": 0.4999999999999999, "Write a Python program to find the sum of a non-negative integer.": 0.4999999999999999}, "avg_similarity_score": 0.20078466785939297} -{"instruction": "Write a SQL query to find all the duplicate emails.", "input": "", "output": "SELECT Email FROM Person GROUP BY Email HAVING COUNT(*)>1", "most_similar": {"Write a program to find the n-th ugly number.": 0.5, "Write a program to find the maximum of three numbers.": 0.5, "Write a Python function to find all prime numbers up to the given number n.": 0.48, "Write a C# program to find the sum of all the elements of an array.": 0.48, "Write a program to find the maximum value in an array": 0.47619047619047616, "Write a python code to find the area of a circle.": 0.47619047619047616, "Write a Python function to find the correlation between two lists.": 0.47619047619047616, "Write a program to find the smallest number in a list.": 0.47619047619047616, "Write a python code to find the minimum value in a list.": 0.45454545454545453, "Write a program to find the pearson correlation coefficient of two lists.": 0.45454545454545453}, "avg_similarity_score": 0.17945351241832044} -{"instruction": "What is the output of this code?\n```\ndef sum(numbers):\n result = 0\n for number in numbers:\n result = result + number\n return result\n\ndef len(numbers):\n result = 0\n for number in numbers:\n result = result + 1\n return result\n\ndef avg(numbers):\n sum = sum(numbers)\n length = len(numbers)\n return sum/length\n\nprint(avg([1,2,3,4,5]))\n```", "input": "", "output": "The output of this code is: ```3.0```", "most_similar": {"What is the output of the following code?\n```python\ndef f(x):\n return x * 2\n\ndef g(x):\n return f(x) + 1\n\ndef h(x):\n return g(x) * 2\n\nprint(h(2))\n```": 0.3255813953488372, "What is the output of the following Python code? ```py def f(x): return x + 1 def g(x): return x * 2 print(g(f(3))) ```": 0.325, "What is the output of the code below?\n\n```python x = [1, 2, 3, 4, 5] x = x[1:-1] print(x)```": 0.2933333333333333, "What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.2933333333333333, "What is the output of the following code?\n```python\ndef foo():\n x = 1\n def bar():\n x = 2\n return x\n return bar()\nprint(foo())\n```": 0.2857142857142857, "What is the output of this code?\n```python\ndef f(x):\n x = 2 * x + 1\n return x\n\nx = 3\nz = f(x)\nprint(z)\n```": 0.28205128205128205, "What is the output of the following code?\n```python\ndef func(x):\n return x + 1\n\ndef main():\n x = 1\n y = func(x)\n print(y)\n\nmain()\n```": 0.27848101265822783, "What is the output of the following code? ```py def add(a, b): return a + b print(add(1, 2)) print(add(b=2, a=1)) ```": 0.27499999999999997, "What is the output of the following code? ```py def print_odds(n): for i in range(n): if i % 2 == 0: print(i) print_odds(10) ```": 0.2716049382716049, "What is the output of the following code? ```py def add_five(x): x += 5 return x print(add_five(2)) ```": 0.26666666666666666}, "avg_similarity_score": 0.08746719797396171} -{"instruction": "Find the output of this code.\n```\ndef is_prime(n):\n if n < 2:\n return False\n for i in range(2, n):\n if n % i == 0:\n return False\n return True\n\ndef prime_factorize(n):\n factors = []\n factor = 2\n while n > 1:\n if n % factor == 0:\n factors.append(factor)\n n /= factor\n elif factor == 2:\n factor = 3\n else:\n factor += 2\n return factors\n\nprint(prime_factorize(100))\n```", "input": "", "output": "The output of this code is: ```[2, 2, 5, 5]```", "most_similar": {"What is the output of the following code? ```py def print_odds(n): for i in range(n): if i % 2 == 0: print(i) print_odds(10) ```": 0.3595505617977528, "What is the output of this code?\n```\ndef sum(numbers):\n result = 0\n for number in numbers:\n result = result + number\n return result\n\ndef len(numbers):\n result = 0\n for number in numbers:\n result = result + 1\n return result\n\ndef avg(numbers):\n sum = sum(numbers)\n length = len(numbers)\n return sum/length\n\nprint(avg([1,2,3,4,5]))\n```": 0.24137931034482757, "What does the following python code do?\n```python def is_prime(num):\n\t# Return false if the number is negative\n\tif num < 0:\n\t\treturn False\n\n\t# Check if the number is prime\n\tif not is_harshad_number(num):\n\t\treturn False\n\n\t# Check if the number is truncable\n\twhile num > 0:\n\t\tr = num % 10\n\t\tnum = num // 10\n\t\tif not is_harshad_number(num):\n\t\t\treturn False\n\treturn True\n ```": 0.24, "What is the output of the following code?\n```python\ndef f(x):\n return x * 2\n\ndef g(x):\n return f(x) + 1\n\ndef h(x):\n return g(x) * 2\n\nprint(h(2))\n```": 0.23404255319148934, "What does this Python code do? ``` import random def montecarloPi(calcs): hits = 0 for i in range(calcs): x = random.random() y = random.random() if (x**2 + y**2) < 1: hits = hits + 1 return 4.0 * hits / calcs print(montecarloPi(10000)) ```": 0.23300970873786406, "What is the output of this code?\n```python\ndef f(x):\n x = 2 * x + 1\n return x\n\nx = 3\nz = f(x)\nprint(z)\n```": 0.2325581395348837, "What does this python code do? ```python import numpy as np\n\ndef get_random_vector(n):\n return np.random.rand(n)\n\ndef get_random_matrix(n, m):\n return np.random.rand(n, m)\n\ndef get_random_symmetric_matrix(n):\n A = get_random_matrix(n, n)\n return A + A.T\n\ndef get_random_positive_definite_matrix(n):\n A = get_random_symmetric_matrix(n)\n return A.dot(A.T) ```": 0.21705426356589147, "What is the output of the following code?\n```python\ndef foo():\n x = 1\n def bar():\n x = 2\n return x\n return bar()\nprint(foo())\n```": 0.21176470588235294, "What is the output of the following python code?\n```python\ndef function(a):\n if a > 0:\n print('Positive')\n else:\n print('Negative')\n\nfunction(0)\n```": 0.21176470588235294, "What is the output of the following code?\n```python\ndef func(x):\n return x + 1\n\ndef main():\n x = 1\n y = func(x)\n print(y)\n\nmain()\n```": 0.20689655172413796}, "avg_similarity_score": 0.07560824923258971} -{"instruction": "Find the output of this code.\n```\ndef my_filter(x, y):\n return x\n\nprint(my_filter(1, 2))\n```", "input": "", "output": "The output of this code is: ```1```", "most_similar": {"What is the output of the following code? ```py def add_five(x): x += 5 return x print(add_five(2)) ```": 0.5128205128205129, "What is the output of this code?\n```\nx = 10\ndef func():\n x = 20\n print(x)\nfunc()\nprint(x)\n```": 0.5, "What is the output of this code?\n```python\ndef f(x):\n x = 2 * x + 1\n return x\n\nx = 3\nz = f(x)\nprint(z)\n```": 0.4761904761904762, "What is the output of the following Python code? ```py def f(x): return x + 1 def g(x): return x * 2 print(g(f(3))) ```": 0.4545454545454546, "What is the output of the following code?\n```python\ndef foo():\n x = 1\n def bar():\n x = 2\n return x\n return bar()\nprint(foo())\n```": 0.4390243902439025, "What are the drawbacks of using this python code? ``` py def get_random_index(my_list): return random.randint(0, len(my_list)-1) ```": 0.42857142857142855, "What is the output of the following code?\n```python\ndef func(x):\n return x + 1\n\ndef main():\n x = 1\n y = func(x)\n print(y)\n\nmain()\n```": 0.41860465116279066, "What is the output of the following code? ```py def add(a, b): return a + b print(add(1, 2)) print(add(b=2, a=1)) ```": 0.40909090909090906, "What is the output of the following code?\n```python\ndef f(x):\n return x * 2\n\ndef g(x):\n return f(x) + 1\n\ndef h(x):\n return g(x) * 2\n\nprint(h(2))\n```": 0.39999999999999997, "What is the output of the code below?\n\n```python x = [1, 2, 3, 4, 5] x = x[1:-1] print(x)```": 0.358974358974359}, "avg_similarity_score": 0.10904663678938638} -{"instruction": "What is the output of this code?\n```\nfor i in range(10):\n print(i)\n```", "input": "", "output": "The output of this code is: ```0 1 2 3 4 5 6 7 8 9```", "most_similar": {"What is the output of the following code? ```py def print_odds(n): for i in range(n): if i % 2 == 0: print(i) print_odds(10) ```": 0.5853658536585367, "What is the output of this code?\n```\nx = 10\ndef func():\n x = 20\n print(x)\nfunc()\nprint(x)\n```": 0.5625000000000001, "What is the output of the code below?\n\n```python import math print(math.sqrt(16))```": 0.4827586206896552, "What is the python code to print hello world?": 0.43478260869565216, "What is the output of this code?\n```python\ndef f(x):\n x = 2 * x + 1\n return x\n\nx = 3\nz = f(x)\nprint(z)\n```": 0.4210526315789474, "What is the output of the following code? ```py def a(): print(\"a\") b = a def c(): print(\"c\") b() ```": 0.4117647058823529, "What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.4, "What is the output of the code below?\n\n```python x = [1, 2, 3, 4, 5] x = x[1:-1] print(x)```": 0.4, "What is the output of the following code? ```py def add_five(x): x += 5 return x print(add_five(2)) ```": 0.4, "What is the output of the following code?\n```python\ndef foo():\n print(\"foo\")\n\ndef bar():\n print(\"bar\")\n\ndef main():\n foo()\n bar()\n\nmain()\n```": 0.3888888888888889}, "avg_similarity_score": 0.14349282541766176} -{"instruction": "What is the output of this code?\n```\nmy_dict = {\n 'key1': 'value1',\n 'key2': 'value2',\n}\n\nfor key, value in my_dict.items():\n print(key, value)\n```", "input": "", "output": "The output of this code is: ```key1 value1 key2 value2```", "most_similar": {"What is the output of this code?\n```\nfor i in range(10):\n print(i)\n```": 0.5405405405405405, "What is the output of this code?\n```\nx = 10\ndef func():\n x = 20\n print(x)\nfunc()\nprint(x)\n```": 0.3902439024390244, "What is the output of the code below?\n\n```python import math print(math.sqrt(16))```": 0.3684210526315789, "What is the output of the following code? ```py def print_odds(n): for i in range(n): if i % 2 == 0: print(i) print_odds(10) ```": 0.36, "Find the output of this code.\n```\ndef my_filter(x, y):\n return x\n\nprint(my_filter(1, 2))\n```": 0.34146341463414637, "What is the output of this code?\n```python\ndef f(x):\n x = 2 * x + 1\n return x\n\nx = 3\nz = f(x)\nprint(z)\n```": 0.3404255319148936, "What is the output of the following code? ```py def a(): print(\"a\") b = a def c(): print(\"c\") b() ```": 0.3255813953488372, "What is the output of the following code? ```py def add_five(x): x += 5 return x print(add_five(2)) ```": 0.31818181818181823, "What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.31818181818181823, "What is the output of the code below?\n\n```python x = [1, 2, 3, 4, 5] x = x[1:-1] print(x)```": 0.31818181818181823}, "avg_similarity_score": 0.10944964775646371} -{"instruction": "Find the output of this code.\n```\nimport numpy as np\n\na = np.array([1, 2, 3])\n\nprint(a)\nprint(a.shape)\nprint(a.size)\nprint(a.dtype)\n```", "input": "", "output": "The output of this code is: ```[1 2 3] (3,) 3 int64```", "most_similar": {"What is the output of the following code?\n```\na = 1\nb = 2\nc = 3\nif a > b:\n print(\"a is greater than b\")\nelif a > c:\n print(\"a is greater than c\")\nelse:\n print(\"a is not greater than b or c\")\n```": 0.43478260869565216, "What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.4166666666666667, "What is the output of the following code? ```py a = 5 b = 15 print(\"a / b is\", a / b) print(\"a % b is\", a % b) print(\"a // b is\", a // b) ```": 0.41379310344827586, "What is the output of the following code? ```py def a(): print(\"a\") b = a def c(): print(\"c\") b() ```": 0.3829787234042553, "Find the output of this code.\n```\ndef my_filter(x, y):\n return x\n\nprint(my_filter(1, 2))\n```": 0.3555555555555555, "What is the output of the following code? ```py def add(a, b): return a + b print(add(1, 2)) print(add(b=2, a=1)) ```": 0.33962264150943394, "What is the output of the code below?\n\n```python x = [1, 2, 3, 4, 5] x = x[1:-1] print(x)```": 0.3333333333333333, "What is the output of the following python code?\n```python\ndef function(a):\n if a > 0:\n print('Positive')\n else:\n print('Negative')\n\nfunction(0)\n```": 0.31999999999999995, "What is the output of this code?\n```python\ndef f(x):\n x = 2 * x + 1\n return x\n\nx = 3\nz = f(x)\nprint(z)\n```": 0.3137254901960785, "What is the output of this code?\n```\nx = 10\ndef func():\n x = 20\n print(x)\nfunc()\nprint(x)\n```": 0.3111111111111111}, "avg_similarity_score": 0.1284100057850732} -{"instruction": "Write a python code that asks the user to input a date and tells the user how many days are remaining until the inputted date.", "input": "", "output": "```\nfrom datetime import datetime, date\n\nfuture_date = input(\"Enter the future date: \")\n\ndef get_days_between_dates(future_date):\n today = date.today()\n future = datetime.strptime(future_date, \"%Y-%m-%d\")\n\n return abs(today - future).days\n\nprint(f\"{get_days_between_dates(future_date)} days left\")\n```", "most_similar": {"Write a python function that adds a new key to a dictionary and returns the value of the key.": 0.40909090909090906, "Write a Python function that returns True if the specified list and the specified value are not empty.": 0.37209302325581395, "Write a Python function that removes the first item from a list and returns it.": 0.35000000000000003, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.34782608695652173, "Write a function that takes a string and returns the number of vowels in the string.": 0.34146341463414637, "Write a python code to find the area of a circle.": 0.3333333333333333, "Write a Python function that takes a number as input and returns the square of that number.": 0.3333333333333333, "Write a Python function that returns a list containing only the items that are present in both lists.": 0.32558139534883723, "Write a C program that takes a character from user and displays the ASCII value of the character.": 0.32558139534883723, "Write a Python function that takes a string as input and returns the string in reverse order.\n'Hello'": 0.32558139534883723}, "avg_similarity_score": 0.16987694605591375} -{"instruction": "Write an algorithm to output all the prime numbers in a given range", "input": "", "output": "def prime_numbers(range):\n prime_list = []\n for i in range:\n if i % 2 == 0:\n continue\n for j in range(2, i):\n if i % j == 0:\n break\n else:\n prime_list.append(i)\n return prime_list", "most_similar": {"I want to find the average of all the numbers in a list.": 0.46153846153846156, "Write a Python program to find the most common words in a given text.": 0.4444444444444445, "Write a Python program to find the frequency of each word in a given string.": 0.42857142857142855, "Write a Python function to find all prime numbers up to the given number n.": 0.42857142857142855, "Write a Python function to find the first non-pallindrome string in a given list.": 0.42857142857142855, "Write a program to find the smallest number in a list.": 0.41666666666666663, "How to find the largest prime factor of a given number?": 0.41666666666666663, "Write a Python program to find the sum of the positive integers of a given range.": 0.41379310344827586, "Write a Python function to find the largest number in a dictionary.": 0.4, "Write a script to output the mean of a list of integers.": 0.4}, "avg_similarity_score": 0.17635018284650322} -{"instruction": "Given a year, return the century it is in. The first century spans from the year 1 up to and including the year 100, the second - from the year 101 up to and including the year 200, etc.", "input": "", "output": "def centuryFromYear(year):\n if year <= 0:\n raise ValueError('The year must be a positive number.')\n century = year // 100\n if (year % 100) > 0:\n century = century + 1\n return century", "most_similar": {"Given a list of strings, find the longest string in the list. You can use the len function to find the length of a string.": 0.25396825396825395, "Given a string, return the number of vowels used in the text.": 0.23999999999999996, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number whose square when divided into two parts, one part being the original number and the other part being the remaining part, add up to the original number.": 0.22988505747126436, "Write a Python function that returns the number of items that are present in the first list but not in the second list.": 0.22950819672131145, "Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.\n\nThe function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2.": 0.22727272727272727, "Write a Python program to find the frequency of the words from the sentence given.": 0.22641509433962267, "Write a program that prints the numbers from 1 to 100. But for multiples of three print \"Fizz\" instead of the number and for the multiples of five print \"Buzz\". For numbers which are multiples of both three and five print \"FizzBuzz\".": 0.225, "Write a Python program to find the first appearance of the substring 'not' and 'poor' from a given string, if 'not' follows the 'poor', replace the whole 'not'...'poor' substring with 'good'. Return the resulting string.": 0.21621621621621623, "Given a string s, return the number of palindromic substrings in it. A string is a palindrome when it reads the same backward as forward. A substring is a contiguous sequence of characters within the string.": 0.21621621621621623, "Using the comment as a guide, replace the \"TODO\" comment in the code with the proper code.\ndef greet_to(name):\n \"\"\"Print a greeting to the name provided.\"\"\"\n # TODO: assert name is a string\n print(\"Hello, \" + name + \"!\")": 0.21333333333333335}, "avg_similarity_score": 0.11272859936246452} -{"instruction": "Write a function that takes a number and returns its first digit", "input": "", "output": "def get_first_digit(num):\n if type(num) is not int:\n raise ValueError('The given number is not an integer.')\n return num // 10 ** int(math.log10(num))", "most_similar": {"Write a Python function that takes a number as input and returns the square of that number.": 0.6206896551724139, "Write a function that takes a string and returns the number of vowels in the string.": 0.5714285714285715, "Write a function that takes a string and returns a new string with the first letter of each word capitalized.": 0.5625000000000001, "Write a Python function that takes a list and returns a new list with unique elements of the first list.": 0.5625000000000001, "Write a Python function that takes a number as input and returns its square, cube, square root, cube root, and the sum of its digits.": 0.5405405405405406, "Write a Python function that takes two numbers as input and returns their sum.": 0.5384615384615384, "Write a Python function that takes a string as input and returns the string in reverse order.\n'Hello'": 0.5333333333333333, "Write a Python function that removes the first item from a list and returns it.": 0.5185185185185186, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.5, "Write a function that reverses a given string.": 0.5}, "avg_similarity_score": 0.16902346982188982} -{"instruction": "What's the solution for the problem?", "input": "", "output": "That's simple. You can use the solution function.", "most_similar": {"What are the major differences between the Array and List data structures?": 0.3157894736842105, "What is the difference between a for loop and a while loop?": 0.3157894736842105, "What is the value of the following expression?\n10 + 2 * 3 / 4": 0.3157894736842105, "What does the function `print()` do?": 0.30769230769230765, "What does the HTML tag `

` do?": 0.2857142857142857, "What is the output of this code?\n```\nfor i in range(10):\n print(i)\n```": 0.2857142857142857, "Given a string `s`, find the length of the longest substring without repeating characters.": 0.2857142857142857, "What is the output of the code below?\n\n```python import math print(math.sqrt(16))```": 0.27272727272727276, "What is the purpose of a hash table?": 0.26666666666666666, "What does the CSS style `float: left;` do?": 0.26666666666666666}, "avg_similarity_score": 0.10063290188215471} -{"instruction": "Define a function named as maxOfThree() that takes three numbers as arguments and returns the greatest of them.", "input": "", "output": "def maxOfThree(num1, num2, num3):\n # insert the code here", "most_similar": {"Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.5142857142857143, "Write a Python function that takes a number as input and returns the square of that number.": 0.5142857142857143, "Write a Python function that takes two numbers as input and returns their sum.": 0.5, "Write a function that takes a string and returns the number of vowels in the string.": 0.47058823529411764, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.4615384615384615, "Write a function that takes a string as input and reverse only the vowels of a string.": 0.45714285714285713, "Write a function that takes an array of numbers and returns the largest number in the array.": 0.45714285714285713, "Write a Python function that takes a string as input and returns the string in reverse order.\n'Hello'": 0.4444444444444444, "Write a function that returns the sum of two numbers.": 0.42857142857142855, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.4210526315789474}, "avg_similarity_score": 0.1453115215987618} -{"instruction": "Help me to optimize this code: def check_int(value): \"\"\"Checks whether value is int\"\"\" try: value = int(value) return value except ValueError: return False", "input": "", "output": "Here's the optimized version of the function: ```python def check_int(value): \"\"\"Checks whether value is int\"\"\" if isinstance(value, int): return value else: return False ``` Here's a summary of the changes made: 1. Checked whether the value is already an integer using `isinstance`. 2. Returned the value directly if the condition is true. 3. Returned `False` if the condition is false. Make sure to test the optimized code to ensure it still meets your requirements.", "most_similar": {"I have the following code: ```python def get_max_value(list): max_value = list[0] for i in range(1, len(list)): if list[i] > max_value: max_value = list[i] return max_value ``` What does the function do?": 0.25, "Write a Python function to check whether a passed string is palindrome or not.": 0.20512820512820512, "Add comments in the given function to make the code more readable for humans.\ndef hill_climbing(initial_board):\n current = initial_board\n while current.has_successors():\n neighbour = Board(current.get_random_successor(), \"best\")\n if neighbour.value() >= current.value():\n return current\n current = neighbour\n return current": 0.2028985507246377, "How to make this code work? ```py def foo(): print('foo') def bar(function): function() bar(foo) ```": 0.19047619047619052, "Find the output of this code.\n```\ndef my_filter(x, y):\n return x\n\nprint(my_filter(1, 2))\n```": 0.18604651162790697, "Translate the following code from python in Java.\ndef function(a : int, b : int, c : int):\n if a > b :\n print('You lost.')\n else :\n if c > a :\n print('Nice try.')\n else :\n print('You won.')": 0.17241379310344826, "What is the output of the following code?\n```python\ndef foo():\n x = 1\n def bar():\n x = 2\n return x\n return bar()\nprint(foo())\n```": 0.16666666666666666, "Write a python program to check if the number is prime.": 0.16666666666666666, "How to check quickly if a number is prime in C?": 0.16666666666666666, "What is the output of this code?\n```\nmy_dict = {\n 'key1': 'value1',\n 'key2': 'value2',\n}\n\nfor key, value in my_dict.items():\n print(key, value)\n```": 0.16666666666666666}, "avg_similarity_score": 0.053326779652216064} -{"instruction": "Given an array of integers, return the largest sum of non-adjacent numbers. Numbers can be 0 or negative.", "input": "", "output": "```python def max_non_adjacent(nums):\n # write your code here\n current_sum = nums[0]\n next_sum = max(current_sum, nums[1])\n for i in range(2, len(nums)):\n temp = next_sum\n next_sum = max(current_sum + nums[i], next_sum)\n current_sum = temp\n return next_sum\n\nprint(max_non_adjacent([2, 4, 6, 2, 5])) ```", "most_similar": {"Given an array of integers, return indices of the two numbers such that they add up to a specific target.": 0.41025641025641024, "Given an array of integers, find the pair of adjacent elements that has the largest product and return that product.": 0.41025641025641024, "Given a list of numbers, find the sum of the numbers.": 0.39999999999999997, "Given an array of integers nums, write a method that returns the \"pivot\" index of this array.": 0.3888888888888889, "Given an integer array nums, find the subarray with the largest sum, and return its sum.": 0.34285714285714286, "Write a Python program to find the sum of a non-negative integer.": 0.3125, "Given the `root` of a binary tree, return the inorder traversal of its nodes' values.": 0.29411764705882354, "Write a function that takes an array of numbers and returns the largest number in the array.": 0.27777777777777773, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.27777777777777773, "Write a function that returns the sum of two numbers.": 0.27586206896551724}, "avg_similarity_score": 0.1026062070950263} -{"instruction": "Given an array of numbers, find the maximum sum of any contiguous subarray of the array.", "input": "", "output": "```python def maxSubArray(nums):\n max_so_far = max_ending_here = 0\n for num in nums:\n max_ending_here = max_ending_here + num\n if max_so_far < max_ending_here:\n max_so_far = max_ending_here\n if max_ending_here < 0:\n max_ending_here = 0\n return max_so_far\n\nprint(maxSubArray([1, 2, 3, -4, 5, 6, -1])) ```", "most_similar": {"Given a list of numbers, find the sum of the numbers.": 0.5925925925925926, "Given a binary array, find the maximum number of consecutive 1s in this array.": 0.4666666666666667, "Given an array of integers, find the pair of adjacent elements that has the largest product and return that product.": 0.4444444444444445, "Given an integer array nums, find the subarray with the largest sum, and return its sum.": 0.4375, "You are given a list of numbers. You need to find the median of the list.": 0.4375, "Given a list of numbers, find the largest number in the list.": 0.42857142857142855, "Write a function that takes an array of numbers and returns the largest number in the array.": 0.42424242424242425, "Given an array of integers nums, write a method that returns the \"pivot\" index of this array.": 0.42424242424242425, "Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product.": 0.4210526315789474, "Write a Python function to find the maximum sum of a contiguous subsequence from a list of integers.": 0.411764705882353}, "avg_similarity_score": 0.12974637427187852} -{"instruction": "Write a function that returns true if a number is prime, and otherwise returns false.", "input": "", "output": "def is_prime(number): if number <= 3: return number > 1 if number % 2 == 0 or number % 3 == 0: return False for i in range(3, int(number**0.5) + 1, 2): if number % i == 0: return False return True", "most_similar": {"Write a function that takes a number and returns its first digit": 0.5925925925925926, "Write a Python function that returns true if a string contains any space character.": 0.5517241379310344, "Write a Python function to check if a given number is a prime number or not.": 0.5161290322580646, "Write a function to check if a number is divisible by 7 or 5 and not 3.": 0.5, "Write a Python function that takes a number as input and returns the square of that number.": 0.5, "Write a Python function that returns True if the specified list and the specified value are not empty.": 0.4848484848484848, "Write a Python function that removes the first item from a list and returns it.": 0.4666666666666667, "Write a python program to check if the number is prime.": 0.4615384615384615, "Write a function that takes a string and returns the number of vowels in the string.": 0.45161290322580644, "Write a Python function that returns the largest item in a list.": 0.4444444444444445}, "avg_similarity_score": 0.16834444658774694} -{"instruction": "Convert this sentence to pascal case: \"this is an example of pascal case\"", "input": "", "output": "ThisIsAnExampleOfPascalCase", "most_similar": {"Can you give me an example of a computer vision task?": 0.24999999999999994, "How can I convert a list of strings to a list of integers?": 0.23076923076923078, "Write a function to find the longest common prefix string amongst an array of strings.": 0.21428571428571427, "Write a program in C to insert an element at the beginning of the linked list.": 0.20689655172413793, "Convert this list into a list of sets: [[1, 2, 3], [4, 5, 6], [7, 8, 9]]": 0.20000000000000004, "Write Python code to solve this leetcode problem.": 0.1904761904761905, "What is the purpose of a hash table?": 0.1904761904761905, "Tranlate this `curl` command to Python: `curl ifconfig.me`": 0.18181818181818185, "How to find the standard deviation of a list?": 0.18181818181818185, "Can I convert a dictionary to a JSON string?": 0.18181818181818185}, "avg_similarity_score": 0.07881290948973539} -{"instruction": "Write a Python function that accepts an integer (positive or zero) and returns the factorial of that number. The factorial of any positive number n is equal to the product of all positive integers less than or equal to n. Factorial of 0 is 1. For example, factorial of 6 is equal to 6*5*4*3*2*1 which is equal to 720.", "input": "", "output": "def factorial(n): if n < 0: return None result = 1 for i in range(1, n + 1): result = result * i return result", "most_similar": {"Write a function that takes an integer as input and returns the number of bits that are equal to 1 in the binary representation of that number. You can guarantee that input is non-negative.": 0.32323232323232326, "Write a function that takes a positive integer n and returns the next biggest number with the same number of 1 bits. For example, given the number 6 (0110 in binary), the function should return 9 (1001).": 0.31683168316831684, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.3146067415730337, "Write a Python function to check if a number is a strong number or not. A strong number is a number whose sum of factorial of digits is equal to the original number. For example, 145 is strong number since 1! + 4! + 5! = 1 + 24 + 120 = 145.": 0.30630630630630634, "Write a Python function to check if a given number is an Armstrong number or not. An Armstrong number is a number that is equal to the sum of its own digits each raised to the power of the number of digits.": 0.3018867924528302, "Write a Python function to check if a given number is a Neon number or not. A Neon number is a number where the sum of digits of square of the number is equal to the number itself. For example, 9 is a Neon number because 92 = 81 and 8 + 1 = 9.": 0.2931034482758621, "Write a Python function to check if a given number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. For example, 6 has divisors 1, 2 and 3 (excluding the number itself), and 6 = 1 + 2 + 3. Similarly, 28 has divisors 1, 2, 4, 7, 14 and 28, and 28 = 1 + 2 + 4 + 7 + 14.": 0.291970802919708, "Write a Python function to check if a number is a Smith number or not. A Smith number is a composite number, whose sum of digits is equal to the sum of digits of its prime factors. For example, 42 is a Smith number, since its prime factors are 2 and 21, and 2 + 2 + 1 = 2 + 4 + 2 = 8.": 0.29032258064516125, "Write a Python function that takes a number as input and returns the sum of all the numbers from 1 to that number that are divisible by 3 and 5.": 0.2765957446808511, "Write a Python function to check if a given number is a Harshad number or not. A Harshad number is a number that is divisible by the sum of its digits. For example, 42 is a Harshad number because it is divisible by 6 (the sum of its two digits 4 + 2).": 0.27586206896551724}, "avg_similarity_score": 0.12641217732578422} -{"instruction": "Write a python function to return the remainder of a number divided by 3 using the modulo % operator.", "input": "", "output": "def remainder(number): return number % 3", "most_similar": {"Write a Python function to calculate the factorial of a number.": 0.6206896551724137, "Write a Python function to find the sum of all items in a list.": 0.5, "Write a Python program to find the average of a list using for loop.": 0.5, "Write a Python function that returns the sum of all numbers in a list that are divisible by 3.": 0.4864864864864865, "Write a python code to find the area of a circle.": 0.4827586206896552, "Write a Python function to find the largest number in a dictionary.": 0.4666666666666666, "Write a function to check if a number is divisible by 7 or 5 and not 3.": 0.45714285714285713, "Write a Python program to find the sum of a non-negative integer.": 0.45161290322580644, "write a code to get the current value of a Bitcoin in US dollars using the bitcoincharts API.": 0.4444444444444444, "Write a Python function to find the maximum sum of a contiguous subsequence from a list of integers.": 0.4444444444444444}, "avg_similarity_score": 0.22186101894023783} -{"instruction": "Write a function that prints the reverse of a string.", "input": "", "output": "def print_reverse(str): print(str[::-1])", "most_similar": {"Write a python function that returns the number of words in a given string.": 0.6666666666666666, "Write a function that reverses a given string.": 0.6666666666666665, "Write a function that returns the sum of two numbers.": 0.6, "Write a function that takes a string as input and reverse only the vowels of a string.": 0.5925925925925927, "Write a python function that returns the sum of the elements of a list.": 0.5833333333333334, "write a c++ program that calculates the perimeter of a square": 0.5714285714285713, "Write a Python function to calculate the factorial of a number.": 0.5714285714285713, "Write a Python function that returns the largest item in a list.": 0.5454545454545454, "Write a function that takes a string and returns the number of vowels in the string.": 0.5384615384615384, "Write a function that returns the number of times a given string occurs in a given text as its substring.": 0.5333333333333333}, "avg_similarity_score": 0.22367859035221865} -{"instruction": "What is the sum of the ASCII values of all the letters in the word \"apple\"?", "input": "", "output": "The sum of the ASCII values of all the letters in the word \"apple\" is 224.", "most_similar": {"How to find the sum of all the elements in a list in python?": 0.39999999999999997, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.37837837837837834, "Identify the pos tag of the word in the given sentence.": 0.3703703703703703, "How to find the sum of all numbers in an array?": 0.3703703703703703, "What is the value of the following expression?\n10 + 2 * 3 / 4": 0.35714285714285715, "I want to find the average of all the numbers in a list.": 0.3448275862068966, "What is the purpose of a hash table?": 0.3333333333333333, "How do I find the sum of the first 1000 prime numbers in C++?": 0.3333333333333333, "Write a python function that returns the sum of the elements of a list.": 0.3333333333333333, "What is the output of this code?\n```\nfor i in range(10):\n print(i)\n```": 0.3333333333333333}, "avg_similarity_score": 0.14548073652960664} -{"instruction": "Can you write a program to get all the inputs from a user until he/she enters 'stop'?", "input": "", "output": "Here is the code that asks the user for input and stops when the user enters 'stop'. ```python x = input(\"Please enter a word or 'stop' to exit: \") while x != \"stop\": print(x) x = input(\"Please enter a word or 'stop' to exit: \") ```", "most_similar": {"Write a Python program to find the longest pallindrome substring from a given string.": 0.43750000000000006, "Write a Python program to get the volume of a sphere with radius 6.": 0.43750000000000006, "Write a Python program to find the maximum and minimum number from a given list.": 0.42424242424242425, "Write a Python program to create a dictionary from a string.": 0.41379310344827586, "Write a program to find the smallest number in a list.": 0.41379310344827586, "Write a Python program to find the number of even and odd numbers from a series of numbers.": 0.3888888888888889, "Write a Python program to find the unique common elements from two lists.": 0.3870967741935484, "Write a Python program to find the sum of a non-negative integer.": 0.3870967741935484, "Write a program to compute the sum of integers from k to n.": 0.3870967741935484, "Write a Python program to find the average of a list using for loop.": 0.375}, "avg_similarity_score": 0.1656034731131376} -{"instruction": "Write a Java program to remove a set of characters from a string.", "input": "", "output": "public class Test {\n\n public static void main(String[] args) {\n\n // initialize the string\n String str = \"Hello Java!\";\n\n // initialize the array\n char[] arr = {'a', 'o'};\n\n // calling the removeChars method\n // with the string and array\n String result = removeChars(str, arr);\n\n // print the final result\n System.out.println(result);\n }\n\n // removing characters method\n public static String removeChars(String str, char[] arr) {\n\n // creating a string buffer\n StringBuffer sb = new StringBuffer();\n\n // traversing through the string\n for (int i = 0; i < str.length(); i++) {\n\n // traversing through the array\n for (int j = 0; j < arr.length; j++) {\n\n // if the character matches\n if (str.charAt(i) == arr[j]) {\n break;\n }\n\n // if the character doesn't match\n else {\n sb.append(str.charAt(i));\n }\n }\n }\n return sb.toString();\n }\n}", "most_similar": {"Write a Python program to create a dictionary from a string.": 0.6666666666666667, "Write a Python program to find the longest pallindrome substring from a given string.": 0.5185185185185186, "Write a Python program to find the frequency of each word in a given string.": 0.5, "Write a Python program to add a key to a dictionary.": 0.4999999999999999, "Write a C# program that creates a new string from a given string by removing all vowels.": 0.4666666666666667, "Write a program to compute the sum of integers from k to n.": 0.46153846153846156, "Write a Python program to find the sum of a non-negative integer.": 0.46153846153846156, "Write a Python program to find the number of even and odd numbers from a series of numbers.": 0.45161290322580644, "Write a Python program to find the first non-repeated character in a string.": 0.4444444444444445, "Write a Python program to get the volume of a sphere with radius 6.": 0.4444444444444445}, "avg_similarity_score": 0.1841504401606411} -{"instruction": "What is the difference between `NaN` and `Infinity`?", "input": "", "output": "NaN stands for Not a Number. Infinity is the concept of being infinitely large or infinitely small. Infinity is a number while NaN is not a number. Infinity can be positive or negative while NaN is not a number.", "most_similar": {"What is the difference between a relative and absolute path?": 0.6666666666666665, "What is the difference between `git pull` and `git fetch` ?": 0.6666666666666665, "What is the difference between a class and an object?": 0.6666666666666665, "What is the difference between a static and a dynamic method?": 0.631578947368421, "What is the difference between an ingress and a persistent volume?": 0.631578947368421, "What is the difference between a pod and a horizontal pod autoscaler?": 0.6, "What is the difference between a deep copy and a shallow copy?": 0.6, "What is the difference between a replica set and a stateful set?": 0.6, "What is the difference between a for loop and a while loop?": 0.6, "What is the difference between a list and a tuple in Python?": 0.6}, "avg_similarity_score": 0.1057363676465559} -{"instruction": "Write a Java program to find the cube root of a number.", "input": "", "output": "import static java.lang.Math.cbrt;\n\nclass CubeRootOfANumber {\n\n public static void main(String[] args) {\n\n double result = cbrt(125);\n System.out.println(\"The cube root of 125 is \" + result);\n }\n}", "most_similar": {"Write a Python program to find the sum of a non-negative integer.": 0.64, "I need a simple C++ program to find the factorial of a number.": 0.64, "Write a program to find the maximum of three numbers.": 0.6363636363636365, "Write a program to find the n-th ugly number.": 0.6363636363636365, "Write a Python program to find the average of a list using for loop.": 0.6153846153846153, "Write a Python function to calculate the factorial of a number.": 0.6086956521739131, "Write a python code to find the area of a circle.": 0.6086956521739131, "Write a program to find the smallest number in a list.": 0.6086956521739131, "Write a Python program to find the frequency of each word in a given string.": 0.5925925925925926, "Write a program to find the pearson correlation coefficient of two lists.": 0.5833333333333334}, "avg_similarity_score": 0.23289180352938763} -{"instruction": "How do you initialize an ArrayList in Java?", "input": "", "output": "ArrayLists are objects and cannot be initialized directly. However, you can create an ArrayList using one of two methods: using the ArrayList class or the Collections class.\n\nUsing the ArrayList Class\nYou can create an ArrayList using the ArrayList class. To initialize an ArrayList, you first need to import the ArrayList class. You can do this using the following statement:\n\nimport java.util.ArrayList;\nOnce you've imported the ArrayList class, you can create an ArrayList using the following statement:\n\nArrayList list1 = new ArrayList<>();\nIn the above statement, the name of the ArrayList is list1 and it is an ArrayList of integers.\n\nUsing the Collections Class\nYou can create an ArrayList using the Collections class. To initialize an ArrayList, you first need to import the Collections class. You can do this using the following statement:\n\nimport java.util.Collections;\nOnce you've imported the Collections class, you can create an ArrayList using the following statement:\n\nList list1 = new ArrayList();\nIn the above statement, the name of the ArrayList is list1 and it is an ArrayList of integers.", "most_similar": {"How do you create a variable in Python?": 0.5, "How do you find the index of an item in a list?": 0.5, "How do you sort a list of strings in Python?": 0.4444444444444445, "How do you remove duplicates from a list in Python?": 0.4444444444444445, "How to find the largest number in an array in Java?": 0.4210526315789474, "How do you count the number of items in a list?": 0.4210526315789474, "How do you find the length of a string in Python?": 0.4210526315789474, "How do you find the largest number in a list using Python?": 0.4, "How do you check if a value is present in a list?": 0.4, "How do you output all the contents of a list in Python?": 0.4}, "avg_similarity_score": 0.0728953422045986} -{"instruction": "What is the difference between the `==` and the `.equals()` methods in Java?", "input": "", "output": "The `==` operator is used to determine if two objects are equal by comparing their references. The `.equals()` method is used to determine if two objects are equal by comparing their contents.", "most_similar": {"What is the difference between `NaN` and `Infinity`?": 0.6, "What is the difference between a list and a tuple in Python?": 0.5833333333333334, "What is the difference between a class and an object?": 0.5454545454545454, "What is the difference between `git pull` and `git fetch` ?": 0.5454545454545454, "What is the difference between a relative and absolute path?": 0.5454545454545454, "What is the difference between a static and a dynamic method?": 0.5217391304347826, "What is the difference between an ingress and a persistent volume?": 0.5217391304347826, "What is the difference between a replica set and a stateful set?": 0.5, "What is the difference between a pod and a horizontal pod autoscaler?": 0.5, "What is the difference between a deep copy and a shallow copy?": 0.5}, "avg_similarity_score": 0.13381549339173748} -{"instruction": "Write a Java program to convert an int to a string.", "input": "", "output": "Integer.toString(123); // returns \"123\"", "most_similar": {"Write a Java program to remove a set of characters from a string.": 0.5833333333333334, "Write a Python program to add a key to a dictionary.": 0.5454545454545454, "Write a Python program to create a dictionary from a string.": 0.5454545454545454, "Write a Java program to find the cube root of a number.": 0.5217391304347826, "Write a Python program to find the first non-repeated character in a string.": 0.4799999999999999, "Write a Python program to find the longest pallindrome substring from a given string.": 0.4799999999999999, "Write a Python program to find the frequency of each word in a given string.": 0.4615384615384615, "Write a program to find the maximum value in an array": 0.45454545454545453, "Write a program to find the smallest number in a list.": 0.45454545454545453, "Write a code to implement a binary search.": 0.4210526315789474}, "avg_similarity_score": 0.16787789595669605} -{"instruction": "What are the basic data types in Java?", "input": "", "output": "The basic data types in Java are:\n\nNumeric\n\n`byte` - an 8-bit signed two's complement integer\n`short` - a 16-bit signed two's complement integer\n`int` - a 32-bit signed two's complement integer\n`long` - a 64-bit signed two's complement integer\n`float` - a single-precision 32-bit IEEE 754 floating point\n`double` - a double-precision 64-bit IEEE 754 floating point\n\nNon-Numeric\n\n`char` - a single 16-bit Unicode character\n`boolean` - a `true` or `false` value", "most_similar": {"What are the major differences between the Array and List data structures?": 0.4, "What is the difference between the `==` and the `.equals()` methods in Java?": 0.4, "Translate the following code from python in Java.": 0.375, "What are the different methods to remove an element from a list in Python?": 0.36363636363636365, "How to find the largest number in an array in Java?": 0.3157894736842105, "What is the difference between a list and a tuple in Python?": 0.3, "What does the function `print()` do?": 0.28571428571428575, "What is the output of this code?\n```\nfor i in range(10):\n print(i)\n```": 0.2727272727272727, "What does the HTML tag `

` do?": 0.26666666666666666, "What's the solution for the problem?": 0.26666666666666666}, "avg_similarity_score": 0.10138917205008775} -{"instruction": "I want to find a specific item in a long list of items. The list is sorted by an item field. What is the best data structure to use?", "input": "", "output": "The best data structure to use in this case would be a binary search tree. The binary search tree offers O(log n) performance for insertion, searching, and deletion operations.", "most_similar": {"I want to find the average of all the numbers in a list.": 0.3333333333333333, "Write a Python function to find the index of the first occurrence of a specified item in a list.": 0.2916666666666667, "If you have an array of numbers and you want to get the average of all the numbers, what is the shortest code to do it?": 0.29090909090909095, "How do I make a function that takes a string and returns a list of the words in the string?": 0.2857142857142857, "I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.27450980392156865, "How do I make a list of all the prime numbers up to a certain number?": 0.26666666666666666, "How to find the maximum value in a list?": 0.26315789473684215, "I have a list of numbers and I want to find the average of all the numbers.": 0.2608695652173913, "Given a list of strings, find the longest string in the list. You can use the len function to find the length of a string.": 0.25925925925925924, "Write a Python function to find the maximum sum of a contiguous subsequence from a list of integers.": 0.2553191489361702}, "avg_similarity_score": 0.14661313428658546} -{"instruction": "Describe how a compiler works.", "input": "", "output": "A compiler is a program that converts a program written in one language, called the source language, into a program written in another language, called the target language. The source language is usually a human-readable language, such as C, C++, Java, Python, Ruby, and many more. The target language is usually a machine language, which is a language that the computer can execute. For example, a compiler that converts C code into x86 code is called a C compiler. A compiler that converts Java code into bytecode is called a Java compiler. A compiler that converts Haskell code into JavaScript is called a Haskell to JavaScript compiler.", "most_similar": {"How to capitalize a string in Python?": 0.3333333333333333, "How do I make a dropdown menu?": 0.3333333333333333, "How to split a string into a list?": 0.3076923076923077, "How can I make a button in HTML?": 0.3076923076923077, "How do I print a list in Python?": 0.3076923076923077, "How do you create a variable in Python?": 0.3076923076923077, "How to find the maximum value in a list?": 0.2857142857142857, "How do I output a string in C++ programming?": 0.2857142857142857, "How do I create a text field in HTML?": 0.2857142857142857, "How to find the standard deviation of a list?": 0.2857142857142857}, "avg_similarity_score": 0.0919792250826749} -{"instruction": "I have a code that is too slow. How can I make it faster?", "input": "", "output": "You can optimize the code to make it faster. Here are some ways to make your program run faster:\n\nUse less memory. The more memory you use, the slower your program will run.\nUse less CPU. The more CPU your program uses, the slower it will run.\nUse fewer operations. The more operations your program uses, the slower it will run.\nUse a different algorithm. A more efficient algorithm can make your program run faster.\nUse a different data structure. A more efficient data structure can make your program run faster.", "most_similar": {"I have a list of strings, how do I convert them to numbers?": 0.3703703703703704, "How can I make a button in HTML?": 0.36363636363636365, "I have a list of numbers, how do I find the second largest number?": 0.35714285714285715, "How do I make a variable that is only declared?": 0.3333333333333333, "I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.33333333333333326, "I have 2 EC2 machines on AWS, I'm having trouble making them communicate. How could I troubleshoot it?": 0.30303030303030304, "How do I make a dropdown menu?": 0.2857142857142857, "How can I make a program that will find the largest number in a list?": 0.2758620689655172, "How can I rotate an element in CSS?": 0.2727272727272727, "I have a list of numbers and I want to find the average of all the numbers.": 0.2580645161290323}, "avg_similarity_score": 0.10284434102991404} -{"instruction": "Explain the difference between a compiler and an interpreter.", "input": "", "output": "A compiler converts source code into machine code and then runs the program. An interpreter reads source code line by line and then runs the program. Compilers are faster than interpreters because compilers translate the entire program before running it, whereas interpreters translate the program line by line while running it.", "most_similar": {"What is the difference between a class and an object?": 0.631578947368421, "What is the difference between a relative and absolute path?": 0.5263157894736842, "What is the difference between a static and a dynamic method?": 0.5, "What is the difference between a deep copy and a shallow copy?": 0.4761904761904762, "What is the difference between a pod and a horizontal pod autoscaler?": 0.4761904761904762, "What is the difference between a replica set and a stateful set?": 0.4761904761904762, "What is the difference between a for loop and a while loop?": 0.4761904761904762, "What is the difference between a list and a tuple in Python?": 0.4761904761904762, "What is the difference between `NaN` and `Infinity`?": 0.47058823529411764, "What is the difference between a binary search tree and a red-black tree?": 0.43478260869565216}, "avg_similarity_score": 0.1222677146909285} -{"instruction": "What are the benefits and drawbacks of using virtual machines in cloud computing?", "input": "", "output": "The benefits of virtual machines include:\n\nYou can run any operating system in a virtual machine.\nYou can easily replicate a virtual machine in case of system failure.\nYou can create customized environments that are tailored to a specific purpose.\nThe drawbacks of using virtual machines include:\n\nVirtual machines take up disk space.\nVirtual machines are slower than native machines because they have to translate the operating system and applications.\nVirtual machines have more overhead than native machines.", "most_similar": {"What are the basic data types in Java?": 0.380952380952381, "What are the drawbacks of using this python code? ``` py def get_random_index(my_list): return random.randint(0, len(my_list)-1) ```": 0.32432432432432434, "What are the major differences between the Array and List data structures?": 0.32, "What is the difference between the `==` and the `.equals()` methods in Java?": 0.32, "What is the difference between a list and a tuple in Python?": 0.32, "What are the different methods to remove an element from a list in Python?": 0.29629629629629634, "What is the output of this code?\n```\nfor i in range(10):\n print(i)\n```": 0.29629629629629634, "What is the purpose of a hash table?": 0.2857142857142857, "What is the difference between `NaN` and `Infinity`?": 0.2857142857142857, "What is the sum of the ASCII values of all the letters in the word \"apple\"?": 0.27586206896551724}, "avg_similarity_score": 0.11716574898220712} -{"instruction": "What is the difference between a web server and a web application server?", "input": "", "output": "A web server is a computer server that processes HTTP requests and returns web pages. A web application server is a server that processes requests and returns data. A web server can be a web application server. For example, Apache is a web server that can also be used as a web application server. IIS is a web server that can also be used as a web application server.", "most_similar": {"What is the difference between a static and a dynamic method?": 0.6666666666666667, "What is the difference between a for loop and a while loop?": 0.64, "What is the difference between a list and a tuple in Python?": 0.64, "What is the difference between a pod and a horizontal pod autoscaler?": 0.64, "What is the difference between a replica set and a stateful set?": 0.64, "What is the difference between a deep copy and a shallow copy?": 0.64, "What is the difference between a relative and absolute path?": 0.608695652173913, "What is the difference between a class and an object?": 0.608695652173913, "What is the difference between a binary search tree and a red-black tree?": 0.5925925925925927, "What is the difference between an ingress and a persistent volume?": 0.5833333333333334}, "avg_similarity_score": 0.13975799100369132} -{"instruction": "What are the differences between functional programming and object-oriented programming?", "input": "", "output": "Functional programming and object-oriented programming are two different styles of programming. A functional programming language uses functions to process data. An object-oriented programming language uses objects to process data.", "most_similar": {"What are the major differences between the Array and List data structures?": 0.5217391304347826, "What is the difference between a class and an object?": 0.47619047619047616, "What is the difference between `NaN` and `Infinity`?": 0.4210526315789474, "What is the difference between a relative and absolute path?": 0.380952380952381, "What is the difference between `git pull` and `git fetch` ?": 0.380952380952381, "What is the difference between an ingress and a persistent volume?": 0.36363636363636365, "What is the difference between a static and a dynamic method?": 0.36363636363636365, "What is the difference between a for loop and a while loop?": 0.34782608695652173, "What is the difference between a replica set and a stateful set?": 0.34782608695652173, "What is the difference between a pod and a horizontal pod autoscaler?": 0.34782608695652173}, "avg_similarity_score": 0.08167339545483582} -{"instruction": "How do you find the element with the lowest value in a list?", "input": "", "output": "You can find the lowest value in a list using the min() function. For example:\n\n```min([2, 1, 4, 3, 5])```", "most_similar": {"How do you find the index of an item in a list?": 0.64, "How do you find the largest number in a list using Python?": 0.64, "How to find the maximum value in a list?": 0.6363636363636364, "How do you find the number of occurrences of a given value in a list in Python?": 0.5999999999999999, "How do you count the number of items in a list?": 0.5833333333333334, "How do you find the standard deviation of all items in a list in Python?": 0.5714285714285715, "How do you check if a value is present in a list?": 0.5599999999999999, "How do I find the p-variance of all elements in a list?": 0.5384615384615384, "How do I get the first element of a list?": 0.5217391304347826, "How do I find the maximum value in an array?": 0.5217391304347826}, "avg_similarity_score": 0.17135937970559556} -{"instruction": "Write a function that creates a list of the multiples of a number between 0 and a limit.", "input": "", "output": "def create_list_of_multiples(multiple, limit):\n return [multiple * x for x in range(limit+1)]", "most_similar": {"Write a Python function that returns a list of numbers in a specified range.": 0.5, "Write a python function that returns the sum of the elements of a list.": 0.5, "Write a function that prints the reverse of a string.": 0.5, "Write a Python function to calculate the factorial of a number.": 0.4827586206896552, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.4736842105263158, "Write a function that takes a number and returns its first digit": 0.4666666666666666, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.4615384615384615, "Write a Python function that takes a number as input and returns the square of that number.": 0.45714285714285713, "Write a function that takes a string as input and reverse only the vowels of a string.": 0.45714285714285713, "Write a Python function that returns a specified number of elements in a list from a specified index.": 0.4444444444444444}, "avg_similarity_score": 0.20954525846465874} -{"instruction": "Write a function that takes an integer and returns the nth digit of the number.", "input": "", "output": "def find_nth_digit(n, k):\n return int(str(n)[k-1])", "most_similar": {"Write a function that takes a string and returns the number of vowels in the string.": 0.6451612903225806, "Write a function that takes an array of numbers and returns the largest number in the array.": 0.625, "Write a Python function that takes a number as input and returns the square of that number.": 0.625, "Write a function that takes a number and returns its first digit": 0.5925925925925926, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.5625, "Write a function that returns the sum of two numbers.": 0.56, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.5555555555555556, "Write a python function that returns the sum of the elements of a list.": 0.5517241379310344, "Write a function that takes an integer minutes and converts it to hours and minutes.": 0.5333333333333333, "Write a python function that adds a new key to a dictionary and returns the value of the key.": 0.5294117647058824}, "avg_similarity_score": 0.20491516898188156} -{"instruction": "Write a function that receives a list of items and returns the items in reverse order.", "input": "", "output": "def reverse_list(items):\n return items[::-1]", "most_similar": {"Write a Python function that takes a string as input and returns the string in reverse order.\n'Hello'": 0.6470588235294118, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.5945945945945946, "Write a function that takes a string and returns the number of vowels in the string.": 0.5625, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.5555555555555556, "Write a function that takes an array of numbers and returns the largest number in the array.": 0.5454545454545455, "Write a Python function that takes a string and returns a new string with the words in sorted order and unique.": 0.5405405405405405, "Write a Python function that returns a list of numbers in a specified range.": 0.5333333333333333, "Write a Python function that returns a list containing only the items that are present in both lists.": 0.5294117647058824, "Write a Python function that removes the first item from a list and returns it.": 0.5161290322580646, "Write a Python function that takes a list and returns a new list with unique elements of the first list.": 0.5}, "avg_similarity_score": 0.20013072962329478} -{"instruction": "Write a function that returns the number of times the string 'hi' appears anywhere in the given string.", "input": "", "output": "def count_hi(string):\n count = 0\n for i in range(0, len(string) - 1):\n if string[i] == 'h' and string[i + 1] == 'i':\n count = count + 1\n return count", "most_similar": {"Write a python function that returns the number of words in a given string.": 0.6875000000000001, "Write a function that takes a string and returns the number of vowels in the string.": 0.6470588235294118, "Write a function that returns the number of times a given string occurs in a given text as its substring.": 0.631578947368421, "Write a Python function that returns the number of items that are present in the first list but not in the second list.": 0.5365853658536586, "Write a function that takes an array of numbers and returns the largest number in the array.": 0.5142857142857143, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.5128205128205129, "Write a function that returns the sum of two numbers.": 0.5, "Write a python function that returns the sum of the elements of a list.": 0.5, "Write a function that prints the reverse of a string.": 0.5, "Write a function that takes an integer and returns the nth digit of the number.": 0.4848484848484848}, "avg_similarity_score": 0.2056252005567615} -{"instruction": "Write a function that returns True if the string is a palindrome or False if it is not.", "input": "", "output": "def is_palindrome(string):\n if string == string[::-1]:\n return True\n else:\n return False", "most_similar": {"Write a function that returns true if a number is prime, and otherwise returns false.": 0.5454545454545454, "Write a Python function that returns true if a string contains any space character.": 0.5, "Write a Python function to check whether a passed string is palindrome or not.": 0.5, "Write a Python function that returns True if the specified list and the specified value are not empty.": 0.5, "Write a Python function to check if a given number is a prime number or not.": 0.47058823529411764, "Write a Python function that returns the largest item in a list.": 0.4666666666666666, "Write a python function that returns the sum of the elements of a list.": 0.43750000000000006, "Write a python function that returns the number of words in a given string.": 0.43750000000000006, "Write a function that prints the reverse of a string.": 0.42857142857142855, "Write a function that returns the sum of two numbers.": 0.42857142857142855}, "avg_similarity_score": 0.18190779950468544} -{"instruction": "Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.", "input": "", "output": "class Solution:\n def firstUniqChar(self, s: str) -> int:\n dic = {}\n for i in s:\n if i in dic:\n dic[i] += 1\n else:\n dic[i] = 1\n for i, c in enumerate(s):\n if dic[c] == 1:\n return i\n return -1", "most_similar": {"Write a Python program to find the first non-repeated character in a string.": 0.3783783783783784, "Return the first non-repeating character in a string.": 0.37500000000000006, "Given a string s, return the longest palindromic substring in s.": 0.3529411764705882, "Given a string s, return the number of palindromic substrings in it.": 0.3428571428571428, "Given a string `s`, find the length of the longest substring without repeating characters.": 0.3243243243243243, "Write a Python function to find the first non-pallindrome string in a given list.": 0.31578947368421056, "Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.": 0.31111111111111117, "Given a string s, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.": 0.3, "Write a Python function to find the first repeated word in a given string, ignoring case and punctuation.": 0.2926829268292683, "Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n).": 0.2909090909090909}, "avg_similarity_score": 0.12824965250649886} -{"instruction": "Given an array of integers, sort it in ascending order using the bubble sort algorithm.", "input": "", "output": "```\ndef bubbleSort(array):\n for _ in range(len(array)):\n swapped = False\n for j in range(len(array) - 1):\n if array[j] > array[j + 1]:\n swapped = True\n array[j], array[j + 1] = array[j + 1], array[j]\n if not swapped:\n break\n return array\n```", "most_similar": {"Could you please write me Rust code that takes ownership of an array of integers and sorts them in ascending order?": 0.3888888888888889, "Given an array of integers nums, write a method that returns the \"pivot\" index of this array.": 0.37500000000000006, "Given an array of integers, return the largest sum of non-adjacent numbers. Numbers can be 0 or negative.": 0.35294117647058826, "Given an array of integers, return indices of the two numbers such that they add up to a specific target.": 0.34285714285714286, "Given an array of integers, find the pair of adjacent elements that has the largest product and return that product.": 0.34285714285714286, "How can I iterate through each item in an array in a random order using c++?": 0.3225806451612903, "Given an array of numbers, find the maximum sum of any contiguous subarray of the array.": 0.3225806451612903, "Write a function that takes an array of numbers and returns the largest number in the array.": 0.3125, "Given a string, return the number of vowels used in the text.": 0.2962962962962963, "Given a list of numbers, find the largest number in the list.": 0.2962962962962963}, "avg_similarity_score": 0.09853260161510585} -{"instruction": "Write a Java program to check a given number is a triangle number or not. The triangle numbers are the numbers of the form n(n+1)/2, where n is a natural number.", "input": "", "output": "```java class TriangleNumber {\n public static void main(String[] args) {\n int n = 10;\n System.out.println(isTriangleNumber(n));\n }\n static boolean isTriangleNumber(int number) {\n float val = (float)Math.sqrt(8*number + 1);\n return val % 1 == 0;\n }\n} ```", "most_similar": {"Write a Python function to check if a given number is a Fermat number or not. A Fermat number is a number of the form 22n + 1, where n is a non-negative integer.": 0.5882352941176471, "Write a Python function to check if a given number is a Catalan number or not. A Catalan number is a number that occurs in the sequence of Catalan numbers. The sequence of Catalan numbers is generated by the following formula: Cn = (2n)! / (n+1)!n!": 0.5, "Write a Python function to check if a given number is a Heptagonal number or not. A Heptagonal number is a number that can be expressed as n(5n-3)/2 where n is an integer.": 0.4857142857142857, "Write a Python function to check if a given number is a prime number or not.": 0.48, "Write a Python function to check if a number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence.": 0.4745762711864407, "Write a Python function to check if a given number is a Keith number or not. A Keith number is a number which is one less than a perfect square.": 0.46875, "Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.46875, "Write a Python function to check if a given number is a Ugly number or not. An Ugly number is a number whose prime factors are only 2, 3 or 5.": 0.4615384615384615, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.45714285714285713, "Write a Python function to check if a given number is a Truncable number or not. A Truncable number is a number where the number generated by truncating it from left or right is also a number.": 0.4507042253521127}, "avg_similarity_score": 0.18642032026043823} -{"instruction": "Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0. Not", "input": "", "output": "```java public List> threeSum(int[] nums) {\n Arrays.sort(nums);\n List> res = new ArrayList<>();\n for (int i = 0; i < nums.length; i++) {\n if (i > 0 && nums[i] == nums[i - 1]) continue;\n int lo = i + 1, hi = nums.length - 1, sum = -nums[i];\n while (lo < hi) {\n if (nums[lo] + nums[hi] == sum) {\n res.add(Arrays.asList(nums[i], nums[lo], nums[hi]));\n while (lo < hi && nums[lo] == nums[lo + 1]) lo++;\n while (lo < hi && nums[hi] == nums[hi - 1]) hi--;\n lo++;\n hi--;\n } else if (nums[lo] + nums[hi] < sum) lo++;\n else hi--;\n }\n }\n return res;\n} ```", "most_similar": {"You are given a list of numbers. You need to find the number of pairs of indices (i, j) such that the difference between nums[i] and nums[j] is at most t and i < j.": 0.34782608695652173, "Given an integer array nums, find the subarray with the largest sum, and return its sum.": 0.2857142857142857, "Given an array of integers, return indices of the two numbers such that they add up to a specific target.": 0.26415094339622636, "Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.": 0.2545454545454546, "Given an array of integers `nums` and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order.": 0.23809523809523808, "Given an array of integers, return the largest sum of non-adjacent numbers. Numbers can be 0 or negative.": 0.23076923076923078, "Given an array of integers, find the pair of adjacent elements that has the largest product and return that product.": 0.22641509433962265, "Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product.": 0.21818181818181817, "Given an array of integers nums, write a method that returns the \"pivot\" index of this array.": 0.19999999999999998, "Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.": 0.18918918918918917}, "avg_similarity_score": 0.06721143493534577} -{"instruction": "Given an array of n integers nums, a 132 pattern is a subsequence of three integers nums[i], nums[j] and nums[k] such that i < j < k and nums[i] < nums[k] < nums[j]. Return true if there is a 132 pattern in nums, otherwise, return false.", "input": "", "output": "```java public boolean find132pattern(int[] nums) {\n int second = Integer.MIN_VALUE;\n Stack stack = new Stack<>();\n for (int i = nums.length-1; i >= 0; i--) {\n if (nums[i] < second) return true;\n while (!stack.empty() && nums[i] > stack.peek()) {\n second = Math.max(second, stack.pop());\n }\n stack.push(nums[i]);\n }\n return false;\n} ```", "most_similar": {"Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0. Not": 0.5185185185185185, "Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.": 0.29213483146067415, "You are given a list of numbers. You need to find the number of pairs of indices (i, j) such that the difference between nums[i] and nums[j] is at most t and i < j.": 0.28571428571428575, "Given an array of integers, find the pair of adjacent elements that has the largest product and return that product.": 0.26470588235294124, "Given an array of integers, return indices of the two numbers such that they add up to a specific target.": 0.26470588235294124, "Given an array of integers nums, write a method that returns the \"pivot\" index of this array.": 0.24615384615384617, "Given an array of integers `nums` and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order.": 0.24242424242424243, "Write a function that returns true if a number is prime, and otherwise returns false.": 0.22222222222222224, "Write a function that returns True if the string is a palindrome or False if it is not.": 0.21212121212121213, "You need to read a code and detect if there is a syntax error or not. Outpus true if there is error, output false if there is not.": 0.2105263157894737}, "avg_similarity_score": 0.09875695705894907} -{"instruction": "Write a Python function that accepts a sequence of strings and returns a dictionary in which the keys are elements of the sequence and the values are the number of times each element occurs in the sequence.", "input": "", "output": "from collections import Counter\n\ndef count_char(seq):\n count_dict = Counter(seq)\n return dict(count_dict)\n\nprint(count_char('mississippi'))", "most_similar": {"Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.48275862068965514, "Write a function that takes a string and returns the number of vowels in the string.": 0.4528301886792453, "Write a python function that adds a new key to a dictionary and returns the value of the key.": 0.42857142857142855, "Write a Python function that takes a list and returns a new list with unique elements of the first list.": 0.4210526315789474, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.4193548387096775, "Write a function that takes an array of numbers and returns the largest number in the array.": 0.40740740740740744, "Write a Python function that takes a number as input and returns the square of that number.": 0.40740740740740744, "Write a Python function that returns the number of items that are present in the first list but not in the second list.": 0.4, "Write a function that returns the number of times the string 'hi' appears anywhere in the given string.": 0.39999999999999997, "Write a python function that returns the sum of the elements of a list.": 0.39215686274509803}, "avg_similarity_score": 0.17319015023144413} -{"instruction": "Write a Python program to find the highest 3 values from a list of values.", "input": "", "output": "def find_highest3(lst):\n sorted_lst = sorted(lst)\n return sorted_lst[-3:][::-1]\n\nprint(find_highest3([3, 1, 4, 9, 4, 7, 8]))", "most_similar": {"Write a Python program to find the maximum and minimum number from a given list.": 0.6666666666666666, "Write a Python program to find the longest common prefix of a given list of strings.": 0.6451612903225806, "Write a Python program to find the average of a list using for loop.": 0.6206896551724138, "Write a Python program to find the longest pallindrome substring from a given string.": 0.6206896551724138, "Write a Python function to find the smallest number from a sequence of numbers.": 0.6206896551724138, "Write a program to find the smallest number in a list.": 0.6153846153846153, "Write a Python program to find the list of words that are longer than n from a given list of words.": 0.611111111111111, "Write a Python function to find the maximum sum of a contiguous subsequence from a list of integers.": 0.606060606060606, "Write a Python program to find the number of even and odd numbers from a series of numbers.": 0.606060606060606, "Write a python code to find the minimum value in a list.": 0.5925925925925926}, "avg_similarity_score": 0.23001975919750572} -{"instruction": "Write a Python program to find the number of equal numbers from three given integers.", "input": "", "output": "def find_equal(x, y, z):\n if x == y and y == z:\n return 'All three numbers are equal.'\n equal = 0\n if x == y or x == z:\n equal += 1\n if y == z:\n equal += 1\n return '{} number(s) are equal.'.format(equal)\n\nprint(find_equal(5, 8, 5))", "most_similar": {"Write a Python program to find the maximum and minimum number from a given list.": 0.6666666666666666, "Write a Python program to find the number of even and odd numbers from a series of numbers.": 0.6666666666666666, "Write a Python program to find the frequency of the words from the sentence given.": 0.6666666666666666, "Write a program to find the maximum of three numbers.": 0.64, "Write a Python program to find the number of occurrences of a specified element in a given array of integers.": 0.6285714285714286, "Write a Python function to find the smallest number from a sequence of numbers.": 0.6206896551724138, "Write a Python program to find the longest pallindrome substring from a given string.": 0.6206896551724138, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.6206896551724138, "Write a Python program to find the frequency of each word in a given string.": 0.6, "Write a Python program to find the longest common prefix of a given list of strings.": 0.5806451612903225}, "avg_similarity_score": 0.22185329065792256} -{"instruction": "Write a Python program to generate all permutations of a given list.", "input": "", "output": "from itertools import permutations\n\nprint(list(permutations([1, 2, 3])))", "most_similar": {"Write a Python program to find the longest common prefix of a given list of strings.": 0.6428571428571429, "Write a Python program to find the average of a list using for loop.": 0.6153846153846153, "Write a Python function to reverse a given list of integers.": 0.6086956521739131, "Write a Python program to find the frequency of each word in a given string.": 0.5925925925925926, "Write a Python program to find the maximum and minimum number from a given list.": 0.5925925925925926, "Write a Python program to find the sum of the positive integers of a given range.": 0.5714285714285715, "Write a Python program to find the sum of a non-negative integer.": 0.5599999999999999, "Write a Python program to find the list of words that are longer than n from a given list of words.": 0.5454545454545454, "Write a Python program to find the longest pallindrome substring from a given string.": 0.5384615384615384, "Write a Python program to find the most common words in a given text.": 0.5384615384615384}, "avg_similarity_score": 0.20956347978959133} -{"instruction": "Write a Python program to sort a given list of names in ascending order.", "input": "", "output": "lst = ['Gerald', 'Gina', 'David', 'Shou', 'Alex', 'Andre']\nprint(sorted(lst))", "most_similar": {"Write a Python function to reverse a given list of integers.": 0.64, "Write a Python program to generate all permutations of a given list.": 0.6153846153846153, "Write a Python program to find the longest common prefix of a given list of strings.": 0.6000000000000001, "Write a Python program to find the maximum and minimum number from a given list.": 0.5517241379310344, "Write a Python program to find the highest 3 values from a list of values.": 0.5517241379310344, "Write a Python program to find the list of words that are longer than n from a given list of words.": 0.5142857142857143, "Write a Python function that returns a list of numbers in a specified range.": 0.5, "Write a Python program to find the average of a list using for loop.": 0.5, "Write a Python program to find the longest pallindrome substring from a given string.": 0.5, "Write a Python program to find the most common words in a given text.": 0.5}, "avg_similarity_score": 0.2105245706465668} -{"instruction": "Write a Python program to remove and print every third number from a list of numbers until the list becomes empty.", "input": "", "output": "import random\n\ndef main():\n num_list = [i for i in range(100)]\n random.shuffle(num_list)\n while num_list:\n print(num_list[2])\n del num_list[2]\nmain()", "most_similar": {"Write a Python program to find the maximum and minimum number from a given list.": 0.5555555555555556, "Write a Python function to find the smallest number from a sequence of numbers.": 0.5142857142857143, "Write a Python program to find the number of even and odd numbers from a series of numbers.": 0.5128205128205129, "Write a Python program to find the highest 3 values from a list of values.": 0.5, "Write a Python program to sort a given list of names in ascending order.": 0.4571428571428571, "Write a Python program to find the number of equal numbers from three given integers.": 0.4444444444444444, "Write a Python function that takes a list and returns a new list with unique elements of the first list.": 0.4390243902439024, "Write a Python program to create a dictionary from a string.": 0.43749999999999994, "Write a Python function to reverse a given list of integers.": 0.43749999999999994, "Write a program to find the smallest number in a list.": 0.43749999999999994}, "avg_similarity_score": 0.19470251805194486} -{"instruction": "Write a Python program to check whether a specified number is a perfect square.", "input": "", "output": "def is_perfect_square(num):\n if num < 0:\n return False\n guess = num // 2\n while guess * guess != num:\n guess = (guess + (num // guess)) // 2\n return guess * guess == num\n\nprint(is_perfect_square(25))", "most_similar": {"Write a python program to check if the number is prime.": 0.64, "Write a Python function to check if a given number is a prime number or not.": 0.6000000000000001, "Write a Python function to check whether a passed string is palindrome or not.": 0.5714285714285714, "Write a Python program to create a dictionary from a string.": 0.56, "Write a Python program to add a key to a dictionary.": 0.56, "Write a Python function to check if a given number is a Keith number or not. A Keith number is a number which is one less than a perfect square.": 0.5, "Write a Python program to find the maximum and minimum number from a given list.": 0.4827586206896552, "Write a program to find the smallest number in a list.": 0.4799999999999999, "Write a Python function to calculate the factorial of a number.": 0.4799999999999999, "Write a Python program to find the number of occurrences of a specified element in a given array of integers.": 0.47058823529411764}, "avg_similarity_score": 0.1975174744305651} -{"instruction": "What is the difference between a variable and a constant in a programming language?", "input": "", "output": "A variable is a data item that can be used for storing a value or expression, while a constant is a data item that cannot be changed during the program\u2019s execution.", "most_similar": {"What is the difference between a list and a tuple in Python?": 0.6923076923076924, "What is the difference between a static and a dynamic method?": 0.64, "What is the difference between a deep copy and a shallow copy?": 0.6153846153846153, "What is the difference between a pod and a horizontal pod autoscaler?": 0.6153846153846153, "What is the difference between a replica set and a stateful set?": 0.6153846153846153, "What is the difference between a for loop and a while loop?": 0.6153846153846153, "What is the difference between a web server and a web application server?": 0.5925925925925927, "What is the difference between a class and an object?": 0.5833333333333334, "What is the difference between a relative and absolute path?": 0.5833333333333334, "What is the difference between a binary search tree and a red-black tree?": 0.5714285714285714}, "avg_similarity_score": 0.163923020858047} -{"instruction": "What is a \u201cPythonic\u201d way of writing code?", "input": "", "output": "Pythonic code adheres to a set of style and naming conventions that make the code easier to read, write, and maintain. For example, it is recommended that you use underscores instead of camelCase to name variables in Python, and you should use double quotes for string literals.", "most_similar": {"What is a Dockerfile?": 0.5, "What is a cron job ?": 0.4615384615384615, "What is a Docker container?": 0.4615384615384615, "What is a list comprehension?": 0.4615384615384615, "What is a persistent volume ?": 0.4615384615384615, "What is a stateful set ?": 0.4615384615384615, "What is the purpose of a hash table?": 0.375, "What is the output of this code?\n```\nfor i in range(10):\n print(i)\n```": 0.36363636363636365, "What is Kubernetes ?": 0.36363636363636365, "What is the python code to print hello world?": 0.35294117647058826}, "avg_similarity_score": 0.12920682825150454} -{"instruction": "I want to know what is the difference between abstract classes and interfaces?", "input": "", "output": "An interface defines a group of related methods with empty bodies. It is used to achieve abstraction in a program. The main objective of an interface is to achieve abstraction. An abstract class is a class that contains at least one abstract method. An abstract class can provide the implementation of some of its methods while leaving other methods without implementation.", "most_similar": {"What is the difference between `NaN` and `Infinity`?": 0.5714285714285714, "What is the difference between `git pull` and `git fetch` ?": 0.5217391304347826, "What is the difference between a relative and absolute path?": 0.5217391304347826, "What is the difference between a class and an object?": 0.5217391304347826, "What is the difference between an ingress and a persistent volume?": 0.4999999999999999, "What is the difference between a static and a dynamic method?": 0.4999999999999999, "What is the difference between a deep copy and a shallow copy?": 0.48000000000000004, "What is the difference between a pod and a horizontal pod autoscaler?": 0.48000000000000004, "What is the difference between a replica set and a stateful set?": 0.48000000000000004, "What is the difference between a list and a tuple in Python?": 0.48000000000000004}, "avg_similarity_score": 0.12711846955265216} -{"instruction": "I have written the following Java code:\n`int num = 0; while (num > 0) { // code block }`\nWhy does the code inside the while loop not run?", "input": "", "output": "The code inside the while loop does not run because the condition num > 0 is initially false, since num is assigned the value 0. So the code block is skipped and the program continues executing the next statement.", "most_similar": {"I have the following code in python: ```python b = sorted(a, key=lambda x: (x[0], x[1]), reverse=True) ``` What does it do?": 0.2857142857142857, "I have the following code: ```python def get_max_value(list): max_value = list[0] for i in range(1, len(list)): if list[i] > max_value: max_value = list[i] return max_value ``` What does the function do?": 0.25, "I have this python code: ```python def make_dict(df): d = dict(zip(df.columns, df.values[0])) return d ``` What does the function do?": 0.24, "What does the following python code do?\n```python def is_prime(num):\n\t# Return false if the number is negative\n\tif num < 0:\n\t\treturn False\n\n\t# Check if the number is prime\n\tif not is_harshad_number(num):\n\t\treturn False\n\n\t# Check if the number is truncable\n\twhile num > 0:\n\t\tr = num % 10\n\t\tnum = num // 10\n\t\tif not is_harshad_number(num):\n\t\t\treturn False\n\treturn True\n ```": 0.22727272727272727, "What is the output of the following python code?\n```python\ndef function(a):\n if a > 0:\n print('Positive')\n else:\n print('Negative')\n\nfunction(0)\n```": 0.20833333333333331, "Find the bug in the following code piece: a = 1 while a == 1: b = input(\"what's your name ?\") print(\"Hi \",b, \" this is infinity loop !\")": 0.19607843137254902, "Using the comment as a guide, replace the \"TODO\" comment in the code with the proper code.": 0.19047619047619052, "I have a list of numbers and I want to find the average of all the numbers.": 0.19047619047619052, "I am trying to run the following code in Python: ```python def f(x): return x + 1 print(f(1)) ``` I get an error. What is the problem?": 0.1886792452830189, "What is the output of the following code?\n```\npublic class Test {\n public static void main(String[] args) {\n int i = 1;\n while (i <= 5) {\n System.out.println(i);\n i++;\n }\n }\n}\n```": 0.1886792452830189}, "avg_similarity_score": 0.07561991394257525} -{"instruction": "I have the following list: ```[['Apple', 'Google', 'Microsoft'], ['Amazon', 'Intel', 'NVIDIA'], ['Sony', 'Samsung', 'LG']]```. How do I access the string \"Apple\" using Python?", "input": "", "output": "You can access the string \"Apple\" using Python by referencing the 0th index of the 0th index of the parent list.\n\n```python my_list = [['Apple', 'Google', 'Microsoft'], ['Amazon', 'Intel', 'NVIDIA'], ['Sony', 'Samsung', 'LG']] print(my_list[0][0]) ```", "most_similar": {"I have a list of numbers, how do I find the second largest number?": 0.3783783783783784, "I have a list of strings, how do I convert them to numbers?": 0.33333333333333337, "How do I convert a string to a number in Python?": 0.29411764705882354, "How do I get the power of a number in python?": 0.29411764705882354, "How do you find the length of a string in Python?": 0.29411764705882354, "How do you find the largest number in a list using Python?": 0.2857142857142857, "How can I find the maximum and minimum value in a list using Python?": 0.27027027027027023, "I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.2666666666666666, "How do I print a list in Python?": 0.25806451612903225, "How do I output a string in C++ programming?": 0.25}, "avg_similarity_score": 0.09572788045597089} -{"instruction": "Write a Python function that takes a list of numbers and make a new list containing the numbers in a random order.", "input": "", "output": "import random def shuffle(num_list):\n shuffled_list = []\n # Shuffle the list\n while len(num_list) > 0:\n i = random.randint(0, len(num_list) - 1)\n shuffled_list.append(num_list[i])\n del num_list[i]\n\n return shuffled_list\n\nnum_list = [1, 2, 3, 4, 5, 6, 7, 8, 9]\nprint(shuffle(num_list))", "most_similar": {"Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.6511627906976744, "Write a Python function that takes a list and returns a new list with unique elements of the first list.": 0.6190476190476191, "Write a Python function that returns a list of numbers in a specified range.": 0.6111111111111112, "Write a Python function that takes a string and returns a new string with the words in sorted order and unique.": 0.6046511627906977, "Write a function that takes a list of numbers and returns a list of the same numbers, but with the first and last elements swapped.": 0.5957446808510639, "Write a function that receives a list of items and returns the items in reverse order.": 0.5789473684210527, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.5714285714285713, "Write a Python function that takes a string as input and returns the string in reverse order.\n'Hello'": 0.55, "Write a function that takes an array of numbers and returns the largest number in the array.": 0.5128205128205129, "Write a python function that returns a value from a list, selected at random.": 0.5000000000000001}, "avg_similarity_score": 0.21256297274477384} -{"instruction": "Write a function that receives a number and prints its integer digits separately.", "input": "", "output": "def print_digits(num):\n while num > 0:\n digit = num % 10\n print(digit, end = ' ')\n num //= 10", "most_similar": {"Write a function that takes a number and returns its first digit": 0.64, "Write a function that returns true if a number is prime, and otherwise returns false.": 0.5, "Write a function that receives a list of items and returns the items in reverse order.": 0.4827586206896552, "Write a function that reverses a given string.": 0.4761904761904762, "Write a Python function that takes a number as input and returns its square, cube, square root, cube root, and the sum of its digits.": 0.47368421052631576, "Write a Python function that takes a number as input and returns the square of that number.": 0.4666666666666667, "Write a function that creates a list of the multiples of a number between 0 and a limit.": 0.45161290322580644, "Write a function that prints the reverse of a string.": 0.4347826086956522, "Write a Python function that removes the first item from a list and returns it.": 0.42857142857142855, "Write a Python function to calculate the factorial of a number.": 0.41666666666666663}, "avg_similarity_score": 0.15816145776278426} -{"instruction": "Write a Python function to concatenate all elements in a list into a string and return it.", "input": "", "output": "def list_to_string(ls):\n string = \"\"\n for element in ls:\n string += str(element)\n return string", "most_similar": {"Write a Python function to find the sum of all items in a list.": 0.5806451612903226, "Write a Python function to find the first repeated word in a given string, ignoring case and punctuation.": 0.5142857142857143, "Write a Python function that returns a specified number of elements in a list from a specified index.": 0.5142857142857143, "Write a Python function to reverse a given list of integers.": 0.5, "Write a Python function that removes the first item from a list and returns it.": 0.5, "Write a Python program to create a dictionary from a string.": 0.5, "Write a Python function to find the first non-pallindrome string in a given list.": 0.5, "Write a python code to find the minimum value in a list.": 0.4827586206896552, "Write a Python function to find the largest number in a dictionary.": 0.4827586206896552, "Write a Python program to generate all permutations of a given list.": 0.4827586206896552}, "avg_similarity_score": 0.20519571741397366} -{"instruction": "Write a function in Python that takes a number and prints a right triangle with that many rows.", "input": "", "output": "def print_triangle(rows):\n for i in range(1, rows + 1):\n for j in range(i):\n print(i, end = ' ')\n print()\n\nprint_triangle(4)", "most_similar": {"Write a function that takes a number and returns its first digit": 0.5333333333333333, "Write a function that receives a number and prints its integer digits separately.": 0.5161290322580646, "Write a Python function that takes a number as input and returns the square of that number.": 0.5142857142857143, "Write a Python function that takes a list and returns a new list with unique elements of the first list.": 0.4736842105263158, "Write a function that takes a string and returns a new string with the first letter of each word capitalized.": 0.4736842105263158, "Write a Python function that takes a string and returns a new string with the words in sorted order and unique.": 0.4615384615384615, "Write a function that takes a string as input and reverse only the vowels of a string.": 0.45714285714285713, "Write a function that creates a list of the multiples of a number between 0 and a limit.": 0.4444444444444444, "Write a function that prints the reverse of a string.": 0.42857142857142855, "Write a function that returns true if a number is prime, and otherwise returns false.": 0.42424242424242425}, "avg_similarity_score": 0.1781295296517959} -{"instruction": "Write a Python program to sort (ascending and descending) a dictionary by value.", "input": "", "output": "import operator\ndef sort_by_value(d, descending=False):\n return sorted(d.items(), key=operator.itemgetter(1), reverse=descending)", "most_similar": {"Write a Python program to add a key to a dictionary.": 0.5833333333333334, "Write a Python program to create a dictionary from a string.": 0.5833333333333334, "Write a Python program to sort a given list of names in ascending order.": 0.5185185185185186, "Write a Python program to find the maximum and minimum number from a given list.": 0.5, "Write a Python program to generate all permutations of a given list.": 0.48000000000000004, "Write a Python function to find the largest number in a dictionary.": 0.48000000000000004, "Write a python code to implement quick sort": 0.4761904761904762, "Write a Python program to find the sum of a non-negative integer.": 0.46153846153846156, "Can you tell me how to sort a dictionary by value in Python?": 0.46153846153846156, "Write a Python program to find the number of even and odd numbers from a series of numbers.": 0.45161290322580644}, "avg_similarity_score": 0.17962449743122005} -{"instruction": "In Python, what does the following code output?\n[3, 4, 5][-1]", "input": "", "output": "It outputs 5.\n\nA negative index for a Python list refers to an index starting from the end of the list. If a list has n elements, then the index -1 refers to the element at position n-1. The expression [3, 4, 5][-1] uses a negative index to refer to the last element in the list, [3, 4, 5].", "most_similar": {"What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.4242424242424242, "What is the output of the code below?\n\n```python x = [1, 2, 3, 4, 5] x = x[1:-1] print(x)```": 0.4242424242424242, "What is the value of the following expression?\n10 + 2 * 3 / 4": 0.4166666666666667, "I need to sum all the values in the following list: `[1,2,3,4,5,6,7,8,9]`.": 0.37499999999999994, "What does the function `print()` do?": 0.3333333333333333, "What does the following python code do?\n```python def sum_divisible_by_three(lst):\n\treturn sum(x for x in lst if x % 3 == 0)\n ```": 0.32432432432432434, "What does the HTML tag `

` do?": 0.3157894736842105, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.3125, "How to make a python program that will print the following pattern?\n```\n1\n1 2\n1 2 3\n1 2 3 4\n1 2 3 4 5\n```": 0.30769230769230765, "How to make a python program that will print the following pattern?\n```\n1\n2 3\n4 5 6\n7 8 9 10\n11 12 13 14 15\n```": 0.30769230769230765}, "avg_similarity_score": 0.12228582881667079} -{"instruction": "What is the correct syntax for creating a dictionary?", "input": "", "output": "You can create a dictionary using curly brackets, for example, d = { 'key': 'value' }. You can also use a dictionary comprehension, for example, d = { 'key': 'value' for item in list }.", "most_similar": {"What is the difference between a for loop and a while loop?": 0.4761904761904762, "What is the purpose of a hash table?": 0.47058823529411764, "What is a Dockerfile?": 0.46153846153846156, "What is a cron job ?": 0.42857142857142855, "What is a Docker container?": 0.42857142857142855, "What is a list comprehension?": 0.42857142857142855, "What is a stateful set ?": 0.42857142857142855, "What is a persistent volume ?": 0.42857142857142855, "What is the difference between a class and an object?": 0.4210526315789474, "What is the difference between a relative and absolute path?": 0.4210526315789474}, "avg_similarity_score": 0.13022384802086828} -{"instruction": "Write a Python function that takes a string and checks if it contains only consonants.", "input": "", "output": "def is_consonant(s):\n for c in s:\n if c not in 'aeiou':\n return True\n return False", "most_similar": {"Write a function that takes a string as input and reverse only the vowels of a string.": 0.5625, "Write a Python function that returns true if a string contains any space character.": 0.5517241379310344, "Write a Python function that takes a string as input and returns the string in reverse order.\n'Hello'": 0.5454545454545454, "Write a Python function that removes the first item from a list and returns it.": 0.5333333333333333, "Write a function that reverses a given string.": 0.5217391304347827, "Write a function that takes a number and returns its first digit": 0.5185185185185186, "Write a function that takes a string and returns the number of vowels in the string.": 0.5161290322580646, "Write a Python function to concatenate all elements in a list into a string and return it.": 0.5, "Write a Python function that takes a number as input and returns the square of that number.": 0.5, "Write a Python function that takes a string and returns a new string with the words in sorted order and unique.": 0.5}, "avg_similarity_score": 0.17822269761810655} -{"instruction": "In the following code snippet, what will be the value of the variable `year` after the last print statement?\n\n```\ndays = 365\nyear = days * 3\nprint(year)\nyear = year - 100\nprint(year)\n```", "input": "", "output": "The value of `year` will be 265.\n\nThe first print statement prints the value of `year` which is 365 * 3 = 1095. The second print statement prints the value of `year` after subtracting 100 which is 265.", "most_similar": {"What is the value of the following expression?\n10 + 2 * 3 / 4": 0.27906976744186046, "What is the output of the following code? ```py def print_odds(n): for i in range(n): if i % 2 == 0: print(i) print_odds(10) ```": 0.24137931034482757, "What is the output of the following code? ```py def a(): print(\"a\") b = a def c(): print(\"c\") b() ```": 0.23529411764705882, "In Python, what does the following code output?\n[3, 4, 5][-1]": 0.2325581395348837, "Given a year, return the century it is in. The first century spans from the year 1 up to and including the year 100, the second - from the year 101 up to and including the year 200, etc.": 0.23188405797101447, "What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.23076923076923075, "What is the output of the code below?\n\n```python x = [1, 2, 3, 4, 5] x = x[1:-1] print(x)```": 0.23076923076923075, "Given the following code, what does it print? ```python import requests url = \"https://example.com\" r = requests.get(url) if r.status_code != 200: print(\"error\") else: print(r.text) ```": 0.22950819672131148, "What is the output of the following code?\n```python\ndef foo():\n print(\"foo\")\n\ndef bar():\n print(\"bar\")\n\ndef main():\n foo()\n bar()\n\nmain()\n```": 0.22641509433962262, "What is the output of the following code? ```py a = 5 b = 15 print(\"a / b is\", a / b) print(\"a % b is\", a % b) print(\"a // b is\", a // b) ```": 0.22580645161290322}, "avg_similarity_score": 0.08975062249724976} -{"instruction": "Write a Python program to remove all duplicates from a list in Python", "input": "", "output": "```\ndef remove_duplicates(l):\n l = list(set(l))\n return l\n```", "most_similar": {"Write a Python program to generate all permutations of a given list.": 0.64, "How do you remove duplicates from a list in Python?": 0.608695652173913, "Write a Python program to sort a given list of names in ascending order.": 0.5925925925925927, "Write a Python program to create a dictionary from a string.": 0.5833333333333334, "Write a Python program to find the maximum and minimum number from a given list.": 0.5714285714285715, "Write a Python program to find the highest 3 values from a list of values.": 0.5714285714285715, "Write a Java program to remove a set of characters from a string.": 0.5384615384615384, "Write a Python program to remove and print every third number from a list of numbers until the list becomes empty.": 0.5294117647058824, "Write a Python program to find the average of a list using for loop.": 0.5185185185185186, "What are the different methods to remove an element from a list in Python?": 0.5185185185185186}, "avg_similarity_score": 0.20678123232429496} -{"instruction": "Write a function that computes the running total of the integers in a list.", "input": "", "output": "def running_total(l):\n total = 0\n for n in l:\n total += n\n return total", "most_similar": {"Write a python function that returns the sum of the elements of a list.": 0.6428571428571429, "Write a Python function that returns the largest item in a list.": 0.6153846153846153, "Write a function that prints the reverse of a string.": 0.5833333333333334, "Write a python function that returns the number of words in a given string.": 0.5714285714285714, "Write a Python function to find the sum of all items in a list.": 0.5714285714285714, "Write a Python function that returns the sum of all numbers in a list that are divisible by 3.": 0.5454545454545454, "Write a Python function to find the index of the first occurrence of a specified item in a list.": 0.5454545454545454, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.5142857142857143, "Write a Python function that returns a specified number of elements in a list from a specified index.": 0.5, "Write a Python function that returns a list of numbers in a specified range.": 0.5}, "avg_similarity_score": 0.23301133936803364} -{"instruction": "Complete the function.\ndef not_bad(s):\n if \"not\" not in s:\n return \"bad\"\n return \"good\"", "input": "", "output": "def not_bad(s):\n if \"not\" in s:\n return \"good\"\n return \"bad\"", "most_similar": {"Write a Python program to find the first appearance of the substring 'not' and 'poor' from a given string, if 'not' follows the 'poor', replace the whole 'not'...'poor' substring with 'good'. Return the resulting string.": 0.23076923076923078, "Given a string s, return the longest palindromic substring in s.": 0.2222222222222222, "What is the output of the following code?\n```python\ndef foo():\n x = 1\n def bar():\n x = 2\n return x\n return bar()\nprint(foo())\n```": 0.20512820512820512, "Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.": 0.20512820512820512, "Add comments in the given function to make the code more readable for humans.\ndef hill_climbing(initial_board):\n current = initial_board\n while current.has_successors():\n neighbour = Board(current.get_random_successor(), \"best\")\n if neighbour.value() >= current.value():\n return current\n current = neighbour\n return current": 0.19999999999999998, "Write a Python function to check if a number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence.": 0.19512195121951217, "What is the output of the following Python code? ```py def f(x): return x + 1 def g(x): return x * 2 print(g(f(3))) ```": 0.1904761904761905, "Write a Python function to check if a given number is a prime number or not.": 0.1875, "Given a string S, check if the letters can be rearranged so that two characters that are adjacent to each other are not the same.\n\nIf possible, output any possible result. If not possible, return the empty string.": 0.18518518518518517, "write a sum function in asm": 0.18181818181818182}, "avg_similarity_score": 0.08794114806764909} -{"instruction": "Consider the following code:\ndef f(x):\n return x + 1\nf(x) = x + 1\n\nWhat is the error in this code?", "input": "", "output": "There is a syntax error in the last line of the code. The correct way to assign f(x) to x+1 would be using an equal sign, as follows:\nf(x) = x + 1", "most_similar": {"I am trying to run the following code in Python: ```python def f(x): return x + 1 print(f(1)) ``` I get an error. What is the problem?": 0.5714285714285715, "What is the output of the following Python code? ```py def f(x): return x + 1 def g(x): return x * 2 print(g(f(3))) ```": 0.4680851063829788, "What is the output of the following code?\n```python\ndef func(x):\n return x + 1\n\ndef main():\n x = 1\n y = func(x)\n print(y)\n\nmain()\n```": 0.43478260869565216, "What is the output of the following code?\n```python\ndef f(x):\n return x * 2\n\ndef g(x):\n return f(x) + 1\n\ndef h(x):\n return g(x) * 2\n\nprint(h(2))\n```": 0.4150943396226415, "What is the output of this code?\n```python\ndef f(x):\n x = 2 * x + 1\n return x\n\nx = 3\nz = f(x)\nprint(z)\n```": 0.39999999999999997, "What is the output of the following code?\n```python\ndef foo():\n x = 1\n def bar():\n x = 2\n return x\n return bar()\nprint(foo())\n```": 0.3636363636363636, "Find the output of this code.\n```\ndef my_filter(x, y):\n return x\n\nprint(my_filter(1, 2))\n```": 0.358974358974359, "I have the following code in python: ```python b = sorted(a, key=lambda x: (x[0], x[1]), reverse=True) ``` What does it do?": 0.35555555555555557, "What does the following python code do?\n```python def sum_divisible_by_three(lst):\n\treturn sum(x for x in lst if x % 3 == 0)\n ```": 0.34782608695652173, "What is the output of the code below?\n\n```python x = [1, 2, 3, 4, 5] x = x[1:-1] print(x)```": 0.3333333333333333}, "avg_similarity_score": 0.10822678307885612} -{"instruction": "Write a function to find the first and last occurences of an element in a sorted array.", "input": "", "output": "def first_and_last(arr, x):\n first = -1\n last = -1\n for i, val in enumerate(arr):\n if val == x:\n if first == -1:\n first = i\n last = i\n return first, last", "most_similar": {"Write a Python function to find the sum of all items in a list.": 0.5806451612903226, "Write a Python function to find the first non-pallindrome string in a given list.": 0.5625, "Write a Python function to find the index of the first occurrence of a specified item in a list.": 0.5555555555555555, "Write a Python function to find the largest number in a dictionary.": 0.5517241379310345, "Write a Python program to find the number of occurrences of a specified element in a given array of integers.": 0.5405405405405405, "Write a Python program to find the first non-repeated character in a string.": 0.5161290322580646, "Write a Python function to find the first repeated word in a given string, ignoring case and punctuation.": 0.5142857142857143, "Write a C# program to find the sum of all the elements of an array.": 0.5, "Write a python code to find the area of a circle.": 0.5, "Write a function to find the longest common prefix string amongst an array of strings.": 0.5}, "avg_similarity_score": 0.22821595949236684} -{"instruction": "What are the differences between dictionary and list in Python?", "input": "", "output": "In Python, a dictionary is an unordered collection of items, while a list is an ordered collection of items. The items in a dictionary are identified by a key, which can be any immutable type, such as numbers, strings, or tuples. The items in a list are identified by an index, which is an integer starting from 0. The items in a dictionary are accessed using the square brackets operator, for example, `dict[key]`, while items in a list are accessed using the square brackets operator, for example, `list[index]`. A dictionary is declared using curly brackets and commas, for example, `dict = {'key1': 1, 'key2': 2, 'key3': 3}`, while a list is declared using square brackets and commas, for example, `list = ['one', 'two', 'three']`. In Python, a dictionary is mutable and a list is mutable. In other words, you can change the values of items in a dictionary and you can change the values of items in a list.", "most_similar": {"What are the major differences between the Array and List data structures?": 0.6363636363636365, "What are the differences between functional programming and object-oriented programming?": 0.5714285714285713, "What is the difference between a list and a tuple in Python?": 0.5454545454545454, "What are the different methods to remove an element from a list in Python?": 0.5, "What is the difference between the `==` and the `.equals()` methods in Java?": 0.45454545454545453, "What are the basic data types in Java?": 0.4444444444444445, "What is the difference between `NaN` and `Infinity`?": 0.4444444444444445, "What are the benefits and drawbacks of using virtual machines in cloud computing?": 0.4347826086956522, "What is the difference between a variable and a constant in a programming language?": 0.41666666666666663, "What is the difference between `git pull` and `git fetch` ?": 0.4000000000000001}, "avg_similarity_score": 0.13058799655431258} -{"instruction": "If you wanted to create a variable that counts up from 0 to 100, how would you do it in C++?", "input": "", "output": "You can create a variable that counts up from 0 to 100 in C++ using the following code: ``` int counter = 0; while (counter <= 100) { std::cout << counter << std::endl; counter++; } ``` In the example above, a variable named `counter` is created and set to 0. The `while` loop condition is set to `counter <= 100`. The body of the `while` loop will execute until the `counter` variable is greater than or equal to 100. The body of the `while` loop contains two statements. The first statement prints the current value of the `counter` variable using the `std::cout` stream. The second statement increments the `counter` variable by 1. The `std::endl` stream inserts a new line character after the value of the `counter` variable is printed. In the body of the `while` loop, the statements are executed sequentially, starting from the top. When the last statement is executed, the loop continues by incrementing the `counter` variable by 1, checking the `while` loop condition, and then executing the body of the `while` loop again.", "most_similar": {"How do you create a variable in Python?": 0.3448275862068965, "I am trying to use the following code to create a list of numbers from 1 to 100. But it is not working. Can you help me fix it? ```python numbers = [] for i in range(1, 100): numbers.append(i) ```": 0.2950819672131147, "How do I output a string in C++ programming?": 0.26666666666666666, "How do you create a new list from two lists in Python by picking one element each?": 0.2631578947368421, "If you have an array of numbers and you want to get the average of all the numbers, what is the shortest code to do it?": 0.25531914893617025, "Write a Python program to create a dictionary from a string.": 0.25, "How to check quickly if a number is prime in C?": 0.25, "Write a python function that sorts a list from large to small.": 0.24242424242424246, "Can you tell me how to sort a dictionary by value in Python?": 0.23529411764705882, "How do I find the sum of the first 1000 prime numbers in C++?": 0.22857142857142854}, "avg_similarity_score": 0.1119460851744161} -{"instruction": "What are the differences between `size_t` and `ssize_t` in C?", "input": "", "output": "In C, the `size_t` and `ssize_t` data types are both used to represent sizes and counts. Both of these data types are unsigned integer types. The `size_t` data type is a nonnegative integral data type that can hold any size or count. It is defined in the `` header file. The `ssize_t` data type is defined in the `` header file. It is a signed integer type that is used to represent a size or count that can be negative, 0, or positive. In other words, the `ssize_t` data type can hold any value that the `size_t` data type can hold, plus the negative values. The `ssize_t` data type is not defined in ANSI C or ISO C. It is a POSIX data type that is defined in the Single Unix Specification and is supported by most UNIX-based operating systems.", "most_similar": {"What are the differences between dictionary and list in Python?": 0.6363636363636365, "What are the differences between functional programming and object-oriented programming?": 0.5217391304347826, "What are the major differences between the Array and List data structures?": 0.5, "What is the difference between the `==` and the `.equals()` methods in Java?": 0.4166666666666667, "What is the difference between a list and a tuple in Python?": 0.4166666666666667, "What are the basic data types in Java?": 0.4, "What is the difference between `NaN` and `Infinity`?": 0.4, "What are the benefits and drawbacks of using virtual machines in cloud computing?": 0.4, "What is the difference between a variable and a constant in a programming language?": 0.3846153846153846, "What is the difference between a class and an object?": 0.3636363636363636}, "avg_similarity_score": 0.10620410075323759} -{"instruction": "Why should we use `std::thread` instead of `std::async`?", "input": "", "output": "In C++, `std::thread` and `std::async` are two ways to execute functions asynchronously. Both functions accept a function to execute as an argument and execute that function in a separate thread. They both return an object that can be used to query the thread status or wait for the thread to finish. The difference between the two functions is that `std::async` will not necessarily start a new thread to execute the function. It may instead use an existing thread from a thread pool. The thread pool is a collection of threads that are already running. By using an existing thread from the thread pool, `std::async` can save resources by not creating a new thread. If you need to run a function in a new thread, you should use `std::thread` instead of `std::async`.", "most_similar": {"Write a C program that shows the use of the function strtok().": 0.1818181818181818, "The output should be a list of all the prime numbers between 1 and 100.": 0.16, "bubble sort list of int in python": 0.11764705882352941, "If we have a string \"Hello, world!\", what will be the output of this code? ```py def echo(text): print(text) echo(\"Hello, world!\") ```": 0.11764705882352941, "Given a list of strings, find the longest string in the list. You can use the len function to find the length of a string.": 0.11428571428571428, "What is the purpose of a hash table?": 0.11111111111111112, "What is a \u201cPythonic\u201d way of writing code?": 0.11111111111111112, "How to find the standard deviation of a list?": 0.10526315789473685, "How can I sort a list of integers in Rust?": 0.10000000000000002, "Write a program to find the maximum of three numbers.": 0.10000000000000002}, "avg_similarity_score": 0.033775733943380216} -{"instruction": "How do you add a new attribute to an existing class in C#?", "input": "", "output": "You can add a new attribute to an existing class in C# using the following code: ```class MyClass { public int MyInt { get; set; } } var myClass = new MyClass(); myClass.MyInt = 2; ``` In the example above, the `MyClass` class is created using the `class` keyword. It contains a public integer property named `MyInt`. The `MyInt` property is initialized in the body of the class. The `MyClass` class is then instantiated using the `new` keyword. The integer property of the class instance is then set to 2 using the dot operator.", "most_similar": {"How do you add a link to a web page?": 0.5217391304347826, "How do you create a variable in Python?": 0.4761904761904762, "How do you initialize an ArrayList in Java?": 0.4761904761904762, "How do I output a string in C++ programming?": 0.4545454545454546, "How do I create a new branch in git?": 0.4545454545454546, "How do I push a tag to remote in git?": 0.4347826086956522, "How do you sort a list of strings in Python?": 0.4347826086956522, "How do you remove duplicates from a list in Python?": 0.4347826086956522, "How do you find the length of a string in Python?": 0.41666666666666663, "How do I convert a string to a number in Python?": 0.41666666666666663}, "avg_similarity_score": 0.13236988409852313} -{"instruction": "How do you cast the return value of a function to a different data type in C#?", "input": "", "output": "You can cast the return value of a function to a different data type in C# using the following code: ```public class MyClass { public static int GetValue() { return 2; } } public static void Main() { int result = (int)GetValue(); Console.WriteLine(result); } ``` In the example above, the `MyClass` class is defined, which contains a static integer method named `GetValue()`. The `GetValue` method returns the value 2. In the `Main` method, the return value of the `GetValue` method is cast to an `int` data type and assigned to the variable `result`. The value of the `result` variable is then printed to the console using the `Console.WriteLine()` method.", "most_similar": {"How do you find the length of a string in Python?": 0.5, "How do you output all the contents of a list in Python?": 0.4827586206896552, "How do I find the first and last occurrence of a substring in a string in C++?": 0.47058823529411764, "How do you find the number of occurrences of a given value in a list in Python?": 0.47058823529411764, "How do you add a new attribute to an existing class in C#?": 0.4666666666666667, "How do you add a link to a web page?": 0.4444444444444445, "How do you find the standard deviation of all items in a list in Python?": 0.43749999999999994, "How do you count the number of items in a list?": 0.42857142857142855, "How do I get the power of a number in python?": 0.42857142857142855, "How do I convert a string to a number in Python?": 0.42857142857142855}, "avg_similarity_score": 0.1750042512446108} -{"instruction": "How do you get the first and last index of an element in a list in Python?", "input": "", "output": "You can get the first and last index of an element in a list in Python using the following code: ```list = [1, 2, 3, 4, 5, 6, 7] # list of numbers element = 2 # element to search for result = [i for i, e in enumerate(list) if e == element] # list of indexes print(result) # prints [1, 5] ``` In the example above, a list of numbers is defined. An element is defined, which is a value in the list. The `enumerate()` method is used to iterate over the list. In the example above, the variable `i` is the index of the list and the variable `e` is the value of the list. The `enumerate()` method returns a list of tuples, which each contain an index and value. The list of tuples is then used in a list comprehension to search for the index of the element. If the element is found, its index is added to the list. The result is then printed to the console.", "most_similar": {"How do you find the index of an item in a list?": 0.6896551724137931, "How to get the last element of a list in Python?": 0.6428571428571428, "How do you find the standard deviation of all items in a list in Python?": 0.625, "How do you output all the contents of a list in Python?": 0.6206896551724139, "How do I get the first element of a list?": 0.5925925925925927, "How do you find the number of occurrences of a given value in a list in Python?": 0.5882352941176471, "How do I find the first and last occurrence of a substring in a string in C++?": 0.5882352941176471, "How do I get the power of a number in python?": 0.5714285714285714, "How do you count the number of items in a list?": 0.5714285714285714, "How do you find the length of a string in Python?": 0.5714285714285714}, "avg_similarity_score": 0.17559396229398438} -{"instruction": "What is the difference between a `string` and a `char` data type in C#?", "input": "", "output": "A `string` data type and a `char` data type are both used to represent text in C#. The `string` data type represents a string, which is a sequence of characters. The `char` data type represents a single character. The `string` data type is defined in the `System` namespace. The `string` data type can be assigned to a variable using double quotes. For example, `string myString = \"This is a string\";` A `char` data type can be assigned to a variable using single quotes. For example, `char myChar = 'A';` The `char` data type can also be implicitly converted to an `int` data type by casting it to an `int`. For example, `(int)'A'` is 65.", "most_similar": {"What is the difference between a list and a tuple in Python?": 0.6923076923076924, "What is the difference between a variable and a constant in a programming language?": 0.6428571428571429, "What is the difference between a static and a dynamic method?": 0.64, "What is the difference between a pod and a horizontal pod autoscaler?": 0.6153846153846153, "What is the difference between a deep copy and a shallow copy?": 0.6153846153846153, "What is the difference between a for loop and a while loop?": 0.6153846153846153, "What is the difference between a replica set and a stateful set?": 0.6153846153846153, "What is the difference between a web server and a web application server?": 0.5925925925925927, "What is the difference between a class and an object?": 0.5833333333333334, "What is the difference between a relative and absolute path?": 0.5833333333333334}, "avg_similarity_score": 0.16463929966914376} -{"instruction": "What is the difference between `val` and `var` in Kotlin?", "input": "", "output": "The `val` and `var` keywords are used to declare variables in Kotlin. The `val` keyword is used to declare a read-only variable, while the `var` keyword is used to declare a mutable variable. Both keywords can be used to declare variables of any data type, including primitive data types and reference data types. When declaring a variable using the `val` keyword, the variable must be initialized when it is declared. When declaring a variable using the `var` keyword, the variable does not need to be initialized when it is declared. For example, both `val name = \"John\"` and `var name = \"John\"` are valid declarations. However, the following is not valid: `val name;` The value of a variable declared using the `val` keyword cannot be changed. The value of a variable declared using the `var` keyword can be changed. The `val` keyword is used to declare a read-only variable that is initialized when it is declared. The `var` keyword is used to declare a mutable variable that is not initialized when it is declared.", "most_similar": {"What is the difference between `NaN` and `Infinity`?": 0.6666666666666665, "What is the difference between a list and a tuple in Python?": 0.6363636363636365, "What is the difference between the `==` and the `.equals()` methods in Java?": 0.6363636363636365, "What is the difference between a class and an object?": 0.6, "What is the difference between a relative and absolute path?": 0.6, "What is the difference between `git pull` and `git fetch` ?": 0.6, "What is the difference between a variable and a constant in a programming language?": 0.5833333333333334, "What is the difference between a `string` and a `char` data type in C#?": 0.5833333333333334, "What is the difference between an ingress and a persistent volume?": 0.5714285714285713, "What is the difference between a static and a dynamic method?": 0.5714285714285713}, "avg_similarity_score": 0.1287722957109735} -{"instruction": "A valid parentheses string is either empty (`\"\"`), `\"(\"` + `A + \")\"`, or `A + B`, where `A` and `B` are valid parentheses strings, and `+` represents string concatenation. For example, `\"\"`, `\"()\"`, `\"(())()\"`, and `\"(()(()))\"` are all valid parentheses strings.\n\nA valid parentheses string `S` is primitive if it is nonempty, and there does not exist a way to split it into `S = A + B`, with `A` and `B` nonempty valid parentheses strings.\n\nGiven a valid parentheses string `S`, consider its primitive decomposition: `S = P_1 + P_2 + ... + P_k`, where `P_i` are primitive valid parentheses strings.\n\nReturn `S` after removing the outermost parentheses of every primitive string in the primitive decomposition of `S`.", "input": "", "output": "class Solution:\n def removeOuterParentheses(self, S: str) -> str:\n stack = []\n ans = []\n for ch in S:\n if ch == \"(\":\n stack.append(ch)\n else:\n stack.pop()\n if len(stack) == 0:\n ans.append(ch)\n return \"\".join(ans)", "most_similar": {"What is the output of the following code? ```py a = 5 b = 15 print(\"a / b is\", a / b) print(\"a % b is\", a % b) print(\"a // b is\", a // b) ```": 0.1897810218978102, "Write a Python function to check if a given number is a prime number or not. A prime number is a positive integer that has exactly two distinct divisors: 1 and the number itself. For example, 2 is a prime number because it is only divisible by 1 and 2. Similarly, 3 is a prime number because it is only divisible by 1 and 3.": 0.18713450292397663, "Write a Python function to check if a given number is a Sphenic number or not. A Sphenic number is a number whose prime factorization only contains 3, 5, and 7. For example, 105 is a Sphenic number because it is divisible by 3, 5, and 7.": 0.1699346405228758, "Write a Python program to get a string made of the first 2 and the last 2 chars from a given a string. If the string length is less than 2, return instead of the empty string.": 0.16783216783216787, "Write a Python function to check if a given number is a Truncable prime or not. A Truncable prime is a prime number that remains prime when digits are removed from left or right side. For example, 3797 is a truncable prime because 3797, 797, 97 and 7 are all prime.": 0.16560509554140126, "Write a Python function to check if a given number is a palindrome or not. A palindrome is a number that remains the same when its digits are reversed. For example, 121 is a palindrome but 112 is not.": 0.16551724137931037, "Write a Python function to check if a given number is a Harshad number or not. A Harshad number is a number that is divisible by the sum of its digits. For example, 42 is a Harshad number because it is divisible by 6 (the sum of its two digits 4 + 2).": 0.16455696202531647, "Write a Python function to check if a given number is a Sphenic number or not. A Sphenic number is a composite number where the sum of its proper divisors is equal to the sum of its distinct prime factors. For example, 220 is a Sphenic number because its proper divisors are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110, and the sum of its distinct prime factors is 2 + 2 + 5 = 9.": 0.16393442622950818, "Write a Python function to check if a number is a Truncable number or not. A Truncable number is a number where the number generated by truncating the leftmost and rightmost digits of the number is a prime number. For example, 137 is a Truncable number, since 137, 37 and 7 are all prime numbers.": 0.16149068322981366, "Write a Python function to check if a given number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence. The Fibonacci sequence is a sequence of numbers where each number is the sum of the two preceding numbers. The first two numbers in the sequence are 0 and 1.": 0.16049382716049382}, "avg_similarity_score": 0.07594968325602515} -{"instruction": "Write a Python program to count the number of matching parenthesis in a given expression.", "input": "", "output": "def countParenthesis(expr):\n count = 0\n for i in range(len(expr)):\n if expr[i] == '(':\n count += 1\n elif expr[i] == ')':\n count -= 1\n if count < 0:\n return 0\n return count == 0", "most_similar": {"Write a Python program to find the frequency of each word in a given string.": 0.6666666666666666, "Write a Python program to find the number of occurrences of a specified element in a given array of integers.": 0.6285714285714286, "Write a python function that returns the number of words in a given string.": 0.6206896551724138, "Write a Python program to find the most common words in a given text.": 0.6206896551724138, "Write a program to find the smallest number in a list.": 0.6153846153846153, "Write a Python program to find the number of equal numbers from three given integers.": 0.6, "Write a Python program to find the maximum and minimum number from a given list.": 0.6, "Write a Python program to generate all permutations of a given list.": 0.5925925925925926, "Write a Python function to find the largest number in a dictionary.": 0.5925925925925926, "Write a Python program to find the longest common prefix of a given list of strings.": 0.5806451612903225}, "avg_similarity_score": 0.23877800939227964} -{"instruction": "Given an array of integers, find the maximum possible sum that can be obtained by subtracting any number from the array.", "input": "", "output": "class Solution:\n def maxSubtract(self, nums: List[int]) -> int:\n smallest = min(nums)\n return sum(nums) - smallest", "most_similar": {"Given an array of numbers, find the maximum sum of any contiguous subarray of the array.": 0.5945945945945946, "Given an array of integers, return the largest sum of non-adjacent numbers. Numbers can be 0 or negative.": 0.45, "Given an array of integers, find the pair of adjacent elements that has the largest product and return that product.": 0.4390243902439024, "Given an array of integers nums, write a method that returns the \"pivot\" index of this array.": 0.42105263157894735, "Given a binary array, find the maximum number of consecutive 1s in this array.": 0.4, "Given a list of numbers, find the sum of the numbers.": 0.37499999999999994, "Write a function that takes an array of numbers and returns the largest number in the array.": 0.36842105263157887, "Given a list of numbers, find the largest number in the list.": 0.36363636363636365, "Given an array of integers, return indices of the two numbers such that they add up to a specific target.": 0.3414634146341463, "Given an array of integers, sort it in ascending order using the bubble sort algorithm.": 0.3333333333333333}, "avg_similarity_score": 0.11482319446490435} -{"instruction": "Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.\n\nAn input string is valid if:\nOpen brackets must be closed by the same type of brackets.\nOpen brackets must be closed in the correct order.", "input": "", "output": "class Solution:\n def isValid(self, s: str) -> bool:\n stack = []\n for ch in s:\n if ch == '(':\n stack.append(')')\n elif ch == '[':\n stack.append(']')\n elif ch == '{':\n stack.append('}')\n elif not stack or ch != stack.pop():\n return False\n return not stack", "most_similar": {"Given a string, return the number of vowels used in the text.": 0.2641509433962264, "Given a string s, return the number of palindromic substrings in it. A string is a palindrome when it reads the same backward as forward. A substring is a contiguous sequence of characters within the string.": 0.25974025974025977, "Write a Python program to get a string made of the first 2 and the last 2 chars from a given a string. If the string length is less than 2, return instead of the empty string.": 0.2564102564102564, "Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n).": 0.24657534246575344, "Write a function that takes a string and returns the number of vowels in the string.": 0.2456140350877193, "Write a Python function that takes a string as input and returns the string in reverse order.\n'Hello'": 0.23728813559322035, "Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. A palindrome string is a string that reads the same backward as forward.": 0.2337662337662338, "Given a string S, check if the letters can be rearranged so that two characters that are adjacent to each other are not the same.\n\nIf possible, output any possible result. If not possible, return the empty string.": 0.2278481012658228, "Given a string s, return the number of palindromic substrings in it.": 0.22641509433962262, "Write a Python function that takes a string and returns a new string with the words in sorted order and unique.": 0.22580645161290325}, "avg_similarity_score": 0.11390855443370324} -{"instruction": "Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words.", "input": "", "output": "class Solution:\n def wordBreak(self, s: str, wordDict: List[str]) -> bool:\n wordDict = set(wordDict)\n dp = [False] * (len(s) + 1)\n dp[0] = True\n for i in range(1, len(s) + 1):\n for j in range(i):\n if dp[j] and s[j:i] in wordDict:\n dp[i] = True\n break\n return dp[len(s)]", "most_similar": {"Given a string s, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.": 0.2745098039215686, "Write a Python function to check if a given number is a repdigit or not. A repdigit is a positive integer that consists of a single digit repeated one or more times.": 0.27272727272727276, "Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s.": 0.2622950819672131, "How do I make a function that takes a string and returns a list of the words in the string?": 0.25925925925925924, "Given a string s, return the number of palindromic substrings in it. A string is a palindrome when it reads the same backward as forward. A substring is a contiguous sequence of characters within the string.": 0.2571428571428572, "Write a Python program to find the list of words that are longer than n from a given list of words.": 0.2545454545454545, "Write a Python function to check if a number is a Sphenic number or not. A Sphenic number is a number that can be decomposed into a product of two prime numbers.": 0.24242424242424243, "Write a function that takes in a string of one or more words, and returns the same string, but with all words sorted lengthwise.": 0.2413793103448276, "Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. A palindrome string is a string that reads the same backward as forward.": 0.22857142857142856, "Given an array of integers, return the largest sum of non-adjacent numbers. Numbers can be 0 or negative.": 0.22641509433962262}, "avg_similarity_score": 0.10106703571217499} -{"instruction": "Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.", "input": "", "output": "class Solution:\n def subarraySum(self, nums: List[int], k: int) -> int:\n count = 0\n for i in range(len(nums)):\n curr_sum = 0\n for j in range(i, len(nums)):\n curr_sum += nums[j]\n if curr_sum == k:\n count += 1\n return count", "most_similar": {"You are given a list of numbers. You need to find the median of the list.": 0.4, "Given an array of integers, find the pair of adjacent elements that has the largest product and return that product.": 0.3636363636363636, "If you have an array of numbers and you want to get the average of all the numbers, what is the shortest code to do it?": 0.35999999999999993, "Given an array of integers, find the maximum possible sum that can be obtained by subtracting any number from the array.": 0.35555555555555557, "Given an array of numbers, find the maximum sum of any contiguous subarray of the array.": 0.35000000000000003, "Given an array of integers nums, write a method that returns the \"pivot\" index of this array.": 0.34146341463414637, "Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.": 0.3384615384615385, "Given an array of integers, return the largest sum of non-adjacent numbers. Numbers can be 0 or negative.": 0.32558139534883723, "Given an array of integers, return indices of the two numbers such that they add up to a specific target.": 0.31818181818181823, "Given a binary array, find the maximum number of consecutive 1s in this array.": 0.3157894736842105}, "avg_similarity_score": 0.11874966005564297} -{"instruction": "Given a positive integer num, write a function which returns True if num is a perfect square else False.", "input": "", "output": "class Solution:\n def isPerfectSquare(self, num: int) -> bool:\n if num == 0 or num == 1:\n return True\n for i in range(2, num//2 + 1):\n if i * i == num:\n return True\n return False", "most_similar": {"Write a function that returns True if the string is a palindrome or False if it is not.": 0.4864864864864865, "Write a function that returns true if a number is prime, and otherwise returns false.": 0.47058823529411764, "Write a Python function that returns true if a string contains any space character.": 0.4242424242424242, "Write a Python program to check whether a specified number is a perfect square.": 0.36363636363636365, "Write a Python function to check if a given number is a prime number or not.": 0.34285714285714286, "Write a Python function to check if a given number is a Keith number or not. A Keith number is a number which is one less than a perfect square.": 0.326530612244898, "Write a Python function that returns True if the specified list and the specified value are not empty.": 0.3243243243243243, "Write a Python function that returns the largest item in a list.": 0.3225806451612903, "Write a Python function that takes two lists and returns True if they have at least one common member.": 0.3157894736842105, "Write a python function that returns a value from a list, selected at random.": 0.30303030303030304}, "avg_similarity_score": 0.13022063460115155} -{"instruction": "Given an array A of integers, return the number of (contiguous, non-empty) subarrays that have a sum divisible by K.", "input": "", "output": "class Solution:\n def subarraysDivByK(self, A: List[int], K: int) -> int:\n mods = {0: 1}\n count = 0\n curr_sum = 0\n for num in A:\n curr_sum += num\n remainder = curr_sum % K\n count += mods.get(remainder, 0)\n mods[remainder] = mods.get(remainder, 0) + 1\n return count", "most_similar": {"Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.": 0.4888888888888889, "Given an array of integers, return the largest sum of non-adjacent numbers. Numbers can be 0 or negative.": 0.45, "Given an array of integers, return indices of the two numbers such that they add up to a specific target.": 0.4390243902439024, "Given an array of integers, find the pair of adjacent elements that has the largest product and return that product.": 0.3902439024390244, "Given an array of integers, find the maximum possible sum that can be obtained by subtracting any number from the array.": 0.38095238095238093, "Given an array of numbers, find the maximum sum of any contiguous subarray of the array.": 0.37837837837837834, "Given an array of integers nums, write a method that returns the \"pivot\" index of this array.": 0.36842105263157887, "Given a string, return the number of vowels used in the text.": 0.36363636363636365, "Given a string s, return the number of palindromic substrings in it.": 0.36363636363636365, "Given an array of integers, sort it in ascending order using the bubble sort algorithm.": 0.3333333333333333}, "avg_similarity_score": 0.14795104684918778} -{"instruction": "What is the value of a++b?", "input": "", "output": "The value of a++b is b.", "most_similar": {"What is the purpose of a hash table?": 0.6666666666666666, "What is a Dockerfile?": 0.5454545454545454, "What is the value of the following expression?\n10 + 2 * 3 / 4": 0.5263157894736842, "What is a stateful set ?": 0.5, "What is a Docker container?": 0.5, "What is a persistent volume ?": 0.5, "What is a list comprehension?": 0.5, "What is the correct syntax for creating a dictionary?": 0.5, "What is a cron job ?": 0.5, "What is the difference between a class and an object?": 0.47058823529411764}, "avg_similarity_score": 0.17077784920702} -{"instruction": "I have a C# class as below. ```cs public class A { private int _i; public int i { get { return _i; } set { _i = value; } } } ``` How can I get access to the _i field in this class?", "input": "", "output": "You can't. The field is private, and you can't get access to it outside the class.", "most_similar": {"How can I get the current date and time in Python?": 0.26086956521739124, "How can I get the first 1000 prime numbers in Python?": 0.26086956521739124, "I'm trying to run a Python script on a remote server. I'm getting an error: \"ImportError: No module named 'requests'\". How can I fix this?": 0.25806451612903225, "What is the output of the following code?\n```\npublic class Test {\n public static void main(String[] args) {\n int i = 1;\n while (i <= 5) {\n System.out.println(i);\n i++;\n }\n }\n}\n```": 0.25396825396825395, "How can I get the number of days between two dates in python?": 0.25000000000000006, "I have a list of strings, how do I convert them to numbers?": 0.25000000000000006, "I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.2456140350877193, "I have a list of numbers, how do I find the second largest number?": 0.24489795918367346, "I have a code that is too slow. How can I make it faster?": 0.24489795918367346, "I have this interface for a C# class. ``` public interface IPriorityQueue : IEnumerable { void Enqueue(TItem node, TPriority priority); TItem Dequeue(); void Clear(); bool Contains(TItem node); void Remove(TItem node); void UpdatePriority(TItem node, TPriority priority); TItem First { get; } int Count { get; } } ``` Show me how to get the length of the priority queue?": 0.24175824175824176}, "avg_similarity_score": 0.10651945113279121} -{"instruction": "Show me a code in JavaScript that returns the sum of all the integers in a string.", "input": "", "output": "The following JavaScript code will return the sum of all the integers in a string: ```js const getSum = (str) => { let sum = 0; // Loop through each character in str for (let char of str) { // Check whether character is a digit if (char >= '0' && char <= '9') { // Add digit to sum sum += parseInt(char); } } // Return the sum return sum; } ``` The JavaScript function getSum() accepts a string as an argument. Then, it loops through the characters in the string and checks if each character is a digit. If it is, the digit is added to the sum. Finally, the sum is returned.", "most_similar": {"Write a function that computes the running total of the integers in a list.": 0.5161290322580646, "Write a python function that returns the number of words in a given string.": 0.5161290322580646, "Write a python function that returns the sum of the elements of a list.": 0.5161290322580646, "Write me a python function that returns the sum of all even numbers in an array of integers.": 0.5142857142857143, "Write a Python function that returns the sum of all numbers in a list that are divisible by 3.": 0.5, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.4736842105263158, "Write a function that returns the number of times the string 'hi' appears anywhere in the given string.": 0.45714285714285713, "How to find the sum of all the elements in a list in python?": 0.45161290322580644, "Write a Python function to find the sum of all items in a list.": 0.45161290322580644, "Write a function that prints the reverse of a string.": 0.4444444444444445}, "avg_similarity_score": 0.1921172660265573} -{"instruction": "How do you find the maximum value in a 2D array using C#?", "input": "", "output": "You can find the maximum value in a 2D array using the following C# code: ```cs int[,] array = new int[,] { { 3, 4, 5 }, { 6, 7, 8 } }; int max = int.MinValue; for (int i = 0; i < array.GetLength(0); i++) for (int j = 0; j < array.GetLength(1); j++) max = Math.Max(max, array[i, j]); Console.WriteLine($\"Max: {max}\"); ``` This code creates a 2D array, then loops through each item in the array and updates the max value if the current item is larger than the max value. Finally, the max value is output.", "most_similar": {"How do I find the maximum value in an array?": 0.6956521739130435, "How do you find the largest number in a list using Python?": 0.64, "How to find the maximum value in a list?": 0.6363636363636364, "How do you find the element with the lowest value in a list?": 0.6153846153846154, "How can I find the maximum and minimum value in a list using Python?": 0.5925925925925927, "How do you find the index of an item in a list?": 0.5599999999999999, "How do you find the number of occurrences of a given value in a list in Python?": 0.5333333333333333, "How do you find the standard deviation of all items in a list in Python?": 0.5, "How do you find the length of a string in Python?": 0.4999999999999999, "How do you count the number of items in a list?": 0.4999999999999999}, "avg_similarity_score": 0.15484936223882986} -{"instruction": "I am working on a project for my college and I need help. I am trying to make a simple calculator using Python. I want to show the result of an expression in the form of a list, for example 3 + 4 = 7. But I want it to show 3 + 4 = [7]. Is there a way to do this?", "input": "", "output": "You can use string formatting to show the result of an expression in the form of a list. For example: ```py num1 = 3 num2 = 4 expression = f'{num1} + {num2} = [{num1 + num2}]' print(expression) ```", "most_similar": {"I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.29629629629629634, "I need to sum all the values in the following list: `[1,2,3,4,5,6,7,8,9]`.": 0.25316455696202533, "Write a Python function to find the number of items in a list that are not equal to a given value.": 0.25, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.23809523809523808, "I have a list of numbers and I want to find the average of all the numbers.": 0.23684210526315788, "Write a Python function to find the index of the first occurrence of a specified item in a list.": 0.23076923076923078, "Generate a correct python program to fulfill the following purpose:\nCount the occurrence of an element x in a list y.": 0.22500000000000003, "I want to find the average of all the numbers in a list.": 0.2222222222222222, "I need a simple C++ program to find the factorial of a number.": 0.2222222222222222, "Write a Python function to find the sum of all items in a list.": 0.2191780821917808}, "avg_similarity_score": 0.12075988621147594} -{"instruction": "I am trying to reverse a string using Python. I have a function that takes a string as a parameter and returns the string in reverse order. Is there a more pythonic way to do this?", "input": "", "output": "You can reverse a string using the following Python code: ```py s = \"Hello, World!\" s = s[::-1] print(s) ``` This code creates a variable named s and assigns it the value \"Hello, World!\". Then, the variable s is updated to include the reversed string using the slice notation [::-1]. Finally, the updated string is output.", "most_similar": {"Write a Python function that takes a string as input and returns the string in reverse order.\n'Hello'": 0.5555555555555556, "Write a Python function that takes a string and returns a new string with the words in sorted order and unique.": 0.4210526315789474, "How do I make a function that takes a string and returns a list of the words in the string?": 0.39285714285714285, "Write a function that receives a list of items and returns the items in reverse order.": 0.3846153846153846, "Write a function that takes a string and returns the number of vowels in the string.": 0.3846153846153846, "Write a Python function that takes a number as input and returns the square of that number.": 0.3773584905660377, "Write a function that takes a string as input and reverse only the vowels of a string.": 0.3773584905660377, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.36065573770491804, "I am working on a project for my college and I need help. I am trying to make a simple calculator using Python. I want to show the result of an expression in the form of a list, for example 3 + 4 = 7. But I want it to show 3 + 4 = [7]. Is there a way to do this?": 0.35789473684210527, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.3508771929824561}, "avg_similarity_score": 0.15268997877825238} -{"instruction": "I have a dictionary in python where I have a key and the value is a list of strings. I want to search for a particular string in the list and return the key. What is the best way to do that?", "input": "", "output": "You can search for a particular string in the list and return the key in the following Python code: ```py my_dict = {\"a\": [\"str1\", \"str2\", \"str3\"], \"b\": [\"str4\", \"str5\"]} search_str = \"str5\" for key, values in my_dict.items(): if search_str in values: print(\"key:\", key, \"value:\", values) ``` This code creates a dictionary with key-value pairs where the value is a list of strings. Then, the search string is assigned a value. Finally, a for loop is used to iterate through the items in the dictionary. The for loop uses the items() method to return the key and the values. Then, the if statement checks if the search string is in the values for the key. If so, the key and the values are printed.", "most_similar": {"I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.40625000000000006, "I want to find a specific item in a long list of items. The list is sorted by an item field. What is the best data structure to use?": 0.3661971830985915, "I am trying to reverse a string using Python. I have a function that takes a string as a parameter and returns the string in reverse order. Is there a more pythonic way to do this?": 0.358974358974359, "I have a list of numbers and I want to find the average of all the numbers.": 0.33898305084745767, "Write a python function that adds a new key to a dictionary and returns the value of the key.": 0.3278688524590164, "If you have an array of numbers and you want to get the average of all the numbers, what is the shortest code to do it?": 0.3235294117647059, "Given a list of strings, find the longest string in the list. You can use the len function to find the length of a string.": 0.2985074626865672, "I have the following code: ```python def get_max_value(list): max_value = list[0] for i in range(1, len(list)): if list[i] > max_value: max_value = list[i] return max_value ``` What does the function do?": 0.29629629629629634, "I have a list of strings, how do I convert them to numbers?": 0.2909090909090909, "How can I convert a list of strings to a list of integers?": 0.2909090909090909}, "avg_similarity_score": 0.15915149722924593} -{"instruction": "What is the average salary of a software engineer in the US?", "input": "", "output": "The Bureau of Labor Statistics (BLS) conducted a study in 2020 and concluded that the average annual salary for a software engineer is $120,500.", "most_similar": {"What is the value of a++b?": 0.5263157894736842, "What is the purpose of a hash table?": 0.5, "What is the sum of the ASCII values of all the letters in the word \"apple\"?": 0.42857142857142855, "What is the difference between a list and a tuple in Python?": 0.4166666666666667, "What is the value of the following expression?\n10 + 2 * 3 / 4": 0.4166666666666667, "What is the difference between a `string` and a `char` data type in C#?": 0.3846153846153846, "What is the output of this code?\n```\nfor i in range(10):\n print(i)\n```": 0.3846153846153846, "What is the difference between a variable and a constant in a programming language?": 0.3846153846153846, "What is the correct syntax for creating a dictionary?": 0.380952380952381, "What is a Dockerfile?": 0.375}, "avg_similarity_score": 0.1743156371025612} -{"instruction": "The average speed of the jet is 1000km/hr. It takes 1hr 45min to fly from place A to place B. Place B is 800km from place A. What is the speed of the jet for the first half of the journey?", "input": "", "output": "Sol: Let x = the speed of the jet for the first half of the journey\nx = 1000km/hr, which is 27.77777778km/min.\nWe know that the jet flies a total of 800km in 1 hr 45 min, so: 800/27.77777778 = 28.31666667 min.\nWe know the jet flies for 1 hr 45 min, so: 28.31666667 + 45 = 73.31666667 min\nSolve: x * 73.31666667 = 800\nx = 800 / 73.31666667 = 10.94866837 km/min\nThe speed of the jet for the first half of the journey is 10.94866837 km/min.", "most_similar": {"What is the output of the following code? ```py a = 5 b = 15 print(\"a / b is\", a / b) print(\"a % b is\", a % b) print(\"a // b is\", a // b) ```": 0.273972602739726, "Solve the math problems. Intermediate steps are required.\nA train running at the speed of 36 km/hr crosses a pole in 9 seconds. what is the length of the train?": 0.273972602739726, "What is the sum of the ASCII values of all the letters in the word \"apple\"?": 0.24137931034482757, "Write a Python function to check if a given number is an Armstrong number or not. An Armstrong number is a number that is equal to the sum of its own digits each raised to the power of the number of digits.": 0.23809523809523808, "Given a string s, return the number of palindromic substrings in it. A string is a palindrome when it reads the same backward as forward. A substring is a contiguous sequence of characters within the string.": 0.23076923076923075, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.23076923076923075, "Write a Python function to find the index of the first occurrence of a specified item in a list.": 0.22950819672131145, "Write a Python function to check if a given number is a Catalan number or not. A Catalan number is a number that occurs in the sequence of Catalan numbers. The sequence of Catalan numbers is generated by the following formula: Cn = (2n)! / (n+1)!n!": 0.22727272727272724, "Write a Python function to check if a given number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence. The Fibonacci sequence is a sequence of numbers where each number is the sum of the two preceding numbers. The first two numbers in the sequence are 0 and 1.": 0.22448979591836735, "Write a Python program to find the number of strings where the string length is 2 or more and the first and last character are same from a given list of strings.": 0.2162162162162162}, "avg_similarity_score": 0.12410182268815703} -{"instruction": "Tell me the 10th term of the sequence 1, 1, 2, 3, 5, 8, 13, 21, 34, ...?", "input": "", "output": "Sol: Let t = the tth term of the sequence.\nThe first few terms of the sequence are 1, 1, 2, 3, 5, 8, 13, 21, 34, so we know that t1 = 1, t2 = 1, t3 = 2, t4 = 3, t5 = 5, t6 = 8, t7 = 13, t8 = 21, and t9 = 34.\nWe know that the tenth term is 34, so: t10 = 34\nSolve: t10 = t9 + t8\nSubstitute: 34 = 34 + 21\n34 \u2212 34 = 21\n34 \u2212 21 = 0\nThe 10th term of the sequence is 0.", "most_similar": {"I need to sum all the values in the following list: `[1,2,3,4,5,6,7,8,9]`.": 0.37837837837837834, "What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.36842105263157887, "What is the output of the code below?\n\n```python x = [1, 2, 3, 4, 5] x = x[1:-1] print(x)```": 0.36842105263157887, "Convert this list into a list of sets: [[1, 2, 3], [4, 5, 6], [7, 8, 9]]": 0.35294117647058826, "What is the value of the following expression?\n10 + 2 * 3 / 4": 0.3448275862068966, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.3243243243243243, "How to make a python program that will print the following pattern?\n```\n1\n2 3\n4 5 6\n7 8 9 10\n11 12 13 14 15\n```": 0.3181818181818182, "Write a program to find the sum of all the multiples of 3 or 5 below 1000.": 0.29411764705882354, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.28571428571428564, "What is the output of the following Python code? ```py def f(x): return x + 1 def g(x): return x * 2 print(g(f(3))) ```": 0.2790697674418605}, "avg_similarity_score": 0.0974742012538701} -{"instruction": "Please explain how a web browser works?", "input": "", "output": "Sol: A web browser is a computer program that can retrieve and display web pages from a server.\nThe web browser sends a request to a server and the server sends a response. This exchange of data between the browser and the server is called a transaction.\nWeb browsers are known as clients, as they are the client programs that request information from servers.\nThe web server is the program that receives the request from a client, performs a request, and sends a response to the client. The server serves the requested information.", "most_similar": {"Describe how a compiler works.": 0.5, "How do you add a link to a web page?": 0.3529411764705882, "How do I make a dropdown menu?": 0.2857142857142857, "How to capitalize a string in Python?": 0.2857142857142857, "How do you create a variable in Python?": 0.26666666666666666, "How can I make a button in HTML?": 0.26666666666666666, "How do I print a list in Python?": 0.26666666666666666, "How to split a string into a list?": 0.26666666666666666, "Explain the difference between a compiler and an interpreter.": 0.25, "How to find the maximum value in a list?": 0.25}, "avg_similarity_score": 0.08276113985617378} -{"instruction": "How does TCP/IP work?", "input": "", "output": "TCP/IP is a communication protocol that allows computers to exchange data across a network. It consists of four layers: the application, transport, internet, and network access layers.\nHere are the details of each layer:\n- Application layer: In this layer, applications such as a web browser, email client, and spreadsheet application communicate with the TCP/IP network. This layer provides a convenient and easy-to-use interface that allows applications to connect to the network.\n- Transport layer: This layer allows data to be transferred between two points on the network. It determines the best way to deliver the data and provides error-checking.\n- Internet layer: This layer ensures that data is transferred from one computer to another on a network.\n- Network access layer: This layer is responsible for enabling physical devices to communicate with each other.", "most_similar": {"What does `if` do?": 0.22222222222222224, "Describe how a compiler works.": 0.20000000000000004, "What does the function `print()` do?": 0.1818181818181818, "How to make this code work? ```py def foo(): print('foo') def bar(function): function() bar(foo) ```": 0.1818181818181818, "Please explain how a web browser works?": 0.16666666666666666, "How to capitalize a string in Python?": 0.16666666666666666, "How do I make a dropdown menu?": 0.16666666666666666, "What does the HTML tag `

` do?": 0.16666666666666666, "How do you create a variable in Python?": 0.15384615384615385, "How can I make a button in HTML?": 0.15384615384615385}, "avg_similarity_score": 0.024350920296238275} -{"instruction": "Give me the list of the most popular programming languages and their respective use cases?", "input": "", "output": "Here are the most popular programming languages:\n- Python\n- Java\n- C++\n- C\n- PHP\n- Ruby\n- Javascript\n- Objective-C\n- Go\n- C#\nUse cases for programming languages:\n- Python: Python is used in robotics, artificial intelligence, machine learning, and big data analytics.\n- Java: Java is used in enterprise software development, e-commerce, and mobile applications.\n- C++: C++ is used in embedded systems, video games, and operating systems.\n- C: C is used in operating systems and embedded systems.\n- PHP: PHP is used in web development and web applications.\n- Ruby: Ruby is used in web development and application servers.\n- Javascript: Javascript is used in web development, application development, and mobile applications.\n- Objective-C: Objective-C is used in iOS application development.\n- Go: Go is used in system programming, cloud computing, and network programming.\n- C#: C# is used in web development, desktop applications, mobile applications, and games.", "most_similar": {"The output should be a list of all the prime numbers between 1 and 100.": 0.3333333333333333, "Tell me the 10th term of the sequence 1, 1, 2, 3, 5, 8, 13, 21, 34, ...?": 0.25, "Show me a code in JavaScript that returns the sum of all the integers in a string.": 0.25, "Write a function that creates a list of the multiples of a number between 0 and a limit.": 0.2424242424242424, "Solve the following equation system. Give me the final answer.": 0.24, "Can you give me an example of a computer vision task?": 0.23076923076923075, "What are the differences between functional programming and object-oriented programming?": 0.23076923076923075, "Identify the pos tag of the word in the given sentence.": 0.23076923076923075, "Given a list of numbers, find the sum of the numbers.": 0.23076923076923075, "Given an array of integers, find the pair of adjacent elements that has the largest product and return that product.": 0.2285714285714286}, "avg_similarity_score": 0.10625564899069602} -{"instruction": "How many bits are there in a byte?", "input": "", "output": "A byte is the smallest unit of data storage in a computer system. It contains eight bits.", "most_similar": {"How to find the maximum value in a list?": 0.35294117647058826, "How can I find the first repeated word in a string?": 0.3157894736842105, "How do you count the number of items in a list?": 0.3157894736842105, "Describe how a compiler works.": 0.3076923076923077, "How do you check if a value is present in a list?": 0.3, "How do you find the largest number in a list using Python?": 0.3, "How do you find the index of an item in a list?": 0.3, "How to find the frequency distribution of all values in a list?": 0.3, "How do you find the element with the lowest value in a list?": 0.2857142857142857, "How do you find the maximum value in a 2D array using C#?": 0.2857142857142857}, "avg_similarity_score": 0.10106118653004097} -{"instruction": "Write a function to solve the quadratic equation with one real root and one complex root.", "input": "", "output": "def solve(a, b, c):\n if a == 0:\n print('No solution')\n if b**2 - 4*a*c < 0:\n print('No real solution')\n x1 = (-b + sqrt(b**2 - 4*a*c)) / (2*a)\n x2 = (-b - sqrt(b**2 - 4*a*c)) / (2*a)\n print('x1 = {0:.2f}, x2 = {1:.2f}'.format(x1, x2))", "most_similar": {"Write a Python function to calculate the factorial of a number.": 0.3703703703703703, "Write a Python function to find the correlation between two lists.": 0.3703703703703703, "Write a function to find the first and last occurences of an element in a sorted array.": 0.3636363636363636, "Write a Python function to find the largest number in a dictionary.": 0.35714285714285715, "Write a Java program to find the cube root of a number.": 0.35714285714285715, "Write a Python function to find the first repeated word in a given string, ignoring case and punctuation.": 0.35294117647058826, "Write me a function in C++ to find the distance between two points": 0.3448275862068966, "Write a Python program to get the volume of a sphere with radius 6.": 0.3333333333333333, "Write a Python function to find the sum of all items in a list.": 0.3333333333333333, "Write a Python function to find the smallest number from a sequence of numbers.": 0.3333333333333333}, "avg_similarity_score": 0.15303718271216296} -{"instruction": "Find the ASCII value for the following characters: 'a', 'Z', '4', '+', '=', '&', '!', '~', '$', '#' and '%'.", "input": "", "output": "The ASCII value of each of the characters is:\n'a' = 97\n'Z' = 90\n'4' = 52\n'+' = 43\n'=' = 61\n'&' = 38\n'!' = 33\n'~' = 126\n'$' = 36\n'#' = 35\n'%' = 37", "most_similar": {"What is the value of the following expression?\n10 + 2 * 3 / 4": 0.4166666666666667, "How to find the maximum value in a list?": 0.380952380952381, "Write a python code to find the minimum value in a list.": 0.3333333333333333, "I want to find the average of all the numbers in a list.": 0.32, "How do you find the maximum value in a 2D array using C#?": 0.32, "How do you find the element with the lowest value in a list?": 0.32, "What's the solution for the problem?": 0.3157894736842105, "What is the value of a++b?": 0.3157894736842105, "How can I find the maximum and minimum value in a list using Python?": 0.30769230769230765, "How to find the sum of all the elements in a list in python?": 0.30769230769230765}, "avg_similarity_score": 0.1406838430777787} -{"instruction": "Ask the assistant to add two numbers.", "input": "", "output": "I cannot perform the requested action.", "most_similar": {"Write a function that returns the sum of two numbers.": 0.3529411764705882, "How do I find the greatest common divisor of two numbers?": 0.33333333333333326, "Write a Python program to find the Fibonacci series up to n numbers.": 0.3, "Write Python code to generate N Tribonacci numbers": 0.26666666666666666, "What is the python code to print hello world?": 0.25, "Write a program to find the maximum of three numbers.": 0.23529411764705882, "How to find the number of days between two dates?": 0.23529411764705882, "Write a Python program to add a key to a dictionary.": 0.2222222222222222, "Write a Python function to find the correlation between two lists.": 0.2222222222222222, "How can I get the first 1000 prime numbers in Python?": 0.2222222222222222}, "avg_similarity_score": 0.08300838847877742} -{"instruction": "What is the smallest positive integer that is divisible by all of the integers from 1 to 20?", "input": "", "output": "The smallest positive integer that is divisible by all of the integers from 1 to 20 is 232792560.", "most_similar": {"What is the difference between a variable that is:\n1. Immutable\n2. Mutable": 0.3870967741935484, "What is the average salary of a software engineer in the US?": 0.33333333333333337, "What is the value of the following expression?\n10 + 2 * 3 / 4": 0.33333333333333337, "Write a program to compute the sum of integers from k to n.": 0.3225806451612903, "What is the value of a++b?": 0.32, "What is the purpose of a hash table?": 0.30769230769230765, "What is the output of the code below?\n\n```python x = [1, 2, 3, 4, 5] x = x[1:-1] print(x)```": 0.30769230769230765, "What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.30769230769230765, "What is the output of the code below?\n\n```python import math print(math.sqrt(16))```": 0.303030303030303, "What is the python code to print hello world?": 0.2962962962962963}, "avg_similarity_score": 0.132203899148778} -{"instruction": "Write a Rust program that prompts the user to enter a number and then prints whether the number is even or odd.", "input": "", "output": "Here's a sample implementation in Rust: ``` fn main() { println!(\"Enter a number:\"); let mut input_text = String::new(); std::io::stdin().read_line(&mut input_text).expect(\"Failed to read line.\"); let input: u32 = input_text.trim().parse().expect(\"Please type a number!\"); if input % 2 == 0 { println!(\"{} is even\", input); } else { println!(\"{} is odd\", input); } } ``` This program reads a line of text from stdin, parses it as a number, and then prints whether it is even or odd.", "most_similar": {"Write a python program to check if the number is prime.": 0.4242424242424242, "Write a Python program to find the difference between a specified number and 13, if the number is greater than 13 return double the absolute difference.": 0.41666666666666663, "Write a Python function that takes a number as input and returns the square of that number.": 0.41025641025641024, "Write a function that receives a number and prints its integer digits separately.": 0.39999999999999997, "Write a Python program to find the number of even and odd numbers from a series of numbers.": 0.39999999999999997, "Write a Python program to check whether a specified number is a perfect square.": 0.3888888888888889, "Write a python code that asks the user to input a date and tells the user how many days are remaining until the inputted date.": 0.3829787234042554, "Please write a Rust function that takes a u64 input and returns the largest prime number less than that value.": 0.380952380952381, "Write a program to find the n-th ugly number.": 0.37499999999999994, "Write a Python program to find the first pallindromic string from a given string where the length is three or more.": 0.37209302325581395}, "avg_similarity_score": 0.17864783931621256} -{"instruction": "Write a C# program that uses a loop to display the integers from 1 to 20.", "input": "", "output": "```\nint count = 1;\nwhile (count <= 20)\n{\n Console.WriteLine(count);\n count++;\n}\n```", "most_similar": {"Write a program to compute the sum of integers from k to n.": 0.5517241379310345, "write a c++ program that calculates the perimeter of a square": 0.4444444444444444, "Write a C program that shows the use of the function strtok().": 0.42857142857142855, "Write a python function that sorts a list from large to small.": 0.42857142857142855, "Write a C# program that creates a new string from a given string by removing all vowels.": 0.42424242424242425, "Write a Python program to find the unique common elements from two lists.": 0.41379310344827586, "Write a Python program to find the Fibonacci series up to n numbers.": 0.41379310344827586, "Write a C program that takes a character from user and displays the ASCII value of the character.": 0.411764705882353, "What is the smallest positive integer that is divisible by all of the integers from 1 to 20?": 0.411764705882353, "Write a simple C++ program that prints \"Hello, World!\".": 0.39999999999999997}, "avg_similarity_score": 0.17326497250232276} -{"instruction": "Ask the assistant to convert 40 pounds into kilograms.", "input": "", "output": "I cannot perform the requested action.", "most_similar": {"Ask the assistant to add two numbers.": 0.5, "How to split a string into a list?": 0.23529411764705882, "What is the python code to print hello world?": 0.2222222222222222, "Write a Java program to convert an int to a string.": 0.19999999999999998, "Write a program to compute the sum of integers from k to n.": 0.18181818181818185, "Write a Python program to find the Fibonacci series up to n numbers.": 0.18181818181818185, "Add comments in the given function to make the code more readable for humans.": 0.17391304347826086, "What are the different methods to remove an element from a list in Python?": 0.17391304347826086, "Parse the natural language query into a SQL query that can be executed on the table.": 0.16, "How do I make a list of all the prime numbers up to a certain number?": 0.16}, "avg_similarity_score": 0.06936820935509773} -{"instruction": "Write a Java program that prints the numbers 1 through 100.", "input": "", "output": "```\nfor (int i = 1; i <= 100; i++) {\n System.out.println(i);\n}\n```", "most_similar": {"Write a simple C++ program that prints \"Hello, World!\".": 0.5, "Write a simple C# program that prints \"Hello, World!\".": 0.5, "Write a python script that prints the following pattern:\n```\n*\n**\n***\n****\n*****\n```": 0.5, "Write a function that prints the reverse of a string.": 0.47619047619047616, "Write a program to find the maximum of three numbers.": 0.47619047619047616, "Write a function that returns the sum of two numbers.": 0.47619047619047616, "write a c++ program that calculates the perimeter of a square": 0.45454545454545453, "Write a C# program that uses a loop to display the integers from 1 to 20.": 0.4444444444444444, "Write a C program that shows the use of the function strtok().": 0.43478260869565216, "Write a Java program to find the cube root of a number.": 0.43478260869565216}, "avg_similarity_score": 0.16307988535762466} -{"instruction": "Write an algorithm that returns the factorial of a number.", "input": "", "output": "```\npublic static int factorial(int n) {\n if (n <= 1) {\n return 1;\n } else {\n return n * factorial(n - 1);\n }\n}\n```", "most_similar": {"Write a Python function to calculate the factorial of a number.": 0.5714285714285713, "Write a function that prints the reverse of a string.": 0.5, "Write a function that returns the sum of two numbers.": 0.5, "Write a python function that returns the sum of the elements of a list.": 0.5, "Write a python function that returns the number of words in a given string.": 0.5, "Write a function that takes an integer and returns the nth digit of the number.": 0.48, "write a c++ program that calculates the perimeter of a square": 0.47619047619047616, "Write a Java program to find the cube root of a number.": 0.45454545454545453, "Write a Python function that returns the largest item in a list.": 0.45454545454545453, "Write a Python function that takes a number as input and returns the square of that number.": 0.4444444444444445}, "avg_similarity_score": 0.18180169187253897} -{"instruction": "Write a Java program that takes 5 numbers as input and prints the sum of these numbers.", "input": "", "output": "```\npublic static void main(String args[]) {\n int num1, num2, num3, num4, num5, sum;\n\n Scanner sc = new Scanner(System.in);\n\n System.out.print(\"Enter first number: \");\n num1 = sc.nextInt();\n\n System.out.print(\"Enter second number: \");\n num2 = sc.nextInt();\n\n System.out.print(\"Enter third number: \");\n num3 = sc.nextInt();\n\n System.out.print(\"Enter fourth number: \");\n num4 = sc.nextInt();\n\n System.out.print(\"Enter fifth number: \");\n num5 = sc.nextInt();\n\n // calculating sum\n sum = num1 + num2 + num3 + num4 + num5;\n\n System.out.println(\"Sum of numbers: \" + sum);\n}\n```", "most_similar": {"Write a Python function that takes two numbers as input and returns their sum.": 0.5806451612903226, "Write a Java program that prints the numbers 1 through 100.": 0.5714285714285714, "Write a Python function that takes a number as input and returns the square of that number.": 0.5294117647058824, "Write a function that takes a string as input and reverse only the vowels of a string.": 0.5294117647058824, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.5263157894736842, "Write a function that returns the sum of two numbers.": 0.5185185185185185, "Write me a python function that takes two arrays as input, and return the element-wise sum of the two arrays as a new array.": 0.4761904761904762, "Write a Python function that takes a number as input and returns its square, cube, square root, cube root, and the sum of its digits.": 0.4761904761904762, "Write a Python function that takes a number as input and returns the sum of all the numbers from 1 to that number that are divisible by 3 and 5.": 0.46808510638297873, "Write a C program that takes a character from user and displays the ASCII value of the character.": 0.45714285714285713}, "avg_similarity_score": 0.17471729506979927} -{"instruction": "Write a Java program that adds 2 to the number inputted by the user.", "input": "", "output": "```\npublic static void main(String args[]) {\n Scanner sc = new Scanner(System.in);\n\n System.out.print(\"Enter a number: \");\n int num = sc.nextInt();\n\n System.out.println(\"The number plus 2 is: \" + (num + 2));\n}\n```", "most_similar": {"Write a Java program to find the cube root of a number.": 0.5384615384615384, "Write a program to find the n-th ugly number.": 0.5, "Write a Python program to find the first Fibonacci number with the first 1000 digits.": 0.4827586206896552, "Write a Java program that prints the numbers 1 through 100.": 0.4799999999999999, "Write a python program to check if the number is prime.": 0.4799999999999999, "Write a program to find the smallest number in a list.": 0.4799999999999999, "Write a C program that shows the use of the function strtok().": 0.4615384615384615, "Write a python function to return the remainder of a number divided by 3 using the modulo % operator.": 0.43750000000000006, "Write a script to output the nth fibonacci number.": 0.43478260869565216, "Write a Python program to find the first Fibonacci number greater than four million.": 0.42857142857142855}, "avg_similarity_score": 0.18731193367101953} -{"instruction": "What is the output of the following code?\n```py\nnum = 3\n\ndef func(num):\n num += 4\n\nfunc(num)\nprint(num)\n```", "input": "", "output": "The output of the code is: ```py 3``` The code assigns the value 3 to the variable num. It then defines the function func. The function takes one argument called num and adds the value 4 to num. The function func is called and the value of the variable num is passed to it. Inside the function, the value of num is changed to 7. However, the function does not explicitly return anything. The variable num is printed outside the function. When the function is called, a new local variable is created called num with a value of 3. This variable is assigned the value 7 inside the function. However, this does not affect the value of the variable num outside the function. Hence, the value of num is 3 when it is printed.", "most_similar": {"What is the output of the following code? ```py def a(): print(\"a\") b = a def c(): print(\"c\") b() ```": 0.55, "What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.5365853658536585, "What is the output of the following code? ```py def add_five(x): x += 5 return x print(add_five(2)) ```": 0.5365853658536585, "What is the output of the following code?\n```python\ndef func(x):\n return x + 1\n\ndef main():\n x = 1\n y = func(x)\n print(y)\n\nmain()\n```": 0.5333333333333332, "What is the output of this code?\n```\nx = 10\ndef func():\n x = 20\n print(x)\nfunc()\nprint(x)\n```": 0.5263157894736842, "What is the value of the following expression?\n10 + 2 * 3 / 4": 0.5, "What is the output of the code below?\n\n```python x = [1, 2, 3, 4, 5] x = x[1:-1] print(x)```": 0.4878048780487805, "What is the output of the following Python code? ```py def f(x): return x + 1 def g(x): return x * 2 print(g(f(3))) ```": 0.47826086956521735, "What is the output of the following code? ```py def add(a, b): return a + b print(add(1, 2)) print(add(b=2, a=1)) ```": 0.47826086956521735, "What is the output of the following code?\n```python\ndef foo():\n print(\"foo\")\n\ndef bar():\n print(\"bar\")\n\ndef main():\n foo()\n bar()\n\nmain()\n```": 0.47619047619047616}, "avg_similarity_score": 0.1190185289790873} -{"instruction": "Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i.\n```py\nFor example, if our input was [1, 2, 3, 4, 5], the expected output would be [120, 60, 40, 30, 24]. If our input was [3, 2, 1], the expected output would be [2, 3, 6].\n```", "input": "", "output": "```py\ndef calc_products_of_all_ints_except_at_index(int_list):\n products_of_all_ints_except_at_index = []\n product_of_all_ints_except_i = 1\n for i in range(len(int_list)):\n product_of_all_ints_except_i *= int_list[(i + 1) % len(int_list)]\n products_of_all_ints_except_at_index.append(product_of_all_ints_except_i)\n return products_of_all_ints_except_at_index\n```", "most_similar": {"Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.24489795918367346, "I need to sum all the values in the following list: `[1,2,3,4,5,6,7,8,9]`.": 0.23655913978494625, "Write a Python function to check if a given number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. For example, 6 has divisors 1, 2 and 3 (excluding the number itself), and 6 = 1 + 2 + 3. Similarly, 28 has divisors 1, 2, 4, 7, 14 and 28, and 28 = 1 + 2 + 4 + 7 + 14.": 0.2328767123287671, "Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n).": 0.22857142857142856, "Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.": 0.22807017543859648, "Given an array of integers nums, write a method that returns the \"pivot\" index of this array.": 0.22222222222222224, "Write a Python function that accepts an integer (positive or zero) and returns the factorial of that number. The factorial of any positive number n is equal to the product of all positive integers less than or equal to n. Factorial of 0 is 1. For example, factorial of 6 is equal to 6*5*4*3*2*1 which is equal to 720.": 0.21897810218978103, "Given an array of integers, return the largest sum of non-adjacent numbers. Numbers can be 0 or negative.": 0.21739130434782608, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.21505376344086022, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.2127659574468085}, "avg_similarity_score": 0.09582549379200668} -{"instruction": "You are given a string s and an integer k. You can choose one of the first k letters of s and append it at the end of the string.\n\nReturn the lexicographically smallest string you could have after applying the mentioned step any number of moves.", "input": "", "output": "```py\ndef rearrange_to_lexicographically_smallest(s, k):\n # Get the first k letters of the string\n # Sort them\n # Append them to the string\n # Return the new string\n first_k_letters = sorted(s[:k])\n return s + \"\".join(first_k_letters)\n```", "most_similar": {"Write a Python program to get a string made of the first 2 and the last 2 chars from a given a string. If the string length is less than 2, return instead of the empty string.": 0.28571428571428575, "Given a string s, return the number of palindromic substrings in it.": 0.2711864406779661, "Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s.": 0.2702702702702703, "Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. A palindrome string is a string that reads the same backward as forward.": 0.26506024096385544, "Given a string s, return the number of palindromic substrings in it. A string is a palindrome when it reads the same backward as forward. A substring is a contiguous sequence of characters within the string.": 0.26506024096385544, "Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.": 0.2608695652173913, "Write a function that takes an integer and returns the nth digit of the number.": 0.25806451612903225, "You are given a list of numbers. You need to find the median of the list.": 0.25396825396825395, "Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.": 0.25352112676056343, "Given a list of strings, find the longest string in the list. You can use the len function to find the length of a string.": 0.24999999999999994}, "avg_similarity_score": 0.1058676762498371} -{"instruction": "What is the output of the following code?\n```py\ndef get_cube(x):\n return x * x * x\n\nprint(get_cube(get_cube(2)))\n```", "input": "", "output": "The output of the code is: ```py 64``` The code defines the function get_cube. The function takes one argument called x and returns the value of x cubed. The function is called twice with 2 as the argument. The value returned by the second function call is passed to the first function call as the argument. The first function call returns the value of 2 cubed, which is 8. The second function call returns the value of 8 cubed, which is 512. Since the function is called twice, the value 512 is printed when the print statement is executed.", "most_similar": {"What is the output of the following code? ```py def add_five(x): x += 5 return x print(add_five(2)) ```": 0.6818181818181819, "What is the output of the following Python code? ```py def f(x): return x + 1 def g(x): return x * 2 print(g(f(3))) ```": 0.6530612244897959, "What is the output of the following code?\n```python\ndef func(x):\n return x + 1\n\ndef main():\n x = 1\n y = func(x)\n print(y)\n\nmain()\n```": 0.6250000000000001, "What is the output of the following code?\n```python\ndef f(x):\n return x * 2\n\ndef g(x):\n return f(x) + 1\n\ndef h(x):\n return g(x) * 2\n\nprint(h(2))\n```": 0.5818181818181818, "What is the output of the following code?\n```python\ndef foo():\n x = 1\n def bar():\n x = 2\n return x\n return bar()\nprint(foo())\n```": 0.5652173913043478, "What is the output of this code?\n```python\ndef f(x):\n x = 2 * x + 1\n return x\n\nx = 3\nz = f(x)\nprint(z)\n```": 0.5531914893617021, "What is the output of the following code? ```py def add(a, b): return a + b print(add(1, 2)) print(add(b=2, a=1)) ```": 0.5306122448979592, "What is the output of the following code?\n```py\nnum = 3\n\ndef func(num):\n num += 4\n\nfunc(num)\nprint(num)\n```": 0.5116279069767442, "What is the output of the following code? ```py def a(): print(\"a\") b = a def c(): print(\"c\") b() ```": 0.5116279069767442, "What is the output of the code below?\n\n```python x = [1, 2, 3, 4, 5] x = x[1:-1] print(x)```": 0.5}, "avg_similarity_score": 0.11599043445035653} -{"instruction": "Given two strings word1 and word2, return the minimum number of steps required to make word1 and word2 the same. In one step, you can delete exactly one character in either string.", "input": "", "output": "```py\ndef min_num_of_steps(word1, word2):\n # Check if both words are equal\n # If they are, return 0\n # Check the length of the longer string\n # Return the difference between the length of the strings\n if word1 == word2:\n return 0\n if len(word1) > len(word2):\n return len(word1) - len(word2)\n return len(word2) - len(word1)\n```", "most_similar": {"Given a string, return the number of vowels used in the text.": 0.2727272727272727, "Given a string s, return the number of palindromic substrings in it.": 0.2727272727272727, "Given an array of integers `nums` and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order.": 0.26506024096385544, "Write a function that takes a string and returns the number of vowels in the string.": 0.25, "Given a list of strings, find the longest string in the list. You can use the len function to find the length of a string.": 0.2456140350877193, "Return the first non-repeating character in a string.": 0.24390243902439024, "Write a function that returns the number of times the string 'hi' appears anywhere in the given string.": 0.24000000000000005, "Write a function that takes an integer as input and returns the number of bits that are equal to 1 in the binary representation of that number. You can guarantee that input is non-negative.": 0.23880597014925375, "Given a string s, return the number of palindromic substrings in it. A string is a palindrome when it reads the same backward as forward. A substring is a contiguous sequence of characters within the string.": 0.23529411764705882, "Given a binary array, find the maximum number of consecutive 1s in this array.": 0.21739130434782608}, "avg_similarity_score": 0.10827107995110628} -{"instruction": "Write a function that takes an integer n as a parameter and returns the sum of the first n numbers.\n```py\nFor example, if the input is 3, the function should return 6, since 1 + 2 + 3 = 6.\n```", "input": "", "output": "```py\ndef sum_of_first_n_numbers(n):\n # Initialize the sum to 0\n # Iterate from 1 to n and add the number to the sum\n # Return the sum\n sum = 0\n for i in range(1, n + 1):\n sum += i\n return sum\n```", "most_similar": {"Write a function that takes a positive integer n and returns the next biggest number with the same number of 1 bits. For example, given the number 6 (0110 in binary), the function should return 9 (1001).": 0.4799999999999999, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.47619047619047616, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.4745762711864407, "Write a function that takes an integer and returns the nth digit of the number.": 0.45283018867924535, "Write a Python function that takes a number as input and returns the sum of all the numbers from 1 to that number that are divisible by 3 and 5.": 0.4411764705882353, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.41379310344827586, "Write a function that takes an integer as input and returns the number of bits that are equal to 1 in the binary representation of that number. You can guarantee that input is non-negative.": 0.4109589041095891, "Write a function that takes a string and returns the number of vowels in the string.": 0.4074074074074074, "I am trying to write a function that takes a list of numbers and returns the sum of the numbers. I wrote the following code in Python:\n```py def sum(lst):\n total = 0\n for i in lst:\n total += i\n return total\n```": 0.4050632911392405, "Write a function that takes a list of numbers and returns a list of the same numbers, but with the first and last elements swapped.": 0.38095238095238093}, "avg_similarity_score": 0.1590562662999987} -{"instruction": "You are given a string s. You can transform s into a palindrome by adding English lowercase letters in front of it.\n\nReturn the shortest palindrome you can find by performing this transformation.", "input": "", "output": "```py\ndef get_shortest_palindrome(s):\n # Check if the string is a palindrome\n # If it is, return the string\n # Add the string backwards to the string\n # Return the new string\n if is_palindrome(s):\n return s\n return s + get_shortest_palindrome(s[::-1])[::-1]\n\ndef is_palindrome(s):\n # Check if the string is the same when reversed\n # Return the result\n return s == s[::-1]\n```", "most_similar": {"You are given a string s and an integer k. You can choose one of the first k letters of s and append it at the end of the string.\n\nReturn the lexicographically smallest string you could have after applying the mentioned step any number of moves.": 0.35, "Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s.": 0.3333333333333333, "You are given a list of numbers. You need to find the median of the list.": 0.2857142857142857, "Given a list of strings, find the longest string in the list. You can use the len function to find the length of a string.": 0.2758620689655172, "Given a string s, return the longest palindromic substring in s.": 0.2727272727272727, "Given a string s, return the number of palindromic substrings in it.": 0.26666666666666666, "Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. A palindrome string is a string that reads the same backward as forward.": 0.2608695652173913, "Given a string `s`, find the length of the longest substring without repeating characters.": 0.2553191489361702, "Given a string s, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.": 0.24000000000000002, "Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words.": 0.23880597014925375}, "avg_similarity_score": 0.10332608471959014} -{"instruction": "Given a string s, return true if the s can be palindrome after deleting at most one character from it.", "input": "", "output": "```py\ndef can_be_palindrome(s):\n # Check if the string is the same when reversed\n # Return True if it is, False if not\n return is_palindrome(s) or is_palindrome(s[1:]) or is_palindrome(s[:-1])\n\ndef is_palindrome(s):\n # Check if the string is the same when reversed\n # Return the result\n return s == s[::-1]\n```", "most_similar": {"Given a string s, return the longest palindromic substring in s.": 0.45161290322580644, "Given a string s, return the number of palindromic substrings in it.": 0.4375, "Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words.": 0.33333333333333337, "Given a string s, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.": 0.3243243243243243, "Write a function that returns True if the string is a palindrome or False if it is not.": 0.3157894736842105, "Given a string, return the number of vowels used in the text.": 0.3125, "Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s.": 0.29787234042553196, "Given a string `s`, find the length of the longest substring without repeating characters.": 0.2941176470588235, "Given a string s, return the number of palindromic substrings in it. A string is a palindrome when it reads the same backward as forward. A substring is a contiguous sequence of characters within the string.": 0.2857142857142857, "Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.": 0.28571428571428564}, "avg_similarity_score": 0.10345973157118017} -{"instruction": "Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.", "input": "", "output": "```py\ndef move_zeroes(nums):\n # Initialize i to 0\n # Initialize j to the length of the array\n # Iterate from the start of the array until i is equal to j\n # Check if nums[i] is not 0\n # If it is not, move on to the next iteration\n # If it is 0, iterate from i + 1 until j\n # Check if nums[j] is not 0\n # If it is, swap nums[i] with nums[j]\n # Decrement j\n i = 0\n j = len(nums)\n while i < j:\n if nums[i] != 0:\n continue\n for k in range(i + 1, j):\n if nums[k] != 0:\n nums[i], nums[k] = nums[k], nums[i]\n j -= 1\n break\n return nums\n```", "most_similar": {"Given an array of integers nums, write a method that returns the \"pivot\" index of this array.": 0.3636363636363636, "Write a Python function to find the index of the first occurrence of a specified item in a list.": 0.34782608695652173, "Write a python function that returns the sum of the elements of a list.": 0.3414634146341463, "Write a C# program to find the sum of all the elements of an array.": 0.33333333333333337, "Given an array of integers, sort it in ascending order using the bubble sort algorithm.": 0.33333333333333337, "Write a Python function to find all prime numbers up to the given number n.": 0.33333333333333337, "Write a Python program to find the frequency of the words from the sentence given.": 0.33333333333333337, "Given an array A of integers, return the number of (contiguous, non-empty) subarrays that have a sum divisible by K.": 0.3333333333333333, "Given an array of numbers, find the maximum sum of any contiguous subarray of the array.": 0.3255813953488372, "Write a Python program to find the sum of the positive integers of a given range.": 0.3255813953488372}, "avg_similarity_score": 0.1575004195804616} -{"instruction": "Given a 2D integer matrix matrix, handle multiple queries of the following type:\n\nCalculate the sum of the elements of matrix inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2, col2).\nImplement the NumMatrix class:\n\nNumMatrix(int[][] matrix) Initializes the object with the integer matrix matrix.\nint sumRegion(int row1, int col1, int row2, int col2) Returns the sum of the elements of matrix inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2, col2).", "input": "", "output": "```py\nclass NumMatrix:\n def __init__(self, matrix):\n self.matrix = matrix\n self.sums = []\n for i in range(len(matrix)):\n self.sums.append([])\n for j in range(len(matrix[i])):\n self.sums[i].append(0)\n if i == 0 and j == 0:\n self.sums[i][j] = matrix[i][j]\n elif i == 0:\n self.sums[i][j] = self.sums[i][j - 1] + matrix[i][j]\n elif j == 0:\n self.sums[i][j] = self.sums[i - 1][j] + matrix[i][j]\n else:\n self.sums[i][j] = self.sums[i - 1][j] + self.sums[i][j - 1] - self.sums[i - 1][j - 1] + matrix[i][j]\n\n def sumRegion(self, row1, col1, row2, col2):\n if row1 == 0 and col1 == 0:\n return self.sums[row2][col2]\n elif row1 == 0:\n return self.sums[row2][col2] - self.sums[row2][col1 - 1]\n elif col1 == 0:\n return self.sums[row2][col2] - self.sums[row1 - 1][col2]\n else:\n return self.sums[row2][col2] - self.sums[row2][col1 - 1] - self.sums[row1 - 1][col2] + self.sums[row1 - 1][col1 - 1]\n```", "most_similar": {"You are given a string s and an integer k. You can choose one of the first k letters of s and append it at the end of the string.\n\nReturn the lexicographically smallest string you could have after applying the mentioned step any number of moves.": 0.17777777777777776, "Write a Python function that accepts a sequence of strings and returns a dictionary in which the keys are elements of the sequence and the values are the number of times each element occurs in the sequence.": 0.176, "Write a Python program that takes a list of numbers as input from the user, calculates the sum of all even numbers in the list, and returns the result. The program should check if the input is valid (i.e., if it's a list of numbers), and if it's not, it should return an error message. The program should also handle exceptions gracefully and return a user-friendly error message in case of any exceptions.": 0.16969696969696968, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.1651376146788991, "Given a year, return the century it is in. The first century spans from the year 1 up to and including the year 100, the second - from the year 101 up to and including the year 200, etc.": 0.15873015873015872, "Write a Python function to check if a given number is a Sphenic number or not. A Sphenic number is a composite number where the sum of its proper divisors is equal to the sum of its distinct prime factors. For example, 220 is a Sphenic number because its proper divisors are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110, and the sum of its distinct prime factors is 2 + 2 + 5 = 9.": 0.15757575757575756, "Write a Python function to check if a given number is a happy number or not. A happy number is defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers, while those that do not end in 1 are unhappy numbers.": 0.15730337078651688, "Write a python function that returns the sum of the elements of a list.": 0.1568627450980392, "Write a Python function that takes a list of numbers as input and returns the sum of all the numbers in the list that are greater than 5 and less than 10, and are even, and are not divisible by 3.": 0.15503875968992248, "Given the `root` of a binary tree, return the inorder traversal of its nodes' values.\n# Definition for a binary tree node.\nclass TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right": 0.15503875968992248}, "avg_similarity_score": 0.06407501409901725} -{"instruction": "You are given a binary string s consisting of only 0's and 1's. In one operation, you can change any '0' to '1'.\n\nReturn the minimum number of operations required to make s alternating, where s[i] == '0' and s[i + 1] == '1' for all i (0-based).", "input": "", "output": "```py\ndef min_num_of_operations(s):\n # Check if s has a length of 2 or less\n # If it does, return the length of s\n # Check if the string has an odd number of characters\n # If it does, return -1\n # Check if s is already alternating\n # If it is, return 0\n # Otherwise, return the length of the string\n if len(s) <= 2:\n return len(s)\n if len(s) % 2 != 0:\n return -1\n if s == \"01\" * (len(s) // 2):\n return 0\n return len(s)\n```", "most_similar": {"You are given a list of numbers. You need to find the number of pairs of indices (i, j) such that the difference between nums[i] and nums[j] is at most t and i < j.": 0.3023255813953488, "You are given a list of numbers. You need to find the median of the list.": 0.2727272727272727, "Given two strings word1 and word2, return the minimum number of steps required to make word1 and word2 the same. In one step, you can delete exactly one character in either string.": 0.2682926829268293, "You are given a string s and an integer k. You can choose one of the first k letters of s and append it at the end of the string.\n\nReturn the lexicographically smallest string you could have after applying the mentioned step any number of moves.": 0.268041237113402, "Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s.": 0.2597402597402597, "Given a string s, return the number of palindromic substrings in it.": 0.25806451612903225, "Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.": 0.25, "Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.": 0.24324324324324328, "You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins, return -1.": 0.24242424242424243, "You are given a string s. You can transform s into a palindrome by adding English lowercase letters in front of it.\n\nReturn the shortest palindrome you can find by performing this transformation.": 0.24096385542168675}, "avg_similarity_score": 0.10622145836151511} -{"instruction": "You are given a 0-indexed binary string s that represents a number in its binary representation. You are allowed to delete the character at index 0. Return the maximum binary string you can create that does not contain any leading zeros after removing exactly one character.", "input": "", "output": "```py\ndef remove_zeroes(s):\n # Check if s starts with 0\n # If it does not, return s\n # Check if the string is all 0s\n # If it is, return 0\n # Remove the first 0\n # Return the new string\n if not s.startswith(\"0\"):\n return s\n if s == \"0\" * len(s):\n return \"0\"\n return remove_zeroes(s[1:])\n```", "most_similar": {"You are given a string s. You can transform s into a palindrome by adding English lowercase letters in front of it.\n\nReturn the shortest palindrome you can find by performing this transformation.": 0.29999999999999993, "Given a string s, return true if the s can be palindrome after deleting at most one character from it.": 0.2985074626865672, "You are given a string s and an integer k. You can choose one of the first k letters of s and append it at the end of the string.\n\nReturn the lexicographically smallest string you could have after applying the mentioned step any number of moves.": 0.2978723404255319, "Given a string S, check if the letters can be rearranged so that two characters that are adjacent to each other are not the same.\n\nIf possible, output any possible result. If not possible, return the empty string.": 0.2588235294117647, "You are given a list of numbers. You need to find the median of the list.": 0.25396825396825395, "You are given a binary string s consisting of only 0's and 1's. In one operation, you can change any '0' to '1'.\n\nReturn the minimum number of operations required to make s alternating, where s[i] == '0' and s[i + 1] == '1' for all i (0-based).": 0.24742268041237112, "Write a function that takes an integer as input and returns the number of bits that are equal to 1 in the binary representation of that number. You can guarantee that input is non-negative.": 0.24390243902439024, "Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.": 0.23188405797101447, "Given two strings word1 and word2, return the minimum number of steps required to make word1 and word2 the same. In one step, you can delete exactly one character in either string.": 0.22784810126582278, "Given a list of strings, find the longest string in the list. You can use the len function to find the length of a string.": 0.22222222222222224}, "avg_similarity_score": 0.10410028351963391} -{"instruction": "Implement a function to calculate the sum of the elements of an array in Java.", "input": "", "output": "public class SumArrayElements {\n public static void main(String[] args) {\n int[] array = { 1, 2, 3, 4, 5 };\n int result = sumArray(array);\n System.out.println(\"Sum of array elements: \" + result);\n }\n\n public static int sumArray(int[] array) {\n int sum = 0;\n for (int i = 0; i < array.length; i++) {\n sum += array[i];\n }\n return sum;\n }\n}", "most_similar": {"Write a C# program to find the sum of all the elements of an array.": 0.6666666666666666, "Write a python function that returns the sum of the elements of a list.": 0.5517241379310344, "Write a Python function to find the sum of all items in a list.": 0.4827586206896552, "How to find the sum of all the elements in a list in python?": 0.4827586206896552, "Write a Python function to find the index of the first occurrence of a specified item in a list.": 0.47058823529411764, "Write a Python function to calculate the factorial of a number.": 0.4615384615384615, "How to find the largest number in an array in Java?": 0.4615384615384615, "How to find the sum of all numbers in an array?": 0.4615384615384615, "Write a Python program to find the sum of the positive integers of a given range.": 0.45161290322580644, "Write a program to find the sum of all the multiples of 3 or 5 below 1000.": 0.43749999999999994}, "avg_similarity_score": 0.19339284439978036} -{"instruction": "What are two ways to escape single quotes in a single-quoted string?", "input": "", "output": "1. Use double quotes (\") to escape single quotes (') in a single-quoted string. For example: 'She said, \"I'm not sure what to say.\"'\n2. Escape single quotes with a backslash (\\). For example: 'She said, \\'I\\'m not sure what to say.\\''", "most_similar": {"How to capitalize a string in Python?": 0.3, "Write a Python program to find the first non-repeated character in a string.": 0.29629629629629634, "What are the different methods to remove an element from a list in Python?": 0.29629629629629634, "Write a Python program to find the frequency of each word in a given string.": 0.28571428571428575, "What are the basic data types in Java?": 0.2857142857142857, "How many bits are there in a byte?": 0.2857142857142857, "How to split a string into a list?": 0.2857142857142857, "How to find the maximum value in a list?": 0.27272727272727276, "Return the first non-repeating character in a string.": 0.27272727272727276, "Can I convert a dictionary to a JSON string?": 0.27272727272727276}, "avg_similarity_score": 0.10740159378142156} -{"instruction": "Write a Java program to sort an array in ascending order.", "input": "", "output": "import java.util.Arrays;\nclass SortArray {\n public static void main(String[] args) {\n int[] my_array = { 2, 1, 4, 3 };\n Arrays.sort(my_array);\n System.out.println(\"The array elements are:\");\n for (int i = 0; i < my_array.length; i++) {\n System.out.println(my_array[i]);\n }\n }\n}", "most_similar": {"Write a Python program to sort a given list of names in ascending order.": 0.64, "Write a program to find the maximum value in an array": 0.5454545454545454, "Write a Java program to convert an int to a string.": 0.5454545454545454, "Write a Python program to sort (ascending and descending) a dictionary by value.": 0.4999999999999999, "Write a C# program to find the sum of all the elements of an array.": 0.4615384615384615, "Write a program to find the smallest number in a list.": 0.45454545454545453, "Write a Java program to find the cube root of a number.": 0.43478260869565216, "Write a python code to implement quick sort": 0.4210526315789474, "Write a Python program to remove all duplicates from a list in Python": 0.41666666666666663, "Write a Java program to remove a set of characters from a string.": 0.41666666666666663}, "avg_similarity_score": 0.156317361068924} -{"instruction": "Given two integers A and B. You have to print A raised to power B.", "input": "", "output": "class PowerOfNumber {\n public static void main(String[] args) {\n int A = 3;\n int B = 4;\n int result = A;\n for (int i = 1; i < B; i++) {\n result *= A;\n }\n System.out.println(result);\n }\n}", "most_similar": {"Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.": 0.3076923076923077, "Write a Python program to add a key to a dictionary.": 0.30769230769230765, "Write a code to implement a binary search.": 0.26086956521739135, "You are given a list of numbers. You need to find the median of the list.": 0.2580645161290323, "Write a Python program to find the first pythagorean triplet for which a + b + c = 1000.": 0.2580645161290323, "Can I convert a dictionary to a JSON string?": 0.25, "Given a list of strings, find the longest string in the list. You can use the len function to find the length of a string.": 0.25, "How do you add a link to a web page?": 0.24, "Write a Python program to create a dictionary from a string.": 0.23076923076923075, "How do I convert a string to a number in Python?": 0.23076923076923075}, "avg_similarity_score": 0.12359249335833417} -{"instruction": "In a previous example, you have seen how to update a dictionary. Now, create a new dictionary that is empty. Add three new keys to the dictionary.", "input": "", "output": "my_dictionary = {} my_dictionary[\"first_name\"] = \"John\" my_dictionary[\"last_name\"] = \"Smith\" my_dictionary[\"age\"] = 30", "most_similar": {"How can I create a new column in a pandas dataframe that is the sum of two other columns?": 0.30434782608695654, "Given two integers A and B. You have to print A raised to power B.": 0.2857142857142857, "Write a Python function to check if a number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its proper positive divisors.": 0.26666666666666666, "Write a Python program to add a key to a dictionary.": 0.2631578947368421, "Write a Python program to create a dictionary from a string.": 0.2631578947368421, "How to make a python program that will print the following pattern?\n```\n*\n**\n***\n****\n*****\n```": 0.2564102564102564, "Can you tell me how to sort a dictionary by value in Python?": 0.25, "If you wanted to create a variable that counts up from 0 to 100, how would you do it in C++?": 0.25, "How do I create a new array from the values of two existing arrays in JavaScript?": 0.2325581395348837, "Write a Python function to check if a given number is an Armstrong number or not. An Armstrong number is a number that is equal to the sum of its own digits each raised to the power of the number of digits.": 0.2318840579710145}, "avg_similarity_score": 0.12691130073830573} -{"instruction": "What is the result of 1 + \"1\"?", "input": "", "output": "The result of 1 + \"1\" is \"11\". The plus (+) operator performs concatenation if either the first or the second operand is a string.", "most_similar": {"What is the value of a++b?": 0.5714285714285714, "What is the purpose of a hash table?": 0.5333333333333333, "What is the output of the code below?\n\n```python x = [1, 2, 3, 4, 5] x = x[1:-1] print(x)```": 0.42857142857142855, "What is the average salary of a software engineer in the US?": 0.4210526315789474, "What is the value of the following expression?\n10 + 2 * 3 / 4": 0.4210526315789474, "What is the smallest positive integer that is divisible by all of the integers from 1 to 20?": 0.4, "What is the difference between a variable that is:\n1. Immutable\n2. Mutable": 0.4, "What is Kubernetes ?": 0.4, "What is the difference between `NaN` and `Infinity`?": 0.39999999999999997, "What is a \u201cPythonic\u201d way of writing code?": 0.39999999999999997}, "avg_similarity_score": 0.13374679772667553} -{"instruction": "Write a JavaScript program to convert a string to an array, separating the elements by spaces.", "input": "", "output": "string = \"I am a string\"; array = string.split(\" \"); console.log(array);", "most_similar": {"Write a Java program to convert an int to a string.": 0.5185185185185185, "Write a Java program to sort an array in ascending order.": 0.4444444444444444, "Write a Python program to create a dictionary from a string.": 0.4444444444444444, "Write a Python program to add a key to a dictionary.": 0.4444444444444444, "Write a program to find the maximum value in an array": 0.4444444444444444, "Write a Python program to sort (ascending and descending) a dictionary by value.": 0.41379310344827586, "Write a Java program to remove a set of characters from a string.": 0.41379310344827586, "Write a Python program to find the unique common elements from two lists.": 0.41379310344827586, "Write a Python program to find the first non-repeated character in a string.": 0.39999999999999997, "Write a Python program to find the longest pallindrome substring from a given string.": 0.39999999999999997}, "avg_similarity_score": 0.17316605400294385} -{"instruction": "Which is the correct way to access a dictionary key named \"my_key\"?", "input": "", "output": "To access a dictionary key named \"my_key\", use the following code: my_dictionary[\"my_key\"]", "most_similar": {"What is the correct syntax for creating a dictionary?": 0.4545454545454546, "What is the value of a++b?": 0.3, "What is the purpose of a hash table?": 0.2857142857142857, "What is the output of this code?\n```\nmy_dict = {\n 'key1': 'value1',\n 'key2': 'value2',\n}\n\nfor key, value in my_dict.items():\n print(key, value)\n```": 0.27777777777777773, "What is the python code to print hello world?": 0.27272727272727276, "What is the difference between a class and an object?": 0.2608695652173913, "What is the difference between a relative and absolute path?": 0.2608695652173913, "Write a python function that adds a new key to a dictionary and returns the value of the key.": 0.25, "What is the difference between an ingress and a persistent volume?": 0.24999999999999994, "What is the difference between a static and a dynamic method?": 0.24999999999999994}, "avg_similarity_score": 0.10930314838209715} -{"instruction": "Given two arrays of integers, determine whether they have the same elements with the same multiplicities.", "input": "", "output": "Here is a code example that checks whether two arrays have the same elements with the same multiplicities: ``` python\ndef same_multiset(a, b):\n # Make a dictionary of the elements in a\n a_items = dict((i, a.count(i)) for i in a)\n # Compare the elements in b with the elements in a\n for i in b:\n if i in a_items:\n a_items[i] -= 1\n if a_items[i] == 0:\n del a_items[i]\n else:\n return False\n if len(a_items) != 0:\n return False\n return True\nprint(same_multiset([1, 2, 2], [1, 2, 2]))\nprint(same_multiset([1, 2, 2, 3], [1, 2, 2])) ``` This implementation first makes a dictionary of the elements and their multiplicities in array `a`. Then, it checks whether all the elements in array `b` are in array `a` and whether the multiplicities are the same. It does this by decrementing the multiplicities of elements in array `b` from the dictionary of elements in array `a`. If at any point there is an element in array `b` that is not in array `a` or the multiplicity does not match, it returns `False`. After going through the entire array `b` without any errors, it checks whether there are any leftover elements in the dictionary that indicate that array `a` has more elements than array `b`. If there are, it returns `False`. Otherwise, it returns `True`.", "most_similar": {"Given an array of integers, find the pair of adjacent elements that has the largest product and return that product.": 0.33333333333333326, "Given a list of numbers, find the sum of the numbers.": 0.2962962962962963, "Given a list of numbers, find the largest number in the list.": 0.28571428571428575, "Given an array of integers, find the maximum possible sum that can be obtained by subtracting any number from the array.": 0.27027027027027023, "Given two integers A and B. You have to print A raised to power B.": 0.2580645161290323, "Given an array of integers, sort it in ascending order using the bubble sort algorithm.": 0.2580645161290323, "Given an array of numbers, find the maximum sum of any contiguous subarray of the array.": 0.25, "Given an integer array nums, find the subarray with the largest sum, and return its sum.": 0.25, "You are given a list of numbers. You need to find the median of the list.": 0.25, "Write a function that takes a list of numbers and returns a list of the same numbers, but with the first and last elements swapped.": 0.24390243902439027}, "avg_similarity_score": 0.0879707857250836} -{"instruction": "How can I get a list of all the different vowels in a text, and the number of times each of them appeared?", "input": "", "output": "You can use a Counter object to get a list of all the different vowels in a text, and the number of times each of them appeared. Here's an example: ``` from collections import Counter input_string = \"This is a string with lots of words.\" vowels = Counter(input_string) print(vowels) ``` This will print the following output: ``` Counter({' ': 5, 'i': 4, 's': 4, 'a': 3, 't': 2, 'e': 2, 'g': 2, 'h': 1, 'n': 1, 'r': 1, 'w': 1, 'o': 1, 'd': 1, 'f': 1, 'm': 1, 'y': 1}) ```", "most_similar": {"How do I make a list of all the prime numbers up to a certain number?": 0.46153846153846156, "How can I convert a list of strings to a list of integers?": 0.4444444444444444, "How can I sort a list of integers in Rust?": 0.42424242424242425, "How can I get the number of days between two dates in python?": 0.3888888888888889, "How can I create a new column in a pandas dataframe that is the sum of two other columns?": 0.380952380952381, "How do I make a function that takes a string and returns a list of the words in the string?": 0.37209302325581395, "How can I make a program that will find the largest number in a list?": 0.3684210526315789, "How do I get the power of a number in python?": 0.3529411764705882, "How can I find the first repeated word in a string?": 0.3529411764705882, "How can I get the current date and time in Python?": 0.3529411764705882}, "avg_similarity_score": 0.1695842284114879} -{"instruction": "What is the best way to check if a list is empty?", "input": "", "output": "You can use the following statement to check if a list is empty: ``` list = [] # Check if the list is empty print(\"List is empty\" if not list else \"List is not empty\") ``` This will print the following output: ``` List is empty ```", "most_similar": {"What is a list comprehension?": 0.47058823529411764, "How to check quickly if a number is prime in C?": 0.43478260869565216, "What is the value of a++b?": 0.4210526315789474, "What is the difference between a list and a tuple in Python?": 0.4166666666666667, "Which is the correct way to access a dictionary key named \"my_key\"?": 0.4, "What is the purpose of a hash table?": 0.4, "What is the difference between a variable that is:\n1. Immutable\n2. Mutable": 0.4, "What are the different methods to remove an element from a list in Python?": 0.3846153846153846, "What is the python code to print hello world?": 0.380952380952381, "What is the correct syntax for creating a dictionary?": 0.380952380952381}, "avg_similarity_score": 0.15089875828774083} -{"instruction": "How can I get the size of a directory?", "input": "", "output": "You can use the following statement to get the size of a directory: ``` import os os.path.getsize(directory_path) ``` This will return the size of the directory in bytes.", "most_similar": {"How do I get the first element of a list?": 0.631578947368421, "How do I get the power of a number in python?": 0.6, "How can I get the number of days between two dates in python?": 0.5454545454545455, "How do I get the last element of an array?": 0.5263157894736842, "How do I find the fibonacci number of a number?": 0.5263157894736842, "How can I find the first repeated word in a string?": 0.5, "How can I get the first 1000 prime numbers in Python?": 0.5, "How can I get the current date and time in Python?": 0.5, "How to get the last element of a list in Python?": 0.5, "How can I make a button in HTML?": 0.47058823529411764}, "avg_similarity_score": 0.15670270630636599} -{"instruction": "How can I find out the type of a variable?", "input": "", "output": "You can use the following statement to find out the type of a variable: ``` type(my_variable) ``` This will return the type of the variable. For example, if the variable is a string, it will return the following output: ``` ```", "most_similar": {"How can I get the size of a directory?": 0.631578947368421, "How do I find the fibonacci number of a number?": 0.6, "How can I find the first repeated word in a string?": 0.5714285714285713, "How to find the standard deviation of a list?": 0.5263157894736842, "How do I find the p-variance of all elements in a list?": 0.5217391304347826, "How can I find the maximum and minimum value in a list using Python?": 0.5, "How can I find the index of an item in an array in c++?": 0.5, "How do I get the first element of a list?": 0.5, "How can I make a program that will find the largest number in a list?": 0.48, "How do you find the length of a string in Python?": 0.47619047619047616}, "avg_similarity_score": 0.1644492698198449} -{"instruction": "You are given a list of numbers. Return the sum of the numbers. If the input is invalid, return a user-friendly error message.", "input": "", "output": "def sum_numbers(numbers):\ntotal = 0\nfor num in numbers:\ntry:\nnum_int = int(num)\ntotal += num_int\nexcept:\nreturn f\"{num} is not a number\"\nreturn total", "most_similar": {"Given a list of numbers, find the sum of the numbers.": 0.5714285714285715, "You are given a list of numbers. You need to find the median of the list.": 0.5, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.4444444444444445, "I have a list of numbers and I want to find the average of all the numbers.": 0.39024390243902435, "Given a list of numbers, find the largest number in the list.": 0.38888888888888895, "You are given a list of numbers. You need to find the number of pairs of indices (i, j) such that the difference between nums[i] and nums[j] is at most t and i < j.": 0.3666666666666667, "Write a Python program that takes a list of numbers as input from the user, calculates the sum of all even numbers in the list, and returns the result. The program should check if the input is valid (i.e., if it's a list of numbers), and if it's not, it should return an error message. The program should also handle exceptions gracefully and return a user-friendly error message in case of any exceptions.": 0.3564356435643565, "Write a function that takes an integer n as a parameter and returns the sum of the first n numbers.\n```py\nFor example, if the input is 3, the function should return 6, since 1 + 2 + 3 = 6.\n```": 0.3548387096774194, "Given an array of numbers, find the maximum sum of any contiguous subarray of the array.": 0.35000000000000003, "I am trying to write a function that takes a list of numbers and returns the sum of the numbers. I wrote the following code in Python:\n```py def sum(lst):\n total = 0\n for i in lst:\n total += i\n return total\n```": 0.3384615384615385}, "avg_similarity_score": 0.15878123515089068} -{"instruction": "Write a Python program that takes a list of numbers as input from the user, calculates the sum of all even numbers in the list, and returns the result.", "input": "", "output": "def sum_even(numbers):\ntotal = 0\nfor num in numbers:\nif num % 2 == 0:\ntotal += num\nreturn total", "most_similar": {"Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.68, "Write a Python function that takes a list of numbers as input and returns the sum of all the numbers in the list that are greater than 5 and less than 10, and are even, and are not divisible by 3.": 0.5714285714285714, "Write a Python program that takes a list of numbers as input from the user, calculates the sum of all even numbers in the list, and returns the result. The program should check if the input is valid (i.e., if it's a list of numbers), and if it's not, it should return an error message. The program should also handle exceptions gracefully and return a user-friendly error message in case of any exceptions.": 0.5471698113207547, "Write a Java program that takes 5 numbers as input and prints the sum of these numbers.": 0.5217391304347826, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.5185185185185185, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.4897959183673469, "Write a Python function that takes a number as input and returns the square of that number.": 0.4782608695652174, "Write a Python function that takes a number as input and returns the sum of all the numbers from 1 to that number that are divisible by 3 and 5.": 0.47457627118644075, "Write a Python function that takes a list of numbers and make a new list containing the numbers in a random order.": 0.47058823529411764, "Write a C program that takes a character from user and displays the ASCII value of the character.": 0.46808510638297873}, "avg_similarity_score": 0.192802403719853} -{"instruction": "I'm trying to run my Tensorflow model on an Apple M1 Macbook Air but I'm getting an error that looks like this:\n\n```\nIllegal instruction (core dumped)\n```\n\nWhat does this error mean?", "input": "", "output": "Apple M1 Macbook Air devices use the ARM architecture instead of Intel. Tensorflow does not have ARM support as of right now.", "most_similar": {"I'm trying to run a Python script on a remote server. I'm getting an error: \"ImportError: No module named 'requests'\". How can I fix this?": 0.39999999999999997, "I am trying to run the following code in Python: ```python def f(x): return x + 1 print(f(1)) ``` I get an error. What is the problem?": 0.26229508196721313, "I am trying to use the following code in python:\n```py\ndef function(a, b):\n if a > b:\n print('You lost.')\n else:\n if c > a:\n print('Nice try.')\n else:\n print('You won.')\n```\nBut I am getting an error. What is wrong with the code?": 0.23376623376623376, "I'm trying to use the following code to create a new column in a dataframe:\n```python\ndf['new_col'] = df['col_1'].apply(lambda x: x.split(' ')[0])\n```\nBut I'm getting the following error:\n```python\nAttributeError: 'float' object has no attribute 'split'\n```": 0.23376623376623376, "I am trying to reverse a string using Python. I have a function that takes a string as a parameter and returns the string in reverse order. Is there a more pythonic way to do this?": 0.17391304347826086, "I have 2 EC2 machines on AWS, I'm having trouble making them communicate. How could I troubleshoot it?": 0.15384615384615385, "I am working on a project for my college and I need help. I am trying to make a simple calculator using Python. I want to show the result of an expression in the form of a list, for example 3 + 4 = 7. But I want it to show 3 + 4 = [7]. Is there a way to do this?": 0.15217391304347827, "I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.14545454545454545, "I have this python code: ```python def make_dict(df): d = dict(zip(df.columns, df.values[0])) return d ``` What does the function do?": 0.1379310344827586, "I am trying to use the following code to create a list of numbers from 1 to 100. But it is not working. Can you help me fix it? ```python numbers = [] for i in range(1, 100): numbers.append(i) ```": 0.13698630136986303}, "avg_similarity_score": 0.04803098813138273} -{"instruction": "Write a program that prints all the multiples of 3 from 0 to 100.", "input": "", "output": "```py for i in range(100): if i % 3 == 0: print(i) ```", "most_similar": {"Write a Java program that prints the numbers 1 through 100.": 0.56, "Write a program to compute the sum of integers from k to n.": 0.5185185185185186, "Write a program to find the sum of all the multiples of 3 or 5 below 1000.": 0.5161290322580646, "Write a function that prints the reverse of a string.": 0.5, "write a c++ program that calculates the perimeter of a square": 0.4799999999999999, "Write a C# program that uses a loop to display the integers from 1 to 20.": 0.4666666666666667, "Write a C program that shows the use of the function strtok().": 0.4615384615384615, "Write a Java program that takes 5 numbers as input and prints the sum of these numbers.": 0.45161290322580644, "Write a function that creates a list of the multiples of a number between 0 and a limit.": 0.43750000000000006, "Write a simple C++ program that prints \"Hello, World!\".": 0.43478260869565216}, "avg_similarity_score": 0.18127732436897448} -{"instruction": "What is the difference between static and instance variables in C++ programming?", "input": "", "output": "In C++ a static variable is initialized only once at the start of the program, and the variable will keep its value throughout the program. A static variable can be accessed directly by the class name and doesn't need an object of its class. Static variables are also known as class variables. An instance variable is initialized every time an object of the class is created.", "most_similar": {"What is the difference between `val` and `var` in Kotlin?": 0.6363636363636365, "What is the difference between a `string` and a `char` data type in C#?": 0.6153846153846153, "What is the difference between a variable and a constant in a programming language?": 0.6153846153846153, "What is the difference between a static and a dynamic method?": 0.6086956521739131, "What is the difference between `NaN` and `Infinity`?": 0.6, "What is the difference between a list and a tuple in Python?": 0.5833333333333334, "What is the difference between the `==` and the `.equals()` methods in Java?": 0.5833333333333334, "What is the difference between a class and an object?": 0.5454545454545454, "What is the difference between `git pull` and `git fetch` ?": 0.5454545454545454, "What is the difference between a relative and absolute path?": 0.5454545454545454}, "avg_similarity_score": 0.12288397804806392} -{"instruction": "In Python, what does the following expression mean: `x = 3`", "input": "", "output": "This expression is an assignment expression. The variable x is assigned to the value 3.", "most_similar": {"In Python, what does the following code output?\n[3, 4, 5][-1]": 0.6363636363636365, "What is the value of the following expression?\n10 + 2 * 3 / 4": 0.45454545454545453, "What does the function `print()` do?": 0.37499999999999994, "What does the HTML tag `

` do?": 0.3529411764705882, "What does the following python code do?\n```python def sum_divisible_by_three(lst):\n\treturn sum(x for x in lst if x % 3 == 0)\n ```": 0.34285714285714286, "What does the CSS style `float: left;` do?": 0.33333333333333326, "Write a python script that prints the following pattern:\n```\n*\n**\n***\n****\n*****\n```": 0.3157894736842105, "Generate a correct python program to fulfill the following purpose:": 0.3, "What does `if` do?": 0.28571428571428575, "What is the output of the following Python code? ```py def f(x): return x + 1 def g(x): return x * 2 print(g(f(3))) ```": 0.2777777777777778}, "avg_similarity_score": 0.11649959851412439} -{"instruction": "How can we take input from user in a Python program?", "input": "", "output": "We can take input from the user by using the input() function in Python. This function returns the string which the user enters.", "most_similar": {"How can I find the maximum and minimum value in a list using Python?": 0.4, "How do you remove duplicates from a list in Python?": 0.380952380952381, "How can I find the first repeated word in a string?": 0.36363636363636365, "How can I get the current date and time in Python?": 0.36363636363636365, "How can I get the first 1000 prime numbers in Python?": 0.36363636363636365, "How to make a python program that will print the following pattern?\n```\n*\n**\n***\n****\n*****\n```": 0.34782608695652173, "How do you find the largest number in a list using Python?": 0.34782608695652173, "How can I get the number of days between two dates in python?": 0.33333333333333337, "How to capitalize a string in Python?": 0.33333333333333326, "How to find the sum of all the elements in a list in python?": 0.32}, "avg_similarity_score": 0.12286910518029688} -{"instruction": "The relation between two sets is called:", "input": "", "output": "Cartesian product", "most_similar": {"How to find the number of days between two dates?": 0.3529411764705882, "Write a Python function to find the correlation between two lists.": 0.33333333333333326, "What is the difference between a variable that is:\n1. Immutable\n2. Mutable": 0.3, "Write me a function in C++ to find the distance between two points": 0.3, "How can I get the number of days between two dates in python?": 0.3, "Ask the assistant to add two numbers.": 0.2857142857142857, "What is the difference between `NaN` and `Infinity`?": 0.26666666666666666, "Explain the difference between a compiler and an interpreter.": 0.25, "Write a function that returns the sum of two numbers.": 0.23529411764705882, "What is the difference between `git pull` and `git fetch` ?": 0.23529411764705882}, "avg_similarity_score": 0.08173599867023945} -{"instruction": "What is the purpose of the `float` function in Python?", "input": "", "output": "The purpose of the float() function in Python is to convert the data type of a variable from one data type to another. The float() function can convert the data type of a variable from an integer, a string, or a decimal value to a floating point value.", "most_similar": {"What is the purpose of a hash table?": 0.5555555555555556, "What is the output of the code below?\n\n```python import math print(math.sqrt(16))```": 0.48, "What is the value of a++b?": 0.47058823529411764, "What is the result of 1 + \"1\"?": 0.47058823529411764, "What is the sum of the ASCII values of all the letters in the word \"apple\"?": 0.4615384615384615, "What is the difference between the `==` and the `.equals()` methods in Java?": 0.45454545454545453, "What is the difference between a list and a tuple in Python?": 0.45454545454545453, "What is the value of the following expression?\n10 + 2 * 3 / 4": 0.45454545454545453, "What is the average salary of a software engineer in the US?": 0.45454545454545453, "What is the python code to print hello world?": 0.4210526315789474}, "avg_similarity_score": 0.1681166981602392} -{"instruction": "A palindrome is a word, phrase, number, or sequence of characters, symbols, or elements, whose meaning may be interpreted the same way in either forward or reverse direction. For example, '123454321' is a palindrome. Given an integer n, return the smallest palindrome greater than n.", "input": "", "output": "The smallest palindrome greater than n is n + 1.", "most_similar": {"Write a Python function to check if a given number is a palindrome or not. A palindrome is a number that remains the same when its digits are reversed. For example, 121 is a palindrome but 112 is not.": 0.28571428571428575, "Write a Python function to check if a given number is a Fermat number or not. A Fermat number is a number of the form 22n + 1, where n is a non-negative integer.": 0.25316455696202533, "Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s.": 0.25, "Write a Python function to check if a given number is a Catalan number or not. A Catalan number is a number that occurs in the sequence of Catalan numbers. The sequence of Catalan numbers is generated by the following formula: Cn = (2n)! / (n+1)!n!": 0.24175824175824176, "Write a Python function to check if a given number is a Kaprekar number or not. In mathematics, a Kaprekar number for a given base is a non-negative integer, the representation of whose square in that base can be split into two parts that add up to the original number again. For example, 45 is a Kaprekar number, because 45\u00b2 = 2025 and 20+25 = 45.": 0.2342342342342342, "Write a Python function to check if a given number is a pandigital number or not. A pandigital number is a number that contains all the digits from 1 to n exactly once.": 0.23076923076923075, "Write a Python function to check if a given number is a Automorphic number or not. An Automorphic number is a number whose square \"ends\" in the same digits as the number itself.": 0.23076923076923075, "Write a Python function to check if a number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its proper positive divisors.": 0.23076923076923075, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number whose square when divided into two parts and then added gives the original number. For example, 297 is a Kaprekar number because 2972 = 592 + 247 and 592 + 247 = 297.": 0.22916666666666663, "Write a Python function to check if a number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence.": 0.2285714285714286}, "avg_similarity_score": 0.11484601967465433} -{"instruction": "Which of the following is not a valid Python variable name?", "input": "", "output": "-2000is not a valid Python variable name. A valid Python variable name starts with a letter or an underscore, and it may contain letters, digits, or underscores.", "most_similar": {"How to find the sum of all the elements in a list in python?": 0.32, "Suggest a completion for the following python code.": 0.3157894736842105, "Translate the following code from python in Java.": 0.3157894736842105, "What is the purpose of the `float` function in Python?": 0.28571428571428564, "How can I find out the type of a variable?": 0.28571428571428564, "How do you find the length of a string in Python?": 0.2727272727272727, "How to extract all of the unique words from a string?": 0.2727272727272727, "How do I get the power of a number in python?": 0.2727272727272727, "How to get the last element of a list in Python?": 0.2727272727272727, "What is a Dockerfile?": 0.26666666666666666}, "avg_similarity_score": 0.13702002649235936} -{"instruction": "You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array is a cost that you have to pay to walk one step.", "input": "", "output": "class Solution:\n def minCostClimbingStairs(self, nums: List[int]) -> int:\n first = 0\n second = 0\n for i in range(len(nums)):\n first, second = second, min(first, second) + nums[i]\n return min(first, second)", "most_similar": {"You are given a string s and an integer k. You can choose one of the first k letters of s and append it at the end of the string.\n\nReturn the lexicographically smallest string you could have after applying the mentioned step any number of moves.": 0.3170731707317073, "Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product.": 0.2807017543859649, "Given an integer array nums, find the subarray with the largest sum, and return its sum.": 0.27450980392156865, "Given an array of integers nums, write a method that returns the \"pivot\" index of this array.": 0.2692307692307692, "How do you get the first and last index of an element in a list in Python?": 0.2692307692307692, "If you have an array of numbers and you want to get the average of all the numbers, what is the shortest code to do it?": 0.26229508196721313, "Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.": 0.2456140350877193, "You are given a 0-indexed binary string s that represents a number in its binary representation. You are allowed to delete the character at index 0. Return the maximum binary string you can create that does not contain any leading zeros after removing exactly one character.": 0.24390243902439024, "Given two integers A and B. You have to print A raised to power B.": 0.24000000000000002, "Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.": 0.23728813559322035}, "avg_similarity_score": 0.11056471969883465} -{"instruction": "What does it mean that Python is an object-oriented programming language?", "input": "", "output": "Python is an object-oriented programming language. Python uses objects to encapsulate data with functions and other attributes. Python is a high-level, general-purpose programming language. It was designed by Guido van Rossum, and released in 1991. It supports multiple programming paradigms, including object-oriented, imperative, functional programming, and procedural styles.", "most_similar": {"What is the difference between a class and an object?": 0.3636363636363636, "What are the differences between functional programming and object-oriented programming?": 0.34782608695652173, "What is the difference between a variable and a constant in a programming language?": 0.30769230769230765, "Create a calculator in the Python programming language": 0.3, "In Python, what does the following expression mean: `x = 3`": 0.2727272727272727, "What is Kubernetes ?": 0.26666666666666666, "What is the difference between an ingress and a persistent volume?": 0.2608695652173913, "What is the difference between static and instance variables in C++ programming?": 0.25, "What does `if` do?": 0.25, "What is a Dockerfile?": 0.25}, "avg_similarity_score": 0.0753759933668333} -{"instruction": "How can we append items to a list?", "input": "", "output": "We can append items to a list using the append() function.", "most_similar": {"How to split a string into a list?": 0.5, "How can I convert a list of strings to a list of integers?": 0.4761904761904762, "How to find the maximum value in a list?": 0.47058823529411764, "How to find the standard deviation of a list?": 0.47058823529411764, "How can I sort a list of integers in Rust?": 0.4444444444444445, "How can we take input from user in a Python program?": 0.4210526315789474, "How to get the last element of a list in Python?": 0.4210526315789474, "How do you count the number of items in a list?": 0.4210526315789474, "How to find the frequency distribution of all values in a list?": 0.4, "How to capitalize a string in Python?": 0.39999999999999997}, "avg_similarity_score": 0.12130727279607946} -{"instruction": "What is the difference between the if-else statement and the switch statement?", "input": "", "output": "The if-else statement is a control flow statement that executes different blocks of code depending on the values of a condition. The switch statement is a control flow statement that executes different blocks of code depending on the value of an expression. The main difference between the if-else and switch statements is that if-else statements use Boolean expressions to determine which block of code to execute, while switch statements use expressions of integer or string type to determine which block of code to execute. Another difference is that switch statements are not supported in Python, while the if-else statement is supported in all programming languages. In summary, if-else statements use Boolean expressions to determine which block of code to execute, while switch statements use expressions of integer or string type to determine which block of code to execute.", "most_similar": {"What is the difference between the `==` and the `.equals()` methods in Java?": 0.64, "What is the difference between `NaN` and `Infinity`?": 0.5714285714285714, "What is the difference between `git pull` and `git fetch` ?": 0.5217391304347826, "What is the difference between a class and an object?": 0.5217391304347826, "What is the difference between `val` and `var` in Kotlin?": 0.5217391304347826, "What is the difference between a relative and absolute path?": 0.5217391304347826, "What is the difference between an ingress and a persistent volume?": 0.4999999999999999, "What is the difference between a static and a dynamic method?": 0.4999999999999999, "What is the difference between a list and a tuple in Python?": 0.48000000000000004, "What is the difference between a deep copy and a shallow copy?": 0.48000000000000004}, "avg_similarity_score": 0.12046027851155738} -{"instruction": "Can we use the `pass` keyword in a function definition?", "input": "", "output": "No, the `pass` keyword cannot be used in a function definition. The `pass` keyword can only be used to define empty blocks in a function. For example: ``` def empty_block(): pass ``` If the `pass` keyword is used inside a function, it will throw an error. For example, the following code will throw an error: ``` def invalid_block(): print(\"Hello world!\") pass ```", "most_similar": {"How can we take input from user in a Python program?": 0.380952380952381, "How can I find the first repeated word in a string?": 0.380952380952381, "How can I find the maximum and minimum value in a list using Python?": 0.3333333333333333, "How can we append items to a list?": 0.33333333333333326, "How can I make a program that will find the largest number in a list?": 0.32, "How to find the maximum value in a list?": 0.3157894736842105, "How can I get the size of a directory?": 0.3157894736842105, "Return the first non-repeating character in a string.": 0.3157894736842105, "How can I find out the type of a variable?": 0.3, "Write a program to find the smallest number in a list.": 0.28571428571428564}, "avg_similarity_score": 0.12680476900295198} -{"instruction": "What is the difference between the `os.path.isfile()` and the `os.path.exists()` functions in Python?", "input": "", "output": "The `os.path.isfile()` function returns True if the specified path is a file. The `os.path.exists()` function returns True if the specified path exists. The main difference between the `os.path.isfile()` and the `os.path.exists()` functions in Python is that the `os.path.isfile()` function returns True only if the specified path is a file, while the `os.path.exists()` function returns True if the specified path exists, which can be a file or a directory. For example: ``` # os.path.isfile() # It returns True only if the specified path is a file. print(os.path.isfile(\"path/to/myfile.txt\")) print(os.path.isfile(\"path/to/mydirectory/\")) # os.path.exists() # It returns True if the specified path exists, which can be a file or a directory. print(os.path.exists(\"path/to/myfile.txt\")) print(os.path.exists(\"path/to/mydirectory/\")) ``` The output of the above code will be: ``` True False True True ```", "most_similar": {"What is the difference between the `==` and the `.equals()` methods in Java?": 0.6206896551724139, "What is the difference between a list and a tuple in Python?": 0.5517241379310345, "What is the difference between the if-else statement and the switch statement?": 0.5333333333333333, "What is the difference between a relative and absolute path?": 0.5185185185185185, "What is the difference between `val` and `var` in Kotlin?": 0.5185185185185185, "What is the difference between static and instance variables in C++ programming?": 0.4827586206896552, "What is the difference between `NaN` and `Infinity`?": 0.48, "What is the difference between a `string` and a `char` data type in C#?": 0.45161290322580644, "What is the difference between a variable and a constant in a programming language?": 0.45161290322580644, "What is the difference between `git pull` and `git fetch` ?": 0.4444444444444445}, "avg_similarity_score": 0.12842914933922733} -{"instruction": "What is the difference between the `break` and the `continue` keywords?", "input": "", "output": "The `break` keyword exits the current loop. The `continue` keyword jumps to the next iteration of the loop. The main difference between the `break` and the `continue` keywords is that the `break` keyword breaks the current loop, while the `continue` keyword skips the current iteration of the loop and moves to the next iteration. For example: ``` # The break keyword breaks the current loop for x in range(5): print(x) print(\"outside the loop\") # The continue keyword skips the current iteration and moves to the next iteration for x in range(5): if x == 2: continue print(x) print(\"outside the loop\") ``` The output of the above code will be: ``` 0 1 3 4 outside the loop 0 1 3 4 outside the loop ```", "most_similar": {"What is the difference between the `==` and the `.equals()` methods in Java?": 0.6956521739130435, "What is the difference between the if-else statement and the switch statement?": 0.6666666666666667, "What is the difference between `NaN` and `Infinity`?": 0.631578947368421, "What is the difference between the `os.path.isfile()` and the `os.path.exists()` functions in Python?": 0.5714285714285714, "What is the difference between a relative and absolute path?": 0.5714285714285713, "What is the difference between `val` and `var` in Kotlin?": 0.5714285714285713, "What is the difference between `git pull` and `git fetch` ?": 0.5714285714285713, "What is the difference between a class and an object?": 0.5714285714285713, "What is the difference between an ingress and a persistent volume?": 0.5454545454545454, "What is the difference between a static and a dynamic method?": 0.5454545454545454}, "avg_similarity_score": 0.12666685673002548} -{"instruction": "Is it possible to define functions in the body of an `if` statement?", "input": "", "output": "Yes, functions can be defined in the body of an `if` statement. For example: ``` if True: def f(): print(\"Hello world!\") f() ``` The output of the above code will be: ``` Hello world! ```", "most_similar": {"Write a script to output the factorial of an integer.": 0.34782608695652173, "How to find the sum of all numbers in an array?": 0.33333333333333337, "What is the difference between the if-else statement and the switch statement?": 0.3076923076923077, "What is the result of 1 + \"1\"?": 0.3, "What is the value of a++b?": 0.3, "Write a C# program to find the sum of all the elements of an array.": 0.28571428571428575, "Implement a function to calculate the sum of the elements of an array in Java.": 0.28571428571428575, "What is the purpose of a hash table?": 0.2857142857142857, "How to find the standard deviation of a list?": 0.27272727272727276, "Write a function to find the first and last occurences of an element in a sorted array.": 0.26666666666666666}, "avg_similarity_score": 0.12755449964777327} -{"instruction": "Write a Java program that prints a number, its successor, and its predecessor.", "input": "", "output": "public class NumPredecessor {\n\n public static void main(String[] args) {\n\n // We assume that the number entered by the user is valid\n // We assume that the user will always enter a number\n\n Scanner keyboard = new Scanner(System.in);\n\n int num = Integer.parseInt(keyboard.nextLine());\n\n System.out.println(num + \" \" + (num + 1) + \" \" + (num - 1));\n\n }\n\n}", "most_similar": {"Write a function that takes a number and returns its first digit": 0.5599999999999999, "Write a function that receives a number and prints its integer digits separately.": 0.5384615384615384, "Write a Java program that prints the numbers 1 through 100.": 0.4999999999999999, "Write a Java program to find the cube root of a number.": 0.48000000000000004, "Write a simple C++ program that prints \"Hello, World!\".": 0.4545454545454546, "Write a simple C# program that prints \"Hello, World!\".": 0.4545454545454546, "Write a Java program that adds 2 to the number inputted by the user.": 0.4444444444444445, "Write a function that prints the reverse of a string.": 0.4347826086956522, "Write a function that returns true if a number is prime, and otherwise returns false.": 0.42857142857142855, "Write a Python function that takes a number as input and returns its square, cube, square root, cube root, and the sum of its digits.": 0.4210526315789474}, "avg_similarity_score": 0.14936129157739308} -{"instruction": "Write a program that prints the sum of all the numbers between 0 and 1000 that are divisible by 3 or 5.", "input": "", "output": "import java.util.*;\npublic class SumDivisibleBy3or5 {\n public static void main(String[] args) {\n int sum = 0;\n for (int i = 0; i <= 1000; i++) {\n if (i % 3 == 0 || i % 5 == 0) {\n sum += i;\n }\n }\n System.out.println(sum);\n }\n}", "most_similar": {"Write a Python function that returns the sum of all numbers in a list that are divisible by 3.": 0.6341463414634148, "Write a Python function that takes a number as input and returns the sum of all the numbers from 1 to that number that are divisible by 3 and 5.": 0.576923076923077, "Write a program to find the sum of all the multiples of 3 or 5 below 1000.": 0.5641025641025642, "Write a Java program that takes 5 numbers as input and prints the sum of these numbers.": 0.46153846153846156, "Write a Python function that takes a list of numbers as input and returns the sum of all the numbers in the list that are greater than 5 and less than 10, and are even, and are not divisible by 3.": 0.4444444444444445, "Write a program that prints all the multiples of 3 from 0 to 100.": 0.4444444444444444, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.4444444444444444, "Write a function that returns the sum of two numbers.": 0.4375, "Write a C# program to find the sum of all the elements of an array.": 0.43243243243243246, "Write a Java program that prints the numbers 1 through 100.": 0.4242424242424242}, "avg_similarity_score": 0.175838477021836} -{"instruction": "Python Program to find the H.C.F of two numbers using functions", "input": "", "output": "def hcf(x, y):\n \"\"\"This function takes two numbers and returns the H.C.F.\"\"\"\n\n # choose the smaller number\n if x > y:\n smaller = y\n else:\n smaller = x\n for i in range(1, smaller+1):\n if((x % i == 0) and (y % i == 0)):\n hcf = i\n return hcf", "most_similar": {"Write a program to find the maximum of three numbers.": 0.5217391304347826, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.5185185185185186, "Write a Python program to find the average of a list using for loop.": 0.5185185185185186, "Write a Python program to find the number of equal numbers from three given integers.": 0.5, "Write a program to find the pearson correlation coefficient of two lists.": 0.48000000000000004, "Write a Python program to find the sum of a non-negative integer.": 0.46153846153846156, "Write a Python program to find the unique common elements from two lists.": 0.46153846153846156, "Write a Python program to find the Fibonacci series up to n numbers.": 0.46153846153846156, "Write a Python program to find the number of even and odd numbers from a series of numbers.": 0.45161290322580644, "Write a Python function to find the smallest number from a sequence of numbers.": 0.4444444444444445}, "avg_similarity_score": 0.15217593746031355} -{"instruction": "Which of the following statement(s) is/are TRUE?\n1.\tIf a function in a C++ program does not return any value, it is necessary to declare the return type of that function as void.\n2.\tAny function in C++ that does not accept any argument is called a default function.\n3.\tIf the control reaches the end of a function, and it has no explicit return statement, the function returns a garbage value.", "input": "", "output": "All of the above are true. If a function in a C++ program does not return any value, it is necessary to declare the return type of that function as void. Any function in C++ that does not accept any argument is called a default function. If the control reaches the end of a function, and it has no explicit return statement, the function returns a garbage value.", "most_similar": {"Write a Python program to find the first appearance of the substring 'not' and 'poor' from a given string, if 'not' follows the 'poor', replace the whole 'not'...'poor' substring with 'good'. Return the resulting string.": 0.2181818181818182, "Write a Python function to find the number of items in a list that are not equal to a given value.": 0.21052631578947367, "The average speed of the jet is 1000km/hr. It takes 1hr 45min to fly from place A to place B. Place B is 800km from place A. What is the speed of the jet for the first half of the journey?": 0.20689655172413793, "Write a function that creates a list of the multiples of a number between 0 and a limit.": 0.1956521739130435, "Write a Python function to find the index of the first occurrence of a specified item in a list.": 0.1935483870967742, "What is the output of the following code? ```py a = 5 b = 15 print(\"a / b is\", a / b) print(\"a % b is\", a % b) print(\"a // b is\", a // b) ```": 0.1904761904761905, "Solve the math problems. Intermediate steps are required.\nA train running at the speed of 36 km/hr crosses a pole in 9 seconds. what is the length of the train?": 0.1904761904761905, "Write a Python function to check if a given number is a Harshad number or not. A Harshad number is a number that is divisible by the sum of its digits. For example, 42 is a Harshad number because it is divisible by 6 (the sum of its two digits 4 + 2).": 0.19047619047619047, "What is the output of the following code?\n```\na = 1\nb = 2\nc = 3\nif a > b:\n print(\"a is greater than b\")\nelif a > c:\n print(\"a is greater than c\")\nelse:\n print(\"a is not greater than b or c\")\n```": 0.18965517241379312, "Write a Python function to check if a given number is an Armstrong number or not. An Armstrong number is a number that is equal to the sum of its own digits each raised to the power of the number of digits.": 0.18965517241379312}, "avg_similarity_score": 0.11450525902539628} -{"instruction": "Explain the OOPS concept.", "input": "", "output": "OOPs is Object-Oriented Programming System. The OOPs concept includes 4 major features i.e. Abstraction, Encapsulation, Inheritance, and Polymorphism.", "most_similar": {"Explain the difference between a compiler and an interpreter.": 0.30769230769230765, "What does the function `print()` do?": 0.2, "What is the result of 1 + \"1\"?": 0.18181818181818182, "What does the HTML tag `

` do?": 0.18181818181818182, "What's the solution for the problem?": 0.18181818181818182, "What is the value of a++b?": 0.18181818181818182, "Ask the assistant to add two numbers.": 0.18181818181818182, "Please explain how a web browser works?": 0.18181818181818182, "The relation between two sets is called:": 0.18181818181818182, "What is the difference between `NaN` and `Infinity`?": 0.16666666666666666}, "avg_similarity_score": 0.07020089773646278} -{"instruction": "What is a def-use chain in OpenCL?", "input": "", "output": "OpenCL programs contain memory objects that are created by the host and can be accessed by the OpenCL kernels. The host and the OpenCL device communicate with each other using buffers, i.e. a memory region allocated on the host that can be accessed by the OpenCL device. In OpenCL, a kernel is executed in a work-item, which represents the smallest unit of execution. The host needs to transfer data from the host to the device before the kernel can access the data. Once the kernel completes its execution, the data is transferred from the device to the host. This process of data transfer between the host and the device can be considered as a def-use chain.", "most_similar": {"What is a Dockerfile?": 0.5, "What is a list comprehension?": 0.4615384615384615, "What is a Docker container?": 0.4615384615384615, "What is a cron job ?": 0.4615384615384615, "What is a stateful set ?": 0.4615384615384615, "What is a persistent volume ?": 0.4615384615384615, "What is the average salary of a software engineer in the US?": 0.4, "What is the difference between a list and a tuple in Python?": 0.4, "What is the value of a++b?": 0.39999999999999997, "What is the purpose of a hash table?": 0.375}, "avg_similarity_score": 0.12202218630748286} -{"instruction": "The following statement is not valid in C++. Explain why.\n```c++\nvector a(10);\nfor(int i=0;i<10;i++){\n a[i]=i*i;\n}\n```", "input": "", "output": "Because the type of ```a[i]``` is ```int``` and ```i*i``` is an integer too. You need to change the vector type to ```int``` or change ```i*i``` to ```double```.", "most_similar": {"I have a C# class as below. ```cs public class A { private int _i; public int i { get { return _i; } set { _i = value; } } } ``` How can I get access to the _i field in this class?": 0.29508196721311475, "Which of the following is not a valid Python variable name?": 0.27027027027027023, "What is the output of the following code? ```py def print_odds(n): for i in range(n): if i % 2 == 0: print(i) print_odds(10) ```": 0.2641509433962264, "What is the output of the following code?\n```\npublic class Test {\n public static void main(String[] args) {\n int i = 1;\n while (i <= 5) {\n System.out.println(i);\n i++;\n }\n }\n}\n```": 0.2592592592592593, "What is the output of this code?\n```\nfor i in range(10):\n print(i)\n```": 0.25, "Translate the following code from python in Java.\ndef function(a : int, b : int, c : int):\n if a > b :\n print('You lost.')\n else :\n if c > a :\n print('Nice try.')\n else :\n print('You won.')": 0.23728813559322037, "What is the result of the following C program? ```c #include \nint main()\n{\n int a = 2;\n int b = 3;\n int c = 4;\n int d = 5;\n printf(\"%d\\n\", a++ + ++b + c++ + ++d);\n printf(\"%d %d %d %d\\n\", a, b, c, d);\n return 0;\n}\n ```": 0.2222222222222222, "I am trying to use the following code to create a list of numbers from 1 to 100. But it is not working. Can you help me fix it? ```python numbers = [] for i in range(1, 100): numbers.append(i) ```": 0.2121212121212121, "What is the difference between a for loop and a while loop?": 0.21052631578947367, "How in JavaScript draw a circle with radius 10 pixels in a html canvas?": 0.2}, "avg_similarity_score": 0.10354197050853997} -{"instruction": "In the following piece of code, the call to ```f1()``` has two arguments:\n```c++\nvoid f1(int x, int y) {\n cout << x << y;\n}\nvoid f2(int y) {\n f1(y);\n}\n```", "input": "", "output": "The call ```f1(y)``` only has one argument. The compiler must be able to match the number and type of the arguments in the call to the arguments of the function being called. Since ```f1()``` takes two arguments, the call ```f1(y)``` is invalid. You can fix this error by either adding another argument to the call or removing an argument from the function.", "most_similar": {"What is the output of the following C# code?\n```\nint x = 1;\nint y = 2;\nint z = 3;\n\nif (x < y)\n{\n if (y < z)\n {\n Console.WriteLine(\"y is the median\");\n }\n else\n {\n Console.WriteLine(\"x is the median\");\n }\n}\nelse\n{\n if (x < z)\n {\n Console.WriteLine(\"x is the median\");\n }\n else\n {\n Console.WriteLine(\"z is the median\");\n }\n}\n```": 0.2891566265060241, "What is the output of the following code?\n```python\ndef func(x):\n return x + 1\n\ndef main():\n x = 1\n y = func(x)\n print(y)\n\nmain()\n```": 0.25925925925925924, "Find the output of this code.\n```\ndef my_filter(x, y):\n return x\n\nprint(my_filter(1, 2))\n```": 0.2553191489361702, "What is the output of this code?\n```\nx = 10\ndef func():\n x = 20\n print(x)\nfunc()\nprint(x)\n```": 0.21276595744680854, "In Python, what does the following expression mean: `x = 3`": 0.20512820512820515, "Consider the following code:\ndef f(x):\n return x + 1\nf(x) = x + 1\n\nWhat is the error in this code?": 0.19999999999999998, "Generate a correct python program to fulfill the following purpose:\nCount the occurrence of an element x in a list y.": 0.19999999999999998, "What is the output of the following code? ```py def add_five(x): x += 5 return x print(add_five(2)) ```": 0.19999999999999998, "What is the output of the code below?\n\n```python x = [1, 2, 3, 4, 5] x = x[1:-1] print(x)```": 0.19999999999999998, "In Python, what does the following code output?\n[3, 4, 5][-1]": 0.1951219512195122}, "avg_similarity_score": 0.08580696691080339} -{"instruction": "Given a number N, write a program to find the sum of all the digits in N.", "input": "", "output": "```python\ndef sum_of_digits(n):\n sum = 0\n while (n):\n sum += n % 10\n n = n // 10\n return sum\n```", "most_similar": {"Write a C# program to find the sum of all the elements of an array.": 0.625, "Write a program to find the sum of all the multiples of 3 or 5 below 1000.": 0.5882352941176471, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.5806451612903226, "Write a Python function to find the sum of all items in a list.": 0.5806451612903226, "Write a Python program to find the sum of the positive integers of a given range.": 0.5454545454545455, "Write a Python program to find the sum of a non-negative integer.": 0.5333333333333333, "Write a program to compute the sum of integers from k to n.": 0.5333333333333333, "Write a program to find the n-th ugly number.": 0.5185185185185185, "Write a program to find the maximum of three numbers.": 0.5185185185185185, "How to find the sum of all the elements in a list in python?": 0.5161290322580646}, "avg_similarity_score": 0.21674725848474863} -{"instruction": "Write a python function that takes a list of strings and returns the longest common substring.", "input": "", "output": "```py def find_longest_common_substring(string_list): # Get the length of the shortest string in the list length = min(len(s) for s in string_list) # Initialize a dictionary that maps each suffix of the first string to its index in the string longest_suffixes = {} for i in range(length): # Get the suffix at index i suffix = string_list[0][i:] # Add it to the dictionary longest_suffixes[suffix] = i # Loop through the rest of the strings for j in range(1, len(string_list)): # Loop through the indexes of the current string for index in range(length - 1, -1, -1): # Get the suffix of the current string at the current index suffix = string_list[j][index:] # If the suffix is in longest_suffixes and its index is smaller than the current index, # we've found a match for a longer substring than we've seen before, so update the length # and remove it from longest_suffixes if suffix in longest_suffixes and longest_suffixes[suffix] < index: length = index + 1 del longest_suffixes[suffix] return string_list[0][length:length + 1] ``` Here's an example usage: ```py string_list = [\"facebook\", \"book\", \"twitter\"] print(find_longest_common_substring(string_list)) ``` This will output: ```book```", "most_similar": {"Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.6666666666666665, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.6486486486486486, "Write a function that receives a list of items and returns the items in reverse order.": 0.625, "Write a Python function that takes a list and returns a new list with unique elements of the first list.": 0.6111111111111112, "Write a Python function that takes a number as input and returns the square of that number.": 0.6060606060606061, "Write a Python function that takes a string as input and returns the string in reverse order.\n'Hello'": 0.5882352941176471, "Write a Python function that removes the first item from a list and returns it.": 0.5806451612903225, "Write a Python function that takes a list of numbers and make a new list containing the numbers in a random order.": 0.5789473684210527, "Write a function that takes a number and returns its first digit": 0.5714285714285715, "Write a function that takes a string and returns the number of vowels in the string.": 0.5625}, "avg_similarity_score": 0.20393313396007737} -{"instruction": "Given a 1-indexed array of integers numbers that is already sorted in non-decreasing order, find two numbers such that they add up to a specific target number. Let these two numbers be numbers[index1] and numbers[index2] where 1 <= index1 < index2 <= numbers.length. Return the indices of the two numbers, index1 and index2, added by one as an integer array [index1, index2] of length 2.", "input": "", "output": "```py class Solution:\n def twoSum(self, numbers: List[int], target: int) -> List[int]:\n \"\"\"\n :type numbers: List[int]\n :type target: int\n :rtype: List[int]\n \"\"\"\n start, end = 0, len(numbers)-1\n while start < end:\n if numbers[start] + numbers[end] == target:\n return [start+1, end+1]\n elif numbers[start] + numbers[end] > target:\n end -= 1\n else:\n start += 1\n```", "most_similar": {"Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.\n\nThe function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2.": 0.52991452991453, "Given an array of integers, return indices of the two numbers such that they add up to a specific target.": 0.3448275862068966, "Given an array of integers `nums` and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order.": 0.2711864406779661, "Write me a python function that takes two arrays as input, and return the element-wise sum of the two arrays as a new array.": 0.2391304347826087, "Given a list of numbers, find the sum of the numbers.": 0.23076923076923075, "Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.": 0.22471910112359547, "Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.": 0.2222222222222222, "Given an array of numbers, find the maximum sum of any contiguous subarray of the array.": 0.21686746987951808, "What is the output of this code?\n```\ndef sum(numbers):\n result = 0\n for number in numbers:\n result = result + number\n return result\n\ndef len(numbers):\n result = 0\n for number in numbers:\n result = result + 1\n return result\n\ndef avg(numbers):\n sum = sum(numbers)\n length = len(numbers)\n return sum/length\n\nprint(avg([1,2,3,4,5]))\n```": 0.21487603305785125, "Write a Python function to check if a given number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence. The Fibonacci sequence is a sequence of numbers where each number is the sum of the two preceding numbers. The first two numbers in the sequence are 0 and 1.": 0.21138211382113822}, "avg_similarity_score": 0.10516449589666302} -{"instruction": "Implement a function to check if a binary tree is a binary search tree.", "input": "", "output": "```py class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\nclass Solution:\n def isValidBST(self, root: TreeNode) -> bool:\n def helper(root, min, max):\n if not root:\n return True\n if root.val >= max or root.val <= min:\n return False\n return helper(root.left, min, root.val) and helper(root.right, root.val, max)\n return helper(root, float(\"-inf\"), float(\"inf\"))\n```", "most_similar": {"Write a Python function to check if a given number is a prime number or not.": 0.5333333333333333, "Write a code to implement a binary search.": 0.45454545454545453, "Write a function to check if a number is divisible by 7 or 5 and not 3.": 0.45161290322580644, "Write a Python function to check whether a passed string is palindrome or not.": 0.42857142857142855, "Write a Python program to check whether a specified number is a perfect square.": 0.42857142857142855, "Write a Python function to check if a number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence.": 0.41025641025641024, "How to check quickly if a number is prime in C?": 0.4, "Write a python program to check if the number is prime.": 0.4, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.3902439024390244, "What is the best way to check if a list is empty?": 0.3846153846153846}, "avg_similarity_score": 0.14399758397474213} -{"instruction": "Do you know any good sources of machine learning videos and resources?", "input": "", "output": "You can check the course resources of this course: http://course.fast.ai.", "most_similar": {"How do you sort a list of strings in Python?": 0.2727272727272727, "How do you count the number of items in a list?": 0.2608695652173913, "How do you find the length of a string in Python?": 0.2608695652173913, "How do you find the index of an item in a list?": 0.25, "How do you output all the contents of a list in Python?": 0.25, "How do you find the standard deviation of all items in a list in Python?": 0.22222222222222224, "How do you find the number of occurrences of a given value in a list in Python?": 0.20689655172413793, "How do you get the first and last index of an element in a list in Python?": 0.20689655172413793, "How do you cast the return value of a function to a different data type in C#?": 0.20689655172413793, "Given a C# program that contains an error, how do you compile the program and show the error?": 0.2}, "avg_similarity_score": 0.05821315666511799} -{"instruction": "What is the purpose of the following code?\n```python\nif __name__ == '__main__':\n import sys\n sys.dont_write_bytecode = True\n from app import app\n app.run()\n```", "input": "", "output": "This is a Python program to run a Flask application as a standalone application.", "most_similar": {"What is the output of the code below?\n\n```python import math print(math.sqrt(16))```": 0.4, "What is the purpose of the `float` function in Python?": 0.4, "What is the output of the following code?\n```python\ndef foo():\n print(\"foo\")\n\ndef bar():\n print(\"bar\")\n\ndef main():\n foo()\n bar()\n\nmain()\n```": 0.3829787234042554, "What is the output of the following python code?\n```python\ndef function(a):\n if a > 0:\n print('Positive')\n else:\n print('Negative')\n\nfunction(0)\n```": 0.37499999999999994, "What is the output of the following code?\n```python\ndef func(x):\n return x + 1\n\ndef main():\n x = 1\n y = func(x)\n print(y)\n\nmain()\n```": 0.36, "What is the output of the following code?\n```python\ndef foo():\n x = 1\n def bar():\n x = 2\n return x\n return bar()\nprint(foo())\n```": 0.3333333333333333, "What is the value of the following expression?\n10 + 2 * 3 / 4": 0.32432432432432434, "What is the output of the following code?\n```py\nnum = 3\n\ndef func(num):\n num += 4\n\nfunc(num)\nprint(num)\n```": 0.3111111111111111, "What is the output of the following code? ```py def a(): print(\"a\") b = a def c(): print(\"c\") b() ```": 0.3111111111111111, "What is the output of the following code? ```py def print_odds(n): for i in range(n): if i % 2 == 0: print(i) print_odds(10) ```": 0.30769230769230765}, "avg_similarity_score": 0.10817672367914148} -{"instruction": "What is the correct way to add a link to a stylesheet in HTML?", "input": "", "output": "You can add a link to a stylesheet in HTML using the following code:\n```html ```", "most_similar": {"What is the best way to check if a list is empty?": 0.4615384615384615, "What is the difference between a list and a tuple in Python?": 0.4615384615384615, "Which is the correct way to access a dictionary key named \"my_key\"?": 0.4444444444444445, "What is the correct syntax for creating a dictionary?": 0.43478260869565216, "What is the difference between a `string` and a `char` data type in C#?": 0.42857142857142855, "What is the difference between a variable and a constant in a programming language?": 0.42857142857142855, "How do you add a link to a web page?": 0.41666666666666663, "What is the difference between a static and a dynamic method?": 0.4, "Write a Python program to add a key to a dictionary.": 0.4, "What is the difference between a replica set and a stateful set?": 0.3846153846153846}, "avg_similarity_score": 0.15812581167866666} -{"instruction": "What does ORM stand for?", "input": "", "output": "ORM stands for object-relational mapping.", "most_similar": {"What does `if` do?": 0.4444444444444445, "What does the function `print()` do?": 0.3636363636363636, "What does the HTML tag `

` do?": 0.3333333333333333, "What's the solution for the problem?": 0.3333333333333333, "What does the CSS style `float: left;` do?": 0.3076923076923077, "What is the correct syntax for creating a dictionary?": 0.2857142857142857, "In Python, what does the following expression mean: `x = 3`": 0.26666666666666666, "What is Kubernetes ?": 0.25, "What is the difference between a for loop and a while loop?": 0.23529411764705882, "In Python, what does the following code output?\n[3, 4, 5][-1]": 0.23529411764705882}, "avg_similarity_score": 0.02903338215651918} -{"instruction": "How do you create a new virtual environment?", "input": "", "output": "You can create a new virtual environment by using the following command: virtualenv .venv. This will create a new folder named .venv.", "most_similar": {"How do you create a variable in Python?": 0.625, "How do I create a new branch in git?": 0.5882352941176471, "How do you create a new list from two lists in Python by picking one element each?": 0.48, "How do you add a new attribute to an existing class in C#?": 0.4761904761904762, "How do I create a text field in HTML?": 0.47058823529411764, "How do you add a link to a web page?": 0.4444444444444445, "How do you remove duplicates from a list in Python?": 0.4444444444444445, "How do you sort a list of strings in Python?": 0.4444444444444445, "How do you find the length of a string in Python?": 0.4210526315789474, "How do you count the number of items in a list?": 0.4210526315789474}, "avg_similarity_score": 0.09600043667963123} -{"instruction": "What is the difference between virtual environment and conda environment?", "input": "", "output": "A virtual environment is a directory tree that contains Python executable files and other files that indicate that it is a virtual environment. A conda environment is a directory that contains conda metadata (including an environment.yml file if the environment was created using environment.yml), Python executable files, and other packages that are installed with conda or pip.", "most_similar": {"What is the difference between `NaN` and `Infinity`?": 0.6666666666666665, "What is the difference between a class and an object?": 0.6, "What is the difference between a relative and absolute path?": 0.6, "What is the difference between `val` and `var` in Kotlin?": 0.6, "What is the difference between `git pull` and `git fetch` ?": 0.6, "What is the difference between an ingress and a persistent volume?": 0.5714285714285713, "What is the difference between a static and a dynamic method?": 0.5714285714285713, "What is the difference between the `break` and the `continue` keywords?": 0.5714285714285713, "What is the difference between a deep copy and a shallow copy?": 0.5454545454545454, "What is the difference between the `==` and the `.equals()` methods in Java?": 0.5454545454545454}, "avg_similarity_score": 0.10812221137781736} -{"instruction": "Is it possible to create a program that can write all other programs?", "input": "", "output": "It is impossible to write a program that can write all other programs.", "most_similar": {"How to make a python program that will print the following pattern?\n```\n*\n**\n***\n****\n*****\n```": 0.32, "Is it possible to define functions in the body of an `if` statement?": 0.3076923076923077, "Write a program that prints all the multiples of 3 from 0 to 100.": 0.29629629629629634, "Write a simple C++ program that prints \"Hello, World!\".": 0.27272727272727276, "Write a simple C# program that prints \"Hello, World!\".": 0.27272727272727276, "Write a C# program that creates a new string from a given string by removing all vowels.": 0.26666666666666666, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.26666666666666666, "How can I create a new column in a pandas dataframe that is the sum of two other columns?": 0.25, "Write a Python program to create a dictionary from a string.": 0.24999999999999994, "Write a Java program that prints the numbers 1 through 100.": 0.24999999999999994}, "avg_similarity_score": 0.10941289095592713} -{"instruction": "Tell me the difference between depth-first search and breadth-first search", "input": "", "output": "Depth-first search is an algorithm for searching a tree data structure. It starts at the root node (selecting some node as the root node in the start, and explores as far as possible along each branch before backtracking. Depth-first search can be implemented with either a stack or a recursive function. The main advantage of depth-first search is that it is quite easy to implement and it is also quite easy to understand.", "most_similar": {"What is the difference between `NaN` and `Infinity`?": 0.4, "What is the difference between a binary search tree and a red-black tree?": 0.3846153846153846, "Explain the difference between a compiler and an interpreter.": 0.380952380952381, "What is the difference between `val` and `var` in Kotlin?": 0.3636363636363636, "What is the difference between `git pull` and `git fetch` ?": 0.3636363636363636, "What is the difference between a class and an object?": 0.3636363636363636, "What is the difference between virtual environment and conda environment?": 0.3636363636363636, "What is the difference between a relative and absolute path?": 0.3636363636363636, "What is the difference between the `break` and the `continue` keywords?": 0.34782608695652173, "What is the difference between a static and a dynamic method?": 0.34782608695652173}, "avg_similarity_score": 0.07801873583940006} -{"instruction": "Write a python code for the following pseudo-code:\n#Pseudo-code:\n#Start\n# Declare x as an integer\n# x = 25\n# if x > 5:\n# print (x is greater than 5)\n# end-if\n# Declare y as a float\n# y = 7.5\n# print (y)\n# x = 20\n# print (x)\n# print (y)\n#End", "input": "", "output": "x = 25\nif x > 5:\n print(\"x is greater than 5\")\n\ny = 7.5\nprint(y)\nx = 20\nprint(x)\nprint(y)", "most_similar": {"What is the output of the following code?\n```python\ndef func(x):\n return x + 1\n\ndef main():\n x = 1\n y = func(x)\n print(y)\n\nmain()\n```": 0.27777777777777785, "What is the output of this code?\n```python\ndef f(x):\n x = 2 * x + 1\n return x\n\nx = 3\nz = f(x)\nprint(z)\n```": 0.25352112676056343, "What is the output of the following code?\n```python\ndef f(x):\n return x * 2\n\ndef g(x):\n return f(x) + 1\n\ndef h(x):\n return g(x) * 2\n\nprint(h(2))\n```": 0.25316455696202533, "What is the output of the following code?\n```\na = 1\nb = 2\nc = 3\nif a > b:\n print(\"a is greater than b\")\nelif a > c:\n print(\"a is greater than c\")\nelse:\n print(\"a is not greater than b or c\")\n```": 0.24719101123595508, "What is the output of this code?\n```\nx = 10\ndef func():\n x = 20\n print(x)\nfunc()\nprint(x)\n```": 0.24615384615384614, "What is the output of the code below?\n\n```python x = [1, 2, 3, 4, 5] x = x[1:-1] print(x)```": 0.2352941176470588, "Consider the following code:\ndef f(x):\n return x + 1\nf(x) = x + 1\n\nWhat is the error in this code?": 0.2352941176470588, "Generate a correct python program to fulfill the following purpose:\nCount the occurrence of an element x in a list y.": 0.2352941176470588, "What is the output of the following code? ```py def add_five(x): x += 5 return x print(add_five(2)) ```": 0.2352941176470588, "What is the output of the following code? ```py a = 5 b = 15 print(\"a / b is\", a / b) print(\"a % b is\", a % b) print(\"a // b is\", a // b) ```": 0.23076923076923078}, "avg_similarity_score": 0.10353805384722986} -{"instruction": "Find the largest number in the following list:\n[50, -40, 20, 30, 60, 80]", "input": "", "output": "max(50, -40, 20, 30, 60, 80)", "most_similar": {"Given a list of numbers, find the largest number in the list.": 0.5384615384615384, "How do you find the largest number in a list using Python?": 0.4615384615384615, "How can I make a program that will find the largest number in a list?": 0.4137931034482759, "Write a program to find the smallest number in a list.": 0.4, "How to find the largest number in an array in Java?": 0.4, "Write a Python function to find the largest number in a dictionary.": 0.3846153846153846, "How to find the maximum value in a list?": 0.34782608695652173, "How to find the nth prime number in C?": 0.34782608695652173, "I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.33333333333333326, "Write a function that takes an array of numbers and returns the largest number in the array.": 0.3225806451612903}, "avg_similarity_score": 0.12297546124112128} -{"instruction": "Given an integer n, return a list of its multiples up to n, sorted in ascending order. The items in the list should be integers and not strings. For example, if n is 7, your function should return [1, 2, 3, 4, 5, 6, 7] and not ['1', '2', '3', '4', '5', '6', '7'].", "input": "", "output": "def multiples(n):\n return [x for x in range(1, n+1) if x % n == 0]", "most_similar": {"Write a function that takes an integer n as a parameter and returns the sum of the first n numbers.\n```py\nFor example, if the input is 3, the function should return 6, since 1 + 2 + 3 = 6.\n```": 0.391304347826087, "I need to sum all the values in the following list: `[1,2,3,4,5,6,7,8,9]`.": 0.32432432432432434, "Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i.\n```py\nFor example, if our input was [1, 2, 3, 4, 5], the expected output would be [120, 60, 40, 30, 24]. If our input was [3, 2, 1], the expected output would be [2, 3, 6].\n```": 0.31496062992125984, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.3037974683544304, "Convert this list into a list of sets: [[1, 2, 3], [4, 5, 6], [7, 8, 9]]": 0.2816901408450704, "How to make a python program that will print the following pattern?\n```\n1\n1 2\n1 2 3\n1 2 3 4\n1 2 3 4 5\n```": 0.2716049382716049, "Write a Python function to check if a given number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. For example, 6 has divisors 1, 2 and 3 (excluding the number itself), and 6 = 1 + 2 + 3. Similarly, 28 has divisors 1, 2, 4, 7, 14 and 28, and 28 = 1 + 2 + 4 + 7 + 14.": 0.26771653543307083, "Write a function to check if a number is divisible by 7 or 5 and not 3.": 0.2535211267605634, "I am working on a project for my college and I need help. I am trying to make a simple calculator using Python. I want to show the result of an expression in the form of a list, for example 3 + 4 = 7. But I want it to show 3 + 4 = [7]. Is there a way to do this?": 0.24778761061946902, "Write a Python function to check if a given number is a Sphenic number or not. A Sphenic number is a composite number where the sum of its proper divisors is equal to the sum of its distinct prime factors. For example, 220 is a Sphenic number because its proper divisors are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110, and the sum of its distinct prime factors is 2 + 2 + 5 = 9.": 0.24427480916030533}, "avg_similarity_score": 0.10954013925055933} -{"instruction": "Given a list of integers, return a list of those numbers squared and the product added to 10, sorted in descending order.", "input": "", "output": "def square(lst):\n return sorted([(x*x)+10 for x in lst], reverse=True)", "most_similar": {"Write a function that receives a list of items and returns the items in reverse order.": 0.4210526315789474, "Given a list of numbers, find the largest number in the list.": 0.4117647058823529, "Write a Python function that takes a list of numbers and make a new list containing the numbers in a random order.": 0.4090909090909091, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.37209302325581395, "Given a list of numbers, find the sum of the numbers.": 0.3636363636363636, "You are given a list of numbers. Return the sum of the numbers. If the input is invalid, return a user-friendly error message.": 0.34782608695652173, "How can I convert a list of strings to a list of integers?": 0.3428571428571428, "Write a function that takes a list of numbers and returns a list of the same numbers, but with the first and last elements swapped.": 0.3404255319148936, "Given an array of integers, return indices of the two numbers such that they add up to a specific target.": 0.3333333333333333, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.3333333333333333}, "avg_similarity_score": 0.14914685583481507} -{"instruction": "If the banking system has all the needed information, it will need to notify the customer about the new EMI amount, right?", "input": "", "output": "This information should be notified through a mail to the customer. It may be good to have a template for the mail which will be send from a mail server.", "most_similar": {"You are given a list of numbers. You need to find the median of the list.": 0.2105263157894737, "What is the sum of the ASCII values of all the letters in the word \"apple\"?": 0.2105263157894737, "If you have an array of numbers and you want to get the average of all the numbers, what is the shortest code to do it?": 0.20833333333333331, "Using the comment as a guide, replace the \"TODO\" comment in the code with the proper code.": 0.20512820512820512, "Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.": 0.20408163265306123, "What is the smallest positive integer that is divisible by all of the integers from 1 to 20?": 0.19999999999999998, "I need to sum all the values in the following list: `[1,2,3,4,5,6,7,8,9]`.": 0.1904761904761905, "Replace all the human names in the paragraph with .": 0.18749999999999997, "The average speed of the jet is 1000km/hr. It takes 1hr 45min to fly from place A to place B. Place B is 800km from place A. What is the speed of the jet for the first half of the journey?": 0.18749999999999997, "Solve the following equation system. Give me the final answer.": 0.18749999999999997}, "avg_similarity_score": 0.08494297791689243} -{"instruction": "Given an array of numbers, write a function that returns an array that only contains the first element and the difference between consecutive numbers in the original array.", "input": "", "output": "def format_array(arr):\n new_arr = [arr[0]]\n for i in range(1, len(arr)):\n new_arr.append(arr[i] - arr[i - 1])\n return new_arr", "most_similar": {"Write a function that takes an array of numbers and returns the largest number in the array.": 0.4888888888888888, "Given an array of integers nums, write a method that returns the \"pivot\" index of this array.": 0.4444444444444445, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.40816326530612246, "Write a Python function that returns the number of items that are present in the first list but not in the second list.": 0.39215686274509803, "Write a function that returns the number of times the string 'hi' appears anywhere in the given string.": 0.391304347826087, "Write me a python function that returns the sum of all even numbers in an array of integers.": 0.391304347826087, "Write a function that takes an integer and returns the nth digit of the number.": 0.37209302325581395, "Write a function that returns the sum of two numbers.": 0.3684210526315789, "Given an array of numbers, find the maximum sum of any contiguous subarray of the array.": 0.36363636363636365, "Write a function that takes a string and returns the number of vowels in the string.": 0.36363636363636365}, "avg_similarity_score": 0.16077111187291102} -{"instruction": "Let's look at an example to understand the concept of prefix sum. Given an array of integers, [3, 5, 2, 1, 6]. Create an array such that each element at index i of the new array is equal to the sum of elements from index 0 to i of the original array.", "input": "", "output": "def prefix_sum(arr):\n new_arr = [arr[0]]\n for i in range(1, len(arr)):\n new_arr.append(new_arr[i - 1] + arr[i])\n return new_arr", "most_similar": {"Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i.\n```py\nFor example, if our input was [1, 2, 3, 4, 5], the expected output would be [120, 60, 40, 30, 24]. If our input was [3, 2, 1], the expected output would be [2, 3, 6].\n```": 0.365079365079365, "Given an array of numbers, write a function that returns an array that only contains the first element and the difference between consecutive numbers in the original array.": 0.2962962962962963, "Write a Python function to check if a given number is an Armstrong number or not. An Armstrong number is a number that is equal to the sum of its own digits each raised to the power of the number of digits.": 0.29473684210526313, "Given an array of numbers, find the maximum sum of any contiguous subarray of the array.": 0.2898550724637681, "Given an array of integers nums, write a method that returns the \"pivot\" index of this array.": 0.28571428571428575, "Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.": 0.2765957446808511, "Given an array of integers, find the maximum possible sum that can be obtained by subtracting any number from the array.": 0.27027027027027023, "Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.": 0.25974025974025977, "You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array is a cost that you have to pay to walk one step.": 0.25000000000000006, "Given an array of integers, return the largest sum of non-adjacent numbers. Numbers can be 0 or negative.": 0.24999999999999994}, "avg_similarity_score": 0.10207938922283949} -{"instruction": "Write a function that takes an unsigned integer and returns the number of '1' bits it has (also known as the Hamming weight).", "input": "", "output": "class Solution:\n def hammingWeight(self, n: int) -> int:\n binary = bin(n)[2:]\n return binary.count('1')", "most_similar": {"Write a function that takes an integer and returns the nth digit of the number.": 0.6315789473684211, "Write a function that takes a string and returns the number of vowels in the string.": 0.5641025641025642, "Write a function that takes an array of numbers and returns the largest number in the array.": 0.55, "Write a function that takes an integer as input and returns the number of bits that are equal to 1 in the binary representation of that number. You can guarantee that input is non-negative.": 0.48275862068965525, "Write a function that takes an integer minutes and converts it to hours and minutes.": 0.47368421052631576, "Write a function that takes a positive integer n and returns the next biggest number with the same number of 1 bits. For example, given the number 6 (0110 in binary), the function should return 9 (1001).": 0.4666666666666667, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.46511627906976744, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.4545454545454545, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.45, "Write a Python function that takes a number as input and returns the square of that number.": 0.45}, "avg_similarity_score": 0.1680753182543289} -{"instruction": "Given two integers n and k, return all possible combinations of k numbers out of the range [1, n]. You may return the answer in any order.", "input": "", "output": "class Solution:\n def combine(self, n: int, k: int) -> List[List[int]]:\n def backtrack(first=1, curr=[]):\n if len(curr) == k:\n output.append(curr[:])\n for i in range(first, n+1):\n curr.append(i)\n backtrack(i+1, curr)\n curr.pop()\n output = []\n backtrack()\n return output", "most_similar": {"Given an array of integers `nums` and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order.": 0.358974358974359, "Given a list of integers, return a list of those numbers squared and the product added to 10, sorted in descending order.": 0.32653061224489793, "Given two strings word1 and word2, return the minimum number of steps required to make word1 and word2 the same. In one step, you can delete exactly one character in either string.": 0.2711864406779661, "You are given a string s and an integer k. You can choose one of the first k letters of s and append it at the end of the string.\n\nReturn the lexicographically smallest string you could have after applying the mentioned step any number of moves.": 0.2702702702702703, "Given a list of numbers, find the sum of the numbers.": 0.2631578947368421, "Given a list of numbers, find the largest number in the list.": 0.2564102564102564, "Given two integers A and B. You have to print A raised to power B.": 0.23809523809523808, "Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n).": 0.23728813559322032, "Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.": 0.23529411764705882, "You are given a list of numbers. Return the sum of the numbers. If the input is invalid, return a user-friendly error message.": 0.23529411764705882}, "avg_similarity_score": 0.09806816684406466} -{"instruction": "Given an array nums of size n, return the majority element.", "input": "", "output": "class Solution:\n def majorityElement(self, nums: List[int]) -> int:\n hashmap = {}\n for i in nums:\n if i in hashmap:\n hashmap[i] += 1\n else:\n hashmap[i] = 1\n for k,v in hashmap.items():\n if v > len(nums)//2:\n return k", "most_similar": {"Given an array of integers, return the largest sum of non-adjacent numbers. Numbers can be 0 or negative.": 0.39999999999999997, "Given an array of integers, return indices of the two numbers such that they add up to a specific target.": 0.3870967741935483, "Given an array of integers, sort it in ascending order using the bubble sort algorithm.": 0.3846153846153846, "Given an array A of integers, return the number of (contiguous, non-empty) subarrays that have a sum divisible by K.": 0.37499999999999994, "Given an array of numbers, find the maximum sum of any contiguous subarray of the array.": 0.3703703703703703, "Given an integer array nums, find the subarray with the largest sum, and return its sum.": 0.3703703703703703, "Given an array of integers nums, write a method that returns the \"pivot\" index of this array.": 0.35714285714285715, "Given an array of integers, find the pair of adjacent elements that has the largest product and return that product.": 0.3225806451612903, "Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.": 0.3157894736842105, "Given an array of integers, find the maximum possible sum that can be obtained by subtracting any number from the array.": 0.31249999999999994}, "avg_similarity_score": 0.09809621427142638} -{"instruction": "Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number, find the duplicate one.", "input": "", "output": "class Solution:\n def findDuplicate(self, nums: List[int]) -> int:\n visited = set()\n for i in nums:\n if i in visited:\n return i\n else:\n visited.add(i)", "most_similar": {"Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product.": 0.3333333333333333, "Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.": 0.27848101265822783, "Given an array nums of size n, return the majority element.": 0.24489795918367344, "Given an array of integers, find the maximum possible sum that can be obtained by subtracting any number from the array.": 0.23728813559322035, "Given an array of n integers nums, a 132 pattern is a subsequence of three integers nums[i], nums[j] and nums[k] such that i < j < k and nums[i] < nums[k] < nums[j]. Return true if there is a 132 pattern in nums, otherwise, return false.": 0.23255813953488372, "Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.": 0.22580645161290325, "Given an array of integers, find the first missing positive integer in linear time and constant space. In other words, find the lowest positive integer that does not exist in the array. The array can contain duplicates and negative numbers as well.": 0.225, "Given an array of integers `nums` and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order.": 0.2247191011235955, "Given an integer array nums, find the subarray with the largest sum, and return its sum.": 0.22222222222222218, "You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array is a cost that you have to pay to walk one step.": 0.21917808219178084}, "avg_similarity_score": 0.0803578791596656} -{"instruction": "What is the difference between a pass-by-reference and a pass-by-value in Java?", "input": "", "output": "It's a very common interview question and has a lot of different answers. I've seen some people say that Java is pass-by-value and others say it's pass-by-reference. The truth is, Java doesn't pass by reference or value. It passes by value of reference. So, it's actually pass-by-value. The reason for this is that Java passes the value of the reference of the object to the method. So, if you want to change the object itself, you need to pass the reference to the object to the method.", "most_similar": {"What is the difference between a list and a tuple in Python?": 0.6428571428571429, "What is the difference between a variable and a constant in a programming language?": 0.6000000000000001, "What is the difference between a `string` and a `char` data type in C#?": 0.6000000000000001, "What is the difference between a static and a dynamic method?": 0.5925925925925926, "What is the difference between a pod and a horizontal pod autoscaler?": 0.5714285714285715, "What is the difference between the `==` and the `.equals()` methods in Java?": 0.5714285714285715, "What is the difference between a for loop and a while loop?": 0.5714285714285715, "What is the difference between a deep copy and a shallow copy?": 0.5714285714285715, "What is the difference between a replica set and a stateful set?": 0.5714285714285715, "What is the difference between a web server and a web application server?": 0.5517241379310345}, "avg_similarity_score": 0.1515815191064649} -{"instruction": "Write a C++ program to convert binary number to decimal number using stack.", "input": "", "output": "```c++ #include using namespace std; \nint main() { \n int binary, decimal = 0, i = 1, rem; \n cout << \"Enter a binary number: \"; \n cin >> binary; \n while (binary != 0) { \n rem = binary % 10; \n decimal = decimal + rem * i; \n binary = binary / 10; \n i = i * 2; \n } \n cout << \"The decimal form is: \" << decimal; \n return 0; \n} \n```", "most_similar": {"Write a Java program to convert an int to a string.": 0.4999999999999999, "Write a program to find the n-th ugly number.": 0.4347826086956522, "Write a Python program to add a key to a dictionary.": 0.41666666666666663, "Write a python program to check if the number is prime.": 0.41666666666666663, "Write a program to find the smallest number in a list.": 0.41666666666666663, "Write a JavaScript program to convert a string to an array, separating the elements by spaces.": 0.41379310344827586, "Write a C# program that uses a loop to display the integers from 1 to 20.": 0.41379310344827586, "Write a Java program to find the cube root of a number.": 0.4, "Write a program to compute the sum of integers from k to n.": 0.38461538461538464, "I need a simple C++ program to find the factorial of a number.": 0.38461538461538464}, "avg_similarity_score": 0.1307986586176961} -{"instruction": "Given a string with repeated characters. Find the largest window that can be generated with all distinct characters.", "input": "", "output": "```python\n#!/usr/bin/python\ndef string_of_distinct_characters(input_string):\n window_start, max_len, max_substring = 0, 0, ''\n char_index_map = {}\n #try:\n # Traverse the String\n for window_end in range(len(input_string)):\n right_char = input_string[window_end]\n # if the current character is not seen before in the window.\n if right_char not in char_index_map:\n # Add the index of current character to the map\n # and increment window size.\n char_index_map[right_char] = window_end\n max_len = max(max_len, window_end - window_start + 1)\n else:\n # If the current character is seen before, then\n # calculate the window start position\n # after removing all the characters in between\n # the current character and the previous occurrence.\n window_start = max(window_start,\n char_index_map[right_char] + 1)\n # update the window end and the character map.\n char_index_map[right_char] = window_end\n max_substring = input_string[window_start:window_start + max_len]\n return max_substring\n #except:\n # return \"None\"\n \n \nif __name__ == '__main__':\n input_string = 'aa'\n print(string_of_distinct_characters(input_string))\n input_string = 'abcabcbc'\n print(string_of_distinct_characters(input_string))\n input_string = 'abacb'\n print(string_of_distinct_characters(input_string))\n input_string = 'abcde'\n print(string_of_distinct_characters(input_string))\n```", "most_similar": {"Given a string `s`, find the length of the longest substring without repeating characters.": 0.375, "Given a list of numbers, find the largest number in the list.": 0.33333333333333337, "Given a string s, return true if the s can be palindrome after deleting at most one character from it.": 0.3157894736842105, "Given an array of integers, find the maximum possible sum that can be obtained by subtracting any number from the array.": 0.30769230769230765, "Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.": 0.3, "Given a number N, write a program to find the sum of all the digits in N.": 0.28571428571428575, "Given a string s, return the longest palindromic substring in s.": 0.27586206896551724, "Given a list of numbers, find the sum of the numbers.": 0.27586206896551724, "Given an array of integers, return the largest sum of non-adjacent numbers. Numbers can be 0 or negative.": 0.27027027027027023, "Given a string s, return the number of palindromic substrings in it.": 0.26666666666666666}, "avg_similarity_score": 0.11394721130218026} -{"instruction": "Implement an efficient algorithm to search a given word in a given dictionary. A dictionary is a list of words where each word is stored as a linked list node.", "input": "", "output": "```python\n# Python program to implement Dictionary\n \n# Class to create a node\nclass Node:\n \n def __init__(self, value, next):\n self.value = value\n self.next = next\n \n \n# Class to create a dictionary\nclass Dictionary:\n \n def __init__(self):\n self.head = None\n self.size = 0\n \n def insert(self, value):\n new_node = Node(value, self.head)\n self.head = new_node\n self.size += 1\n \n def search(self, value):\n if self.head is None:\n return False\n node = self.head\n while node is not None:\n if node.value == value:\n return True\n node = node.next\n return False\n \n def __len__(self):\n return self.size\n \n def delete(self):\n if self.head is None:\n return\n self.head = self.head.next\n self.size -= 1\n \n def __iter__(self):\n node = self.head\n while node is not None:\n yield node.value\n node = node.next\n \n \n# Driver code\nif __name__ == '__main__':\n dict = Dictionary()\n \n dict.insert('Geeks')\n dict.insert('For')\n dict.insert('Geeks')\n dict.insert('A')\n dict.insert('Portal')\n dict.insert('To')\n dict.insert('Learn')\n \n print(\"Dictionary is: \", end='')\n for i in dict:\n print(i, end=' ')\n \n if dict.search('Geeks') == True:\n print(\"\\nGeeks is in dictionary\")\n else:\n print(\"\\nGeeks is not in dictionary\")\n \n if dict.search('Python') == True:\n print(\"\\nPython is in dictionary\")\n else:\n print(\"\\nPython is not in dictionary\")\n \n print(\"\\nLength of dictionary is \", len(dict))\n \n dict.delete()\n dict.delete()\n print(\"\\nLength of dictionary is \", len(dict))\n```", "most_similar": {"Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.3508771929824561, "Write a Python function to check if a given number is a Fermat number or not. A Fermat number is a number of the form 22n + 1, where n is a non-negative integer.": 0.34375, "Write a Python function to check if a given number is a Keith number or not. A Keith number is a number which is one less than a perfect square.": 0.3, "Write a Python function to check if a given number is a Truncable number or not. A Truncable number is a number where the number generated by truncating it from left or right is also a number.": 0.29850746268656714, "Write a Python function to check if a given number is a repdigit or not. A repdigit is a positive integer that consists of a single digit repeated one or more times.": 0.29032258064516125, "Write a Java program to check a given number is a triangle number or not. The triangle numbers are the numbers of the form n(n+1)/2, where n is a natural number.": 0.28125, "Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words.": 0.28125, "Write an algorithm to output all the prime numbers in a given range": 0.27906976744186046, "Write a Python function to check if a given number is a Heptagonal number or not. A Heptagonal number is a number that can be expressed as n(5n-3)/2 where n is an integer.": 0.2727272727272727, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.2727272727272727}, "avg_similarity_score": 0.12348023776291131} -{"instruction": "A node in a binary tree can be identified as special if the node and its descendants are all having identical values. Write a function that takes a root node of a binary tree and returns a list of all the special nodes.", "input": "", "output": "```python\n# Python program to find all special\n# nodes of a tree\n \n# A binary tree node\nclass Node:\n \n # Constructor to create a new node\n def __init__(self, value):\n self.left = None\n self.right = None\n self.value = value\n \n# Utility function to print\n# all special nodes\ndef printSpecial(root):\n \n # A list to store all special\n # nodes of tree\n specialNodes = []\n \n # To store parent of root node\n root.parent = None\n \n # To store current node of tree\n cur = root\n \n # To store current node of tree\n while cur:\n \n # If current node is special,\n # then add it to the list\n if checkSpecial(cur):\n specialNodes.append(cur)\n \n # If current node has left child,\n # then make that node current node\n if cur.left:\n cur.left.parent = cur\n cur = cur.left\n \n # Else if current node has right child,\n # then make that node current node\n elif cur.right:\n cur.right.parent = cur\n cur = cur.right\n \n # If both left and right child are None,\n # then make parent of current node current\n elif cur.parent:\n cur = cur.parent\n \n # Return list of special nodes\n return specialNodes\n \n# A utility function to check if a given\n# node is special or not\ndef checkSpecial(root):\n \n # If the node has no children,\n # then return true\n if not root.left and not root.right:\n return True\n \n # If the node has children, then\n # make sure all the node's\n # descendants have the same value\n # as root node\n def check(root):\n if root.left and root.left.value != root.value:\n return False\n if root.right and root.right.value != root.value:\n return False\n if root.left and not check(root.left):\n return False\n if root.right and not check(root.right):\n return False\n return True\n \n # If all descendants of node\n # have same value as root node,\n # then return True\n return check(root)\n \n \n# Driver code\nroot = Node(1)\nroot.left = Node(2)\nroot.left.left = Node(3)\nroot.left.right = Node(3)\nroot.left.right.left = Node(3)\nroot.left.right.right = Node(3)\nroot.right = Node(1)\nroot.right.left = Node(1)\nroot.right.left.right = Node(1)\nroot.right.right = Node(1)\nroot.right.right.left = Node(1)\nroot.right.right.left.right = Node(1)\nroot.right.right.right = Node(1)\nroot.right.right.right.right = Node(1)\nroot.right.right.right.right.right = Node(1)\n \nprint(\"The special nodes are :\")\nfor node in printSpecial(root):\n print(node.value)\n```", "most_similar": {"Write a function that takes a list of numbers and returns a list of the same numbers, but with the first and last elements swapped.": 0.38235294117647056, "Write a Python function that takes a list and returns a new list with unique elements of the first list.": 0.380952380952381, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.37499999999999994, "How do I make a function that takes a string and returns a list of the words in the string?": 0.34920634920634924, "Write a function that takes a string and returns the number of vowels in the string.": 0.33898305084745767, "Write a python function that takes a list of strings and returns the longest common substring.": 0.33898305084745767, "Write a Python function that takes a list of numbers and make a new list containing the numbers in a random order.": 0.3384615384615385, "Write a python function that adds a new key to a dictionary and returns the value of the key.": 0.3225806451612903, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.31746031746031744, "Write a function that takes a string and returns a new string with the first letter of each word capitalized.": 0.31746031746031744}, "avg_similarity_score": 0.1363724808243132} -{"instruction": "Create a class to represent the following data structure. The structure is made up of rectangles.\n```\npublic class Rectangle\n{\n public int x, y, width, height;\n}\n```\nThe class should have the following methods:\n```\npublic class BunchOfRectangles\n{\n public void Add(Rectangle r);\n public void Remove(Rectangle r);\n public bool Intersect(int x, int y);\n}\n```\nYour job is to implement the methods.", "input": "", "output": "```python\nclass Rectangle:\n def __init__(self, x=0, y=0, width=0, height=0):\n self.x = x\n self.y = y\n self.width = width\n self.height = height\n\n\nclass BunchOfRectangles:\n def __init__(self):\n self.list_of_rectangles = []\n\n def add(self, rectangle):\n self.list_of_rectangles.append(rectangle)\n\n def remove(self, rectangle):\n self.list_of_rectangles.remove(rectangle)\n\n def intersect(self, x, y):\n for r in self.list_of_rectangles:\n if x in range(r.x, r.x + r.width) and y in range(r.y, r.y + r.height):\n return True\n return False\n```", "most_similar": {"What is the output of the following code?\n```\npublic class Test {\n public static void main(String[] args) {\n int i = 1;\n while (i <= 5) {\n System.out.println(i);\n i++;\n }\n }\n}\n```": 0.20689655172413796, "In the following piece of code, the call to ```f1()``` has two arguments:\n```c++\nvoid f1(int x, int y) {\n cout << x << y;\n}\nvoid f2(int y) {\n f1(y);\n}\n```": 0.20454545454545459, "Generate a correct python program to fulfill the following purpose:\nCount the occurrence of an element x in a list y.": 0.2, "I have a C# class as below. ```cs public class A { private int _i; public int i { get { return _i; } set { _i = value; } } } ``` How can I get access to the _i field in this class?": 0.19148936170212763, "What is the output of the following C# code?\n```\nint x = 1;\nint y = 2;\nint z = 3;\n\nif (x < y)\n{\n if (y < z)\n {\n Console.WriteLine(\"y is the median\");\n }\n else\n {\n Console.WriteLine(\"x is the median\");\n }\n}\nelse\n{\n if (x < z)\n {\n Console.WriteLine(\"x is the median\");\n }\n else\n {\n Console.WriteLine(\"z is the median\");\n }\n}\n```": 0.17699115044247785, "Write a Python program to get a string made of the first 2 and the last 2 chars from a given a string. If the string length is less than 2, return instead of the empty string.": 0.16666666666666669, "Write a Python function to calculate the sum of two given integers. However, if the sum is between 15 to 20 it should return 20.": 0.16666666666666666, "Given a year, return the century it is in. The first century spans from the year 1 up to and including the year 100, the second - from the year 101 up to and including the year 200, etc.": 0.16494845360824742, "Given a 2D integer matrix matrix, handle multiple queries of the following type:\n\nCalculate the sum of the elements of matrix inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2, col2).\nImplement the NumMatrix class:\n\nNumMatrix(int[][] matrix) Initializes the object with the integer matrix matrix.\nint sumRegion(int row1, int col1, int row2, int col2) Returns the sum of the elements of matrix inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2, col2).": 0.163265306122449, "Write a Python program to find the frequency of the words from the sentence given.": 0.16216216216216214}, "avg_similarity_score": 0.08309018993114509} -{"instruction": "Write a Python program to find the first occurrence of a specified value in a given array of integers. Return -1 if the value is not found in the array.", "input": "", "output": "def find_first_occurrence(arr, k):\n for i in range(len(arr)):\n if arr[i] == k:\n return i\n return -1", "most_similar": {"Write a Python program to find the number of occurrences of a specified element in a given array of integers.": 0.64, "Write a Python function to find the index of the first occurrence of a specified item in a list.": 0.5306122448979592, "Write a Python program to find the first repeated character of a given string where the index of first occurrence is smallest.": 0.5, "Write a Python program to find the frequency of each word in a given string.": 0.4888888888888889, "Write a Python program to find the longest common prefix of a given list of strings.": 0.47826086956521735, "Write a Python program to find the first pallindromic string from a given string where the length is three or more.": 0.47058823529411764, "Write a Python program to find the difference between a specified number and 13, if the number is greater than 13 return double the absolute difference.": 0.4642857142857143, "Write a Python function to find the maximum sum of a contiguous subsequence from a list of integers.": 0.45833333333333326, "Write a Python program to find the first appearance of the substring 'not' and 'poor' from a given string, if 'not' follows the 'poor', replace the whole 'not'...'poor' substring with 'good'. Return the resulting string.": 0.45454545454545453, "Write a Python program to find the first non-repeated character in a string.": 0.4545454545454545}, "avg_similarity_score": 0.20810194047539632} -{"instruction": "Write a Python program to compute the distance between the points (x1, y1) and (x2, y2).", "input": "", "output": "```python def distance(x1, y1, x2, y2):\n return ((x2 - x1)**2 + (y2 - y1)**2)**0.5\n\nprint(distance(1, 1, 5, 5)) ```", "most_similar": {"Write me a function in C++ to find the distance between two points": 0.4827586206896552, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.4666666666666667, "Write a Python program to find the first Fibonacci number with the first 1000 digits.": 0.45161290322580644, "Write a Python program to find the maximum and minimum number from a given list.": 0.45161290322580644, "Write a Python program to find the frequency of the words from the sentence given.": 0.45161290322580644, "Write a Python function to find the correlation between two lists.": 0.4444444444444444, "Write a python program to check if the number is prime.": 0.4444444444444444, "Write a Python program to find the sum of the positive integers of a given range.": 0.4375, "Write a program to compute the sum of integers from k to n.": 0.41379310344827586, "Write a Python program to find the sum of a non-negative integer.": 0.41379310344827586}, "avg_similarity_score": 0.17839076411840799} -{"instruction": "Write a Python program to compute the sum of the three given numbers, if one of the value is 13 then return 0.", "input": "", "output": "```python def sum(a, b, c):\n if 13 in (a, b, c):\n return 0\n else:\n return a + b + c\n\nprint(sum(2, 3, 4)) ```", "most_similar": {"Write a Python program to find the sum of three given numbers, if the values are equal then return three times of their sum.": 0.6382978723404256, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.5405405405405405, "Write a Python program to find the sum of the positive integers of a given range.": 0.5128205128205128, "Write a Python function to calculate the sum of two given integers. However, if the sum is between 15 to 20 it should return 20.": 0.4999999999999999, "Write a program to find the maximum of three numbers.": 0.48484848484848486, "Write a Python program to find the number of equal numbers from three given integers.": 0.47368421052631576, "Write a C# program to find the sum of all the elements of an array.": 0.47368421052631576, "Write a Python program to find the frequency of the words from the sentence given.": 0.47368421052631576, "Write a python program to check if the number is prime.": 0.4705882352941176, "Write a Python program to find the longest common prefix of a given list of strings.": 0.46153846153846156}, "avg_similarity_score": 0.19108038360411017} -{"instruction": "Write a Python program to compute the length of a string.", "input": "", "output": "```python def string_len(s):\n return len(s)\n\nprint(string_len(\"hello\")) ```", "most_similar": {"Write a Python program to find the frequency of each word in a given string.": 0.6923076923076923, "Write a Python program to find the sum of a non-negative integer.": 0.6666666666666667, "Write a Python program to find the average of a list using for loop.": 0.64, "Write a Python program to find the first non-repeated character in a string.": 0.64, "Write a Python program to get the volume of a sphere with radius 6.": 0.64, "Write a Python program to find the longest pallindrome substring from a given string.": 0.64, "Write a python code to find the area of a circle.": 0.6363636363636364, "Write a Python program to create a dictionary from a string.": 0.6363636363636364, "Write a Python function to calculate the factorial of a number.": 0.6363636363636364, "Write a Python program to count the number of matching parenthesis in a given expression.": 0.6153846153846153}, "avg_similarity_score": 0.23490667344233404} -{"instruction": "Given the `head` of a singly linked list, return the middle node of the linked list. If there are two middle nodes, return the second middle node.", "input": "", "output": "class Solution:\n def middleNode(self, head: Optional[ListNode]) -> Optional[ListNode]:\n slow = fast = head\n while fast and fast.next:\n slow = slow.next\n fast = fast.next.next\n return slow", "most_similar": {"Given the `root` of a binary tree, return the inorder traversal of its nodes' values.": 0.38095238095238093, "You are given a list of numbers. Return the sum of the numbers. If the input is invalid, return a user-friendly error message.": 0.35294117647058826, "You are given a list of numbers. You need to find the median of the list.": 0.3255813953488372, "Given a list of numbers, find the sum of the numbers.": 0.3157894736842105, "Given a string, return the number of vowels used in the text.": 0.30769230769230765, "Given a list of numbers, find the largest number in the list.": 0.30769230769230765, "Write a Python function that returns the number of items that are present in the first list but not in the second list.": 0.27999999999999997, "What is the sum of the ASCII values of all the letters in the word \"apple\"?": 0.27906976744186046, "Write a program in C to insert an element at the beginning of the linked list.": 0.27906976744186046, "Given a list of strings, find the longest string in the list. You can use the len function to find the length of a string.": 0.2692307692307692}, "avg_similarity_score": 0.13089468290942619} -{"instruction": "Given a string, write a function to check if it is a permutation of a palindrome. A palindrome is a word or phrase that is the same forwards and backwards. A permutation is a rearrangement of letters. The palindrome does not need to be limited to just dictionary words.", "input": "", "output": "def palindrome_permutation(string):\n # Use a set to keep track of all the letters\n # that appear in the string.\n letters = set()\n\n # Traverse the string and add letters to the set.\n for char in string:\n if char in letters:\n letters.remove(char)\n else:\n letters.add(char)\n\n # If the string is a permutation of a palindrome,\n # then the set should only contain one letter\n # (the middle character of the palindrome).\n return len(letters) == 1", "most_similar": {"Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.47368421052631576, "Write a Python function to check if a given number is a palindrome or not. A palindrome is a number that remains the same when its digits are reversed. For example, 121 is a palindrome but 112 is not.": 0.45454545454545453, "Write a Python function to check if a given string is a pangram or not. A pangram is a sentence containing every letter of the English alphabet at least once.": 0.379746835443038, "Write a Python function to check if a number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence.": 0.37837837837837834, "Write a Python function to check if a given number is a pandigital number or not. A pandigital number is a number that contains all the digits from 1 to n exactly once.": 0.3658536585365854, "Write a Python function to check if a number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its proper positive divisors.": 0.3658536585365854, "Write a Python function to check if a given number is a Fermat number or not. A Fermat number is a number of the form 22n + 1, where n is a non-negative integer.": 0.3614457831325301, "Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.35443037974683544, "Write a Python function to check if a given number is a Keith number or not. A Keith number is a number which is one less than a perfect square.": 0.35443037974683544, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.35294117647058826}, "avg_similarity_score": 0.1461412658859135} -{"instruction": "Find a pair of integers, given an array of integers, that have the maximum product. Return that product.", "input": "", "output": "def max_pair_product(array):\n # Sort the array in descending order.\n array.sort(reverse = True)\n\n # Return the product of the first two elements.\n return array[0] * array[1]", "most_similar": {"Given an array of integers, find the pair of adjacent elements that has the largest product and return that product.": 0.5789473684210527, "Given an array of integers, find the maximum possible sum that can be obtained by subtracting any number from the array.": 0.41025641025641024, "Given an array of integers nums, write a method that returns the \"pivot\" index of this array.": 0.39999999999999997, "Given an array of integers, return indices of the two numbers such that they add up to a specific target.": 0.36842105263157887, "Given an array of integers, sort it in ascending order using the bubble sort algorithm.": 0.3636363636363636, "Given an array A of integers, return the number of (contiguous, non-empty) subarrays that have a sum divisible by K.": 0.358974358974359, "Given an array of numbers, find the maximum sum of any contiguous subarray of the array.": 0.35294117647058826, "Given an array nums of size n, return the majority element.": 0.3448275862068966, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.34285714285714286, "Write me a python function that returns the sum of all even numbers in an array of integers.": 0.3333333333333333}, "avg_similarity_score": 0.1323754727980042} -{"instruction": "Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the given string consists of lowercase English letters only and its length will not exceed 10000.", "input": "", "output": "class Solution:\n def repeatedSubstringPattern(self, s: str) -> bool:\n for i in range(len(s)):\n if len(s) % (len(s) - i) != 0:\n continue\n if s == s[i:]*(len(s) // (len(s) - i)):\n return True\n return False", "most_similar": {"Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.": 0.30303030303030304, "Given a string s, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.": 0.26229508196721313, "Given a string, write a function to check if it is a permutation of a palindrome. A palindrome is a word or phrase that is the same forwards and backwards. A permutation is a rearrangement of letters. The palindrome does not need to be limited to just dictionary words.": 0.25806451612903225, "Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words.": 0.25641025641025644, "Given a string s, return the number of palindromic substrings in it. A string is a palindrome when it reads the same backward as forward. A substring is a contiguous sequence of characters within the string.": 0.25, "Given a string S, check if the letters can be rearranged so that two characters that are adjacent to each other are not the same.\n\nIf possible, output any possible result. If not possible, return the empty string.": 0.24390243902439024, "You are given a string s and an integer k. You can choose one of the first k letters of s and append it at the end of the string.\n\nReturn the lexicographically smallest string you could have after applying the mentioned step any number of moves.": 0.24175824175824176, "You are given a string s. You can transform s into a palindrome by adding English lowercase letters in front of it.\n\nReturn the shortest palindrome you can find by performing this transformation.": 0.23376623376623376, "Write a function that takes a list of numbers and returns a list of the same numbers, but with the first and last elements swapped.": 0.2318840579710145, "Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s.": 0.22535211267605634}, "avg_similarity_score": 0.10549252321466812} -{"instruction": "You are given an array of n pairs pairs where pairs[i] = [lefti, righti] and lefti < righti. A pair p2 = [c, d] follows a pair p1 = [a, b] if b < c. A chain of pairs can be formed in this fashion. Return the length longest chain which can be formed. You may assume that there is at least one pair in the array.", "input": "", "output": "def findLongestChain(self, pairs: List[List[int]]) -> int:\n pairs.sort(key=lambda x: (x[1], x[0]))\n dp = [1] * len(pairs)\n for i in range(1, len(pairs)):\n for j in range(i):\n if pairs[j][1] < pairs[i][0]:\n dp[i] = max(dp[i], dp[j] + 1)\n return max(dp)", "most_similar": {"Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.": 0.3076923076923077, "Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number, find the duplicate one.": 0.2376237623762376, "Given an array of integers `nums` and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order.": 0.22807017543859648, "Write a script to output 'Hello World' in python\nYou are given an array `prices` where `prices[i]` is the price of a given stock on the i^th day. You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. Return the maximum profit you can achieve from this transaction. If you cannot achieve any profit, return 0.": 0.21739130434782608, "Given an array of n integers nums, a 132 pattern is a subsequence of three integers nums[i], nums[j] and nums[k] such that i < j < k and nums[i] < nums[k] < nums[j]. Return true if there is a 132 pattern in nums, otherwise, return false.": 0.2162162162162162, "Write a Python program to find the first occurrence of a specified value in a given array of integers. Return -1 if the value is not found in the array.": 0.21505376344086022, "Given an array of integers, find the maximum possible sum that can be obtained by subtracting any number from the array.": 0.21428571428571427, "Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.": 0.21176470588235294, "Given an array of integers, find the first missing positive integer in linear time and constant space. In other words, find the lowest positive integer that does not exist in the array. The array can contain duplicates and negative numbers as well.": 0.20952380952380953, "You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array is a cost that you have to pay to walk one step.": 0.2040816326530612}, "avg_similarity_score": 0.09505090422685432} -{"instruction": "You are given an integer array nums and you have to return a new counts array. The counts array has the property where counts[i] is the number of smaller elements to the right of nums[i].", "input": "", "output": "class Solution:\n def countSmaller(self, nums: List[int]) -> List[int]:\n def mergeSort(start, end):\n if start == end:\n return [0]\n mid = (start + end) // 2\n left = mergeSort(start, mid)\n right = mergeSort(mid + 1, end)\n return merge(left, right)\n\n def merge(left, right):\n res = []\n i, j = 0, 0\n while i < len(left) or j < len(right):\n if j == len(right) or (i < len(left) and nums[left[i]] <= nums[right[j]]):\n res.append(left[i])\n i += 1\n else:\n res.append(right[j])\n count[left[i]] += len(left) - i\n j += 1\n return res\n count = [0] * len(nums)\n mergeSort(0, len(nums) - 1)\n return count", "most_similar": {"You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array is a cost that you have to pay to walk one step.": 0.36111111111111116, "If you have an array of numbers and you want to get the average of all the numbers, what is the shortest code to do it?": 0.34920634920634924, "Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.": 0.3278688524590164, "Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product.": 0.3050847457627119, "You are given a list of numbers. You need to find the median of the list.": 0.3018867924528302, "You are given a list of numbers. You need to find the number of pairs of indices (i, j) such that the difference between nums[i] and nums[j] is at most t and i < j.": 0.3013698630136986, "Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0. Not": 0.2857142857142857, "Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.": 0.28125, "You are given a binary string s consisting of only 0's and 1's. In one operation, you can change any '0' to '1'.\n\nReturn the minimum number of operations required to make s alternating, where s[i] == '0' and s[i + 1] == '1' for all i (0-based).": 0.27586206896551724, "Given two integers A and B. You have to print A raised to power B.": 0.2692307692307693}, "avg_similarity_score": 0.1281925587765288} -{"instruction": "Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that the intervals were initially sorted according to their start times.", "input": "", "output": "class Solution:\n def insert(self, intervals: List[List[int]], newInterval: List[int]) -> List[List[int]]:\n i = 0\n while i < len(intervals) and intervals[i][1] < newInterval[0]:\n i += 1\n if i == len(intervals):\n intervals.append(newInterval)\n else:\n intervals[i:i] = [newInterval]\n while i > 0 and intervals[i - 1][1] >= intervals[i][0]:\n intervals[i - 1:i + 1] = [[intervals[i - 1][0], max(intervals[i - 1][1], intervals[i][1])]]\n i -= 1\n while i < len(intervals) - 1 and intervals[i][1] >= intervals[i + 1][0]:\n intervals[i:i + 2] = [[intervals[i][0], max(intervals[i][1], intervals[i + 1][1])]]\n return intervals", "most_similar": {"Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.": 0.3018867924528302, "Given a list of strings, find the longest string in the list. You can use the len function to find the length of a string.": 0.25, "Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the given string consists of lowercase English letters only and its length will not exceed 10000.": 0.24000000000000005, "Given a list of numbers, find the sum of the numbers.": 0.23809523809523805, "Given a list of numbers, find the largest number in the list.": 0.2325581395348837, "Given a list of integers, return a list of those numbers squared and the product added to 10, sorted in descending order.": 0.22641509433962262, "You are given a list of numbers. Return the sum of the numbers. If the input is invalid, return a user-friendly error message.": 0.21818181818181817, "You are given a list of numbers. You need to find the median of the list.": 0.2127659574468085, "Given an array of integers nums, write a method that returns the \"pivot\" index of this array.": 0.20833333333333331, "Given a number N, write a program to find the sum of all the digits in N.": 0.20833333333333331}, "avg_similarity_score": 0.10632120169864517} -{"instruction": "Rewrite the following code in Java:\n```py\nnum = 5\n\ndef func(num):\n num += 5\n\nprint(num)\n```", "input": "", "output": "The following code in Java:\n```java\npublic class MyClass {\n public static void main(String args[]) {\n int num = 5;\n func(num);\n System.out.println(num);\n }\n\n public static void func(int num) {\n num += 5;\n }\n}\n```", "most_similar": {"What is the output of the following code?\n```py\nnum = 3\n\ndef func(num):\n num += 4\n\nfunc(num)\nprint(num)\n```": 0.6111111111111112, "Translate the following code from python in Java.": 0.4166666666666667, "What is the output of the following code? ```py def add_five(x): x += 5 return x print(add_five(2)) ```": 0.37837837837837834, "What is the output of the following code? ```py def a(): print(\"a\") b = a def c(): print(\"c\") b() ```": 0.33333333333333326, "What is the output of the following code?\n```py\ndef get_cube(x):\n return x * x * x\n\nprint(get_cube(get_cube(2)))\n```": 0.30769230769230765, "What is the output of this code?\n```\nx = 10\ndef func():\n x = 20\n print(x)\nfunc()\nprint(x)\n```": 0.29411764705882354, "What is the output of the following code?\n```python\ndef func(x):\n return x + 1\n\ndef main():\n x = 1\n y = func(x)\n print(y)\n\nmain()\n```": 0.2926829268292683, "In Python, what does the following code output?\n[3, 4, 5][-1]": 0.28571428571428575, "Translate the following code from python in Java.\ndef function(a : int, b : int, c : int):\n if a > b :\n print('You lost.')\n else :\n if c > a :\n print('Nice try.')\n else :\n print('You won.')": 0.2857142857142857, "What is the output of the following code? ```py def add(a, b): return a + b print(add(1, 2)) print(add(b=2, a=1)) ```": 0.2857142857142857}, "avg_similarity_score": 0.08625409394560168} -{"instruction": "Your mother has asked you to bring 5 kilograms of potatoes from the nearby market. You know that one kilogram of potatoes costs 30 rupees. You have 200 rupees in your pocket. How many kilograms of potatoes can you buy?", "input": "", "output": "The cost of one kilogram of potatoes is 30 rupees. \nYou have 200 rupees in your pocket. \n200 rupees / 30 rupees = 6.6667 kilograms. \nYou can buy only 6 kilograms of potatoes.", "most_similar": {"Implement a function to calculate the sum of the elements of an array in Java.": 0.18181818181818182, "Write a Python function to find the index of the first occurrence of a specified item in a list.": 0.1694915254237288, "Write a Python program to find the number of occurrences of a specified element in a given array of integers.": 0.16666666666666666, "If you wanted to create a variable that counts up from 0 to 100, how would you do it in C++?": 0.16393442622950818, "I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.16129032258064516, "You are given a string s and an integer k. You can choose one of the first k letters of s and append it at the end of the string.\n\nReturn the lexicographically smallest string you could have after applying the mentioned step any number of moves.": 0.16091954022988506, "Write a Python program to compute the sum of the three given numbers, if one of the value is 13 then return 0.": 0.15873015873015875, "You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins, return -1.": 0.15730337078651685, "How to get the last element of a list in Python?": 0.15686274509803924, "How do you count the number of items in a list?": 0.15686274509803924}, "avg_similarity_score": 0.0808333880750761} -{"instruction": "Ten cars are moving towards the same direction at 60 km/hr, 40 km/hr, 10 km/hr, 30 km/hr, 50 km/hr, 60 km/hr, 10 km/hr, 20 km/hr, 40 km/hr, and 20 km/hr respectively. How many cars will be moving at 40 km/hr when they reach a distance of 100 km from the starting point?", "input": "", "output": "The cars moving at 60 km/hr will take 100 / 60 = 1.67 hours to reach a distance of 100 km from the starting point. \nThe cars moving at 40 km/hr will take 100 / 40 = 2.5 hours to reach a distance of 100 km from the starting point. \nThe cars moving at 10 km/hr will take 100 / 10 = 10 hours to reach a distance of 100 km from the starting point. \nThe cars moving at 30 km/hr will take 100 / 30 = 3.33 hours to reach a distance of 100 km from the starting point. \nThe cars moving at 50 km/hr will take 100 / 50 = 2 hours to reach a distance of 100 km from the starting point. \nThe cars moving at 60 km/hr will take 100 / 60 = 1.67 hours to reach a distance of 100 km from the starting point. \nThe cars moving at 10 km/hr will take 100 / 10 = 10 hours to reach a distance of 100 km from the starting point. \nThe cars moving at 20 km/hr will take 100 / 20 = 5 hours to reach a distance of 100 km from the starting point. \nThe cars moving at 40 km/hr will take 100 / 40 = 2.5 hours to reach a distance of 100 km from the starting point. \nThe cars moving at 20 km/hr will take 100 / 20 = 5 hours to reach a distance of 100 km from the starting point. \nHence, after 2.5 hours, there will be 3 cars moving at 40 km/hr.", "most_similar": {"Solve the math problems. Intermediate steps are required.\nA train running at the speed of 36 km/hr crosses a pole in 9 seconds. what is the length of the train?": 0.14893617021276595, "The output should be a list of all the prime numbers between 1 and 100.": 0.1282051282051282, "Write a python code that asks the user to input a date and tells the user how many days are remaining until the inputted date.": 0.11363636363636363, "You are given a string s and an integer k. You can choose one of the first k letters of s and append it at the end of the string.\n\nReturn the lexicographically smallest string you could have after applying the mentioned step any number of moves.": 0.10909090909090909, "Fill in the in the python code. The output should be a list of 10 random integers between 0 and 100.\n\n```python import random def ten_random_numbers(): ```": 0.10752688172043011, "Given a string, write a function to check if it is a permutation of a palindrome. A palindrome is a word or phrase that is the same forwards and backwards. A permutation is a rearrangement of letters. The palindrome does not need to be limited to just dictionary words.": 0.10714285714285715, "In the following code snippet, what will be the value of the variable `year` after the last print statement?\n\n```\ndays = 365\nyear = days * 3\nprint(year)\nyear = year - 100\nprint(year)\n```": 0.10638297872340426, "What are the benefits and drawbacks of using virtual machines in cloud computing?": 0.10526315789473684, "Find the largest number in the following list:\n[50, -40, 20, 30, 60, 80]": 0.10389610389610389, "How do you remove an item at a given index from a list using Python?": 0.10256410256410255}, "avg_similarity_score": 0.057739163829603535} -{"instruction": "Which is the most suitable option for storing binary data?", "input": "", "output": "A file. A file is used to store binary data.", "most_similar": {"What is the correct syntax for creating a dictionary?": 0.3157894736842105, "What is the difference between a for loop and a while loop?": 0.2727272727272727, "Which is the correct way to access a dictionary key named \"my_key\"?": 0.2608695652173913, "What is the output of this code?\n```\nfor i in range(10):\n print(i)\n```": 0.25, "What is the difference between a `string` and a `char` data type in C#?": 0.25, "What is the difference between a binary search tree and a red-black tree?": 0.25, "What's the solution for the problem?": 0.23529411764705882, "What is the value of a++b?": 0.23529411764705882, "Write a python code for binary search": 0.23529411764705882, "What is the result of 1 + \"1\"?": 0.23529411764705882}, "avg_similarity_score": 0.07878191464015194} -{"instruction": "A man who owns a house built on 2660 square feet of land decides to sell it. He wants to break even from his sale. If he bought the house for $40,000, what should he sell it for?", "input": "", "output": "To break even from the sale of the house, the owner should sell it for 2660 x 40000 / 2660 = 100,000.", "most_similar": {"Write a python program to check if the number is prime.": 0.16, "Write a Python program to get a string made of the first 2 and the last 2 chars from a given a string. If the string length is less than 2, return instead of the empty string.": 0.15789473684210525, "Write a Python function to calculate the sum of two given integers. However, if the sum is between 15 to 20 it should return 20.": 0.15625, "Write a function that takes an integer n as a parameter and returns the sum of the first n numbers.\n```py\nFor example, if the input is 3, the function should return 6, since 1 + 2 + 3 = 6.\n```": 0.15584415584415584, "Write a Java program to remove a set of characters from a string.": 0.15384615384615385, "If you have an array of numbers and you want to get the average of all the numbers, what is the shortest code to do it?": 0.15384615384615385, "Write a Python function to check if a given number is a Neon number or not. A Neon number is a number where the sum of digits of square of the number is equal to the number itself. For example, 9 is a Neon number because 92 = 81 and 8 + 1 = 9.": 0.15384615384615383, "I am trying to use the following code to create a list of numbers from 1 to 100. But it is not working. Can you help me fix it? ```python numbers = [] for i in range(1, 100): numbers.append(i) ```": 0.1518987341772152, "Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.": 0.15151515151515152, "Write a Python program to find the average of a list using for loop.": 0.1509433962264151}, "avg_similarity_score": 0.08525705416875785} -{"instruction": "You have a list of numbers. You want to find the largest number among them. How will you do it?", "input": "", "output": "The largest number among the given numbers can be found by sorting the numbers in decreasing order. The first number will be the largest one.", "most_similar": {"I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.5714285714285713, "I have a list of numbers, how do I find the second largest number?": 0.5294117647058824, "Given a list of numbers, find the largest number in the list.": 0.5, "You are given a list of numbers. You need to find the median of the list.": 0.5, "I have a list of numbers and I want to find the average of all the numbers.": 0.48648648648648646, "If you have an array of numbers and you want to get the average of all the numbers, what is the shortest code to do it?": 0.4347826086956522, "Given a list of numbers, find the sum of the numbers.": 0.3870967741935483, "Write a Python function to find the largest number in a dictionary.": 0.37499999999999994, "I have a list of strings, how do I convert them to numbers?": 0.3636363636363637, "You are given a list of numbers. You need to find the number of pairs of indices (i, j) such that the difference between nums[i] and nums[j] is at most t and i < j.": 0.35714285714285715}, "avg_similarity_score": 0.14190702902288657} -{"instruction": "If you want to determine if your date of birth is a leap year or not, what is the condition that you need to apply?", "input": "", "output": "The condition that you need to apply to determine if your date of birth is a leap year or not is: Year % 4 = 0", "most_similar": {"If you have an array of numbers and you want to get the average of all the numbers, what is the shortest code to do it?": 0.35294117647058826, "Write a Python function to check if a number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence.": 0.32, "Write a Python function to check if a given number is a pandigital number or not. A pandigital number is a number that contains all the digits from 1 to n exactly once.": 0.3103448275862069, "Write a Python function to check if a number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its proper positive divisors.": 0.3103448275862069, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.30769230769230765, "You need to read a code and detect if there is a syntax error or not. Outpus true if there is error, output false if there is not.": 0.30188679245283023, "I want to find a specific item in a long list of items. The list is sorted by an item field. What is the best data structure to use?": 0.29629629629629634, "Write a Python function to check if a given number is a prime number or not.": 0.2926829268292683, "Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.2909090909090909, "Write a Python function to check if a given string is a pangram or not. A pangram is a sentence containing every letter of the English alphabet at least once.": 0.2909090909090909}, "avg_similarity_score": 0.12696113594178565} -{"instruction": "Which of the following programming languages is an interpreted language?", "input": "", "output": "Python is an interpreted language.", "most_similar": {"Which of the following is not a valid Python variable name?": 0.47619047619047616, "Create a calculator in the Python programming language": 0.33333333333333326, "Give me the list of the most popular programming languages and their respective use cases?": 0.32, "What is the value of the following expression?\n10 + 2 * 3 / 4": 0.2727272727272727, "What does it mean that Python is an object-oriented programming language?": 0.2727272727272727, "What is the difference between a variable and a constant in a programming language?": 0.25, "Implement a function to calculate the sum of the elements of an array in Java.": 0.24, "Write a C# program to find the sum of all the elements of an array.": 0.24, "The relation between two sets is called:": 0.23529411764705882, "How do I find the index of the first occurrence of a value in an array?": 0.23076923076923075}, "avg_similarity_score": 0.09758642368390281} -{"instruction": "What is the result of 4 + 3 * 2?", "input": "", "output": "4 + 3 * 2 = 4 + 6 = 10", "most_similar": {"What is the result of 1 + \"1\"?": 0.6666666666666666, "What is the value of a++b?": 0.5333333333333333, "What is the value of the following expression?\n10 + 2 * 3 / 4": 0.5, "What is the purpose of a hash table?": 0.5, "What is the purpose of the `float` function in Python?": 0.4444444444444445, "What is the average salary of a software engineer in the US?": 0.4, "What is the difference between a variable that is:\n1. Immutable\n2. Mutable": 0.380952380952381, "What is a \u201cPythonic\u201d way of writing code?": 0.375, "What is the difference between `NaN` and `Infinity`?": 0.375, "What is Kubernetes ?": 0.36363636363636365}, "avg_similarity_score": 0.12927138100839158} -{"instruction": "Write a function that takes an array and returns a new array where each element is the square of the original array.", "input": "", "output": "Here's a function that takes an array and returns a new array where each element is the square of the original array: ```javascript function squareArray(array) { const squareArray = []; for (let num of array) { squareArray.push(num * num); } return squareArray; } ``` Explanation: - We define a function that takes an array as input and returns a new array. - We define a squareArray variable that will store the squared array elements. - We loop through each element in the array parameter using a for...of loop. - We append each squared element to the squareArray variable. - After the loop completes, we return the squareArray variable.", "most_similar": {"Write a function that takes an array of numbers and returns the largest number in the array.": 0.6153846153846153, "Write a function that takes an integer and returns the nth digit of the number.": 0.5945945945945945, "Write a function that takes a string and returns the number of vowels in the string.": 0.5263157894736842, "Write a function that takes a string and returns a new string with the first letter of each word capitalized.": 0.5238095238095238, "Write a Python function that takes a list and returns a new list with unique elements of the first list.": 0.5238095238095238, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.5128205128205129, "Write a Python function that takes a number as input and returns the square of that number.": 0.5128205128205129, "Write a function that takes an unsigned integer and returns the number of '1' bits it has (also known as the Hamming weight).": 0.4888888888888889, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.46511627906976744, "Write a Python function that takes a string and returns a new string with the words in sorted order and unique.": 0.46511627906976744}, "avg_similarity_score": 0.18544526505847936} -{"instruction": "Find the number of occurrences of a given word in a string.", "input": "", "output": "Here's a function that finds the number of occurrences of a given word in a string: ```javascript function findOccurences(str, word) { let occurences = 0; let wordLength = word.length; for (let i = 0; i <= str.length - wordLength; i++) { if (str.substring(i, i + wordLength) === word) { occurences++; } } return occurences; } ``` Explanation: - We define a function that takes a string and a word as parameters and returns the number of times the word occurs in the string. - We initialize a counter variable to 0. - We loop through each character in the string parameter using a for loop. - We check if the word exists at the current index in the string. - If it does, we increment the counter variable. - After the loop completes, we return the counter variable. - Note that this function is case sensitive and will not match words that only differ by case.", "most_similar": {"How do you find the number of occurrences of a given value in a list in Python?": 0.6896551724137931, "Write a Python program to find the number of occurrences of a specified element in a given array of integers.": 0.5625000000000001, "How can I find the first repeated word in a string?": 0.5217391304347826, "Write a Python program to find the frequency of each word in a given string.": 0.5185185185185186, "How do I find the index of the last occurrence of a substring in a string, starting at a particular index?": 0.4848484848484849, "How do I find the first and last occurrence of a substring in a string in C++?": 0.4827586206896552, "Write a python function that returns the number of words in a given string.": 0.4615384615384615, "How do I find the fibonacci number of a number?": 0.45454545454545453, "Write a Python function to find the index of the first occurrence of a specified item in a list.": 0.4516129032258065, "How do I replace all occurrences of a substring in a string with another string?": 0.4444444444444445}, "avg_similarity_score": 0.17881828171441233} -{"instruction": "Find the total number of days in a year.", "input": "", "output": "Here's a function that finds the total number of days in a year: ```javascript function getDaysInYear(year) { return (isLeapYear(year) ? 366 : 365); } ``` Explanation: - We define a function that takes a year as input and returns the total number of days in the year. - We use the built-in isLeapYear function to determine if the year is a leap year. - If the year is a leap year, we return 366. - Otherwise, we return 365.", "most_similar": {"Find the number of occurrences of a given word in a string.": 0.5714285714285715, "How do I find the fibonacci number of a number?": 0.5263157894736842, "How to find the number of days between two dates?": 0.5263157894736842, "Write a program to find the smallest number in a list.": 0.5, "How do you count the number of items in a list?": 0.5, "Write a Python function to find the largest number in a dictionary.": 0.4761904761904762, "How do you find the index of an item in a list?": 0.4761904761904762, "How do you find the largest number in a list using Python?": 0.4761904761904762, "How to find the frequency distribution of all values in a list?": 0.4761904761904762, "How do you find the number of occurrences of a given value in a list in Python?": 0.46153846153846156}, "avg_similarity_score": 0.16900119741174335} -{"instruction": "Write a function that returns the smallest integer in an array.", "input": "", "output": "Here's a function that returns the smallest integer in an array: ```javascript function findSmallestInt(arr) { let smallestInt = arr[0]; for (let i = 1; i < arr.length; i++) { if (arr[i] < smallestInt) { smallestInt = arr[i]; } } return smallestInt; } ``` Explanation: - We define a function that takes an array as input and returns the smallest integer in the array. - We initialize the smallestInt variable to the first element in the array. - We loop through each element in the array using a for loop. - If the current element is less than smallestInt, we update smallestInt to the current element. - After the loop completes, we return smallestInt.", "most_similar": {"Write me a python function that returns the sum of all even numbers in an array of integers.": 0.6206896551724137, "Write a Python function that returns the largest item in a list.": 0.6086956521739131, "Write a function that takes an array of numbers and returns the largest number in the array.": 0.5714285714285714, "Write a function that returns the sum of two numbers.": 0.5714285714285713, "Write a python function that returns the number of words in a given string.": 0.56, "Write a program to find the maximum value in an array": 0.5454545454545454, "Write a function that takes a string and returns the number of vowels in the string.": 0.5185185185185185, "Write a function that receives a list of items and returns the items in reverse order.": 0.5185185185185185, "Write a Python function that takes a string as input and returns the string in reverse order.\n'Hello'": 0.4827586206896552, "Write a function that returns the number of times the string 'hi' appears anywhere in the given string.": 0.4827586206896552}, "avg_similarity_score": 0.18775822923205968} -{"instruction": "Write a function that returns the lowest temperature that occurred this month.", "input": "", "output": "Here's a function that returns the lowest temperature that occurred this month: ```javascript function lowestTemperature(temperatures) { let lowestTemperature = Number.MAX_SAFE_INTEGER; for (let temp of temperatures) { lowestTemperature = Math.min(temp, lowestTemperature); } return lowestTemperature; } ``` Explanation: - We define a function that takes an array as input and returns the lowest temperature that occurred this month. - We initialize a lowestTemperature variable to the highest possible integer using the Number.MAX_SAFE_INTEGER constant. - We loop through each element in the temperatures array using a for...of loop. - We compare each element to lowestTemperature and update lowestTemperature to the lowest of the two temperatures. - After the loop completes, we return lowestTemperature.", "most_similar": {"Write a function that returns the sum of two numbers.": 0.5454545454545454, "Write a function that returns the smallest integer in an array.": 0.5217391304347826, "Write a Python function that returns the largest item in a list.": 0.5, "Write a Python function that takes a number as input and returns the square of that number.": 0.4827586206896552, "Write a Python function that returns a list containing only the items that are present in both lists.": 0.4666666666666666, "Write a python function that returns the sum of the elements of a list.": 0.4615384615384615, "Write a python function that returns the number of words in a given string.": 0.4615384615384615, "Write a function that prints the reverse of a string.": 0.45454545454545453, "Write a Python function that returns the sum of all numbers in a list that are divisible by 3.": 0.4516129032258065, "Write a function that takes an integer and returns the nth digit of the number.": 0.4444444444444445}, "avg_similarity_score": 0.1555524531904977} -{"instruction": "How to test if an element is in a list?", "input": "", "output": "To test if an element is in a list, you can use the ```in``` keyword. For example, to test if 4 is in the list [1, 2, 3, 4, 5]: ``` list = [1, 2, 3, 4, 5] if 4 in list: print('4 is in the list') ```", "most_similar": {"How do you check if a value is present in a list?": 0.5454545454545454, "How to find the maximum value in a list?": 0.5263157894736842, "How to check quickly if a number is prime in C?": 0.47619047619047616, "How to get the last element of a list in Python?": 0.47619047619047616, "How to find the frequency distribution of all values in a list?": 0.45454545454545453, "How do you find the index of an item in a list?": 0.45454545454545453, "How can I rotate an element in CSS?": 0.4444444444444445, "How do you get the first and last index of an element in a list in Python?": 0.4444444444444445, "How to split a string into a list?": 0.4444444444444445, "How can we append items to a list?": 0.4444444444444445}, "avg_similarity_score": 0.14980219092807492} -{"instruction": "How to test if a key exists in a dictionary?", "input": "", "output": "To test if a key exists in a dictionary, you can use the ```in``` keyword. For example, to test if the key \"key2\" exists in the dictionary ```list = {\"key1\": 1, \"key2\": 2, \"key3\": 3, \"key4\": 4, \"key5\": 5}```:\n\nif \"key2\" in list: print('The key \"key2\" exists')", "most_similar": {"How to test if an element is in a list?": 0.6, "How to check quickly if a number is prime in C?": 0.47619047619047616, "Write a Python program to add a key to a dictionary.": 0.47619047619047616, "How to capitalize a string in Python?": 0.47058823529411764, "How do you check if a value is present in a list?": 0.45454545454545453, "How to split a string into a list?": 0.4444444444444445, "How to find the maximum value in a list?": 0.4210526315789474, "How do I check if a string contains a substring?": 0.4000000000000001, "How to get the last element of a list in Python?": 0.380952380952381, "How do I convert a string to a number in Python?": 0.380952380952381}, "avg_similarity_score": 0.139903418328881} -{"instruction": "If I have two lists, how do I check if they have any items in common?", "input": "", "output": "To check if two lists have items in common, you can use a for loop to loop through one list and check if each item is in the other list.\n\nFor example, to check if the lists ```list1 = [1, 2, 3]``` and ```list2 = [2, 3, 4]``` have any items in common, you can use the following for loop:\n\nlist1 = [1, 2, 3] list2 = [2, 3, 4] for x in list1: if x in list2: print(\"The lists have items in common\")", "most_similar": {"How do I check if a string contains a substring?": 0.38461538461538464, "How do you check if a value is present in a list?": 0.35714285714285715, "I have a list of strings, how do I convert them to numbers?": 0.3448275862068966, "Write a Python function that takes two lists and returns True if they have at least one common member.": 0.34285714285714286, "I have a list of numbers, how do I find the second largest number?": 0.3333333333333333, "How do I print a list in Python?": 0.3333333333333333, "How do I incorporate CSS in my HTML page?": 0.32, "How do I create a text field in HTML?": 0.32, "How do I output a string in C++ programming?": 0.32, "How do I create a new branch in git?": 0.32}, "avg_similarity_score": 0.0702166678000841} -{"instruction": "I want to take a string and print it backwards. How would I do that?", "input": "", "output": "To take a string and print it backwards, you can use the ```reverse()``` method. The ```reverse()``` method reverses a list in place. For example, to print the string \"Hello World!\" backwards, you can use the following code:\n\n```py list = list(reversed(\"Hello World!\")) print(\"\".join(list)) ```", "most_similar": {"I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.3783783783783784, "Can I convert a dictionary to a JSON string?": 0.33333333333333337, "Write a Python function to concatenate all elements in a list into a string and return it.": 0.3125, "I have a list of strings, how do I convert them to numbers?": 0.28571428571428575, "I want to know what is the difference between abstract classes and interfaces?": 0.28571428571428575, "I want to find the average of all the numbers in a list.": 0.28571428571428575, "I have a dictionary in python where I have a key and the value is a list of strings. I want to search for a particular string in the list and return the key. What is the best way to do that?": 0.2807017543859649, "If you wanted to create a variable that counts up from 0 to 100, how would you do it in C++?": 0.2777777777777778, "I have a code that is too slow. How can I make it faster?": 0.2758620689655172, "I have a list of numbers, how do I find the second largest number?": 0.2758620689655172}, "avg_similarity_score": 0.11455778892431591} -{"instruction": "I have a list of integers: ```list = [1, 2, 3]```. How would I sum these integers?", "input": "", "output": "To sum these integers, you can use the ```sum()``` function. The sum() function takes an iterable, and returns the sum of its elements. For example, to sum the elements in ```list```, you can use the following code: ``` list = [1, 2, 3] sum_of_list = sum(list) ```", "most_similar": {"I have a list of strings, how do I convert them to numbers?": 0.4827586206896552, "I have a list of numbers, how do I find the second largest number?": 0.4666666666666667, "I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.4210526315789474, "How can I convert a list of strings to a list of integers?": 0.41379310344827586, "How can I sort a list of integers in Rust?": 0.38461538461538464, "Convert this list into a list of sets: [[1, 2, 3], [4, 5, 6], [7, 8, 9]]": 0.3636363636363636, "I have a list of numbers and I want to find the average of all the numbers.": 0.3636363636363636, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.34146341463414637, "I have a code that is too slow. How can I make it faster?": 0.3333333333333333, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.33333333333333326}, "avg_similarity_score": 0.11013847265500012} -{"instruction": "I'm trying to concatenate strings in a list.", "input": "", "output": "To concatenate strings in a list, you can use a for loop to loop through the list and concatenate each item.\n\nFor example, to concatenate the strings in ```list = ['Hello', 'World']```, you can use the following for loop:\n\n```py list = ['Hello', 'World'] str = '' for x in list: str += x print(str) ```", "most_similar": {"I want to find the average of all the numbers in a list.": 0.4545454545454546, "How to find the maximum value in a list?": 0.4444444444444444, "How to test if an element is in a list?": 0.4210526315789474, "Write a program to find the smallest number in a list.": 0.39999999999999997, "Write a Python function to concatenate all elements in a list into a string and return it.": 0.3846153846153846, "How to find the frequency distribution of all values in a list?": 0.380952380952381, "Write a python code to find the minimum value in a list.": 0.380952380952381, "How do I find the p-variance of all elements in a list?": 0.3636363636363637, "How can I convert a list of strings to a list of integers?": 0.3636363636363637, "How do I print a list in Python?": 0.35294117647058826}, "avg_similarity_score": 0.12289318829367624} -{"instruction": "I want to create a list of integers from 1 to 1000. How would I do that?", "input": "", "output": "To create a list of integers from 1 to 1000, you can use the ```range()``` function. The ```range()``` function returns a sequence of numbers, starting from 0 by default and increments by 1 (by default), and ends at a specified number. For example, to create a list of integers from 1 to 1000, you can use the following code:\n\n```py list = list(range(1, 1001)) ```", "most_similar": {"I want to take a string and print it backwards. How would I do that?": 0.5625, "I have a list of integers: ```list = [1, 2, 3]```. How would I sum these integers?": 0.5454545454545455, "I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.46153846153846156, "If you wanted to create a variable that counts up from 0 to 100, how would you do it in C++?": 0.42105263157894735, "I have a list of strings, how do I convert them to numbers?": 0.4000000000000001, "How can I convert a list of strings to a list of integers?": 0.4000000000000001, "I have a list of numbers, how do I find the second largest number?": 0.3870967741935484, "How can I sort a list of integers in Rust?": 0.37037037037037035, "Write a Python function to reverse a given list of integers.": 0.35714285714285715, "I am trying to use the following code to create a list of numbers from 1 to 100. But it is not working. Can you help me fix it? ```python numbers = [] for i in range(1, 100): numbers.append(i) ```": 0.3508771929824561}, "avg_similarity_score": 0.1289156589724678} -{"instruction": "How do I remove the first item from a list?", "input": "", "output": "To remove the first item from a list, you can use the ```pop()``` method. The ```pop()``` method removes an item from a list. For example, to remove the first item from the list ```list = [1, 2, 3]```, you can use the following code:\n\n```py list = [1, 2, 3] list.pop(0) ```", "most_similar": {"How do I get the first element of a list?": 0.7, "How do you remove duplicates from a list in Python?": 0.6, "How do you remove an item at a given index from a list using Python?": 0.56, "How do I print a list in Python?": 0.5555555555555556, "How do you find the index of an item in a list?": 0.5454545454545454, "How do I find the p-variance of all elements in a list?": 0.5217391304347826, "How do I find the fibonacci number of a number?": 0.5, "How do I find the first element that satisfies a condition in an array?": 0.5, "Write a Python function that removes the first item from a list and returns it.": 0.48, "How do I get the power of a number in python?": 0.47619047619047616}, "avg_similarity_score": 0.14683915987743765} -{"instruction": "How would you go about modifying the following code to create a 200x200 identity matrix instead of a 200x200 matrix of 1s?\n```py\nmatrix = np.ones((200, 200), dtype=np.float32)\n```", "input": "", "output": "To create a 200x200 identity matrix, you can use the following code:\n```py\nmatrix = np.eye(200, dtype=np.float32)\n```\nThe np.eye() function creates an identity matrix. For more information, you can read the documentation for the np.eye() function [here](https://numpy.org/doc/stable/reference/generated/numpy.eye.html).", "most_similar": {"How do you count the number of items in a list?": 0.23809523809523805, "How do you find the length of a string in Python?": 0.23809523809523805, "How do you output all the contents of a list in Python?": 0.2325581395348837, "How do you find the index of an item in a list?": 0.2325581395348837, "How can I convert a list of strings to a list of integers?": 0.22727272727272727, "How do you find the standard deviation of all items in a list in Python?": 0.21739130434782605, "How do you get the first and last index of an element in a list in Python?": 0.20833333333333331, "How do you cast the return value of a function to a different data type in C#?": 0.20833333333333331, "How do you find the number of occurrences of a given value in a list in Python?": 0.20833333333333331, "How do you create a variable in Python?": 0.20512820512820512}, "avg_similarity_score": 0.10499870266178425} -{"instruction": "Is it possible to create a python list by using a python dict comprehension?", "input": "", "output": "You can't create a Python list using a Python dictionary comprehension. Instead, you can create a list using a list comprehension. Here's an example:\n```py\nmy_list = [i ** 2 for i in range(1, 5)]\n```", "most_similar": {"Is it possible to create a program that can write all other programs?": 0.4444444444444445, "What is a list comprehension?": 0.4210526315789473, "What is the difference between a list and a tuple in Python?": 0.3846153846153846, "Write a python code for a queue using a dictionary": 0.3333333333333333, "Write a Python program to create a dictionary from a string.": 0.32, "How to get the last element of a list in Python?": 0.32, "What is the best way to check if a list is empty?": 0.30769230769230765, "How do you find the largest number in a list using Python?": 0.30769230769230765, "Write a Python program to remove all duplicates from a list in Python": 0.29629629629629634, "Can you tell me how to sort a dictionary by value in Python?": 0.29629629629629634}, "avg_similarity_score": 0.12529108468569847} -{"instruction": "What is the meaning of this python code?\n```py\ndef get_sequences(f):\n sequences = []\n sequence = []\n for token in f.read().split('\\n'):\n if not token or token[0] == '>':\n if sequence:\n sequences.append(sequence)\n sequence = []\n if token:\n sequence.append(token[1:])\n else:\n sequence.append(token)\n if sequence:\n sequences.append(sequence)\n return sequences\n```", "input": "", "output": "The code snippet you provided reads in sequences of nucleotides from a file and returns a list of sequences. The input file has one sequence per line. Each sequence has the ID of the sequence, represented by a line beginning with '>', followed by the nucleotides of the sequence. This is an example of the input file format:\n```\n>Sequence_A\nATGTTGAGAAATGAAGATG\n>Sequence_B\nATTGTTGAGAAATAAGATG\n>Sequence_C\nATGGTTGAGAAATAAGATG\n```\nThe code you provided processes the input file and returns a list of sequences. The list of sequences is represented by a list of lists. The outer list represents all sequences, while the inner list represents each individual sequence.", "most_similar": {"What is the output of the following code? ```py def print_odds(n): for i in range(n): if i % 2 == 0: print(i) print_odds(10) ```": 0.30769230769230765, "What are the drawbacks of using this python code? ``` py def get_random_index(my_list): return random.randint(0, len(my_list)-1) ```": 0.2933333333333333, "What is the output of the following Python code? ```py def f(x): return x + 1 def g(x): return x * 2 print(g(f(3))) ```": 0.28571428571428575, "What is the output of the following python code?\n```python\ndef function(a):\n if a > 0:\n print('Positive')\n else:\n print('Negative')\n\nfunction(0)\n```": 0.2702702702702703, "What is the output of this code?\n```python\ndef f(x):\n x = 2 * x + 1\n return x\n\nx = 3\nz = f(x)\nprint(z)\n```": 0.26666666666666666, "Find the output of this code.\n```\ndef is_prime(n):\n if n < 2:\n return False\n for i in range(2, n):\n if n % i == 0:\n return False\n return True\n\ndef prime_factorize(n):\n factors = []\n factor = 2\n while n > 1:\n if n % factor == 0:\n factors.append(factor)\n n /= factor\n elif factor == 2:\n factor = 3\n else:\n factor += 2\n return factors\n\nprint(prime_factorize(100))\n```": 0.24778761061946902, "What is the output of this code?\n```\nfor i in range(10):\n print(i)\n```": 0.24615384615384614, "What is the output of the following code?\n```py\ndef get_cube(x):\n return x * x * x\n\nprint(get_cube(get_cube(2)))\n```": 0.24324324324324328, "What is the output of the following code?\n```python\ndef f(x):\n return x * 2\n\ndef g(x):\n return f(x) + 1\n\ndef h(x):\n return g(x) * 2\n\nprint(h(2))\n```": 0.24096385542168675, "What does the following python code do?\n```python def sum_divisible_by_three(lst):\n\treturn sum(x for x in lst if x % 3 == 0)\n ```": 0.2368421052631579}, "avg_similarity_score": 0.07726351475002836} -{"instruction": "Is it possible to apply a mask on a tensor using tf.boolean_mask()?", "input": "", "output": "Yes, you can apply a mask on a tensor using tf.boolean_mask(). The tf.boolean_mask() function masks elements from a tensor. For example, you can use the following code to apply a mask on a tensor:\n```py\nx = tf.constant([2.0, 3.0, 4.0])\nmask = tf.constant([True, False, True])\nresult = tf.boolean_mask(x, mask)\n```\nThe code above will return the following tensor:\n```\n\n```", "most_similar": {"Is it possible to create a python list by using a python dict comprehension?": 0.42857142857142855, "Is it possible to create a program that can write all other programs?": 0.3703703703703704, "Is it possible to define functions in the body of an `if` statement?": 0.29629629629629634, "What is the correct way to add a link to a stylesheet in HTML?": 0.2857142857142857, "How to split a string into a list?": 0.2727272727272727, "Write a python code for a queue using a dictionary": 0.25, "How to test if a key exists in a dictionary?": 0.25, "Write a python code for a stack using an array": 0.25, "Write a Python program to add a key to a dictionary.": 0.23999999999999996, "Write a Python program to create a dictionary from a string.": 0.23999999999999996}, "avg_similarity_score": 0.0975979418627787} -{"instruction": "Can you give me a code example of using tf.nn.dropout() for an input tensor?", "input": "", "output": "You can use tf.nn.dropout() to randomly drop elements from an input tensor. Here's an example of how to use tf.nn.dropout():\n```py\nimport tensorflow as tf\n\nx = tf.constant([[1., 2., 3.], [4., 5., 6.]])\noutput = tf.nn.dropout(x, rate=0.5)\n```\nIn the code above, you create an input tensor and pass it to the tf.nn.dropout() function. The rate parameter determines how many elements will be dropped in the output tensor. Here, 50% of the elements are dropped from the tensor because the rate is set to 0.5. The code above will return the following output tensor:\n```\n\n```", "most_similar": {"Can you give me an example of a computer vision task?": 0.4444444444444444, "Write a python code for a stack using an array": 0.3076923076923077, "Can you tell me how to sort a dictionary by value in Python?": 0.27586206896551724, "Could you please write me Rust code that takes ownership of an array of integers and sorts them in ascending order?": 0.27027027027027023, "Write a Python program to find the average of a list using for loop.": 0.26666666666666666, "Write a python code for binary search": 0.26086956521739124, "Write a python code for a linked list": 0.25, "Write a python code for queues using stack": 0.25, "Show me a code in JavaScript that returns the sum of all the integers in a string.": 0.24242424242424243, "write a code to get the current value of a Bitcoin in US dollars using the bitcoincharts API.": 0.23529411764705882}, "avg_similarity_score": 0.0918847719504624} -{"instruction": "What does the following python code print?\n```py\nprint(f'500:{500:08d}')\n```", "input": "", "output": "The code snippet you provided prints the following output:\n```\n500:0000500\n```", "most_similar": {"What is the python code to print hello world?": 0.4545454545454546, "What does the function `print()` do?": 0.42105263157894735, "What is the output of the following Python code? ```py def f(x): return x + 1 def g(x): return x * 2 print(g(f(3))) ```": 0.4102564102564103, "In Python, what does the following code output?\n[3, 4, 5][-1]": 0.4, "What is the output of the following python code?\n```python\ndef function(a):\n if a > 0:\n print('Positive')\n else:\n print('Negative')\n\nfunction(0)\n```": 0.3888888888888889, "Suggest a completion for the following python code.": 0.380952380952381, "What is the output of the following code? ```py def a(): print(\"a\") b = a def c(): print(\"c\") b() ```": 0.3636363636363637, "What is the output of the following code?\n```py\nnum = 3\n\ndef func(num):\n num += 4\n\nfunc(num)\nprint(num)\n```": 0.3636363636363637, "What is the output of the following code? ```py def add_five(x): x += 5 return x print(add_five(2)) ```": 0.35294117647058826, "In Python, what does the following expression mean: `x = 3`": 0.34782608695652173}, "avg_similarity_score": 0.09049493194719686} -{"instruction": "Give me a SQL query to find all the records where \"Salary\" is greater than 2000 in the \"Employee\" table.", "input": "", "output": "You can use the following SQL query to get all the records where the \"Salary\" is greater than 2000:\n```sql\nSELECT * FROM Employee WHERE Salary > 2000\n```", "most_similar": {"Write a SQL query to find all the duplicate emails.": 0.4666666666666667, "Write an SQL query to select all columns from a table named 'employees' where the age is greater than 30.": 0.4000000000000001, "Write a Python program to find the first Fibonacci number greater than four million.": 0.3529411764705882, "Write a Python program to find the difference between a specified number and 13, if the number is greater than 13 return double the absolute difference.": 0.34782608695652173, "Write an SQL query to select all columns from a table named 'employees' where the age is greater than 30 and the salary is greater than 10000 or the name is 'John' and the age is less than 40.": 0.3389830508474576, "Given a number N, write a program to find the sum of all the digits in N.": 0.3243243243243243, "Write a program to find the smallest number in a list.": 0.3225806451612903, "Write a program to find the maximum value in an array": 0.3225806451612903, "Write a code snippet to list the directories in the current directory.": 0.3125, "Write a python code to find the minimum value in a list.": 0.3125}, "avg_similarity_score": 0.14460392247426332} -{"instruction": "How would you create a python list with the numbers 1 to 10, where each number is repeated twice?", "input": "", "output": "You can create a list with the numbers 1 to 10, where each number is repeated twice, by using list comprehension. Here's an example:\n```py\nresult = [item for item in range(1, 11) for i in range(2)]\n```\nThe code above will create the following list:\n```\n[1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10]\n```", "most_similar": {"How do I make a list of all the prime numbers up to a certain number?": 0.39999999999999997, "How do you create a variable in Python?": 0.37037037037037035, "How do you create a new list from two lists in Python by picking one element each?": 0.33333333333333337, "Write a python program to check if the number is prime.": 0.3333333333333333, "You have a list of numbers. You want to find the largest number among them. How will you do it?": 0.3076923076923077, "Write a Python program to check whether a specified number is a perfect square.": 0.30303030303030304, "How do you create a new virtual environment?": 0.2962962962962963, "Write a Python function to find all prime numbers up to the given number n.": 0.29411764705882354, "The output should be a list of all the prime numbers between 1 and 100.": 0.29411764705882354, "Write a Python function that takes a number as input and returns the sum of all the numbers from 1 to that number that are divisible by 3 and 5.": 0.2857142857142857}, "avg_similarity_score": 0.1460583981883041} -{"instruction": "What is the output of the following code?\n```py\nsentence = 'The quick brown fox jumps over the lazy dog'\nprint(sentence[4:19:2])\n```", "input": "", "output": "The code you provided prints the following output:\n```\nquickrownjmpoverth\n```", "most_similar": {"What is the output of the following code? ```py def add_five(x): x += 5 return x print(add_five(2)) ```": 0.4888888888888889, "What is the output of the following code?\n```py\ndef get_cube(x):\n return x * x * x\n\nprint(get_cube(get_cube(2)))\n```": 0.4680851063829787, "What is the output of the following code? ```py def a(): print(\"a\") b = a def c(): print(\"c\") b() ```": 0.45454545454545453, "What is the output of the following code?\n```py\nnum = 3\n\ndef func(num):\n num += 4\n\nfunc(num)\nprint(num)\n```": 0.45454545454545453, "What is the output of the following code? ```py def add(a, b): return a + b print(add(1, 2)) print(add(b=2, a=1)) ```": 0.43999999999999995, "What is the output of the following code? ```py def print_odds(n): for i in range(n): if i % 2 == 0: print(i) print_odds(10) ```": 0.4313725490196078, "What is the output of the code below?\n\n```python import math print(math.sqrt(16))```": 0.4102564102564102, "What is the output of the following Python code? ```py def f(x): return x + 1 def g(x): return x * 2 print(g(f(3))) ```": 0.4, "What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.39999999999999997, "What is the output of the following code?\n```python\ndef foo():\n print(\"foo\")\n\ndef bar():\n print(\"bar\")\n\ndef main():\n foo()\n bar()\n\nmain()\n```": 0.3913043478260869}, "avg_similarity_score": 0.11173344428913834} -{"instruction": "Is it possible to add multiple columns in a SQL table?", "input": "", "output": "Yes, you can add multiple columns in a SQL table. Here's an example of how you can add multiple columns to a SQL table:\n```sql\nALTER TABLE table_name ADD column1 datatype, ADD column2 datatype;\n```", "most_similar": {"Is it possible to create a program that can write all other programs?": 0.41666666666666663, "Is it possible to define functions in the body of an `if` statement?": 0.41666666666666663, "Is it possible to apply a mask on a tensor using tf.boolean_mask()?": 0.4, "Is it possible to create a python list by using a python dict comprehension?": 0.4, "What is the correct way to add a link to a stylesheet in HTML?": 0.32, "What is the purpose of a hash table?": 0.3157894736842105, "I'm trying to concatenate strings in a list.": 0.3, "How to find the maximum value in a list?": 0.3, "How to test if an element is in a list?": 0.28571428571428564, "How to test if a key exists in a dictionary?": 0.28571428571428564}, "avg_similarity_score": 0.10706193705987674} -{"instruction": "What is the output of the following code?\n```py\nnum = 5\nwhile num >= 0:\n print('number is:', num)\n num -= 1\n```", "input": "", "output": "The code snippet you provided prints the following output:\n```\nnumber is: 5\nnumber is: 4\nnumber is: 3\nnumber is: 2\nnumber is: 1\nnumber is: 0\n```", "most_similar": {"What is the output of the following code?\n```py\nnum = 3\n\ndef func(num):\n num += 4\n\nfunc(num)\nprint(num)\n```": 0.65, "What is the output of the following code? ```py def add_five(x): x += 5 return x print(add_five(2)) ```": 0.5365853658536585, "What is the output of the following code? ```py def a(): print(\"a\") b = a def c(): print(\"c\") b() ```": 0.5, "Rewrite the following code in Java:\n```py\nnum = 5\n\ndef func(num):\n num += 5\n\nprint(num)\n```": 0.5, "What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.4878048780487805, "What is the output of the following code? ```py def add(a, b): return a + b print(add(1, 2)) print(add(b=2, a=1)) ```": 0.47826086956521735, "What is the output of the following code? ```py a = 5 b = 15 print(\"a / b is\", a / b) print(\"a % b is\", a % b) print(\"a // b is\", a // b) ```": 0.47058823529411764, "What is the output of the following code? ```py def print_odds(n): for i in range(n): if i % 2 == 0: print(i) print_odds(10) ```": 0.46808510638297873, "What is the output of the following python code?\n```python\ndef function(a):\n if a > 0:\n print('Positive')\n else:\n print('Negative')\n\nfunction(0)\n```": 0.46511627906976744, "What is the output of the following code?\n```py\ndef get_cube(x):\n return x * x * x\n\nprint(get_cube(get_cube(2)))\n```": 0.46511627906976744}, "avg_similarity_score": 0.13045170512909507} -{"instruction": "Write a python code that takes a list of values and removes all the odd values.", "input": "", "output": "```python\nfor i in range(len(lst)):\n if lst[i] % 2 == 1:\n lst.remove(lst[i])\n```", "most_similar": {"Write a python function that takes a list of strings and returns the longest common substring.": 0.625, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.5945945945945946, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.5555555555555556, "Write a Python function that takes a list of numbers and make a new list containing the numbers in a random order.": 0.5263157894736842, "Write a Python function that takes a list and returns a new list with unique elements of the first list.": 0.5, "Write a python code for a linked list": 0.5, "Write a function that receives a list of items and returns the items in reverse order.": 0.5, "Write a Python function that takes a number as input and returns the square of that number.": 0.48484848484848486, "Write a Python function that takes a string as input and returns the string in reverse order.\n'Hello'": 0.47058823529411764, "Write a Python function that returns a list of numbers in a specified range.": 0.4666666666666667}, "avg_similarity_score": 0.18948099930248707} -{"instruction": "You have a list of integers, and for each index you want to find the product of every integer except the integer at that index. Write a function get_products_of_all_ints_except_at_index() that takes an array of integers and returns an array of the products.", "input": "", "output": "def get_products_of_all_ints_except_at_index(array):\n products = []\n for i in range(len(array)):\n products.append(reduce(lambda x, y: x*y, [x for j, x in enumerate(array) if j != i]))\n return products", "most_similar": {"I have a list of numbers and I want to find the average of all the numbers.": 0.36363636363636365, "Write a function that takes an array and returns a new array where each element is the square of the original array.": 0.3380281690140845, "Write a function that takes an array of numbers and returns the largest number in the array.": 0.33333333333333337, "Write a function that takes an integer and returns the nth digit of the number.": 0.3125, "I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.30985915492957744, "You are given a list of numbers. You need to find the median of the list.": 0.3076923076923077, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.30303030303030304, "If you have an array of numbers and you want to get the average of all the numbers, what is the shortest code to do it?": 0.29333333333333333, "You have a list of numbers. You want to find the largest number among them. How will you do it?": 0.2898550724637681, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.2857142857142857}, "avg_similarity_score": 0.1321022823143804} -{"instruction": "Write a function that takes in a non-empty array of integers and returns true if there is a place to split the array so that the sum of the numbers on one side is equal to the sum of the numbers on the other side.", "input": "", "output": "```python\ndef find_even_index(array):\n left_sum = 0\n right_sum = sum(array)\n for i in range(len(array)):\n right_sum -= array[i]\n if left_sum == right_sum:\n return i\n left_sum += array[i]\n return -1\n```", "most_similar": {"Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.4477611940298507, "Write a function that takes an array and returns a new array where each element is the square of the original array.": 0.411764705882353, "Write a function that takes a list of numbers and returns a list of the same numbers, but with the first and last elements swapped.": 0.3943661971830986, "Write a Python function that takes a number as input and returns the sum of all the numbers from 1 to that number that are divisible by 3 and 5.": 0.3684210526315789, "I am trying to write a function that takes a list of numbers and returns the sum of the numbers. I wrote the following code in Python:\n```py def sum(lst):\n total = 0\n for i in lst:\n total += i\n return total\n```": 0.36781609195402304, "Write a Python function that accepts a sequence of strings and returns a dictionary in which the keys are elements of the sequence and the values are the number of times each element occurs in the sequence.": 0.3614457831325302, "Write a function that takes an integer n as a parameter and returns the sum of the first n numbers.\n```py\nFor example, if the input is 3, the function should return 6, since 1 + 2 + 3 = 6.\n```": 0.35714285714285715, "Write a function that takes a string and returns the number of vowels in the string.": 0.3548387096774194, "Write a function that takes an array of numbers and returns the largest number in the array.": 0.34920634920634924, "Write a Python program that takes a list of numbers as input from the user, calculates the sum of all even numbers in the list, and returns the result.": 0.3466666666666666}, "avg_similarity_score": 0.15401738931300643} -{"instruction": "Given a string, return True if the number of appearances of \"is\" anywhere in the string is equal to the number of appearances of \"not\" anywhere in the string (case sensitive).", "input": "", "output": "```python\ndef equal_is_not(my_string):\n return my_string.count('is') == my_string.count('not')\n```", "most_similar": {"Given a string, return the number of vowels used in the text.": 0.4186046511627908, "Given a string s, return the number of palindromic substrings in it. A string is a palindrome when it reads the same backward as forward. A substring is a contiguous sequence of characters within the string.": 0.417910447761194, "Write a function that returns the number of times the string 'hi' appears anywhere in the given string.": 0.40816326530612246, "Given a string s, return the number of palindromic substrings in it.": 0.37209302325581395, "Write a function that takes a string and returns the number of vowels in the string.": 0.3404255319148936, "Write a Python function that returns the number of items that are present in the first list but not in the second list.": 0.33333333333333337, "Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.\n\nAn input string is valid if:\nOpen brackets must be closed by the same type of brackets.\nOpen brackets must be closed in the correct order.": 0.3333333333333333, "Given a list of numbers, find the largest number in the list.": 0.3255813953488372, "Given a list of strings, find the longest string in the list. You can use the len function to find the length of a string.": 0.3214285714285714, "Write a function that takes in a non-empty array of integers and returns true if there is a place to split the array so that the sum of the numbers on one side is equal to the sum of the numbers on the other side.": 0.31168831168831174}, "avg_similarity_score": 0.15705169517038697} -{"instruction": "Write a function that accepts a string as a parameter and converts it to an array where every character is an element of the array.", "input": "", "output": "```python\ndef get_char_array(my_string):\n return [c for c in my_string]\n```", "most_similar": {"Write a function that takes an array and returns a new array where each element is the square of the original array.": 0.46808510638297873, "Write a function that takes a string and returns the number of vowels in the string.": 0.43902439024390244, "Write a function that takes an array of numbers and returns the largest number in the array.": 0.42857142857142855, "Write a function that takes a string as input and reverse only the vowels of a string.": 0.42857142857142855, "Write a Python function that takes a string as input and returns the string in reverse order.\n'Hello'": 0.41860465116279066, "Write a python function that adds a new key to a dictionary and returns the value of the key.": 0.40909090909090906, "Write me a python function that takes two arrays as input, and return the element-wise sum of the two arrays as a new array.": 0.4000000000000001, "Write a function that takes an integer minutes and converts it to hours and minutes.": 0.4, "Write a Python function that takes a string and checks if it contains only consonants.": 0.4, "Write a JavaScript program to convert a string to an array, separating the elements by spaces.": 0.39024390243902435}, "avg_similarity_score": 0.16803786333289739} -{"instruction": "Given a list of numbers and a number k, return whether any two numbers from the list add up to k.", "input": "", "output": "```python\ndef sum_exists(lst, k):\n for i in range(len(lst)):\n for j in range(i+1, len(lst)):\n if lst[i] + lst[j] == k:\n return True\n return False\n```", "most_similar": {"Given a list of numbers, find the largest number in the list.": 0.4848484848484849, "Given an array of integers, return indices of the two numbers such that they add up to a specific target.": 0.3902439024390244, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.38095238095238093, "You are given a list of numbers. You need to find the median of the list.": 0.37837837837837834, "Given a list of numbers, find the sum of the numbers.": 0.37499999999999994, "Given a list of integers, return a list of those numbers squared and the product added to 10, sorted in descending order.": 0.37209302325581395, "I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.37209302325581395, "You are given a list of numbers. Return the sum of the numbers. If the input is invalid, return a user-friendly error message.": 0.35555555555555557, "Write a function that takes a list of numbers and returns a list of the same numbers, but with the first and last elements swapped.": 0.34782608695652173, "Write a Python function that takes a list of numbers and make a new list containing the numbers in a random order.": 0.3255813953488372}, "avg_similarity_score": 0.14570808411656397} -{"instruction": "Write a function that reverses a string. The input string is given as an array of characters char[].", "input": "", "output": "```python\ndef reverse_string(arr):\n return arr[::-1]\n```", "most_similar": {"Write a function that reverses a given string.": 0.5384615384615385, "Write a function to find the longest common prefix string amongst an array of strings.": 0.4848484848484848, "Write a function that returns the smallest integer in an array.": 0.4827586206896552, "Write a function that takes a string and returns the number of vowels in the string.": 0.47058823529411764, "Write a function that accepts a string as a parameter and converts it to an array where every character is an element of the array.": 0.46511627906976744, "Write a function that takes a string as input and reverse only the vowels of a string.": 0.45714285714285713, "Write a Python function that takes a string as input and returns the string in reverse order.\n'Hello'": 0.4444444444444444, "Write me a python function that returns the sum of all even numbers in an array of integers.": 0.4444444444444444, "Write a function that returns the sum of two numbers.": 0.42857142857142855, "Write a function that prints the reverse of a string.": 0.42857142857142855}, "avg_similarity_score": 0.17658339132490847} -{"instruction": "Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i.", "input": "", "output": "```python\ndef get_products_of_all_ints_except_at_index(array):\n products = []\n for i in range(len(array)):\n products.append(reduce(lambda x, y: x*y, [x for j, x in enumerate(array) if j != i]))\n return products\n```", "most_similar": {"Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i.\n```py\nFor example, if our input was [1, 2, 3, 4, 5], the expected output would be [120, 60, 40, 30, 24]. If our input was [3, 2, 1], the expected output would be [2, 3, 6].\n```": 0.6605504587155963, "Let's look at an example to understand the concept of prefix sum. Given an array of integers, [3, 5, 2, 1, 6]. Create an array such that each element at index i of the new array is equal to the sum of elements from index 0 to i of the original array.": 0.5168539325842696, "Write a function that takes an array and returns a new array where each element is the square of the original array.": 0.4482758620689656, "Given an array of numbers, write a function that returns an array that only contains the first element and the difference between consecutive numbers in the original array.": 0.43750000000000006, "You are given an integer array nums and you have to return a new counts array. The counts array has the property where counts[i] is the number of smaller elements to the right of nums[i].": 0.3835616438356164, "Given an array of integers nums, write a method that returns the \"pivot\" index of this array.": 0.3773584905660377, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.3508771929824561, "Write a function that takes in a non-empty array of integers and returns true if there is a place to split the array so that the sum of the numbers on one side is equal to the sum of the numbers on the other side.": 0.34146341463414637, "Write a Python program that takes a list of numbers as input from the user, calculates the sum of all even numbers in the list, and returns the result.": 0.3384615384615385, "Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.": 0.33766233766233766}, "avg_similarity_score": 0.1400584514259041} -{"instruction": "Given a string, return a new string where the first and last chars have been exchanged.", "input": "", "output": "```python\ndef front_back(str):\n if len(str) < 2:\n return str\n return str[-1] + str[1:-1] + str[0]\n```", "most_similar": {"Write a function that takes a string and returns a new string with the first letter of each word capitalized.": 0.38888888888888884, "Write a Python function that takes a string and returns a new string with the words in sorted order and unique.": 0.37837837837837834, "Given a string s, return the longest palindromic substring in s.": 0.3703703703703703, "Write a Python program to get a string from a given string where all occurrences of its first char have been changed to '$', except the first char itself.": 0.36363636363636365, "Given a string s, return the number of palindromic substrings in it.": 0.35714285714285715, "Given a string, return the number of vowels used in the text.": 0.35714285714285715, "Write a Python program to find the first pallindromic string from a given string where the length is three or more.": 0.3243243243243243, "Write a Python program to find the first repeated character of a given string where the index of first occurrence is smallest.": 0.3157894736842105, "Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.": 0.30769230769230765, "Write a function to find the first and last occurences of an element in a sorted array.": 0.30303030303030304}, "avg_similarity_score": 0.12923505760474505} -{"instruction": "Given two arrays, write a function to compute their intersection.", "input": "", "output": "```python\ndef intersection(list1, list2):\n return [x for x in list1 if x in list2]\n```", "most_similar": {"Write a Python function to reverse a given list of integers.": 0.380952380952381, "Write a Python program to compute the length of a string.": 0.380952380952381, "Write a Python function to calculate the factorial of a number.": 0.380952380952381, "Write a Python function to find the correlation between two lists.": 0.380952380952381, "write a sum function in asm": 0.37499999999999994, "Write a python function that sorts a list from large to small.": 0.3636363636363636, "Write a Python function to find the largest number in a dictionary.": 0.3636363636363636, "Write a program to compute the sum of integers from k to n.": 0.34782608695652173, "Write me a function in C++ to find the distance between two points": 0.34782608695652173, "Write a Python function to check whether a passed string is palindrome or not.": 0.3333333333333333}, "avg_similarity_score": 0.13086017503932007} -{"instruction": "Consider the following text: ``` This is a line of text. This is another line of text. This is the last line. ``` On a screen of width 10, this text would be rendered as follows: ``` This is a ``` ``` line of ``` ``` text. This ``` ``` is ano ``` ``` ther line ``` ``` of text. ``` ``` This is th ``` ``` e last ``` ``` line. ```\nGiven a string and a screen width, write a function that renders the string onto the screen. Your function should return the text rendered to the screen.", "input": "", "output": "``` python def render(string, width): words = string.split(\" \") rendered = \"\" for word in words: if len(rendered.split(\"\\n\")[-1]) + len(word) + 1 > width: rendered += \"\\n\" rendered += word + \" \" return rendered ```", "most_similar": {"Which of the following statement(s) is/are TRUE?\n1.\tIf a function in a C++ program does not return any value, it is necessary to declare the return type of that function as void.\n2.\tAny function in C++ that does not accept any argument is called a default function.\n3.\tIf the control reaches the end of a function, and it has no explicit return statement, the function returns a garbage value.": 0.2077922077922078, "Write a Python program to get a string made of the first 2 and the last 2 chars from a given a string. If the string length is less than 2, return instead of the empty string.": 0.20512820512820512, "Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. A palindrome string is a string that reads the same backward as forward.": 0.1896551724137931, "Given a string, write a function to check if it is a permutation of a palindrome. A palindrome is a word or phrase that is the same forwards and backwards. A permutation is a rearrangement of letters. The palindrome does not need to be limited to just dictionary words.": 0.18604651162790697, "I have a dictionary in python where I have a key and the value is a list of strings. I want to search for a particular string in the list and return the key. What is the best way to do that?": 0.18032786885245902, "The average speed of the jet is 1000km/hr. It takes 1hr 45min to fly from place A to place B. Place B is 800km from place A. What is the speed of the jet for the first half of the journey?": 0.18032786885245902, "What is the output of the following code? ```py a = 5 b = 15 print(\"a / b is\", a / b) print(\"a % b is\", a % b) print(\"a // b is\", a // b) ```": 0.18018018018018017, "Given a string, return True if the number of appearances of \"is\" anywhere in the string is equal to the number of appearances of \"not\" anywhere in the string (case sensitive).": 0.18018018018018017, "How do I find the index of the last occurrence of a substring in a string, starting at a particular index?": 0.1782178217821782, "Write a Python function to check if a given number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence. The Fibonacci sequence is a sequence of numbers where each number is the sum of the two preceding numbers. The first two numbers in the sequence are 0 and 1.": 0.1764705882352941}, "avg_similarity_score": 0.09135012118239609} -{"instruction": "Given an integer array nums, return the number of reverse pairs in the array. A reverse pair is a pair (i, j) where 0 <= i < j < nums.length and nums[i] > 2 * nums[j].", "input": "", "output": "``` python class Solution: def reversePairs(self, nums: List[int]) -> int: count = 0 for i in range(len(nums)): for j in range(i+1, len(nums)): if nums[i] > 2*nums[j]: count += 1 return count ```", "most_similar": {"Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0. Not": 0.4776119402985075, "Given an array of n integers nums, a 132 pattern is a subsequence of three integers nums[i], nums[j] and nums[k] such that i < j < k and nums[i] < nums[k] < nums[j]. Return true if there is a 132 pattern in nums, otherwise, return false.": 0.39024390243902435, "You are given a list of numbers. You need to find the number of pairs of indices (i, j) such that the difference between nums[i] and nums[j] is at most t and i < j.": 0.34285714285714286, "You are given an integer array nums and you have to return a new counts array. The counts array has the property where counts[i] is the number of smaller elements to the right of nums[i].": 0.3380281690140845, "Given an integer array nums, find the subarray with the largest sum, and return its sum.": 0.31999999999999995, "You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array is a cost that you have to pay to walk one step.": 0.31884057971014496, "Given a string, return the number of vowels used in the text.": 0.3043478260869565, "Given a binary array, find the maximum number of consecutive 1s in this array.": 0.2916666666666667, "Given an array A of integers, return the number of (contiguous, non-empty) subarrays that have a sum divisible by K.": 0.29090909090909084, "Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i.": 0.28571428571428575}, "avg_similarity_score": 0.12713232593354276} -{"instruction": "The Hamming distance between two integers is the number of positions at which the corresponding bits are different.\nGiven two integers x and y, return the Hamming distance between them.", "input": "", "output": "``` python def hammingDistance(x: int, y: int) -> int: return sum(c1 != c2 for c1, c2 in zip(bin(x)[2:], bin(y)[2:])) ```", "most_similar": {"Given the `head` of a singly linked list, return the middle node of the linked list. If there are two middle nodes, return the second middle node.": 0.28070175438596495, "What is the difference between the `break` and the `continue` keywords?": 0.2439024390243902, "Given an array of integers, find the pair of adjacent elements that has the largest product and return that product.": 0.24, "What is the difference between the `==` and the `.equals()` methods in Java?": 0.23809523809523808, "What is the output of the following code? ```py def add_five(x): x += 5 return x print(add_five(2)) ```": 0.23529411764705882, "What is the difference between the if-else statement and the switch statement?": 0.2325581395348837, "How can I get a list of all the different vowels in a text, and the number of times each of them appeared?": 0.22641509433962265, "What is the output of the following code?\n```py\ndef get_cube(x):\n return x * x * x\n\nprint(get_cube(get_cube(2)))\n```": 0.22641509433962265, "What is the output of the following code?\n```python\ndef foo():\n x = 1\n def bar():\n x = 2\n return x\n return bar()\nprint(foo())\n```": 0.22641509433962265, "Write a function that takes an unsigned integer and returns the number of '1' bits it has (also known as the Hamming weight).": 0.22641509433962265}, "avg_similarity_score": 0.1062312217657588} -{"instruction": "Given a string s containing only lower case English letters and the '?' character, convert all the '?' characters into lower case letters such that the final string does not contain any consecutive repeating characters. You cannot modify the non '?' characters. It is guaranteed that there are no consecutive repeating characters in the given string except for '?'. Return the final string after all the conversions (possibly zero) have been made. If there is more than one solution, return any of them. It can be shown that an answer is always possible with the given constraints.", "input": "", "output": "``` python class Solution: def modifyString(self, s: str) -> str: chars = list(s) for i in range(len(chars)): if chars[i] == '?': if i > 0 and chars[i-1] != chars[i] and i+1 < len(chars) and chars[i+1] != chars[i]: chars[i] = chars[i-1] elif i == 0: chars[i] = 'a' elif i+1 < len(chars) and chars[i+1] != chars[i]: chars[i] = chars[i+1] return ''.join(chars) ```", "most_similar": {"You are given a string s and an integer k. You can choose one of the first k letters of s and append it at the end of the string.\n\nReturn the lexicographically smallest string you could have after applying the mentioned step any number of moves.": 0.24285714285714288, "Given a string S, check if the letters can be rearranged so that two characters that are adjacent to each other are not the same.\n\nIf possible, output any possible result. If not possible, return the empty string.": 0.22900763358778628, "Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.\n\nAn input string is valid if:\nOpen brackets must be closed by the same type of brackets.\nOpen brackets must be closed in the correct order.": 0.208955223880597, "Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. A palindrome string is a string that reads the same backward as forward.": 0.20155038759689922, "You are given a 0-indexed binary string s that represents a number in its binary representation. You are allowed to delete the character at index 0. Return the maximum binary string you can create that does not contain any leading zeros after removing exactly one character.": 0.2, "Write a Python program to get a string made of the first 2 and the last 2 chars from a given a string. If the string length is less than 2, return instead of the empty string.": 0.2, "Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s.": 0.18333333333333335, "Given a string, return True if the number of appearances of \"is\" anywhere in the string is equal to the number of appearances of \"not\" anywhere in the string (case sensitive).": 0.1774193548387097, "Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.": 0.1739130434782609, "Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.": 0.1724137931034483}, "avg_similarity_score": 0.07794685413680076} -{"instruction": "Given the root of a binary tree, the level of its root is 1, the level of its children is 2, and so on. Return the smallest level X such that the sum of all the values of nodes at level X is maximal.", "input": "", "output": "``` python def maxLevelSum(self, root: TreeNode) -> int: if not root: return 0 ans = 0 curr = 0 def dfs(root, level): nonlocal ans, curr global max_level global max_sum if not root: return max_level, max_sum curr += root.val if level > max_level: max_level = level if level == max_level: max_sum = max(max_sum, curr) dfs(root.left, level + 1) dfs(root.right, level + 1) curr -= root.val return max_level, max_sum dfs(root, 1) return max_level ```", "most_similar": {"Given the `root` of a binary tree, return the inorder traversal of its nodes' values.": 0.3728813559322034, "A node in a binary tree can be identified as special if the node and its descendants are all having identical values. Write a function that takes a root node of a binary tree and returns a list of all the special nodes.": 0.2758620689655172, "Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i.": 0.275, "Given a string, return True if the number of appearances of \"is\" anywhere in the string is equal to the number of appearances of \"not\" anywhere in the string (case sensitive).": 0.26666666666666666, "You are given a list of numbers. Return the sum of the numbers. If the input is invalid, return a user-friendly error message.": 0.2647058823529412, "Write a Python function to check if a given number is a Sphenic number or not. A Sphenic number is a composite number where the sum of its proper divisors is equal to the sum of its distinct prime factors. For example, 220 is a Sphenic number because its proper divisors are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110, and the sum of its distinct prime factors is 2 + 2 + 5 = 9.": 0.26446280991735543, "Given the `root` of a binary tree, return the inorder traversal of its nodes' values.\n# Definition for a binary tree node.\nclass TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right": 0.25882352941176473, "Given a list of numbers, find the sum of the numbers.": 0.2545454545454546, "Given the `head` of a singly linked list, return the middle node of the linked list. If there are two middle nodes, return the second middle node.": 0.2535211267605634, "Given an array of integers, find the pair of adjacent elements that has the largest product and return that product.": 0.25000000000000006}, "avg_similarity_score": 0.1192244984358698} -{"instruction": "You are given an array coordinates, coordinates[i] = [x, y], where [x, y] represents the coordinate of a point. Check if these points make a straight line in the XY plane.", "input": "", "output": "``` python class Solution: def checkStraightLine(self, coordinates: List[List[int]]) -> bool: a = coordinates[1][1] - coordinates[0][1] b = coordinates[1][0] - coordinates[0][0] for i in range(2, len(coordinates)): if coordinates[i][1] * a + coordinates[i][0] * b != a * coordinates[0][1] + b * coordinates[0][0]: return False return True ```", "most_similar": {"You are given an integer array nums and you have to return a new counts array. The counts array has the property where counts[i] is the number of smaller elements to the right of nums[i].": 0.2647058823529412, "Given an array of integers, sort it in ascending order using the bubble sort algorithm.": 0.26086956521739135, "You are given a list of numbers. You need to find the median of the list.": 0.25531914893617014, "Given an array of numbers, find the maximum sum of any contiguous subarray of the array.": 0.25531914893617014, "You are given a list of numbers. Return the sum of the numbers. If the input is invalid, return a user-friendly error message.": 0.2545454545454545, "How do you cast the return value of a function to a different data type in C#?": 0.25, "How do I find the first and last occurrence of a substring in a string in C++?": 0.25, "Given an array of integers nums, write a method that returns the \"pivot\" index of this array.": 0.25, "How do you find the number of occurrences of a given value in a list in Python?": 0.25, "You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array is a cost that you have to pay to walk one step.": 0.24242424242424246}, "avg_similarity_score": 0.12636264399058283} -{"instruction": "Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would have exactly one solution.", "input": "", "output": "``` python def threeSumClosest(nums: List[int], target: int) -> int: nums.sort() ans = nums[0] + nums[1] + nums[2] for i in range(len(nums) - 2): j = i + 1 k = len(nums) - 1 while j < k: s = nums[i] + nums[j] + nums[k] if abs(s - target) < abs(ans - target): ans = s if s < target: j += 1 elif s > target: k -= 1 else: return target return ans ```", "most_similar": {"Given an array of integers `nums` and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order.": 0.5161290322580646, "Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.": 0.4578313253012048, "Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.": 0.36363636363636365, "Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i.": 0.3333333333333333, "Given an array of integers, find the pair of adjacent elements that has the largest product and return that product.": 0.3225806451612903, "Given an array A of integers, return the number of (contiguous, non-empty) subarrays that have a sum divisible by K.": 0.3174603174603175, "Let's look at an example to understand the concept of prefix sum. Given an array of integers, [3, 5, 2, 1, 6]. Create an array such that each element at index i of the new array is equal to the sum of elements from index 0 to i of the original array.": 0.3157894736842105, "Given an integer array nums, find the subarray with the largest sum, and return its sum.": 0.31034482758620685, "Given an array of numbers, find the maximum sum of any contiguous subarray of the array.": 0.31034482758620685, "Given an array of integers nums, write a method that returns the \"pivot\" index of this array.": 0.30508474576271183}, "avg_similarity_score": 0.11072902467434599} -{"instruction": "Given an array of integers nums containing n + 1 integers where each integer is in the range [1, n] inclusive. There is only one duplicate number in nums, return this duplicate number.", "input": "", "output": "``` python def findDuplicate(nums: List[int]) -> int: n = len(nums) for i in range(n): if nums[abs(nums[i])] < 0: return abs(nums[i]) nums[abs(nums[i])] = -nums[abs(nums[i])] ```", "most_similar": {"Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number, find the duplicate one.": 0.6285714285714286, "Given an array of integers nums, write a method that returns the \"pivot\" index of this array.": 0.32653061224489793, "Given an array of n integers nums, a 132 pattern is a subsequence of three integers nums[i], nums[j] and nums[k] such that i < j < k and nums[i] < nums[k] < nums[j]. Return true if there is a 132 pattern in nums, otherwise, return false.": 0.3, "Given an array of integers, sort it in ascending order using the bubble sort algorithm.": 0.2978723404255319, "Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would have exactly one solution.": 0.2972972972972973, "Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i.": 0.29411764705882354, "Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.": 0.28571428571428575, "Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n).": 0.28125, "Find a pair of integers, given an array of integers, that have the maximum product. Return that product.": 0.28, "Given an array nums of size n, return the majority element.": 0.27906976744186046}, "avg_similarity_score": 0.10218984584743412} -{"instruction": "Given a string path, where path[i] = 'N', 'S', 'E' or 'W', each representing moving one unit north, south, east, or west, respectively. You start at the origin (0, 0) on a 2D plane and walk on the path specified by path. Return True if the path crosses itself at any point, that is, if at any time you are on a location you've previously visited. Return False otherwise.", "input": "", "output": "``` python def isPathCrossing(self, path: str) -> bool: mem = set() x = y = 0 for i in path: if i == 'N': x += 1 elif i == 'E': y += 1 elif i == 'S': x -= 1 else: y -= 1 if (x, y) in mem: return True mem.add((x, y)) return False ```", "most_similar": {"Given a string s, return true if the s can be palindrome after deleting at most one character from it.": 0.19999999999999998, "You are given a string s. You can transform s into a palindrome by adding English lowercase letters in front of it.\n\nReturn the shortest palindrome you can find by performing this transformation.": 0.1941747572815534, "You are given a 0-indexed binary string s that represents a number in its binary representation. You are allowed to delete the character at index 0. Return the maximum binary string you can create that does not contain any leading zeros after removing exactly one character.": 0.18803418803418803, "You are given a string s and an integer k. You can choose one of the first k letters of s and append it at the end of the string.\n\nReturn the lexicographically smallest string you could have after applying the mentioned step any number of moves.": 0.18803418803418803, "Given an array of n integers nums, a 132 pattern is a subsequence of three integers nums[i], nums[j] and nums[k] such that i < j < k and nums[i] < nums[k] < nums[j]. Return true if there is a 132 pattern in nums, otherwise, return false.": 0.1864406779661017, "Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s.": 0.18556701030927833, "Given a string S, check if the letters can be rearranged so that two characters that are adjacent to each other are not the same.\n\nIf possible, output any possible result. If not possible, return the empty string.": 0.18518518518518517, "Given a positive integer num, write a function which returns True if num is a perfect square else False.": 0.17977528089887637, "Write a script to output 'Hello World' in python\nYou are given an array `prices` where `prices[i]` is the price of a given stock on the i^th day. You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. Return the maximum profit you can achieve from this transaction. If you cannot achieve any profit, return 0.": 0.1793103448275862, "Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.": 0.17204301075268816}, "avg_similarity_score": 0.08263078041015594} -{"instruction": "Write a program that prints the following pattern:\n```\n1\n2 1\n3 2 1\n4 3 2 1\n5 4 3 2 1\n6 5 4 3 2 1\n7 6 5 4 3 2 1\n```", "input": "", "output": "# Prints the following pattern:\n```\n1\n2 1\n3 2 1\n4 3 2 1\n5 4 3 2 1\n6 5 4 3 2 1\n7 6 5 4 3 2 1\n```\n# Function definition\ndef print_pattern(n):\n\"\"\"\nPrints a pattern from 1 to n\n\"\"\"\n# Base Case\nif n == 1:\nprint(n)\nreturn\n# Recursive Case\nprint_pattern(n-1)\nprint(\" \".join(map(str, range(n, 0, -1))))\n# Main program\nif __name__ == \"__main__\":\nn = 7\nprint_pattern(n)", "most_similar": {"How to make a python program that will print the following pattern?\n```\n1\n1 2\n1 2 3\n1 2 3 4\n1 2 3 4 5\n```": 0.5079365079365079, "How to make a python program that will print the following pattern?\n```\n1\n2 3\n4 5 6\n7 8 9 10\n11 12 13 14 15\n```": 0.4126984126984127, "Sort the following list of tuples by their second item and then by their first item: ```[(4, 0), (0, 3), (0, 2), (2, 6), (3, 4), (5, 2), (1, 6)]```": 0.3333333333333333, "I need to sum all the values in the following list: `[1,2,3,4,5,6,7,8,9]`.": 0.32142857142857145, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.32142857142857145, "Write a python script that prints the following pattern:\n```\n*\n**\n***\n****\n*****\n```": 0.3111111111111111, "Convert this list into a list of sets: [[1, 2, 3], [4, 5, 6], [7, 8, 9]]": 0.3018867924528302, "Write a Java program that prints the numbers 1 through 100.": 0.29787234042553196, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.29508196721311475, "What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.2807017543859649}, "avg_similarity_score": 0.0965715091015195} -{"instruction": "Write a program that prints the following pattern:\n```\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7\n1 2 3 4 5 6\n1 2 3 4 5\n1 2 3 4\n1 2 3\n1 2\n1\n```", "input": "", "output": "def print_pattern(n):\n\"\"\"\nPrints a pattern from 1 to n and from n to 1\n\"\"\"\n# Base Case\nif n == 1:\nprint(n)\nreturn\n# Recursive Case\nprint_pattern(n-1)\nprint(\" \".join(map(str, range(n, 0, -1))))\n# Main program\nif __name__ == \"__main__\":\nn = 8\nprint_pattern(n)", "most_similar": {"How to make a python program that will print the following pattern?\n```\n1\n1 2\n1 2 3\n1 2 3 4\n1 2 3 4 5\n```": 0.5633802816901408, "Write a program that prints the following pattern:\n```\n1\n2 1\n3 2 1\n4 3 2 1\n5 4 3 2 1\n6 5 4 3 2 1\n7 6 5 4 3 2 1\n```": 0.55, "How to make a python program that will print the following pattern?\n```\n1\n2 3\n4 5 6\n7 8 9 10\n11 12 13 14 15\n```": 0.39436619718309857, "Given an integer n, return a list of its multiples up to n, sorted in ascending order. The items in the list should be integers and not strings. For example, if n is 7, your function should return [1, 2, 3, 4, 5, 6, 7] and not ['1', '2', '3', '4', '5', '6', '7'].": 0.32653061224489793, "What will be the output of the following code? ```py a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] b = a[2:8:2] c = a[:8:2] d = a[2:] e = a[:8] f = a[::] g = a[2:8:3] h = a[2:8:2] print(b) print(c) print(d) print(e) print(f) print(g) print(h) ```": 0.32075471698113206, "I need to sum all the values in the following list: `[1,2,3,4,5,6,7,8,9]`.": 0.3125, "Write a Python function to check if a given number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. For example, 6 has divisors 1, 2 and 3 (excluding the number itself), and 6 = 1 + 2 + 3. Similarly, 28 has divisors 1, 2, 4, 7, 14 and 28, and 28 = 1 + 2 + 4 + 7 + 14.": 0.3076923076923077, "Sort the following list of tuples by their second item and then by their first item: ```[(4, 0), (0, 3), (0, 2), (2, 6), (3, 4), (5, 2), (1, 6)]```": 0.29729729729729726, "Convert this list into a list of sets: [[1, 2, 3], [4, 5, 6], [7, 8, 9]]": 0.29508196721311475, "Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of the first 10 ugly numbers. Note that 1 is typically treated as an ugly number.": 0.2857142857142857}, "avg_similarity_score": 0.08639193762996467} -{"instruction": "Write a program that prints the following pattern:\n```\n1\n2 4\n3 5 7\n6 8 10 12\n```", "input": "", "output": "def print_pattern(n):\n\"\"\"\nPrints a pattern from 1 to n and from n to 1\n\"\"\"\n# Base Case\nif n == 1:\nprint(n)\nreturn\n# Recursive Case\nprint_pattern(n-1)\nprint(\" \".join(map(str, range(1, n*2+1, 2))))\n# Main program\nif __name__ == \"__main__\":\nn = 4\nprint_pattern(n)", "most_similar": {"How to make a python program that will print the following pattern?\n```\n1\n2 3\n4 5 6\n7 8 9 10\n11 12 13 14 15\n```": 0.6222222222222222, "Write a program that prints the following pattern:\n```\n1\n2 1\n3 2 1\n4 3 2 1\n5 4 3 2 1\n6 5 4 3 2 1\n7 6 5 4 3 2 1\n```": 0.5555555555555556, "Write a python script that prints the following pattern:\n```\n*\n**\n***\n****\n*****\n```": 0.5185185185185185, "How to make a python program that will print the following pattern?\n```\n1\n1 2\n1 2 3\n1 2 3 4\n1 2 3 4 5\n```": 0.4888888888888889, "Write a program that prints the following pattern:\n```\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7\n1 2 3 4 5 6\n1 2 3 4 5\n1 2 3 4\n1 2 3\n1 2\n1\n```": 0.4838709677419354, "Write a Java program that prints the numbers 1 through 100.": 0.4827586206896552, "Write a program that prints all the multiples of 3 from 0 to 100.": 0.43750000000000006, "I need to sum all the values in the following list: `[1,2,3,4,5,6,7,8,9]`.": 0.4210526315789474, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.4210526315789474, "How to make a python program that will print the following pattern?\n```\n*\n**\n***\n****\n*****\n```": 0.4}, "avg_similarity_score": 0.1386986734853407} -{"instruction": "Given a string, write a program to count the number of unique characters.", "input": "", "output": "def count_unique_characters(string):\n\"\"\"\nReturns the number of unique characters in a given string\n\"\"\"\n# Initialize a set to store unique characters\nunique_chars = set()\n# Iterate through the string and add each unique character to the set\nfor ch in string:\nif ch not in unique_chars:\nunique_chars.add(ch)\n# Return the number of unique characters\nreturn len(unique_chars)\n# Main program\nif __name__ == \"__main__\":\nstring = \"hello world\"\nprint(\"The number of unique characters in\", string, \"is\", count_unique_characters(string))", "most_similar": {"Write a Python program to count the number of matching parenthesis in a given expression.": 0.5714285714285715, "Given a number N, write a program to find the sum of all the digits in N.": 0.5333333333333333, "Write a program to find the maximum of three numbers.": 0.5217391304347826, "Write a program to find the n-th ugly number.": 0.5217391304347826, "Write a Python program to find the number of equal numbers from three given integers.": 0.5, "Write a Python program to compute the length of a string.": 0.4999999999999999, "Write a python program to check if the number is prime.": 0.4999999999999999, "Write a program to find the smallest number in a list.": 0.4999999999999999, "Write a program to find the pearson correlation coefficient of two lists.": 0.48000000000000004, "Given a string s, return the number of palindromic substrings in it.": 0.48000000000000004}, "avg_similarity_score": 0.19273179484256517} -{"instruction": "Given a string, write a program to check whether it is a palindrome.", "input": "", "output": "def check_palindrome(string):\n\"\"\"\nReturns True if the given string is a palindrome, and False otherwise.\n\"\"\"\n# Convert the string to lowercase characters\nstring = string.lower()\n# Check if the string is a palindrome\nif string == string[::-1]:\nreturn True\n# Otherwise, it is not a palindrome\nreturn False\n# Main program\nif __name__ == \"__main__\":\nprint(check_palindrome('racecar'))\nprint(check_palindrome('radar'))", "most_similar": {"Write a Python program to check whether a specified number is a perfect square.": 0.5925925925925927, "Given a string, write a program to count the number of unique characters.": 0.5384615384615384, "Write a Python function to check whether a passed string is palindrome or not.": 0.5185185185185186, "Write a python program to check if the number is prime.": 0.4999999999999999, "Given a string s, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.": 0.4666666666666667, "Write a Python program to compute the length of a string.": 0.41666666666666663, "Write a Python program to add a key to a dictionary.": 0.41666666666666663, "Write a Java program to convert an int to a string.": 0.41666666666666663, "Write a program to find the smallest number in a list.": 0.41666666666666663, "Write a Python program to create a dictionary from a string.": 0.41666666666666663}, "avg_similarity_score": 0.16258707171805475} -{"instruction": "Given a string, write a program to reverse the string.", "input": "", "output": "def reverse_string(string):\n\"\"\"\nReturns the reversed string\n\"\"\"\n# Initialize a new empty string\nreversed_string = \"\"\n# Iterate through the string and add the characters to the new string\n# in reverse order\nfor ch in string:\nreversed_string = ch + reversed_string\n# Return the reversed string\nreturn reversed_string\n# Main program\nif __name__ == \"__main__\":\nprint(reverse_string('hello'))", "most_similar": {"Given a string, write a program to count the number of unique characters.": 0.6956521739130435, "Given a string, write a program to check whether it is a palindrome.": 0.608695652173913, "Write a Python program to compute the length of a string.": 0.5714285714285713, "Given a number N, write a program to find the sum of all the digits in N.": 0.5185185185185185, "Write a Python program to find the first non-repeated character in a string.": 0.5, "Write a program to find the maximum of three numbers.": 0.5, "Write a program to find the n-th ugly number.": 0.5, "Write a Python program to find the longest pallindrome substring from a given string.": 0.5, "Write a Python program to find the frequency of each word in a given string.": 0.48, "Write a Python program to create a dictionary from a string.": 0.47619047619047616}, "avg_similarity_score": 0.18389975580448806} -{"instruction": "Given an array containing 0s and 1s, if you are allowed to replace no more than \u2018k\u2019 0s with 1s, find the length of the longest contiguous subarray having all 1s.", "input": "", "output": "def longest_ones(arr, k):\n\"\"\"\nReturns the length of the longest contiguous subarray\nhaving all 1s\n\"\"\"\n# Initialize the count of 0s to 0\nzeroes = 0\n# Initialize the length of the longest subarray\nmax_length = 0\n# Initialize the starting index of the current window\nstart = 0\n# Iterate through the array\nfor i in range(len(arr)):\n# If the current element is 0, increment count of zeroes\nif arr[i] == 0:\nzeroes += 1\n# If the number of zeroes is more than k,\n# then remove the element from the starting of the current window\nwhile zeroes > k:\nif arr[start] == 0:\nzeroes -= 1\nstart += 1\n# Update the length of longest subarray\nmax_length = max(max_length, i - start + 1)\nreturn max_length\n# Main program\nif __name__ == \"__main__\":\narr = [1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0]\nk = 1\nprint(\"Length of longest contiguous subarray having all 1s is\",\nlongest_ones(arr, k))", "most_similar": {"Given an array of numbers, find the maximum sum of any contiguous subarray of the array.": 0.3404255319148936, "Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.": 0.3272727272727273, "Given a string `s`, find the length of the longest substring without repeating characters.": 0.3111111111111111, "You are given a list of numbers. You need to find the median of the list.": 0.2978723404255319, "If you have an array of numbers and you want to get the average of all the numbers, what is the shortest code to do it?": 0.2807017543859649, "Given an array of integers, find the pair of adjacent elements that has the largest product and return that product.": 0.2745098039215686, "Given a binary array, find the maximum number of consecutive 1s in this array.": 0.26666666666666666, "You are given an integer array nums and you have to return a new counts array. The counts array has the property where counts[i] is the number of smaller elements to the right of nums[i].": 0.2647058823529412, "Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product.": 0.2641509433962264, "Given an integer array nums, find the subarray with the largest sum, and return its sum.": 0.25531914893617014}, "avg_similarity_score": 0.10629097163578106} -{"instruction": "Write a Python program to find whether the given year is a leap year or not.", "input": "", "output": "You can use the following code to determine whether the given year is a leap year or not:\n```python\ndef is_leap(year):\n return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)\n\nyear = int(input(\"Enter the year: \"))\nif is_leap(year):\n print(\"{} is a leap year\".format(year))\nelse:\n print(\"{} is not a leap year\".format(year))\n```", "most_similar": {"Write a Python function to check if a given number is a prime number or not.": 0.5625, "Write a Python program to find the sum of a non-negative integer.": 0.5517241379310345, "Write a Python program to find the first pallindromic string from a given string where the length is three or more.": 0.5405405405405405, "Write a Python program to find the longest pallindrome substring from a given string.": 0.5333333333333333, "Write a Python program to find the most common words in a given text.": 0.5333333333333333, "Write a Python program to check whether a specified number is a perfect square.": 0.5333333333333333, "Write a Python function to check whether a passed string is palindrome or not.": 0.5333333333333333, "Write a Python program to find the average of a list using for loop.": 0.5333333333333333, "Write a Python program to find the first non-repeated character in a string.": 0.5333333333333333, "Write a python code to find the area of a circle.": 0.5185185185185185}, "avg_similarity_score": 0.19882154948684913} -{"instruction": "How can I check if the number 5 is an element of the list [1, 2, 3, 4, 5]?", "input": "", "output": "You can use the `in` keyword to check if the number 5 is an element of the list `[1, 2, 3, 4, 5]`. For example, the following code will print `True` because the number 5 is an element of the list: ``` print(5 in [1, 2, 3, 4, 5]) ```", "most_similar": {"I need to sum all the values in the following list: `[1,2,3,4,5,6,7,8,9]`.": 0.46153846153846156, "How do I get the first element of a list?": 0.41379310344827586, "What is the output of the code below?\n\n```python x = [1, 2, 3, 4, 5] x = x[1:-1] print(x)```": 0.4, "What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.4, "Tell me the 10th term of the sequence 1, 1, 2, 3, 5, 8, 13, 21, 34, ...?": 0.3888888888888889, "What is the value of the following expression?\n10 + 2 * 3 / 4": 0.3870967741935484, "How can I get the number of days between two dates in python?": 0.37499999999999994, "How can I rotate an element in CSS?": 0.37037037037037035, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.3636363636363636, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.358974358974359}, "avg_similarity_score": 0.1504176563421543} -{"instruction": "Create a function that prints \"Hello, world!\"", "input": "", "output": "This is a function that prints \"Hello, world!\": ``` def print_hello_world(): print(\"Hello, world!\") ``` Here's an example of how to use the function: ``` print_hello_world() ``` This will print `Hello, world!`", "most_similar": {"Write a simple C# program that prints \"Hello, World!\".": 0.6250000000000001, "Write a simple C++ program that prints \"Hello, World!\".": 0.6250000000000001, "Write a function that prints the reverse of a string.": 0.47058823529411764, "Write a function that receives a number and prints its integer digits separately.": 0.4, "Write a function that reverses a given string.": 0.39999999999999997, "Write a script to output 'Hello World' in python": 0.375, "Write a python script that prints the following pattern:\n```\n*\n**\n***\n****\n*****\n```": 0.375, "Write a function that returns the sum of two numbers.": 0.3529411764705882, "Create a JavaScript function that takes an array of numbers and returns the product of all elements.": 0.3333333333333333, "Write a Java program that prints the numbers 1 through 100.": 0.33333333333333326}, "avg_similarity_score": 0.1036022393439595} -{"instruction": "How do I define a function called `my_function` that prints \"Hello, world!\"?", "input": "", "output": "This is a function that prints \"Hello, world!\": ``` def my_function(): print(\"Hello, world!\") ``` Here's an example of how to use the function: ``` my_function() ``` This will print `Hello, world!`", "most_similar": {"Create a function that prints \"Hello, world!\"": 0.6, "Write a simple C++ program that prints \"Hello, World!\".": 0.4545454545454546, "Write a simple C# program that prints \"Hello, World!\".": 0.4545454545454546, "How do I make a variable that is only declared?": 0.4347826086956522, "How do I make a dropdown menu?": 0.4, "How do I print a list in Python?": 0.380952380952381, "How do I incorporate CSS in my HTML page?": 0.3636363636363637, "How do I create a text field in HTML?": 0.3636363636363637, "How do I output a string in C++ programming?": 0.3636363636363637, "How do I create a new branch in git?": 0.3636363636363637}, "avg_similarity_score": 0.11022160549230058} -{"instruction": "Write a Python program that constructs a list called my_list and fills it with the integers from 0 to 100, inclusive.", "input": "", "output": "my_list = []\nfor x in range(100):\n my_list.append(x)", "most_similar": {"Write a program that prints all the multiples of 3 from 0 to 100.": 0.5000000000000001, "Write a C# program that uses a loop to display the integers from 1 to 20.": 0.47368421052631576, "Write a python function that sorts a list from large to small.": 0.4705882352941177, "Write a Python function that removes the first item from a list and returns it.": 0.43243243243243246, "Write a Python function that takes a list and returns a new list with unique elements of the first list.": 0.4285714285714286, "Write a python code that takes a list of values and removes all the odd values.": 0.4210526315789474, "Write a python function that takes a list of strings and returns the longest common substring.": 0.4210526315789474, "Write a program to compute the sum of integers from k to n.": 0.39999999999999997, "Write a Python program that takes a list of numbers as input from the user, calculates the sum of all even numbers in the list, and returns the result.": 0.39215686274509803, "Write a Python function that takes a list of numbers and returns the largest number.\n[1, 2, 3, 4, 5]": 0.380952380952381}, "avg_similarity_score": 0.16152568951312601} -{"instruction": "What is the difference between the Docker and Virtual Machine?", "input": "", "output": "A Docker container is an isolated environment which includes everything the application needs to run. The container consists of an application, its configuration and its dependencies. The Virtual Machine on the other hand creates a whole virtual computing environment which includes the application, an operating system, a virtual file system, network interface, memory, and many more components. In case of VM, multiple operating systems can run on the same hardware concurrently.", "most_similar": {"What is the difference between the `break` and the `continue` keywords?": 0.6666666666666666, "What is the difference between `NaN` and `Infinity`?": 0.6666666666666665, "What is the difference between the `==` and the `.equals()` methods in Java?": 0.6363636363636365, "What is the difference between the if-else statement and the switch statement?": 0.608695652173913, "What is the difference between virtual environment and conda environment?": 0.6, "What is the difference between a relative and absolute path?": 0.6, "What is the difference between `val` and `var` in Kotlin?": 0.6, "What is the difference between `git pull` and `git fetch` ?": 0.6, "What is the difference between a class and an object?": 0.6, "What is the difference between a static and a dynamic method?": 0.5714285714285713}, "avg_similarity_score": 0.12282304086368119} -{"instruction": "What are the elements of a for loop in Python?", "input": "", "output": "In Python, a for loop consists of three different parts: the initialization of the loop variable, the condition that must be met for the loop to continue, and the increment of the loop variable. A for loop in Python can be represented as: for x in range(10): print(x) This loop starts with the initialization of the variable x and then prints the numbers 0 through 9.", "most_similar": {"What are the different methods to remove an element from a list in Python?": 0.5, "What is the purpose of the `float` function in Python?": 0.5, "What are the differences between dictionary and list in Python?": 0.5, "How do I get the power of a number in python?": 0.47619047619047616, "How to get the last element of a list in Python?": 0.47619047619047616, "How do you find the length of a string in Python?": 0.47619047619047616, "What is the value of a++b?": 0.47058823529411764, "How do you output all the contents of a list in Python?": 0.45454545454545453, "What is the difference between a for loop and a while loop?": 0.45454545454545453, "What is the average salary of a software engineer in the US?": 0.45454545454545453}, "avg_similarity_score": 0.16825278277300515} -{"instruction": "Explain what is a static IP address.", "input": "", "output": "A static IP address is an IP address that does not change. There are two main ways that you can get a static IP address. The first is through your Internet service provider. They can give you a fixed IP address that does not change. This is only available in some regions and usually requires a monthly fee. The other way to get a static IP address is through a Dynamic Host Configuration Protocol (DHCP) server. This is a computer that is in charge of assigning IP addresses to your devices. You can use the DHCP server to reserve an IP address for your device.", "most_similar": {"What is a Dockerfile?": 0.5454545454545454, "What is a Docker container?": 0.5, "What is a persistent volume ?": 0.5, "What is a stateful set ?": 0.5, "What is a cron job ?": 0.5, "What is a list comprehension?": 0.5, "What is the difference between a static and a dynamic method?": 0.4444444444444444, "What is the value of a++b?": 0.42857142857142855, "What is Kubernetes ?": 0.4, "What is the purpose of a hash table?": 0.39999999999999997}, "avg_similarity_score": 0.09813060103424272} -{"instruction": "I have a list of strings. How can I sort the list in reverse order based on the first character of each string?", "input": "", "output": "You can use the built-in sort() method with the key keyword argument to sort the list in reverse order based on the first character of each string. Here is an example:\n```python \ndata = [\"Car\", \"apple\", \"Ball\", \"Apple\", \"bat\", \"Apple\"] \ndata.sort(key=lambda x: x[0], reverse=True) \n```\n```\n['Apple', 'Apple', 'Apple', 'Ball', 'Car', 'bat', 'apple'] \n```", "most_similar": {"I have a list of strings, how do I convert them to numbers?": 0.4444444444444444, "I have a list of numbers, how do I find the second largest number?": 0.4324324324324324, "I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.4, "I have a list of numbers and I want to find the average of all the numbers.": 0.39999999999999997, "How can I get a list of all the different vowels in a text, and the number of times each of them appeared?": 0.391304347826087, "How can I convert a list of strings to a list of integers?": 0.3888888888888889, "Given a list of strings, find the longest string in the list. You can use the len function to find the length of a string.": 0.37499999999999994, "How do I make a function that takes a string and returns a list of the words in the string?": 0.37209302325581395, "How can I sort a list of integers in Rust?": 0.36363636363636365, "Write a function that receives a list of items and returns the items in reverse order.": 0.358974358974359}, "avg_similarity_score": 0.14501990590639743} -{"instruction": "Is there a Python function to remove a key from a dictionary?", "input": "", "output": "Yes, you can use Python's del function to delete a key from a dictionary. For example, you can use this to delete the key `a` from the dictionary:\n```py my_dict = {'a': 1, 'b': 2, 'c': 3} del my_dict['a'] print(my_dict) ```\n\nThis will print: `{'b': 2, 'c': 3}`", "most_similar": {"Write a Python program to add a key to a dictionary.": 0.6086956521739131, "Write a Python program to create a dictionary from a string.": 0.5217391304347826, "Write a Python function to find the largest number in a dictionary.": 0.5, "Write a Python program to remove all duplicates from a list in Python": 0.48000000000000004, "Write a Java program to remove a set of characters from a string.": 0.48000000000000004, "Write a Python function to find the maximum sum of a contiguous subsequence from a list of integers.": 0.4666666666666666, "Write a python function that returns a value from a list, selected at random.": 0.4615384615384615, "Write a Python function to find the smallest number from a sequence of numbers.": 0.4615384615384615, "How to test if a key exists in a dictionary?": 0.45454545454545453, "Write a python code for a queue using a dictionary": 0.45454545454545453}, "avg_similarity_score": 0.16145432037868565} -{"instruction": "Write a Python program to sum of three given numbers, if two or less than two numbers are given then return 0.", "input": "", "output": "```py def add_three_numbers(num1, num2, num3=0):\n return num1 + num2 + num3\n```", "most_similar": {"Write a Python program to compute the sum of the three given numbers, if one of the value is 13 then return 0.": 0.6222222222222223, "Write a Python program to find the sum of three given numbers, if the values are equal then return three times of their sum.": 0.6086956521739131, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.4444444444444444, "Write a program to find the maximum of three numbers.": 0.4375, "Write a Python program to find the number of equal numbers from three given integers.": 0.43243243243243246, "Write a Python program to find the sum of the positive integers of a given range.": 0.4210526315789474, "Write a Python program to generate all permutations of a given list.": 0.4117647058823529, "Write a Python program to find the number of even and odd numbers from a series of numbers.": 0.39999999999999997, "Write a Python program to find the sum of a non-negative integer.": 0.39999999999999997, "Write a Python function to calculate the sum of two given integers. However, if the sum is between 15 to 20 it should return 20.": 0.3829787234042554}, "avg_similarity_score": 0.14584040257723022} -{"instruction": "I have a dictionary where each key is a string and each value is a list. The dictionary looks like this:\n\n```py names = {\n \"group1\": [\n \"Peter\", \"John\", \"Mary\", \"Peter\", \"Peter\", \"Mary\", \"John\", \"John\", \"Mary\", \"Peter\"\n ],\n \"group2\": [\n \"Paul\", \"John\", \"Mary\", \"John\", \"John\", \"Paul\", \"Peter\", \"Mary\", \"Paul\", \"John\"\n ],\n \"group3\": [\n \"Mary\", \"Peter\", \"Paul\", \"Peter\", \"Paul\", \"John\", \"Mary\", \"John\", \"Paul\", \"Mary\"\n ]\n}\n```\n\nI want to print out a new dictionary that has all the keys from the original dictionary but the values are the number of occurrences of each name in the list. For example, the key `group1` has the value `Peter` 3 times, the value `John` 2 times, the value `Mary` 2 times. In the new dictionary, the key `group1` should have the value 3, 2, 2 instead.", "input": "", "output": "```py from collections import Counter\n\ndef find_number_of_occurrences(names):\n result = {}\n for key in names.keys():\n result[key] = list(Counter(names[key]).values())\n return result\n```", "most_similar": {"I have a dictionary in python where I have a key and the value is a list of strings. I want to search for a particular string in the list and return the key. What is the best way to do that?": 0.2545454545454546, "Write a Python function that accepts a sequence of strings and returns a dictionary in which the keys are elements of the sequence and the values are the number of times each element occurs in the sequence.": 0.21250000000000002, "Write a Python function to check if a given number is a perfect number or not. A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself. For example, 6 has divisors 1, 2 and 3 (excluding the number itself), and 6 = 1 + 2 + 3. Similarly, 28 has divisors 1, 2, 4, 7, 14 and 28, and 28 = 1 + 2 + 4 + 7 + 14.": 0.18367346938775506, "I am working on a project for my college and I need help. I am trying to make a simple calculator using Python. I want to show the result of an expression in the form of a list, for example 3 + 4 = 7. But I want it to show 3 + 4 = [7]. Is there a way to do this?": 0.17582417582417584, "Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i.\n```py\nFor example, if our input was [1, 2, 3, 4, 5], the expected output would be [120, 60, 40, 30, 24]. If our input was [3, 2, 1], the expected output would be [2, 3, 6].\n```": 0.173469387755102, "I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.16551724137931037, "Write a Python function to check if a number is a Smith number or not. A Smith number is a composite number, whose sum of digits is equal to the sum of digits of its prime factors. For example, 42 is a Smith number, since its prime factors are 2 and 21, and 2 + 2 + 1 = 2 + 4 + 2 = 8.": 0.16393442622950818, "Write a function that takes a positive integer n and returns the next biggest number with the same number of 1 bits. For example, given the number 6 (0110 in binary), the function should return 9 (1001).": 0.1625, "Write a function that takes an integer n as a parameter and returns the sum of the first n numbers.\n```py\nFor example, if the input is 3, the function should return 6, since 1 + 2 + 3 = 6.\n```": 0.16149068322981366, "Write a Python function to check if a given number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence. The Fibonacci sequence is a sequence of numbers where each number is the sum of the two preceding numbers. The first two numbers in the sequence are 0 and 1.": 0.1564245810055866}, "avg_similarity_score": 0.07395666337294807} -{"instruction": "I am trying to write a Python program that prints the sum of two numbers. However, the result of my code is not correct.\n\n```py def add_numbers(a, b):\n return a + b\n```\n\n```py print(add_numbers(10, 10)) ```\n\nThe expected output is 20, but my program prints 1010. What's wrong with my code?", "input": "", "output": "Your code looks good, but it's just a small typo that's making your program not working as expected. The print function does not know how to print the sum of two numbers as a single number. To fix this, you can convert the sum into a string before printing it.\n\nHere's an example:\n\n```py def add_numbers(a, b):\n return a + b\n\nprint(str(add_numbers(10, 10))) ```\n\nThis will print 20 as expected.", "most_similar": {"I am trying to use the following code in python:\n```py\ndef function(a, b):\n if a > b:\n print('You lost.')\n else:\n if c > a:\n print('Nice try.')\n else:\n print('You won.')\n```\nBut I am getting an error. What is wrong with the code?": 0.3636363636363637, "What is the output of the following code? ```py def add(a, b): return a + b print(add(1, 2)) print(add(b=2, a=1)) ```": 0.345679012345679, "I am trying to write a function that takes a list of numbers and returns the sum of the numbers. I wrote the following code in Python:\n```py def sum(lst):\n total = 0\n for i in lst:\n total += i\n return total\n```": 0.3333333333333333, "Write a Python function to calculate the sum of two given integers. However, if the sum is between 15 to 20 it should return 20.": 0.3, "Write a python function that returns the sum of the elements of a list.": 0.2898550724637682, "Write a Python program to compute the sum of the three given numbers, if one of the value is 13 then return 0.": 0.28205128205128205, "Write a Python program to find the sum of the positive integers of a given range.": 0.28169014084507044, "What is the output of the following code? ```py def a(): print(\"a\") b = a def c(): print(\"c\") b() ```": 0.26666666666666666, "What is the output of the following code? ```py def add_five(x): x += 5 return x print(add_five(2)) ```": 0.26315789473684215, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.26315789473684215}, "avg_similarity_score": 0.13486798725355187} -{"instruction": "I am trying to write a program to check if a given number is a power of two. A power of two is a number that is the power of 2. For example, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, etc. are powers of 2.", "input": "", "output": "There are many ways to check if a number is a power of 2. Here's one of them:\n\n```py def is_power_of_two(n):\n return n != 0 and n & (n - 1) == 0\n\nprint(is_power_of_two(0)) # False\nprint(is_power_of_two(1)) # True\nprint(is_power_of_two(2)) # True\nprint(is_power_of_two(8)) # True\nprint(is_power_of_two(9)) # False ```\n\nHere's another one:\n\n```py def is_power_of_two(n):\n if n == 0:\n return False\n while n % 2 == 0:\n n //= 2\n return n == 1\n\nprint(is_power_of_two(0)) # False\nprint(is_power_of_two(1)) # True\nprint(is_power_of_two(2)) # True\nprint(is_power_of_two(8)) # True\nprint(is_power_of_two(9)) # False ```", "most_similar": {"Write a Python function to check if a given number is a repdigit or not. A repdigit is a number that contains only one digit. For example, 11, 22, 3333, 44444444 are repdigits.": 0.4444444444444444, "Write a Python function to check if a given number is a Harshad number or not. A Harshad number is a number that is divisible by the sum of its digits. For example, 42 is a Harshad number because it is divisible by 6 (the sum of its two digits 4 + 2).": 0.43999999999999995, "Write a Python function to check if a given number is a prime number or not. A prime number is a number that is divisible only by 1 and itself.": 0.4358974358974359, "Write a Python function to check if a given number is a Kaprekar number or not. A Kaprekar number is a number for which the square of the number is 1 when the digits are reversed.": 0.42857142857142855, "Write a Python function to check if a given number is a circular prime or not. A circular prime is a prime number that remains a prime when the digits are rotated.": 0.425, "Write a Python function to check if a given number is a pandigital number or not. A pandigital number is a number that contains all the digits from 1 to n exactly once.": 0.41975308641975306, "Write a Python function to check if a given number is a palindrome or not. A palindrome is a number that remains the same when its digits are reversed. For example, 121 is a palindrome but 112 is not.": 0.41379310344827586, "Write a Python function to check if a number is a Smith number or not. A Smith number is a composite number, whose sum of digits is equal to the sum of digits of its prime factors. For example, 42 is a Smith number, since its prime factors are 2 and 21, and 2 + 2 + 1 = 2 + 4 + 2 = 8.": 0.4074074074074074, "Write a Python function to check if a given number is a circular prime or not. A circular prime is a prime number that remains prime when each digit is rotated individually around the number (clockwise or counterclockwise). For example, 197 is a circular prime because 971 and 719 are both prime.": 0.4, "Write a Python function to check if a number is a strong number or not. A strong number is a number whose sum of factorial of digits is equal to the original number. For example, 145 is strong number since 1! + 4! + 5! = 1 + 24 + 120 = 145.": 0.39999999999999997}, "avg_similarity_score": 0.14696824645800022} -{"instruction": "I have a string like this:\n\n```py name = \"Alice Bob Carol\" ```\n\nHow can I get the last name?", "input": "", "output": "You can use the split function to split the string into a list of names. Then, you can use the -1 index to get the last name. For example:\n\n```py name = \"Alice Bob Carol\"\n\n# Split the string to a list of names\nnames = name.split()\n\n# Print the last name\nlast_name = names[-1]\nprint(last_name) ```\n\nThe output will be: `Carol`", "most_similar": {"I have a list of numbers, how do I find the second largest number?": 0.375, "I have a code that is too slow. How can I make it faster?": 0.375, "How can I get the size of a directory?": 0.3703703703703704, "How do I get the last element of an array?": 0.35714285714285715, "How can I get the first 1000 prime numbers in Python?": 0.3448275862068966, "How can I get the current date and time in Python?": 0.3448275862068966, "I have a list of strings. How can I sort the list in reverse order based on the first character of each string?": 0.34146341463414637, "I have a list of strings, how do I convert them to numbers?": 0.3225806451612903, "How can I get the number of days between two dates in python?": 0.3225806451612903, "I want to take a string and print it backwards. How would I do that?": 0.303030303030303}, "avg_similarity_score": 0.10534006625395763} -{"instruction": "I have a string with many spaces between the words. How can I remove the extra spaces?", "input": "", "output": "You can use Python's split and join functions. The split function splits the string into a list of words and the join function joins the list into a string. For example:\n\n```py sentence = \"Python is a programming language.\"\n\n# Split the string to a list of words\nwords = sentence.split()\n\n# Join the list of words into a single string\nnew_sentence = ' '.join(words)\n\n# Print the new sentence\nprint(new_sentence) ```\n\nThe output will be: `Python is a programming language.`", "most_similar": {"I have a string like this:\n\n```py name = \"Alice Bob Carol\" ```\n\nHow can I get the last name?": 0.45714285714285713, "I have a code that is too slow. How can I make it faster?": 0.3870967741935484, "I have a list of numbers, how do I find the second largest number?": 0.3870967741935484, "I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.358974358974359, "I have a list of strings. How can I sort the list in reverse order based on the first character of each string?": 0.35, "I have a list of strings, how do I convert them to numbers?": 0.33333333333333337, "How do I make a function that takes a string and returns a list of the words in the string?": 0.3243243243243243, "I want to take a string and print it backwards. How would I do that?": 0.3125, "How can I get the size of a directory?": 0.30769230769230765, "I have a list of integers: ```list = [1, 2, 3]```. How would I sum these integers?": 0.30303030303030304}, "avg_similarity_score": 0.12186731685290297} -{"instruction": "Given a list of integers, find the number that occurs odd number of times in the list.", "input": "", "output": "Here's a function that finds the number that occurs odd number of times in a list:\n\n```py def find_odd_occurrence(numbers):\n result = 0\n for number in numbers:\n result ^= number\n return result\n\nprint(find_odd_occurrence([1, 3, 2])) # 3\nprint(find_odd_occurrence([10, 3, 2])) # 10 ```", "most_similar": {"Given a list of numbers, find the largest number in the list.": 0.6896551724137931, "Given a list of numbers, find the sum of the numbers.": 0.5714285714285714, "You are given a list of numbers. You need to find the median of the list.": 0.5454545454545455, "Given a string, return the number of vowels used in the text.": 0.4827586206896552, "I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.46153846153846156, "Given a binary array, find the maximum number of consecutive 1s in this array.": 0.45161290322580644, "Write a program to find the smallest number in a list.": 0.42857142857142855, "Given a list of strings, find the longest string in the list. You can use the len function to find the length of a string.": 0.42857142857142855, "Given an array of integers, find the maximum possible sum that can be obtained by subtracting any number from the array.": 0.42105263157894735, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.42105263157894735}, "avg_similarity_score": 0.1861323379649528} -{"instruction": "Print a pattern as shown below", "input": "", "output": "Here's a C# program to print the pattern: ```csharp public class MainClass { public static void Main() { int i, j; for (i = 1; i <= 5; i++) { for (j = 1; j <= i; j++) { Console.Write(j); } Console.WriteLine(); } } } ``` The program prints the following pattern: 1 2 3 4 5 1 2 3 4 1 2 3 1 2 1", "most_similar": {"How do I print a list in Python?": 0.28571428571428575, "Write a python script that prints the following pattern:\n```\n*\n**\n***\n****\n*****\n```": 0.26666666666666666, "How to make a python program that will print the following pattern?\n```\n*\n**\n***\n****\n*****\n```": 0.2222222222222222, "What is a Dockerfile?": 0.2, "Write a Python function that takes two numbers as input and returns their sum.": 0.2, "Given two integers A and B. You have to print A raised to power B.": 0.19047619047619044, "What is a Docker container?": 0.1818181818181818, "Describe how a compiler works.": 0.1818181818181818, "What is a list comprehension?": 0.1818181818181818, "What is a persistent volume ?": 0.1818181818181818}, "avg_similarity_score": 0.07316015307102132} -{"instruction": "what is the difference between an angle bracket and a pipe in regular expressions?", "input": "", "output": "The angle bracket matches any character in the list, while the pipe matches any of the alternatives.\n\nFor example:\n\n[abc] matches \"b\" in \"abc\" [a|b|c] matches \"b\" in \"abc\"", "most_similar": {"What is the difference between an ingress and a persistent volume?": 0.64, "What is the difference between a list and a tuple in Python?": 0.6153846153846153, "What is the difference between `val` and `var` in Kotlin?": 0.5833333333333334, "What is the difference between a `string` and a `char` data type in C#?": 0.5714285714285714, "What is the difference between a variable and a constant in a programming language?": 0.5714285714285714, "What is the difference between a static and a dynamic method?": 0.56, "What is the difference between `NaN` and `Infinity`?": 0.5454545454545454, "What is the difference between a deep copy and a shallow copy?": 0.5384615384615384, "What is the difference between a pod and a horizontal pod autoscaler?": 0.5384615384615384, "What is the difference between static and instance variables in C++ programming?": 0.5384615384615384}, "avg_similarity_score": 0.14001155326222373} -{"instruction": "What are the ways to delete a character from a string using Python?", "input": "", "output": "You can delete a character from a string using slicing or the pop method.\n\nFor example, this string:\n\nstring = \"apple\"\nwill become this string:\n\n\"appl\"\n\nHere is the code using the slicing method:\n\nstring = \"apple\"\n\nstring = string[:-1]\n\nprint(string)\n\nHere is the code using the pop method:\n\nstring = \"apple\"\n\nstring.pop()\n\nprint(string)", "most_similar": {"What are the different methods to remove an element from a list in Python?": 0.5185185185185186, "What are two ways to escape single quotes in a single-quoted string?": 0.46153846153846156, "What are the elements of a for loop in Python?": 0.4347826086956522, "Write a Python program to create a dictionary from a string.": 0.41666666666666663, "What is the difference between a list and a tuple in Python?": 0.4, "How to capitalize a string in Python?": 0.4, "Write a Java program to remove a set of characters from a string.": 0.38461538461538464, "What is the correct way to add a link to a stylesheet in HTML?": 0.3703703703703704, "Return the first non-repeating character in a string.": 0.3636363636363637, "How do you remove an item at a given index from a list using Python?": 0.3571428571428571}, "avg_similarity_score": 0.1442988082557582} -{"instruction": "Write a bash script to find the average of 4 numbers?", "input": "", "output": "Here's a script that finds the average of 4 numbers: ```bash read -p \"Enter 1st number: \" num1 read -p \"Enter 2nd number: \" num2 read -p \"Enter 3rd number: \" num3 read -p \"Enter 4th number: \" num4 avg=$(echo \"scale=2;($num1 + $num2 + $num3 + $num4)/4\" | bc) echo \"Average of $num1, $num2, $num3 and $num4 is $avg\" ```", "most_similar": {"Write a program to find the maximum of three numbers.": 0.6666666666666666, "Write a script to output the factorial of an integer.": 0.5714285714285713, "Write a Python function to find the smallest number from a sequence of numbers.": 0.56, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.56, "Write a Python program to find the average of a list using for loop.": 0.56, "Write a python code to find the area of a circle.": 0.5454545454545454, "Write a Python program to find the number of equal numbers from three given integers.": 0.5384615384615385, "Write a script to output the mean of a list of integers.": 0.5217391304347826, "Write a program to find the pearson correlation coefficient of two lists.": 0.5217391304347826, "Write a Java program to find the cube root of a number.": 0.5217391304347826}, "avg_similarity_score": 0.1910998715097815} -{"instruction": "How do I check if a list is empty?", "input": "", "output": "You can check if a list is empty using the len function or the not keyword.\n\nFor example, this list:\n\nlst = [1, 2, 3, 4, 5]\nwill become this list:\n\nlst = []\n\nHere is the code using the len function:\n\nlst = [1, 2, 3, 4, 5]\n\nif len(lst) == 0:\n\nprint(\"List is empty\")\n\nelse:\n\nprint(\"List is not empty\")\n\nHere is the code using the not keyword:\n\nlst = [1, 2, 3, 4, 5]\n\nif not lst:\n\nprint(\"List is empty\")\n\nelse:\n\nprint(\"List is not empty\")", "most_similar": {"How do I check if a string contains a substring?": 0.631578947368421, "How do I print a list in Python?": 0.5882352941176471, "What is the best way to check if a list is empty?": 0.5714285714285715, "How do you check if a value is present in a list?": 0.5714285714285715, "How do I make a variable that is only declared?": 0.5263157894736842, "How do I remove the first item from a list?": 0.5263157894736842, "How do I get the first element of a list?": 0.5263157894736842, "How do I make a dropdown menu?": 0.5, "How to check quickly if a number is prime in C?": 0.5, "How do I find the p-variance of all elements in a list?": 0.4545454545454546}, "avg_similarity_score": 0.13107048587257958} -{"instruction": "What are the difference between a float and an int in Python?", "input": "", "output": "An int represents a whole number without any decimal places, while a float represents a number with decimal places.\n\nFor example, 23 is an int, while 23.45 is a float.", "most_similar": {"What is the difference between a list and a tuple in Python?": 0.6666666666666666, "What are the differences between dictionary and list in Python?": 0.6363636363636365, "What is the difference between a class and an object?": 0.6363636363636365, "Explain the difference between a compiler and an interpreter.": 0.5714285714285715, "What are the elements of a for loop in Python?": 0.5454545454545454, "What is the difference between a relative and absolute path?": 0.5454545454545454, "What is the difference between `val` and `var` in Kotlin?": 0.5454545454545454, "What is the difference between a variable and a constant in a programming language?": 0.5384615384615384, "What is the difference between a `string` and a `char` data type in C#?": 0.5384615384615384, "What is the difference between a static and a dynamic method?": 0.5217391304347826}, "avg_similarity_score": 0.1561965637448463} -{"instruction": "What does the following JavaScript code print?", "input": "", "output": "The JavaScript code given below:\n\nvar a = 0;\n\na = a + 1;\n\na = a + 3;\n\ndocument.write(a);\n\nwill print 4.\n\nThis is because a is incremented twice by the value 1.\n\nThe first time the value of a is incremented, it becomes 1.\n\nWhen the second value is added to it, it becomes 4.", "most_similar": {"What does the function `print()` do?": 0.6153846153846153, "What does the following python code print?\n```py\nprint(f'500:{500:08d}')\n```": 0.6, "In Python, what does the following code output?\n[3, 4, 5][-1]": 0.5263157894736842, "What is the python code to print hello world?": 0.5, "In Python, what does the following expression mean: `x = 3`": 0.47058823529411764, "What does the HTML tag `

` do?": 0.42857142857142855, "What does the CSS style `float: left;` do?": 0.39999999999999997, "Suggest a completion for the following python code.": 0.39999999999999997, "Translate the following code from python in Java.": 0.39999999999999997, "What is the output of this code?\n```\nfor i in range(10):\n print(i)\n```": 0.38095238095238093}, "avg_similarity_score": 0.09806680979161801} -{"instruction": "When do you use the long type in Java?", "input": "", "output": "The Java long type is used when a variable needs to store values that are greater than the maximum value an int can store (which is 231 \u2212 1).\n\nFor example, the maximum value an int can store is 231 \u2212 1 or 2147483647.\n\nIf a variable needs to store values greater than this, you can use the long type.\n\nHere is a code example:\n\nint x = 1;\n\nlong y = 10000000000L;", "most_similar": {"How do you initialize an ArrayList in Java?": 0.47058823529411764, "How do you find the length of a string in Python?": 0.39999999999999997, "How do you count the number of items in a list?": 0.39999999999999997, "How do you cast the return value of a function to a different data type in C#?": 0.3846153846153846, "How do you find the largest number in a list using Python?": 0.380952380952381, "How do you output all the contents of a list in Python?": 0.380952380952381, "How do you find the index of an item in a list?": 0.380952380952381, "How do you find the element with the lowest value in a list?": 0.3636363636363637, "How do you find the maximum value in a 2D array using C#?": 0.3636363636363637, "What are the basic data types in Java?": 0.35294117647058826}, "avg_similarity_score": 0.09798981852738159} -{"instruction": "What is a character constant?", "input": "", "output": "A character constant is a single character enclosed in single quotes (').\n\nHere is a code example:\n\n'a'", "most_similar": {"What is a Dockerfile?": 0.6666666666666665, "What is a cron job ?": 0.6, "What is a list comprehension?": 0.6, "What is a stateful set ?": 0.6, "What is a persistent volume ?": 0.6, "What is a Docker container?": 0.6, "What is the value of a++b?": 0.5, "Explain what is a static IP address.": 0.5, "What is Kubernetes ?": 0.5, "What is a \u201cPythonic\u201d way of writing code?": 0.4615384615384615}, "avg_similarity_score": 0.10974500600220642} -{"instruction": "You are given an array prices where prices[i] is the price of a given stock on the ith day.\nFind the maximum profit you can achieve. You may complete as many transactions as you like (i.e., buy one and sell one share of the stock multiple times).", "input": "", "output": "```py class Solution:\n def maxProfit(self, prices: List[int]) -> int:\n profit = 0\n for i in range(1, len(prices)):\n if prices[i] > prices[i-1]:\n profit += prices[i] - prices[i-1]\n return profit ```", "most_similar": {"Write a script to output 'Hello World' in python\nYou are given an array `prices` where `prices[i]` is the price of a given stock on the i^th day. You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. Return the maximum profit you can achieve from this transaction. If you cannot achieve any profit, return 0.": 0.41935483870967744, "You are given an integer array nums and you have to return a new counts array. The counts array has the property where counts[i] is the number of smaller elements to the right of nums[i].": 0.2790697674418604, "Given an array of numbers, find the maximum sum of any contiguous subarray of the array.": 0.27692307692307694, "Given an array of integers, find the maximum possible sum that can be obtained by subtracting any number from the array.": 0.2571428571428572, "You are given an array coordinates, coordinates[i] = [x, y], where [x, y] represents the coordinate of a point. Check if these points make a straight line in the XY plane.": 0.25000000000000006, "You are given an array of n pairs pairs where pairs[i] = [lefti, righti] and lefti < righti. A pair p2 = [c, d] follows a pair p1 = [a, b] if b < c. A chain of pairs can be formed in this fashion. Return the length longest chain which can be formed. You may assume that there is at least one pair in the array.": 0.25, "You are given a list of numbers. You need to find the median of the list.": 0.24615384615384614, "Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i.": 0.23529411764705882, "Given an array of integers, find the pair of adjacent elements that has the largest product and return that product.": 0.23188405797101447, "Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would have exactly one solution.": 0.21978021978021978}, "avg_similarity_score": 0.10828591112759536} -{"instruction": "Given two strings s and t, return true if t is an anagram of s, and false otherwise.", "input": "", "output": "```py class Solution:\n def isAnagram(self, s: str, t: str) -> bool:\n return sorted(s) == sorted(t) ```", "most_similar": {"Given a string s, return true if the s can be palindrome after deleting at most one character from it.": 0.3157894736842105, "Write a function that returns true if a number is prime, and otherwise returns false.": 0.303030303030303, "Given a string s, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.": 0.28571428571428575, "Given two strings word1 and word2, return the minimum number of steps required to make word1 and word2 the same. In one step, you can delete exactly one character in either string.": 0.28, "Given a string s, return the longest palindromic substring in s.": 0.27586206896551724, "Given a positive integer num, write a function which returns True if num is a perfect square else False.": 0.27027027027027023, "Given a string s, return the number of palindromic substrings in it.": 0.26666666666666666, "Given a string, return True if the number of appearances of \"is\" anywhere in the string is equal to the number of appearances of \"not\" anywhere in the string (case sensitive).": 0.24489795918367346, "Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.": 0.24390243902439024, "Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s.": 0.22222222222222224}, "avg_similarity_score": 0.08332792198582949} -{"instruction": "Given two strings s and t, determine if they are isomorphic. Two strings s and t are isomorphic if the characters in s can be replaced to get t.", "input": "", "output": "```py class Solution:\n def isIsomorphic(self, s: str, t: str) -> bool:\n d = {}\n for i, ch in enumerate(s):\n if ch not in d:\n d[ch] = t[i]\n elif d[ch] != t[i]:\n return False\n return True ```", "most_similar": {"Given two strings s and t, return true if t is an anagram of s, and false otherwise.": 0.3829787234042554, "Given a string s, return true if the s can be palindrome after deleting at most one character from it.": 0.2857142857142857, "Given two strings word1 and word2, return the minimum number of steps required to make word1 and word2 the same. In one step, you can delete exactly one character in either string.": 0.26229508196721313, "Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words.": 0.253968253968254, "Given a string s, return the longest palindromic substring in s.": 0.25000000000000006, "Given a list of strings, find the longest string in the list. You can use the len function to find the length of a string.": 0.22222222222222224, "Given two arrays of integers, determine whether they have the same elements with the same multiplicities.": 0.22222222222222224, "Given a string s, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.": 0.2173913043478261, "Write a Python function that accepts a sequence of strings and returns a dictionary in which the keys are elements of the sequence and the values are the number of times each element occurs in the sequence.": 0.21212121212121213, "Given a string S, check if the letters can be rearranged so that two characters that are adjacent to each other are not the same.\n\nIf possible, output any possible result. If not possible, return the empty string.": 0.208955223880597}, "avg_similarity_score": 0.07940586072942286} -{"instruction": "If you're using Kotlin, how do you declare and initialize a variable?", "input": "", "output": "In Kotlin, you can declare a variable using the val keyword and initialize it at the same time. Here's an example of a variable declaration in Kotlin: ``` val variableName: type = value ``` Here, variableName is the name of the variable, type is the type of the variable, and value is the value you want to assign to the variable. For example, you can declare and initialize an Int variable like this: ``` val age: Int = 25 ``` In this example, the variable name is age, the type is Int, and the value is 25. You can also declare and initialize a variable without specifying its type, like this: ``` val age = 25 ``` Here, Kotlin will infer the type of the variable to be Int based on the value provided.", "most_similar": {"How do you create a variable in Python?": 0.4761904761904762, "How do you initialize an ArrayList in Java?": 0.380952380952381, "How do you create a new virtual environment?": 0.380952380952381, "How do you add a link to a web page?": 0.34782608695652173, "How do I make a variable that is only declared?": 0.34782608695652173, "How do you remove duplicates from a list in Python?": 0.34782608695652173, "How do you sort a list of strings in Python?": 0.34782608695652173, "How do you get the first and last index of an element in a list in Python?": 0.33333333333333337, "How do you count the number of items in a list?": 0.33333333333333337, "How do you find the length of a string in Python?": 0.33333333333333337}, "avg_similarity_score": 0.0900125110908288} -{"instruction": "How can I make a list of numbers divisible by 5 in c++", "input": "", "output": "What do you mean by \"make a list of numbers divisible by 5\"? Do you mean you want a program that outputs the first 100 numbers divisible by 5? Here's how to do that: ``` for(int i = 0; i < 100; i++){ if(i % 5 == 0){ std::cout << i << std::endl; } } ``` Here's an explanation: we use a for loop to iterate through the numbers 0 to 100 and print each number divisible by 5 (i % 5 == 0 is true). If you want to print the first 25 numbers divisible by 5, you can change the loop condition to i < 100 * 5, and that will give you the first 100 numbers divisible by 5.", "most_similar": {"How can I sort a list of integers in Rust?": 0.608695652173913, "How can I make a button in HTML?": 0.5714285714285714, "How do I make a list of all the prime numbers up to a certain number?": 0.4827586206896552, "How do I print a list in Python?": 0.4761904761904762, "How can I convert a list of strings to a list of integers?": 0.46153846153846156, "How do I output a string in C++ programming?": 0.4545454545454546, "How do I find the sum of the first 1000 prime numbers in C++?": 0.4444444444444445, "How can I find the index of an item in an array in c++?": 0.4444444444444445, "How do you sort a list of strings in Python?": 0.4347826086956522, "How can I make a program that will find the largest number in a list?": 0.42857142857142855}, "avg_similarity_score": 0.14324739980030363} -{"instruction": "How can I compare a character in a string to an integer in c++?", "input": "", "output": "If you mean an integer like `int x = 5`, then you can use the method `x == '5'` because `x` can be implicitly casted to a `char` type. If you mean a variable that is a string, then you can't compare it to a character. Instead, you can use the index operator to get the character at a certain index of the string, and then compare that to the character. For example: ``` string x = \"Hello\"; if(x[0] == 'H'){ // do something } ``` Here, `x[0]` gets the character at index 0, which is 'H'.", "most_similar": {"How do I output a string in C++ programming?": 0.5217391304347826, "How do I find the first and last occurrence of a substring in a string in C++?": 0.5161290322580646, "How can I find the index of an item in an array in c++?": 0.5, "How can I find the first repeated word in a string?": 0.4799999999999999, "How do I convert a string to a number in Python?": 0.4799999999999999, "How can I iterate through each item in an array in a random order using c++?": 0.4666666666666667, "How can I make a button in HTML?": 0.45454545454545453, "How can I rotate an element in CSS?": 0.45454545454545453, "How can I make a list of numbers divisible by 5 in c++": 0.4444444444444445, "How do you add a new attribute to an existing class in C#?": 0.4444444444444445}, "avg_similarity_score": 0.1469741634494937} -{"instruction": "How can I make a switch statement with 20 cases in c++?", "input": "", "output": "In C++, a switch statement can have a maximum of 65535 cases. Here's an example of a switch statement with 20 cases: ``` switch(x){ case 1: // do something case 2: // do something case 3: // do something // and so on... } ```", "most_similar": {"How can I make a button in HTML?": 0.6, "How can I make a list of numbers divisible by 5 in c++": 0.5599999999999999, "How do I output a string in C++ programming?": 0.4761904761904762, "How can I compare a character in a string to an integer in c++?": 0.4615384615384615, "How can I sort a list of integers in Rust?": 0.45454545454545453, "How can I make a program that will find the largest number in a list?": 0.4444444444444445, "How do I make a dropdown menu?": 0.4210526315789474, "How do I print a list in Python?": 0.4, "How can I rotate an element in CSS?": 0.4, "How can I find the index of an item in an array in c++?": 0.3846153846153846}, "avg_similarity_score": 0.1077083549142002} -{"instruction": "How can I convert string to integer in c++?", "input": "", "output": "In C++, you can use the atoi() function to convert a string to an integer. Here's an example of how to use the atoi() function: ``` string str = \"1234\"; int x = atoi(str.c_str()); ``` Here, str is the string that you want to convert to an integer, and x is the integer that will contain the converted value. Here's an explanation: the atoi() function converts a string to an integer. The atoi() function takes the string as a parameter and returns the integer value.", "most_similar": {"How can I compare a character in a string to an integer in c++?": 0.6956521739130435, "How do I convert a string to a number in Python?": 0.6, "How do I output a string in C++ programming?": 0.5555555555555556, "How can I make a switch statement with 20 cases in c++?": 0.4761904761904762, "How can I rotate an element in CSS?": 0.47058823529411764, "How can I make a button in HTML?": 0.47058823529411764, "How can I make a list of numbers divisible by 5 in c++": 0.4545454545454546, "How can I convert a list of strings to a list of integers?": 0.4545454545454546, "Can I convert a dictionary to a JSON string?": 0.4444444444444444, "How to find the nth prime number in C?": 0.4444444444444444}, "avg_similarity_score": 0.10147983638966553} -{"instruction": "What is the size of a short integer in c++?", "input": "", "output": "The size of a short integer in C++ is 2 bytes.", "most_similar": {"What is the value of a++b?": 0.588235294117647, "What is the purpose of a hash table?": 0.5555555555555556, "What is the average salary of a software engineer in the US?": 0.5454545454545454, "What are the elements of a for loop in Python?": 0.5, "What is the difference between a `string` and a `char` data type in C#?": 0.5, "What is the purpose of the `float` function in Python?": 0.5, "What is the result of 1 + \"1\"?": 0.47058823529411764, "What is the difference between static and instance variables in C++ programming?": 0.45454545454545453, "What are the differences between `size_t` and `ssize_t` in C?": 0.45454545454545453, "What is the difference between a list and a tuple in Python?": 0.45454545454545453}, "avg_similarity_score": 0.17015686067524205} -{"instruction": "What is the default value of a boolean variable in java?", "input": "", "output": "The default value of a boolean variable in Java is false.", "most_similar": {"What is the value of a++b?": 0.6666666666666665, "What is the size of a short integer in c++?": 0.5714285714285713, "What is the purpose of a hash table?": 0.5263157894736842, "What is the average salary of a software engineer in the US?": 0.5217391304347826, "What is the difference between a variable and a constant in a programming language?": 0.4799999999999999, "What are the elements of a for loop in Python?": 0.47619047619047616, "What is the purpose of the `float` function in Python?": 0.47619047619047616, "What is the difference between a pass-by-reference and a pass-by-value in Java?": 0.4444444444444444, "What is the result of 1 + \"1\"?": 0.4444444444444444, "What is the difference between a list and a tuple in Python?": 0.43478260869565216}, "avg_similarity_score": 0.1641766602403326} -{"instruction": "How can I add a default method to an interface in java?", "input": "", "output": "You can add a default method to an interface in Java by using the `default` keyword. Here's an example: ``` interface MyInterface{ void myMethod(); default void print(){ System.out.println(\"Hello World!\"); } } ``` Here, the default method print() is defined in the interface MyInterface.", "most_similar": {"How can I compare a character in a string to an integer in c++?": 0.5384615384615384, "How can I make a button in HTML?": 0.5, "How can I rotate an element in CSS?": 0.5, "How do you add a new attribute to an existing class in C#?": 0.48000000000000004, "How can I convert string to integer in c++?": 0.4761904761904762, "How can I sort a list of integers in Rust?": 0.45454545454545453, "How do I push a tag to remote in git?": 0.45454545454545453, "How do I convert a string to a number in Python?": 0.43478260869565216, "How to find the largest number in an array in Java?": 0.43478260869565216, "How can I make a switch statement with 20 cases in c++?": 0.4166666666666667}, "avg_similarity_score": 0.1311061982028849} -{"instruction": "What is the output of the following code?\n```js\nvar x = 2;\nvar y = 3;\nvar z = 4;\n\n(function(){\n var x = 1;\n y = 10;\n z = 100;\n console.log(x + \" \" + y + \" \" + z);\n})();\n\nconsole.log(x + \" \" + y + \" \" + z);\n```", "input": "", "output": "The output will be ``` 1 10 100 2 3 4 ```", "most_similar": {"What is the output of the following code?\n```python\ndef func(x):\n return x + 1\n\ndef main():\n x = 1\n y = func(x)\n print(y)\n\nmain()\n```": 0.49180327868852464, "What is the output of the code below?\n\n```python x = [1, 2, 3, 4, 5] x = x[1:-1] print(x)```": 0.49122807017543857, "What is the output of this code?\n```python\ndef f(x):\n x = 2 * x + 1\n return x\n\nx = 3\nz = f(x)\nprint(z)\n```": 0.4666666666666666, "What is the output of the following C# code?\n```\nint x = 1;\nint y = 2;\nint z = 3;\n\nif (x < y)\n{\n if (y < z)\n {\n Console.WriteLine(\"y is the median\");\n }\n else\n {\n Console.WriteLine(\"x is the median\");\n }\n}\nelse\n{\n if (x < z)\n {\n Console.WriteLine(\"x is the median\");\n }\n else\n {\n Console.WriteLine(\"z is the median\");\n }\n}\n```": 0.4444444444444445, "What is the output of the following Python code? ```py def f(x): return x + 1 def g(x): return x * 2 print(g(f(3))) ```": 0.4193548387096774, "What is the output of the following code?\n```python\ndef f(x):\n return x * 2\n\ndef g(x):\n return f(x) + 1\n\ndef h(x):\n return g(x) * 2\n\nprint(h(2))\n```": 0.411764705882353, "What is the output of the following code?\n```py\ndef get_cube(x):\n return x * x * x\n\nprint(get_cube(get_cube(2)))\n```": 0.4067796610169491, "What is the output of the following code?\n```python\ndef foo():\n x = 1\n def bar():\n x = 2\n return x\n return bar()\nprint(foo())\n```": 0.4067796610169491, "What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.3859649122807018, "What is the output of the following code? ```py def add_five(x): x += 5 return x print(add_five(2)) ```": 0.3859649122807018}, "avg_similarity_score": 0.0912857658620033} -{"instruction": "Write a javascript program to get the string after removing the vowels.", "input": "", "output": "```javascript function remove_vowels(string) {\nlet result = '';\nfor (let i = 0; i < string.length; i++) {\nconst ch = string[i];\nif (ch != 'a' && ch != 'e' && ch != 'i' && ch != 'o' && ch != 'u' && ch != 'A' && ch != 'E' && ch != 'I' && ch != 'O' && ch != 'U') {\nresult += ch;\n}\n}\nreturn result;\n}\n```", "most_similar": {"Given a string, write a program to reverse the string.": 0.5454545454545454, "Write a Python program to compute the length of a string.": 0.5217391304347826, "Write a JavaScript program to convert a string to an array, separating the elements by spaces.": 0.5, "Write a Python program to get the volume of a sphere with radius 6.": 0.4615384615384615, "Write a Python program to find the sum of the first 1000 prime numbers.": 0.4615384615384615, "Write a Python program to find the first non-repeated character in a string.": 0.4615384615384615, "Write a Java program that adds 2 to the number inputted by the user.": 0.4615384615384615, "Write a Python program to find the longest pallindrome substring from a given string.": 0.4615384615384615, "Write a program to find the n-th ugly number.": 0.45454545454545453, "Write a program to find the maximum of three numbers.": 0.45454545454545453}, "avg_similarity_score": 0.1727572923433123} -{"instruction": "Write a python program to reverse the case of a string. For example, if the string is Hello World, then the output should be hELLO wORLD.", "input": "", "output": "```python def reverse_case(string):\n\"\"\"\nReturns the string after reversing the case of each character\n\"\"\"\n# Convert the string into lower case\nstring = string.lower()\n# Initialize a variable to store the result\nresult = ''\n# Iterate through each character in the string\nfor ch in string:\n# Check if the character is an alphabet\nif ch in 'abcdefghijklmnopqrstuvwxyz':\n# Add the upper case character to the result\nresult += ch.upper()\n# If the character is not an alphabet, add it as is\nelse:\nresult += ch\n# Return the result\nreturn result\n```", "most_similar": {"Write a Python program to compute the length of a string.": 0.4864864864864865, "Write a Python program to find the first repeated character of a given string where the index of first occurrence is smallest.": 0.4583333333333333, "Write a Python program to find the average of a list using for loop.": 0.45, "Write a Python program to compute the sum of the three given numbers, if one of the value is 13 then return 0.": 0.44897959183673475, "Write a Python program to find the frequency of each word in a given string.": 0.43902439024390244, "Write a Python program to find the frequency of the words from the sentence given.": 0.43902439024390244, "Write a python program to check if the number is prime.": 0.43243243243243246, "Write a Python program to find the first occurrence of a specified value in a given array of integers. Return -1 if the value is not found in the array.": 0.42857142857142855, "Write a Python program to find the first pallindromic string from a given string where the length is three or more.": 0.42553191489361697, "Write a Python program to find the difference between a specified number and 13, if the number is greater than 13 return double the absolute difference.": 0.4230769230769231}, "avg_similarity_score": 0.1819107774245178} -{"instruction": "You are given a string. You need to print the sum of the two largest integers in that string.\nString: 1234", "input": "", "output": "def find_two_largest_nums(nums):\n numbers = [int(num) for num in nums.split(\" \")]\n numbers.sort()\n return str(sum(numbers[-2:]))", "most_similar": {"You are given a list of numbers. You need to find the median of the list.": 0.5405405405405405, "Show me a code in JavaScript that returns the sum of all the integers in a string.": 0.42105263157894735, "Given a number N, write a program to find the sum of all the digits in N.": 0.42105263157894735, "Implement a function to calculate the sum of the elements of an array in Java.": 0.3888888888888889, "Given a string, write a program to reverse the string.": 0.3870967741935483, "Write a Python program to find the sum of the positive integers of a given range.": 0.37837837837837834, "Given a list of numbers, find the sum of the numbers.": 0.37499999999999994, "Given a string s, return the number of palindromic substrings in it.": 0.36363636363636365, "Given a list of numbers, find the largest number in the list.": 0.36363636363636365, "Given a string, return the number of vowels used in the text.": 0.36363636363636365}, "avg_similarity_score": 0.16848292683564262} -{"instruction": "You are given a string. You need to remove all the vowels from the string.\nString: She is a girl.", "input": "", "output": "def remove_vowels(sentence):\n vowels = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']\n sentence = list(sentence)\n for i in range(len(sentence)-1, -1, -1):\n if sentence[i] in vowels:\n del sentence[i]\n return \"\".join(sentence)", "most_similar": {"You are given a string. You need to print the sum of the two largest integers in that string.\nString: 1234": 0.5853658536585366, "You are given a list of numbers. You need to find the median of the list.": 0.5, "Given a string, write a program to reverse the string.": 0.4, "Given a string, return the number of vowels used in the text.": 0.37499999999999994, "Can you write a program to get all the inputs from a user until he/she enters 'stop'?": 0.36842105263157887, "Given a string, write a program to check whether it is a palindrome.": 0.3636363636363637, "Write a Python program to remove all duplicates from a list in Python": 0.3636363636363637, "You are given a list of numbers. Return the sum of the numbers. If the input is invalid, return a user-friendly error message.": 0.3636363636363636, "You are given a list of numbers. You need to find the number of pairs of indices (i, j) such that the difference between nums[i] and nums[j] is at most t and i < j.": 0.35714285714285715, "Write a function that takes a string and returns the number of vowels in the string.": 0.33333333333333326}, "avg_similarity_score": 0.15445891598173964} -{"instruction": "Given an array, find the sum of all elements in it.", "input": "", "output": "def sum_array(arr):\n return sum(arr)", "most_similar": {"How to find the sum of all the elements in a list in python?": 0.56, "How to find the sum of all numbers in an array?": 0.5454545454545454, "Given an array of numbers, find the maximum sum of any contiguous subarray of the array.": 0.5185185185185185, "Given a number N, write a program to find the sum of all the digits in N.": 0.5, "How do I find the p-variance of all elements in a list?": 0.4999999999999999, "How do I find the standard deviation of all elements in an array?": 0.4999999999999999, "Write a Python function to find the sum of all items in a list.": 0.4799999999999999, "Given a binary array, find the maximum number of consecutive 1s in this array.": 0.4799999999999999, "Write a C# program to find the sum of all the elements of an array.": 0.4615384615384615, "Given a list of numbers, find the sum of the numbers.": 0.45454545454545453}, "avg_similarity_score": 0.1481598399768426} -{"instruction": "Given an array and a number, find the position of the number in the array.", "input": "", "output": "def find_position(arr, num):\n try:\n return arr.index(num)\n except:\n return -1", "most_similar": {"Given an array, find the sum of all elements in it.": 0.5384615384615385, "Given a list of numbers, find the largest number in the list.": 0.5185185185185186, "Given an array of numbers, find the maximum sum of any contiguous subarray of the array.": 0.5161290322580646, "Given a number N, write a program to find the sum of all the digits in N.": 0.5, "Write a function that takes an array of numbers and returns the largest number in the array.": 0.5, "Given a binary array, find the maximum number of consecutive 1s in this array.": 0.4827586206896552, "Given a list of numbers, find the sum of the numbers.": 0.4615384615384615, "Given a string, return the number of vowels used in the text.": 0.4444444444444445, "Given an array of integers, find the maximum possible sum that can be obtained by subtracting any number from the array.": 0.4444444444444444, "Given a list of integers, find the number that occurs odd number of times in the list.": 0.43749999999999994}, "avg_similarity_score": 0.19125328463975538} -{"instruction": "You are given an array. You need to find the length of the array.", "input": "", "output": "def find_length(arr):\n return len(arr)", "most_similar": {"You are given a list of numbers. You need to find the median of the list.": 0.6666666666666666, "Given an array and a number, find the position of the number in the array.": 0.5517241379310344, "Given an array of numbers, find the maximum sum of any contiguous subarray of the array.": 0.5333333333333333, "You are given a string. You need to print the sum of the two largest integers in that string.\nString: 1234": 0.5142857142857143, "Given an array, find the sum of all elements in it.": 0.4799999999999999, "Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k.": 0.4736842105263159, "You are given a string. You need to remove all the vowels from the string.\nString: She is a girl.": 0.47058823529411764, "Given an array containing 0s and 1s, if you are allowed to replace no more than \u2018k\u2019 0s with 1s, find the length of the longest contiguous subarray having all 1s.": 0.4444444444444444, "Given a string `s`, find the length of the longest substring without repeating characters.": 0.42857142857142855, "Given a binary array, find the maximum number of consecutive 1s in this array.": 0.42857142857142855}, "avg_similarity_score": 0.15256130201520027} -{"instruction": "What does the following code print?\n\n```\nfor i in range(4):\n print(i)\n```", "input": "", "output": "It prints the following:\n\n```\n0\n1\n2\n3\n```\n", "most_similar": {"What is the output of this code?\n```\nfor i in range(10):\n print(i)\n```": 0.6666666666666666, "What does the following JavaScript code print?": 0.6, "What is the output of the following code? ```py def print_odds(n): for i in range(n): if i % 2 == 0: print(i) print_odds(10) ```": 0.5499999999999999, "What does the following python code print?\n```py\nprint(f'500:{500:08d}')\n```": 0.5384615384615384, "In Python, what does the following code output?\n[3, 4, 5][-1]": 0.48000000000000004, "What does the function `print()` do?": 0.42105263157894735, "Translate the following code from python in Java.": 0.380952380952381, "What does the following python code do?\n```python def sum_divisible_by_three(lst):\n\treturn sum(x for x in lst if x % 3 == 0)\n ```": 0.3684210526315789, "What is the output of the following code?\n```py\nnum = 3\n\ndef func(num):\n num += 4\n\nfunc(num)\nprint(num)\n```": 0.3636363636363637, "What is the output of the following code? ```py def a(): print(\"a\") b = a def c(): print(\"c\") b() ```": 0.3636363636363637}, "avg_similarity_score": 0.11466605550741416} -{"instruction": "How to generate a random float number between 0 and 1?", "input": "", "output": "To generate a random float number between 0 and 1, use the random.random() method.\n\nFor example:\n\nimport random\n\nprint(random.random())", "most_similar": {"How to find the number of days between two dates?": 0.380952380952381, "How to check quickly if a number is prime in C?": 0.36363636363636365, "How to find the largest prime factor of a given number?": 0.36363636363636365, "How do I convert a string to a number in Python?": 0.36363636363636365, "Write a function that creates a list of the multiples of a number between 0 and a limit.": 0.3448275862068966, "How to capitalize a string in Python?": 0.33333333333333326, "How can we append items to a list?": 0.3157894736842105, "How to split a string into a list?": 0.3157894736842105, "How to find the standard deviation of a list?": 0.3, "How to find the nth prime number in C?": 0.3}, "avg_similarity_score": 0.12322326712983615} -{"instruction": "What is the difference between import and from import statements?", "input": "", "output": "When you use the import statement, you need to use the name of the module when you call functions or access variables defined in that module.\n\nFor example:\n\nimport math\n\nprint(math.sqrt(25))\n\nThis prints 5.0.\n\nWhen you use the from import statement, you do not need to use the name of the module when you call functions or access variables defined in that module.\n\nFor example:\n\nfrom math import sqrt\n\nprint(sqrt(25))\n\nThis prints 5.0.", "most_similar": {"What is the difference between `NaN` and `Infinity`?": 0.6666666666666665, "What is the difference between a class and an object?": 0.6, "What is the difference between `git pull` and `git fetch` ?": 0.6, "What is the difference between virtual environment and conda environment?": 0.6, "What is the difference between a relative and absolute path?": 0.6, "What is the difference between the Docker and Virtual Machine?": 0.6, "What is the difference between `val` and `var` in Kotlin?": 0.6, "What is the difference between an ingress and a persistent volume?": 0.5714285714285713, "What is the difference between a static and a dynamic method?": 0.5714285714285713, "What is the difference between the `break` and the `continue` keywords?": 0.5714285714285713}, "avg_similarity_score": 0.1133780836150783} -{"instruction": "How to define and use an enum type in Python?", "input": "", "output": "You can use the Enum class to define an enumeration.\n\nFor example:\n\nfrom enum import Enum\n\nMonths = Enum('Months', ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'))\n\nprint(Months)\n\nThis prints the following output:\n\n\nYou can access the members of an Enum type like this:\n\nMonths.Jan\n\nThis returns the value 'Jan'.\n\nIf you want to get the list of members in an Enum, use the following code:\n\nprint(list(Months))\n\nThis prints the following output:\n['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']", "most_similar": {"How to capitalize a string in Python?": 0.47058823529411764, "How to get the current time in milliseconds in python?": 0.4000000000000001, "How to test if an element is in a list?": 0.4000000000000001, "How to get the last element of a list in Python?": 0.380952380952381, "How do I convert a string to a number in Python?": 0.380952380952381, "How can I get the current date and time in Python?": 0.380952380952381, "How to find the largest number in an array in Java?": 0.380952380952381, "How do you get the first and last index of an element in a list in Python?": 0.37037037037037035, "What are the difference between a float and an int in Python?": 0.3636363636363636, "How can I add a default method to an interface in java?": 0.3636363636363636}, "avg_similarity_score": 0.10322635402113746} -{"instruction": "Write a Python program to check whether all values of a list are equal?", "input": "", "output": "You can use the set() function to find the unique values in a list.\n\nFor example:\n\ndef all_equal(lst):\n return lst[1:] == lst[:-1]\n\nprint(all_equal([1, 1, 1, 1, 1]))\n\nThis prints True.", "most_similar": {"Write a Python program to generate all permutations of a given list.": 0.6923076923076924, "Write a Python program to remove all duplicates from a list in Python": 0.5925925925925927, "Write a Python program to check whether a specified number is a perfect square.": 0.5714285714285714, "Write a Python program to find the average of a list using for loop.": 0.5714285714285714, "Write a Python program to compute the length of a string.": 0.56, "Write a Python program to find the highest 3 values from a list of values.": 0.5517241379310344, "Write a Python program to find the longest common prefix of a given list of strings.": 0.5333333333333333, "Given a string, write a program to check whether it is a palindrome.": 0.5185185185185186, "Write a Python program to find the sum of a non-negative integer.": 0.5185185185185186, "Write a Python function to find the number of items in a list that are not equal to a given value.": 0.5142857142857143}, "avg_similarity_score": 0.18248973457284245} -{"instruction": "What is the difference between string, bytes and bytearray types in Python?", "input": "", "output": "A string is a sequence of Unicode characters.\n\nFor example:\n\nx = \"Hello\"\nprint(x)\n\nThis prints Hello.\n\nA bytes object is a sequence of bytes, which is an immutable sequence of integers in the range 0 <= x < 256.\n\nFor example:\n\nx = b\"Hello\"\nprint(x)\n\nThis prints b'Hello'.\n\nA bytearray object is a mutable sequence of integers in the range 0 <= x < 256.\n\nFor example:\n\nx = bytearray(5)\nprint(x)\n\nThis prints bytearray(b'\\x00\\x00\\x00\\x00\\x00').\n\nThe bytearray type was introduced in Python 2.6. It is similar to the list type.\n\nFor example:\n\nx = bytearray(\"Hello\", encoding='utf-8')\nprint(x)\n\nThis prints bytearray(b'Hello').", "most_similar": {"What is the difference between a list and a tuple in Python?": 0.6666666666666666, "What is the difference between `val` and `var` in Kotlin?": 0.6363636363636365, "What is the difference between a `string` and a `char` data type in C#?": 0.6153846153846153, "What is the difference between `NaN` and `Infinity`?": 0.6, "What are the difference between a float and an int in Python?": 0.5833333333333334, "What is the difference between static and instance variables in C++ programming?": 0.5833333333333334, "What is the difference between the `==` and the `.equals()` methods in Java?": 0.5833333333333334, "What is the difference between the `os.path.isfile()` and the `os.path.exists()` functions in Python?": 0.5517241379310345, "What are the differences between dictionary and list in Python?": 0.5454545454545454, "What is the difference between a relative and absolute path?": 0.5454545454545454}, "avg_similarity_score": 0.13587464933905274} -{"instruction": "I am trying to learn a new language and I have started to learn the verbs. I need someone to help me to write a program that takes a string and translate it to the language I am learning. I am also interested in learning about other features of the language. For example, if you can add some features like saying what is the weather in the country, etc.", "input": "", "output": "I need to learn to speak Korean. I can use the following program to help me:\ndef say_hello(name):\n print(\"\uc548\ub155\ud558\uc138\uc694, \" + name + \"!\")\n\nsay_hello(\"Amy\")", "most_similar": {"I am trying to reverse a string using Python. I have a function that takes a string as a parameter and returns the string in reverse order. Is there a more pythonic way to do this?": 0.30476190476190473, "I am trying to write a function that takes a list of numbers and returns the sum of the numbers. I wrote the following code in Python:\n```py def sum(lst):\n total = 0\n for i in lst:\n total += i\n return total\n```": 0.27272727272727276, "Write a function that takes an integer n as a parameter and returns the sum of the first n numbers.\n```py\nFor example, if the input is 3, the function should return 6, since 1 + 2 + 3 = 6.\n```": 0.2616822429906542, "Write a function that takes a string and returns the number of vowels in the string.": 0.2588235294117647, "I have a dictionary in python where I have a key and the value is a list of strings. I want to search for a particular string in the list and return the key. What is the best way to do that?": 0.2522522522522523, "I am working on a project for my college and I need help. I am trying to make a simple calculator using Python. I want to show the result of an expression in the form of a list, for example 3 + 4 = 7. But I want it to show 3 + 4 = [7]. Is there a way to do this?": 0.25, "How do I make a function that takes a string and returns a list of the words in the string?": 0.24719101123595502, "Write a function that takes a positive integer n and returns the next biggest number with the same number of 1 bits. For example, given the number 6 (0110 in binary), the function should return 9 (1001).": 0.24528301886792453, "Write a Python function that takes a list of numbers and returns the sum of all the numbers in the list.": 0.24444444444444444, "Write a Python function that takes a list as input and returns the mode of the elements in the list.\n[1, 2, 3, 4, 3]": 0.23404255319148934}, "avg_similarity_score": 0.11526155685841687} -{"instruction": "How could I open ports on my EC2 instance?", "input": "", "output": "You can open ports in your EC2 instance by creating a new security group, adding the necessary inbound and outbound rules, and then associating the security group with the instance.", "most_similar": {"How do I incorporate CSS in my HTML page?": 0.3333333333333333, "How do I define a function called `my_function` that prints \"Hello, world!\"?": 0.27272727272727276, "How do I compile a go program on Linux to a windows executable?": 0.27272727272727276, "How do I make a dropdown menu?": 0.25, "How do I print a list in Python?": 0.23529411764705882, "How can I make a button in HTML?": 0.23529411764705882, "How can I rotate an element in CSS?": 0.23529411764705882, "How can I get the size of a directory?": 0.2222222222222222, "How do I create a text field in HTML?": 0.2222222222222222, "How do I create a new branch in git?": 0.2222222222222222}, "avg_similarity_score": 0.030505942827773205} -{"instruction": "Suppose I want to program a chatbot to teach people math. What are some good resources that could help me accomplish this task?", "input": "", "output": "I would suggest taking a look at the [OpenAI GPT-3](https://openai.com/blog/openai-api/) API and the [Microsoft Conversation Learner](https://docs.microsoft.com/en-us/azure/cognitive-services/labs/conversation-learner/overview) tool. The OpenAI GPT-3 API can be used to train your chatbot to recognize and complete math problems and formulas. The Microsoft Conversation Learner tool can be used to train the chatbot to recognize and complete the math problems posed by users. This tool can also help you define and prioritize the tasks for your chatbot. For example, it can help you prioritize tasks like adding two numbers or recognizing and completing math formulas.", "most_similar": {"I want to create a list of integers from 1 to 1000. How would I do that?": 0.3, "I want to take a string and print it backwards. How would I do that?": 0.26315789473684204, "I want to know what is the difference between abstract classes and interfaces?": 0.2222222222222222, "I want to find the average of all the numbers in a list.": 0.2222222222222222, "If you want to determine if your date of birth is a leap year or not, what is the condition that you need to apply?": 0.20833333333333331, "I want to find a specific item in a long list of items. The list is sorted by an item field. What is the best data structure to use?": 0.19230769230769232, "I am trying to use the following code to create a list of numbers from 1 to 100. But it is not working. Can you help me fix it? ```python numbers = [] for i in range(1, 100): numbers.append(i) ```": 0.19047619047619047, "Can I convert a dictionary to a JSON string?": 0.18750000000000003, "I'm trying to concatenate strings in a list.": 0.18750000000000003, "I have a dictionary in python where I have a key and the value is a list of strings. I want to search for a particular string in the list and return the key. What is the best way to do that?": 0.1846153846153846}, "avg_similarity_score": 0.08563518202136594} -{"instruction": "I have an EC2 instance, and I'm trying to SSH into it using a private key. When I run `ssh -i my-key.pem ec2-user@ec2-my-public-dns.com`, I get the following error: `Permission denied (publickey)`. How can I fix this issue?", "input": "", "output": "I would suggest the following steps to fix this issue: 1. Make sure that the EC2 instance has been launched and is in the running state. 2. Make sure that the permissions of your private key file `my-key.pem` are set to `400` (read-only by the owner) or `600` (read-write by the owner). If you are using Windows, you can set the permissions using the following command: `icacls my-key.pem /setowner ec2-user`. 3. Check that your private key `my-key.pem` was created using the `PEM` file format. If you created your private key using the `PPK` file format, you can use PuttyGen to convert your private key to the `PEM` file format. If you are using macOS or Linux, you can use the following command to convert your private key: `puttygen my-key.ppk -O private-openssh -o my-key.pem`.", "most_similar": {"I'm trying to run a Python script on a remote server. I'm getting an error: \"ImportError: No module named 'requests'\". How can I fix this?": 0.32876712328767116, "I have a C# class as below. ```cs public class A { private int _i; public int i { get { return _i; } set { _i = value; } } } ``` How can I get access to the _i field in this class?": 0.29629629629629634, "I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.2647058823529412, "I'm trying to run my Tensorflow model on an Apple M1 Macbook Air but I'm getting an error that looks like this:\n\n```\nIllegal instruction (core dumped)\n```\n\nWhat does this error mean?": 0.2278481012658228, "I have a string with many spaces between the words. How can I remove the extra spaces?": 0.2222222222222222, "I have 2 EC2 machines on AWS, I'm having trouble making them communicate. How could I troubleshoot it?": 0.21538461538461537, "I'm trying to use the following code to create a new column in a dataframe:\n```python\ndf['new_col'] = df['col_1'].apply(lambda x: x.split(' ')[0])\n```\nBut I'm getting the following error:\n```python\nAttributeError: 'float' object has no attribute 'split'\n```": 0.2, "I have a code that is too slow. How can I make it faster?": 0.2, "I have a list of numbers and I want to find the average of all the numbers.": 0.1904761904761905, "I am working on a project for my college and I need help. I am trying to make a simple calculator using Python. I want to show the result of an expression in the form of a list, for example 3 + 4 = 7. But I want it to show 3 + 4 = [7]. Is there a way to do this?": 0.19047619047619047}, "avg_similarity_score": 0.0726743618513944} -{"instruction": "I am trying to SSH into my EC2 instance using a private key. I ran the `chmod 400 my-key.pem` command to set the permissions, but I still cannot SSH into the EC2 instance. What should I do?", "input": "", "output": "I would suggest checking the following: 1. Ensure that the private key you are using is the correct one for the EC2 instance. 2. Ensure that the public key you uploaded to the EC2 instance is the correct one for the private key.", "most_similar": {"I have an EC2 instance, and I'm trying to SSH into it using a private key. When I run `ssh -i my-key.pem ec2-user@ec2-my-public-dns.com`, I get the following error: `Permission denied (publickey)`. How can I fix this issue?": 0.3764705882352941, "I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.2622950819672131, "I am trying to write a function that takes a list of numbers and returns the sum of the numbers. I wrote the following code in Python:\n```py def sum(lst):\n total = 0\n for i in lst:\n total += i\n return total\n```": 0.25, "I am trying to reverse a string using Python. I have a function that takes a string as a parameter and returns the string in reverse order. Is there a more pythonic way to do this?": 0.24000000000000002, "I am trying to use the following code to create a list of numbers from 1 to 100. But it is not working. Can you help me fix it? ```python numbers = [] for i in range(1, 100): numbers.append(i) ```": 0.22784810126582278, "I am working on a project for my college and I need help. I am trying to make a simple calculator using Python. I want to show the result of an expression in the form of a list, for example 3 + 4 = 7. But I want it to show 3 + 4 = [7]. Is there a way to do this?": 0.22448979591836735, "I have a dictionary in python where I have a key and the value is a list of strings. I want to search for a particular string in the list and return the key. What is the best way to do that?": 0.22222222222222224, "I am trying to learn a new language and I have started to learn the verbs. I need someone to help me to write a program that takes a string and translate it to the language I am learning. I am also interested in learning about other features of the language. For example, if you can add some features like saying what is the weather in the country, etc.": 0.2222222222222222, "I have a C# class as below. ```cs public class A { private int _i; public int i { get { return _i; } set { _i = value; } } } ``` How can I get access to the _i field in this class?": 0.2162162162162162, "I have a list of numbers and I want to find the average of all the numbers.": 0.21428571428571433}, "avg_similarity_score": 0.08821069527244352} -{"instruction": "I am trying to run an experiment on a cluster on Google Cloud. However, it's not working. I suspect that it has something to do with my cluster configuration. What could be causing this issue?", "input": "", "output": "I would recommend the following steps to fix this issue: 1. Make sure that you have configured your cluster with the required amount of vCPUs, RAM, and GPUs. 2. Make sure that the Google Cloud services are enabled for your project. 3. Make sure that you are using the correct version of the Cloud SDK.", "most_similar": {"I am trying to reverse a string using Python. I have a function that takes a string as a parameter and returns the string in reverse order. Is there a more pythonic way to do this?": 0.2777777777777778, "I'm trying to run my Tensorflow model on an Apple M1 Macbook Air but I'm getting an error that looks like this:\n\n```\nIllegal instruction (core dumped)\n```\n\nWhat does this error mean?": 0.2608695652173913, "I'm trying to run a Python script on a remote server. I'm getting an error: \"ImportError: No module named 'requests'\". How can I fix this?": 0.25396825396825395, "Suppose I want to program a chatbot to teach people math. What are some good resources that could help me accomplish this task?": 0.23728813559322037, "I am trying to use the following code to create a list of numbers from 1 to 100. But it is not working. Can you help me fix it? ```python numbers = [] for i in range(1, 100): numbers.append(i) ```": 0.2368421052631579, "I want to take a string and print it backwards. How would I do that?": 0.23529411764705882, "I am working on a project for my college and I need help. I am trying to make a simple calculator using Python. I want to show the result of an expression in the form of a list, for example 3 + 4 = 7. But I want it to show 3 + 4 = [7]. Is there a way to do this?": 0.23157894736842105, "I am trying to run the following code in Python: ```python def f(x): return x + 1 print(f(1)) ``` I get an error. What is the problem?": 0.21875000000000003, "I am trying to SSH into my EC2 instance using a private key. I ran the `chmod 400 my-key.pem` command to set the permissions, but I still cannot SSH into the EC2 instance. What should I do?": 0.21333333333333332, "I am trying to write a Python program that prints the sum of two numbers. However, the result of my code is not correct.\n\n```py def add_numbers(a, b):\n return a + b\n```\n\n```py print(add_numbers(10, 10)) ```\n\nThe expected output is 20, but my program prints 1010. What's wrong with my code?": 0.1978021978021978}, "avg_similarity_score": 0.07740587707788203} -{"instruction": "I am trying to write a Python function that computes the greatest common divisor (GCD) of two numbers. I have written the following code: ``` def gcd(a, b): while b: a, b = b, a % b return a ``` However, I am getting an error when I try to run it. Can you help me figure out what is wrong with this code?", "input": "", "output": "The following line in your code is not correct: ``` a, b = b, a % b ``` You are trying to assign the value of `b` to `a` and the value of `a % b` to `b`, but it is not possible to assign a value to `a` in this way. This is because when you assign a value to a variable, you are actually modifying the variable's reference to the value, but `a` is not a variable, it is just the name of the parameter to your function. To fix this issue, you should assign the value of `b` to a different variable, say `c`, and then assign the value of `c` to `a`. For example, you can write your `gcd` function as follows: ``` def gcd(a, b): while b: c = b a, c = a % c return a ```", "most_similar": {"I am trying to use the following code in python:\n```py\ndef function(a, b):\n if a > b:\n print('You lost.')\n else:\n if c > a:\n print('Nice try.')\n else:\n print('You won.')\n```\nBut I am getting an error. What is wrong with the code?": 0.4380952380952381, "I am trying to write a Python program that prints the sum of two numbers. However, the result of my code is not correct.\n\n```py def add_numbers(a, b):\n return a + b\n```\n\n```py print(add_numbers(10, 10)) ```\n\nThe expected output is 20, but my program prints 1010. What's wrong with my code?": 0.396551724137931, "I am trying to write a function that takes a list of numbers and returns the sum of the numbers. I wrote the following code in Python:\n```py def sum(lst):\n total = 0\n for i in lst:\n total += i\n return total\n```": 0.3529411764705882, "What is the output of the following code? ```py a = 5 b = 15 print(\"a / b is\", a / b) print(\"a % b is\", a % b) print(\"a // b is\", a // b) ```": 0.3260869565217391, "I am trying to run the following code in Python: ```python def f(x): return x + 1 print(f(1)) ``` I get an error. What is the problem?": 0.3146067415730337, "The following code I wrote in haskell ```hs factorial(1)=1 factorial(n)=n*(n-1)*factorial(n-2) ``` gives me an error when I try to run it. Is there anything I did wrong?": 0.2916666666666667, "Write a Python function to calculate the greatest common divisor (GCD) of two positive integers.": 0.2894736842105263, "I am trying to reverse a string using Python. I have a function that takes a string as a parameter and returns the string in reverse order. Is there a more pythonic way to do this?": 0.28865979381443296, "I am trying to use the following code to create a list of numbers from 1 to 100. But it is not working. Can you help me fix it? ```python numbers = [] for i in range(1, 100): numbers.append(i) ```": 0.2772277227722772, "What is the output of the following code? ```py def add(a, b): return a + b print(add(1, 2)) print(add(b=2, a=1)) ```": 0.27586206896551724}, "avg_similarity_score": 0.12300795482276014} -{"instruction": "I am trying to get my EC2 instance to connect to a MySQL database. When I try to connect using the `mysql -h 55.55.55.55 -u user -p` command, I get the following error: `ERROR 2003 (HY000): Can't connect to MySQL server on '55.55.55.55' (110)`. What should I do to fix this issue?", "input": "", "output": "You should make sure that your database server is up and running and that it is accessible over the public internet. To do this, you should enable the public internet access option for your database server. This option can be enabled in the MySQL Server configuration. If this option is disabled, you can only connect to your MySQL server locally. Once you have enabled the public internet access option, you should make sure that the security group attached to your database server has the necessary inbound rules to allow inbound traffic on port `3306`, which is the port used by the MySQL database.", "most_similar": {"I am trying to SSH into my EC2 instance using a private key. I ran the `chmod 400 my-key.pem` command to set the permissions, but I still cannot SSH into the EC2 instance. What should I do?": 0.34693877551020413, "I have an EC2 instance, and I'm trying to SSH into it using a private key. When I run `ssh -i my-key.pem ec2-user@ec2-my-public-dns.com`, I get the following error: `Permission denied (publickey)`. How can I fix this issue?": 0.3428571428571429, "I'm trying to run a Python script on a remote server. I'm getting an error: \"ImportError: No module named 'requests'\". How can I fix this?": 0.2325581395348837, "I am trying to reverse a string using Python. I have a function that takes a string as a parameter and returns the string in reverse order. Is there a more pythonic way to do this?": 0.23157894736842105, "I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.22222222222222224, "I am trying to write a Python function that computes the greatest common divisor (GCD) of two numbers. I have written the following code: ``` def gcd(a, b): while b: a, b = b, a % b return a ``` However, I am getting an error when I try to run it. Can you help me figure out what is wrong with this code?": 0.21666666666666665, "I am trying to run an experiment on a cluster on Google Cloud. However, it's not working. I suspect that it has something to do with my cluster configuration. What could be causing this issue?": 0.21052631578947367, "I am trying to run the following code in Python: ```python def f(x): return x + 1 print(f(1)) ``` I get an error. What is the problem?": 0.20689655172413796, "I am working on a project for my college and I need help. I am trying to make a simple calculator using Python. I want to show the result of an expression in the form of a list, for example 3 + 4 = 7. But I want it to show 3 + 4 = [7]. Is there a way to do this?": 0.20338983050847462, "I am trying to learn a new language and I have started to learn the verbs. I need someone to help me to write a program that takes a string and translate it to the language I am learning. I am also interested in learning about other features of the language. For example, if you can add some features like saying what is the weather in the country, etc.": 0.20312499999999997}, "avg_similarity_score": 0.07022117285486226} -{"instruction": "I am trying to SSH into my EC2 instance. When I run the `ssh -i my-key.pem ec2-user@ec2-my-public-dns.com` command, I get the following error: `Permission denied (publickey)`. Why am I getting this error, and how can I fix it?", "input": "", "output": "This issue could be caused by several reasons: 1. Make sure that your private key `my-key.pem` was created using the `PEM` file format. If you created your private key using the `PPK` file format, you can use PuttyGen to convert your private key to the `PEM` file format. If you are using macOS or Linux, you can use the following command to convert your private key: `puttygen my-key.ppk -O private-openssh -o my-key.pem`. 2. Make sure that the permissions of your private key file `my-key.pem` are set to `400` (read-only by the owner) or `600` (read-write by the owner). If you are using Windows, you can set the permissions using the following command: `icacls my-key.pem /setowner ec2-user`. 3. Make sure that your private key file `my-key.pem` and the public key file on your EC2 instance match. The public key file on your EC2 instance is located in `/home/ec2-user/.ssh/authorized_keys`. 4. Make sure that the EC2 instance has been launched and is in the running state.", "most_similar": {"I have an EC2 instance, and I'm trying to SSH into it using a private key. When I run `ssh -i my-key.pem ec2-user@ec2-my-public-dns.com`, I get the following error: `Permission denied (publickey)`. How can I fix this issue?": 0.6956521739130435, "I am trying to SSH into my EC2 instance using a private key. I ran the `chmod 400 my-key.pem` command to set the permissions, but I still cannot SSH into the EC2 instance. What should I do?": 0.4235294117647059, "I am trying to get my EC2 instance to connect to a MySQL database. When I try to connect using the `mysql -h 55.55.55.55 -u user -p` command, I get the following error: `ERROR 2003 (HY000): Can't connect to MySQL server on '55.55.55.55' (110)`. What should I do to fix this issue?": 0.39999999999999997, "I'm trying to run a Python script on a remote server. I'm getting an error: \"ImportError: No module named 'requests'\". How can I fix this?": 0.30136986301369867, "I am trying to run the following code in Python: ```python def f(x): return x + 1 print(f(1)) ``` I get an error. What is the problem?": 0.24324324324324326, "I am trying to write a Python function that computes the greatest common divisor (GCD) of two numbers. I have written the following code: ``` def gcd(a, b): while b: a, b = b, a % b return a ``` However, I am getting an error when I try to run it. Can you help me figure out what is wrong with this code?": 0.24299065420560748, "I am trying to write a function that takes a list of numbers and returns the sum of the numbers. I wrote the following code in Python:\n```py def sum(lst):\n total = 0\n for i in lst:\n total += i\n return total\n```": 0.22988505747126436, "I'm trying to run my Tensorflow model on an Apple M1 Macbook Air but I'm getting an error that looks like this:\n\n```\nIllegal instruction (core dumped)\n```\n\nWhat does this error mean?": 0.2278481012658228, "I have a C# class as below. ```cs public class A { private int _i; public int i { get { return _i; } set { _i = value; } } } ``` How can I get access to the _i field in this class?": 0.2222222222222222, "I am trying to use the following code to create a list of numbers from 1 to 100. But it is not working. Can you help me fix it? ```python numbers = [] for i in range(1, 100): numbers.append(i) ```": 0.20930232558139536}, "avg_similarity_score": 0.0700229127569578} -{"instruction": "I have created an EC2 instance with a public IP address, but I cannot access my instance using the public IP address. What could be causing this issue?", "input": "", "output": "There are several possible causes for this issue: 1. Make sure that your security group has the necessary inbound rules to allow SSH traffic (port 22). 2. Make sure that your instance is not part of a placement group that requires a tenancy of `host`. 3. Make sure that you are using the correct public IP address for your instance. If you are using a domain name to connect to your instance, make sure that the domain name has been resolved to the correct public IP address. 4. If you are using a VPN connection to access your instance, make sure that your VPN is connected.", "most_similar": {"I am trying to run an experiment on a cluster on Google Cloud. However, it's not working. I suspect that it has something to do with my cluster configuration. What could be causing this issue?": 0.34375000000000006, "I have an EC2 instance, and I'm trying to SSH into it using a private key. When I run `ssh -i my-key.pem ec2-user@ec2-my-public-dns.com`, I get the following error: `Permission denied (publickey)`. How can I fix this issue?": 0.2972972972972973, "I am trying to SSH into my EC2 instance using a private key. I ran the `chmod 400 my-key.pem` command to set the permissions, but I still cannot SSH into the EC2 instance. What should I do?": 0.2686567164179105, "I have a C# class as below. ```cs public class A { private int _i; public int i { get { return _i; } set { _i = value; } } } ``` How can I get access to the _i field in this class?": 0.25396825396825395, "I have a list of numbers, how do I find the second largest number?": 0.2380952380952381, "I am trying to get my EC2 instance to connect to a MySQL database. When I try to connect using the `mysql -h 55.55.55.55 -u user -p` command, I get the following error: `ERROR 2003 (HY000): Can't connect to MySQL server on '55.55.55.55' (110)`. What should I do to fix this issue?": 0.22988505747126434, "I have a string with many spaces between the words. How can I remove the extra spaces?": 0.22222222222222224, "I have a list of numbers and I want to find the average of all the numbers.": 0.22222222222222224, "I have a string like this:\n\n```py name = \"Alice Bob Carol\" ```\n\nHow can I get the last name?": 0.21739130434782608, "I have 2 EC2 machines on AWS, I'm having trouble making them communicate. How could I troubleshoot it?": 0.2127659574468085}, "avg_similarity_score": 0.07892579621990649} -{"instruction": "I'm having trouble installing a package on my EC2 instance. The error I get when I try to install the package is: `cannot install the following packages: 'package-name' no packages available in this version of R`. What should I do to fix this issue?", "input": "", "output": "I would suggest the following steps to fix this issue: 1. Make sure that your instance has access to the internet. 2. Check if your R version is the same as the package you are trying to install. If your R version is not the same as the package you are trying to install, you should upgrade or downgrade your R version.", "most_similar": {"I am trying to get my EC2 instance to connect to a MySQL database. When I try to connect using the `mysql -h 55.55.55.55 -u user -p` command, I get the following error: `ERROR 2003 (HY000): Can't connect to MySQL server on '55.55.55.55' (110)`. What should I do to fix this issue?": 0.3619047619047619, "I am trying to SSH into my EC2 instance using a private key. I ran the `chmod 400 my-key.pem` command to set the permissions, but I still cannot SSH into the EC2 instance. What should I do?": 0.30588235294117644, "I have an EC2 instance, and I'm trying to SSH into it using a private key. When I run `ssh -i my-key.pem ec2-user@ec2-my-public-dns.com`, I get the following error: `Permission denied (publickey)`. How can I fix this issue?": 0.2826086956521739, "I am trying to SSH into my EC2 instance. When I run the `ssh -i my-key.pem ec2-user@ec2-my-public-dns.com` command, I get the following error: `Permission denied (publickey)`. Why am I getting this error, and how can I fix it?": 0.2608695652173913, "I'm trying to run a Python script on a remote server. I'm getting an error: \"ImportError: No module named 'requests'\". How can I fix this?": 0.2465753424657534, "I have created an EC2 instance with a public IP address, but I cannot access my instance using the public IP address. What could be causing this issue?": 0.24324324324324326, "I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.2352941176470588, "I am working on a project for my college and I need help. I am trying to make a simple calculator using Python. I want to show the result of an expression in the form of a list, for example 3 + 4 = 7. But I want it to show 3 + 4 = [7]. Is there a way to do this?": 0.2285714285714286, "I have a C# class as below. ```cs public class A { private int _i; public int i { get { return _i; } set { _i = value; } } } ``` How can I get access to the _i field in this class?": 0.2222222222222222, "I have a dictionary in python where I have a key and the value is a list of strings. I want to search for a particular string in the list and return the key. What is the best way to do that?": 0.20454545454545456}, "avg_similarity_score": 0.10052052389194156} -{"instruction": "I am trying to install a package on my EC2 instance. When I run the `R -e \"install.packages('package-name')\"` command, I get the following error: `Warning message: package 'package-name' is not available (for R version 3.5.3)`. How can I fix this issue?", "input": "", "output": "The warning message in your output indicates that the package you are trying to install is not available for the version of R that you are using on your EC2 instance. You can check the version of R on your instance by running the following command: `R --version`. If you are using an older version of R, you can upgrade your R installation by following the steps outlined in this article: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/install-R-ec2.html", "most_similar": {"I'm having trouble installing a package on my EC2 instance. The error I get when I try to install the package is: `cannot install the following packages: 'package-name' no packages available in this version of R`. What should I do to fix this issue?": 0.45161290322580644, "I am trying to SSH into my EC2 instance. When I run the `ssh -i my-key.pem ec2-user@ec2-my-public-dns.com` command, I get the following error: `Permission denied (publickey)`. Why am I getting this error, and how can I fix it?": 0.45161290322580644, "I am trying to get my EC2 instance to connect to a MySQL database. When I try to connect using the `mysql -h 55.55.55.55 -u user -p` command, I get the following error: `ERROR 2003 (HY000): Can't connect to MySQL server on '55.55.55.55' (110)`. What should I do to fix this issue?": 0.3962264150943396, "I have an EC2 instance, and I'm trying to SSH into it using a private key. When I run `ssh -i my-key.pem ec2-user@ec2-my-public-dns.com`, I get the following error: `Permission denied (publickey)`. How can I fix this issue?": 0.3870967741935484, "I'm trying to run a Python script on a remote server. I'm getting an error: \"ImportError: No module named 'requests'\". How can I fix this?": 0.32432432432432434, "I am trying to SSH into my EC2 instance using a private key. I ran the `chmod 400 my-key.pem` command to set the permissions, but I still cannot SSH into the EC2 instance. What should I do?": 0.3023255813953488, "I am trying to run the following code in Python: ```python def f(x): return x + 1 print(f(1)) ``` I get an error. What is the problem?": 0.26666666666666666, "I am trying to write a function that takes a list of numbers and returns the sum of the numbers. I wrote the following code in Python:\n```py def sum(lst):\n total = 0\n for i in lst:\n total += i\n return total\n```": 0.25, "I am trying to run an experiment on a cluster on Google Cloud. However, it's not working. I suspect that it has something to do with my cluster configuration. What could be causing this issue?": 0.24096385542168677, "I have a list of numbers and I want to find the maximum number in the list. How can I do that?": 0.23188405797101447}, "avg_similarity_score": 0.08499997373278738} -{"instruction": "Given an array with numbers between 1 and 100, find the first missing number (the smallest one).", "input": "", "output": "int firstMissingPositive(int* nums, int numsSize){ if(numsSize < 1) return 0; int i, j; for(i = 0; i < numsSize; i++){ while(nums[i] > 0 && nums[i] <= numsSize && nums[nums[i] - 1] != nums[i]){ int temp = nums[i]; nums[i] = nums[nums[i] - 1]; nums[nums[i] - 1] = temp; } } for(i = 0; i < numsSize; i++){ if(nums[i] != i + 1) return i + 1; } return numsSize + 1; }", "most_similar": {"Given an array and a number, find the position of the number in the array.": 0.5, "Given an array of numbers, find the maximum sum of any contiguous subarray of the array.": 0.42424242424242425, "Given a list of numbers, find the largest number in the list.": 0.41379310344827586, "Write a function that takes an array of numbers and returns the largest number in the array.": 0.4117647058823529, "You are given an array. You need to find the length of the array.": 0.3870967741935484, "Given an array of integers, find the maximum possible sum that can be obtained by subtracting any number from the array.": 0.36842105263157887, "Given an integer array nums, find the subarray with the largest sum, and return its sum.": 0.3636363636363636, "Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product.": 0.358974358974359, "Given a list of numbers, find the sum of the numbers.": 0.35714285714285715, "Given an array, find the sum of all elements in it.": 0.35714285714285715}, "avg_similarity_score": 0.11464434379864502} -{"instruction": "How can I sort an array by the length of each element?", "input": "", "output": "You can use the sort() function to sort an array by any function you define. For example, to sort the array by the length of each element, you would define a function that returns the length of each element and use that in the sort() function.\n\nFor example: ```\nconst array = [\"\", \"a\", \"aa\", \"aaa\"];\nconst sortedArray = array.sort((a, b) => a.length - b.length);\nconsole.log(sortedArray);\n```", "most_similar": {"How can I rotate an element in CSS?": 0.5, "How can I get the size of a directory?": 0.4761904761904762, "How can I sort a list of integers in Rust?": 0.45454545454545453, "How can I find out the type of a variable?": 0.45454545454545453, "How can I get the number of days between two dates in python?": 0.4, "I have a list of strings. How can I sort the list in reverse order based on the first character of each string?": 0.4, "You are given an array. You need to find the length of the array.": 0.3846153846153846, "How can I find the index of an item in an array in c++?": 0.3846153846153846, "How do I get the first element of a list?": 0.3636363636363636, "How do I find the fibonacci number of a number?": 0.3636363636363636}, "avg_similarity_score": 0.12010525607661793} -{"instruction": "Given a string, count the number of words end with 'y' or 'z' .", "input": "", "output": "def count_yz(string):\nwords = string.split()\nreturn len([word for word in words if word.endswith(('y', 'z'))])", "most_similar": {"Given a string, write a program to count the number of unique characters.": 0.5384615384615384, "Given a string s, return the number of palindromic substrings in it.": 0.48000000000000004, "Given a string, return the number of vowels used in the text.": 0.48000000000000004, "Write a python function that returns the number of words in a given string.": 0.3703703703703704, "Given a string `s`, find the length of the longest substring without repeating characters.": 0.3703703703703704, "Given a binary array, find the maximum number of consecutive 1s in this array.": 0.3703703703703704, "Write a Python program to count the number of matching parenthesis in a given expression.": 0.3571428571428571, "Given a string, write a program to reverse the string.": 0.34782608695652173, "Write a function that takes a string and returns the number of vowels in the string.": 0.3448275862068966, "How do you count the number of items in a list?": 0.33333333333333337}, "avg_similarity_score": 0.14258602195102887} -{"instruction": "How can I convert the string \u201chello\u201d to 104, 101, 108, 108, 111 in python?", "input": "", "output": "For example, ```hello = \"hello\"```\nthen ```[ord(i) for i in hello]``` will return ```[104, 101, 108, 108, 111]```", "most_similar": {"How can I convert string to integer in c++?": 0.5833333333333334, "How do I convert a string to a number in Python?": 0.5384615384615385, "How can I get the current date and time in Python?": 0.4615384615384615, "How can I get the first 1000 prime numbers in Python?": 0.4615384615384615, "How can I get the number of days between two dates in python?": 0.42857142857142855, "How can I find the maximum and minimum value in a list using Python?": 0.4137931034482759, "How can I compare a character in a string to an integer in c++?": 0.4137931034482759, "How do you find the length of a string in Python?": 0.3846153846153846, "How can I find the first repeated word in a string?": 0.3846153846153846, "How do I get the power of a number in python?": 0.3846153846153846}, "avg_similarity_score": 0.11505112301574329} -{"instruction": "Given a 2d array, print the array in a snake pattern. For example, the following array:\n```py\n[[1, 2, 3, 4, 5],\n[6, 7, 8, 9, 10],\n[11, 12, 13, 14, 15],\n[16, 17, 18, 19, 20]]\n```\nshould print as:\n```py\n[1, 2, 3, 4, 5, 10, 15, 20, 19, 18, 17, 16, 11, 6, 7, 8, 9, 14, 13, 12]\n```", "input": "", "output": "```py\narr = [\n [1, 2, 3, 4, 5],\n [6, 7, 8, 9, 10],\n [11, 12, 13, 14, 15],\n [16, 17, 18, 19, 20]\n]\n\nfinal_arr = []\n\nfor i in range(len(arr)):\n if i % 2 == 0:\n for j in range(len(arr[i])):\n final_arr.append(arr[i][j])\n else:\n for j in range(len(arr[i])-1, -1, -1):\n final_arr.append(arr[i][j])\n\nprint(final_arr)\n\n```", "most_similar": {"How to make a python program that will print the following pattern?\n```\n1\n2 3\n4 5 6\n7 8 9 10\n11 12 13 14 15\n```": 0.43181818181818177, "How to make a python program that will print the following pattern?\n```\n1\n2 3\n4 5 6\n7 8 9 10\n11 12 13 14 15\n16 17 18 19 20 21\n22 23 24 25 26 27 28\n29 30 31 32 33 34 35 36\n37 38 39 40 41 42 43 44 45\n46 47 48 49 50 51 52 53 54 55\n```": 0.37500000000000006, "Given an integer n, return a list of its multiples up to n, sorted in ascending order. The items in the list should be integers and not strings. For example, if n is 7, your function should return [1, 2, 3, 4, 5, 6, 7] and not ['1', '2', '3', '4', '5', '6', '7'].": 0.3478260869565217, "Write a program that prints the following pattern:\n```\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7\n1 2 3 4 5 6\n1 2 3 4 5\n1 2 3 4\n1 2 3\n1 2\n1\n```": 0.34285714285714286, "What is the output of the following code?\n```\na = 1\nb = 2\nc = 3\nd = 4\ne = 5\nf = 6\ng = 7\nh = 8\ni = 9\nj = 10\nk = 11\nl = 12\nm = 13\nn = 14\no = 15\np = 16\nq = 17\nr = 18\ns = 19\nt = 20\nu = 21\nv = 22\nw = 23\nx = 24\ny = 25\nz = 26\n\nprint(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z)\n```": 0.32432432432432434, "I need to sum all the values in the following list: `[1,2,3,4,5,6,7,8,9]`.": 0.32098765432098764, "How to make a python program that will print the following pattern?\n```\n1\n1 2\n1 2 3\n1 2 3 4\n1 2 3 4 5\n```": 0.29545454545454547, "Write a program that prints the following pattern:\n```\n1\n2 4\n3 5 7\n6 8 10 12\n```": 0.2784810126582279, "What will be the output of the following code? ```py a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] b = a[2:8:2] c = a[:8:2] d = a[2:] e = a[:8] f = a[::] g = a[2:8:3] h = a[2:8:2] print(b) print(c) print(d) print(e) print(f) print(g) print(h) ```": 0.2764227642276423, "Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i.\n```py\nFor example, if our input was [1, 2, 3, 4, 5], the expected output would be [120, 60, 40, 30, 24]. If our input was [3, 2, 1], the expected output would be [2, 3, 6].\n```": 0.26865671641791045}, "avg_similarity_score": 0.08419634857855542} -{"instruction": "Given a linked list, determine if it has a cycle in it.", "input": "", "output": "```py\nclass Solution:\n def hasCycle(self, head: ListNode) -> bool:\n if not head:\n return False\n slow = fast = head\n while fast and fast.next:\n slow = slow.next\n fast = fast.next.next\n if slow == fast:\n return True\n return False\n```", "most_similar": {"Given a string s, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.": 0.41379310344827586, "What is the difference between a list and a tuple in Python?": 0.3333333333333333, "Given a list of numbers, find the largest number in the list.": 0.3333333333333333, "Given a string s, return the number of palindromic substrings in it.": 0.3333333333333333, "Given a string, write a program to check whether it is a palindrome.": 0.32, "How do I print a list in Python?": 0.3, "Write a python code for a linked list": 0.3, "Given a list of integers, return a list of those numbers squared and the product added to 10, sorted in descending order.": 0.29411764705882354, "You are given a list of numbers. Return the sum of the numbers. If the input is invalid, return a user-friendly error message.": 0.2777777777777778, "Write a Python function to concatenate all elements in a list into a string and return it.": 0.27586206896551724}, "avg_similarity_score": 0.119408121203796} -{"instruction": "There is an integer array nums sorted in ascending order (with distinct values). Prior to being passed to your function, nums is possibly rotated at an unknown pivot index k (1 <= k < nums.length) such that the resulting array is [nums[k], nums[k+1], ..., nums[n-1], nums[0], nums[1], ..., nums[k-1]] (0-indexed). For example, [0,1,2,4,5,6,7] might be rotated at pivot index 3 and become [4,5,6,7,0,1,2]. Given the array nums after the possible rotation and an integer target, return the index of target if it is in nums, or -1 if it is not in nums. You must write an algorithm with O(log n) runtime complexity.", "input": "", "output": "```py\nclass Solution:\n def search(self, nums: List[int], target: int) -> int:\n left = 0\n right = len(nums) - 1\n while left <= right:\n mid = (left + right) // 2\n if nums[mid] == target:\n return mid\n if nums[left] <= nums[mid]:\n if nums[left] <= target < nums[mid]:\n right = mid - 1\n else:\n left = mid + 1\n else:\n if nums[mid] < target <= nums[right]:\n left = mid + 1\n else:\n right = mid - 1\n return -1\n```", "most_similar": {"Given an integer n, return a list of its multiples up to n, sorted in ascending order. The items in the list should be integers and not strings. For example, if n is 7, your function should return [1, 2, 3, 4, 5, 6, 7] and not ['1', '2', '3', '4', '5', '6', '7'].": 0.22598870056497175, "Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0. Not": 0.20512820512820515, "Given an array of n integers nums, a 132 pattern is a subsequence of three integers nums[i], nums[j] and nums[k] such that i < j < k and nums[i] < nums[k] < nums[j]. Return true if there is a 132 pattern in nums, otherwise, return false.": 0.19883040935672514, "Write a program that prints the following pattern:\n```\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7\n1 2 3 4 5 6\n1 2 3 4 5\n1 2 3 4\n1 2 3\n1 2\n1\n```": 0.19161676646706588, "Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 is the sequence of the first 10 ugly numbers. Note that 1 is typically treated as an ugly number.": 0.1807909604519774, "Given a 2d array, print the array in a snake pattern. For example, the following array:\n```py\n[[1, 2, 3, 4, 5],\n[6, 7, 8, 9, 10],\n[11, 12, 13, 14, 15],\n[16, 17, 18, 19, 20]]\n```\nshould print as:\n```py\n[1, 2, 3, 4, 5, 10, 15, 20, 19, 18, 17, 16, 11, 6, 7, 8, 9, 14, 13, 12]\n```": 0.1739130434782609, "Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i.\n```py\nFor example, if our input was [1, 2, 3, 4, 5], the expected output would be [120, 60, 40, 30, 24]. If our input was [3, 2, 1], the expected output would be [2, 3, 6].\n```": 0.173469387755102, "A zero-indexed array A consisting of N different integers is given. The array contains all integers in the range [0, N - 1].\n\nSeveral copies of the array A are created, and in every copy exactly one element is changed. The elements are changed in the following way:\n\nin the first copy, the element at index 0 is changed to 0;\nin the second copy, the element at index 1 is changed to 1;\nin the third copy, the element at index 2 is changed to 2;\n...\nin the N-1 copy, the element at index N - 1 is changed to N - 1.\nThe changes are applied in the same order as the described: first the element at index 0 is changed, then the element at index 1 is changed, and so on.\n\nReturn the number of the copy, in which the maximum number of changes is applied.": 0.16974169741697417, "Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would have exactly one solution.": 0.16969696969696968, "Given an integer array nums, return the number of reverse pairs in the array. A reverse pair is a pair (i, j) where 0 <= i < j < nums.length and nums[i] > 2 * nums[j].": 0.1656050955414013}, "avg_similarity_score": 0.06340588070144756} -{"instruction": "Given an integer n, return the number of trailing zeroes in n!.", "input": "", "output": "```py\nclass Solution:\n def trailingZeroes(self, n: int) -> int:\n cnt = 0\n while n > 0:\n n //= 5\n cnt += n\n return cnt\n```", "most_similar": {"Given a string, return the number of vowels used in the text.": 0.5, "Given a string s, return the number of palindromic substrings in it.": 0.5, "Given an array, find the sum of all elements in it.": 0.43478260869565216, "Given an array nums of size n, return the majority element.": 0.43478260869565216, "Given a number N, write a program to find the sum of all the digits in N.": 0.41379310344827586, "Given a binary array, find the maximum number of consecutive 1s in this array.": 0.3846153846153846, "Find the total number of days in a year.": 0.380952380952381, "Given an array and a number, find the position of the number in the array.": 0.3703703703703704, "Given an array A of integers, return the number of (contiguous, non-empty) subarrays that have a sum divisible by K.": 0.36363636363636365, "Given an integer array nums, return the number of reverse pairs in the array. A reverse pair is a pair (i, j) where 0 <= i < j < nums.length and nums[i] > 2 * nums[j].": 0.3478260869565218}, "avg_similarity_score": 0.13176575455927825} -{"instruction": "Given an array of integers, return the index of the first element that is larger than its neighbours. If there is no such element, return -1.", "input": "", "output": "```py def first_larger_neighbour(arr):\n for i in range(len(arr)):\n if i == 0 and arr[i] > arr[i+1]:\n return i\n elif i == len(arr)-1 and arr[i] > arr[i-1]:\n return i\n elif arr[i] > arr[i-1] and arr[i] > arr[i+1]:\n return i\n return -1\nprint(first_larger_neighbour([2, 4, 1, 2, 7, 4, 6, 9, 1]))```", "most_similar": {"Given an array of integers, find the pair of adjacent elements that has the largest product and return that product.": 0.3913043478260869, "Given an array of integers, return indices of the two numbers such that they add up to a specific target.": 0.3913043478260869, "Given an array A of integers, return the number of (contiguous, non-empty) subarrays that have a sum divisible by K.": 0.3829787234042554, "Given an array nums of size n, return the majority element.": 0.37837837837837834, "Given an array of integers nums, write a method that returns the \"pivot\" index of this array.": 0.372093023255814, "You are given a list of numbers. Return the sum of the numbers. If the input is invalid, return a user-friendly error message.": 0.35999999999999993, "Given an array of integers, return the largest sum of non-adjacent numbers. Numbers can be 0 or negative.": 0.35555555555555557, "Given the `head` of a singly linked list, return the middle node of the linked list. If there are two middle nodes, return the second middle node.": 0.33962264150943394, "Given an array of numbers, find the maximum sum of any contiguous subarray of the array.": 0.33333333333333337, "Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i.": 0.3225806451612903}, "avg_similarity_score": 0.11344953562808364} -{"instruction": "Write a python code to remove duplicates from an unsorted linked list", "input": "", "output": "```py class Node:\n def __init__(self, data):\n self.data = data\n self.next = None\ndef removeDuplicates(head):\n data = set()\n dummy = Node(-1)\n prev = dummy\n dummy.next = head\n while head:\n if head.data in data:\n prev.next = head.next\n head = head.next\n else:\n data.add(head.data)\n prev = head\n head = head.next\n return dummy.next\nhead = Node(1)\nhead.next = Node(2)\nhead.next.next = Node(3)\nhead.next.next.next = Node(1)\nhead.next.next.next.next = Node(2)\nhead.next.next.next.next.next = Node(3)\nprint(\"Linked List after removing duplicates : \")\nprintList(removeDuplicates(head))\n# This code is contributed by Smitha Dinesh Semwal```", "most_similar": {"Write a Python program to remove all duplicates from a list in Python": 0.64, "Write a python code for a linked list": 0.6, "Write a python code to find the minimum value in a list.": 0.5, "Write a python code to implement quick sort": 0.5, "Write a python code for a stack using an array": 0.45454545454545453, "Write a Python program to find the maximum and minimum number from a given list.": 0.4444444444444445, "Write a Python program to find the highest 3 values from a list of values.": 0.4444444444444445, "Write a python code to find the area of a circle.": 0.43478260869565216, "Write a Python program to create a dictionary from a string.": 0.43478260869565216, "Write a Python function to reverse a given list of integers.": 0.43478260869565216}, "avg_similarity_score": 0.14622498848891802} -{"instruction": "Find the most frequent item in an array", "input": "", "output": "```py def most_frequent(arr):\n counter = {}\n for i in arr:\n if i in counter:\n counter[i] += 1\n else:\n counter[i] = 1\n max_count = 0\n res = None\n for i in counter:\n if counter[i] > max_count:\n res = i\n max_count = counter[i]\n return res\nprint(most_frequent([1, 3, 5, 3, 7, 5, 3, 7, 8, 9, 9, 9, 9]))```", "most_similar": {"How do I find the maximum value in an array?": 0.5555555555555556, "How can I find the index of an item in an array in c++?": 0.5454545454545454, "Write a program to find the maximum value in an array": 0.5263157894736842, "How to find the sum of all numbers in an array?": 0.5263157894736842, "How to find the largest number in an array in Java?": 0.5263157894736842, "How do I find the standard deviation of all elements in an array?": 0.4761904761904762, "How do I find the first element that satisfies a condition in an array?": 0.45454545454545453, "Write a function that returns the smallest integer in an array.": 0.4210526315789474, "How do I find the index of the first occurrence of a value in an array?": 0.4166666666666667, "How do you find the index of an item in a list?": 0.4}, "avg_similarity_score": 0.11147687110670255} -{"instruction": "Take a string as an input and reverse the string word by word.", "input": "", "output": "```py def reverse_string(string):\n return ' '.join(reversed(string.split(' ')))\n\nprint(reverse_string('This is a test string'))```", "most_similar": {"Write a function that takes a string as input and reverse only the vowels of a string.": 0.5333333333333333, "Write a Python function that takes a string as input and returns the string in reverse order.\n'Hello'": 0.45161290322580644, "Given a string, write a program to reverse the string.": 0.4347826086956522, "Write a JavaScript program to convert a string to an array, separating the elements by spaces.": 0.3448275862068966, "Write a function that takes a string and returns the number of vowels in the string.": 0.3448275862068966, "Write a Python function that takes a number as input and returns the square of that number.": 0.33333333333333337, "Write a Java program that takes 5 numbers as input and prints the sum of these numbers.": 0.33333333333333337, "How do I make a function that takes a string and returns a list of the words in the string?": 0.30303030303030304, "Write a function that takes a string and returns a new string with the first letter of each word capitalized.": 0.30303030303030304, "Write a Python function that takes two numbers as input and returns their sum.": 0.29629629629629634}, "avg_similarity_score": 0.12107989868822452} -{"instruction": "Check if two strings are anagram or not", "input": "", "output": "```py def is_anagram(s1, s2):\n if len(s1) != len(s2):\n return False\n count1 = {}\n count2 = {}\n for i in range(len(s1)):\n if s1[i] in count1:\n count1[s1[i]] += 1\n else:\n count1[s1[i]] = 1\n if s2[i] in count2:\n count2[s2[i]] += 1\n else:\n count2[s2[i]] = 1\n return count1 == count2\n\nprint(is_anagram('apple', 'papel'))```", "most_similar": {"Write a Python function to check if a given number is a prime number or not.": 0.3333333333333333, "Write a function to check if a number is divisible by 7 or 5 and not 3.": 0.31999999999999995, "Write a Python function to check whether a passed string is palindrome or not.": 0.2727272727272727, "Write a Python function to check if a number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence.": 0.24242424242424243, "How do I check if a list is empty?": 0.23529411764705882, "Given two strings s and t, return true if t is an anagram of s, and false otherwise.": 0.23076923076923078, "Write a Python function that returns True if the specified list and the specified value are not empty.": 0.23076923076923078, "Write a function that returns True if the string is a palindrome or False if it is not.": 0.23076923076923078, "Write a Python function to check if a given word is a palindrome or not. A palindrome is a word that reads the same backwards as forwards.": 0.22857142857142856, "How do I check if a string contains a substring?": 0.22222222222222224}, "avg_similarity_score": 0.03404320635752665} -{"instruction": "Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).", "input": "", "output": "```py def min_window_substring(string, pattern):\n windowStart = 0\n patternMap = {}\n for char in pattern:\n if char not in patternMap:\n patternMap[char] = 0\n patternMap[char] += 1\n\n charFrequency = len(patternMap)\n minLength = float('inf')\n for windowEnd in range(len(string)):\n rightChar = string[windowEnd]\n if rightChar in patternMap:\n patternMap[rightChar] -= 1\n if patternMap[rightChar] == 0:\n charFrequency -= 1\n\n while charFrequency == 0:\n if windowEnd - windowStart + 1 < minLength:\n minLength = windowEnd - windowStart + 1\n ans = string[windowStart:windowEnd + 1]\n\n leftChar = string[windowStart]\n windowStart += 1\n if leftChar in patternMap:\n if patternMap[leftChar] == 0:\n charFrequency += 1\n patternMap[leftChar] += 1\n\n return ans\n\nprint(min_window_substring('cabwefgewcwaefgcf', 'cae'))```", "most_similar": {"Given a number N, write a program to find the sum of all the digits in N.": 0.41860465116279066, "Given a string `s`, find the length of the longest substring without repeating characters.": 0.4, "Given a string s, return the longest palindromic substring in s.": 0.37837837837837834, "Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.": 0.37500000000000006, "Given a string with repeated characters. Find the largest window that can be generated with all distinct characters.": 0.3636363636363637, "Given an array and a number, find the position of the number in the array.": 0.3414634146341463, "Given two strings s and t, determine if they are isomorphic. Two strings s and t are isomorphic if the characters in s can be replaced to get t.": 0.32727272727272727, "Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.": 0.32653061224489793, "Given a string, return the number of vowels used in the text.": 0.3157894736842105, "Given a string s, return the number of palindromic substrings in it.": 0.3157894736842105}, "avg_similarity_score": 0.1329537634422876} -{"instruction": "Given two integer arrays preorder and inorder where preorder is the preorder traversal of a binary tree and inorder is the inorder traversal of the same tree, construct and return the binary tree.", "input": "", "output": "```py class TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right\nclass Solution:\n def buildTree(self, preorder, inorder):\n mapping = {val: idx for idx, val in enumerate(inorder)}\n def helper(left, right):\n if left > right:\n return None\n rootVal = preorder[self.preIdx]\n self.preIdx += 1\n root = TreeNode(rootVal)\n idx = mapping[rootVal]\n root.left = helper(left, idx-1)\n root.right = helper(idx+1, right)\n return root\n self.preIdx = 0\n return helper(0, len(inorder)-1)\n\npreorder = [3,9,20,15,7]\ninorder = [9,3,15,20,7]\nresult = Solution().buildTree(preorder, inorder)\nprint(result)```", "most_similar": {"Given the `root` of a binary tree, return the inorder traversal of its nodes' values.": 0.41666666666666663, "Given the `root` of a binary tree, return the inorder traversal of its nodes' values.\n# Definition for a binary tree node.\nclass TreeNode:\n def __init__(self, val=0, left=None, right=None):\n self.val = val\n self.left = left\n self.right = right": 0.32432432432432434, "Given the root of a binary tree, the level of its root is 1, the level of its children is 2, and so on. Return the smallest level X such that the sum of all the values of nodes at level X is maximal.": 0.3116883116883117, "Given the `head` of a singly linked list, return the middle node of the linked list. If there are two middle nodes, return the second middle node.": 0.3, "What is the difference between a binary search tree and a red-black tree?": 0.2978723404255319, "Given an array and a number, find the position of the number in the array.": 0.29166666666666663, "Given two arrays of integers, determine whether they have the same elements with the same multiplicities.": 0.2857142857142857, "What is the sum of the ASCII values of all the letters in the word \"apple\"?": 0.2857142857142857, "Given two integers n and k, return all possible combinations of k numbers out of the range [1, n]. You may return the answer in any order.": 0.26666666666666666, "Given an array of integers, find the pair of adjacent elements that has the largest product and return that product.": 0.26415094339622636}, "avg_similarity_score": 0.12512334160379893} -{"instruction": "Given a string s, return all the palindromic permutations (without duplicates) of it. Return an empty list if no palindromic permutation could be form.", "input": "", "output": "```py def palindromicPermutation(s):\n # Write your code here\n if not s:\n return [''];\n if len(s) == 1:\n return s;\n mid = len(s) // 2;\n first_part = s[:mid];\n second_part = s[mid:];\n result = [];\n def is_palindromic(string):\n left = 0;\n right = len(string) - 1;\n while left <= right:\n if string[left] != string[right]:\n return False;\n left += 1;\n right -= 1;\n return True;\n def helper(left, right, current, result):\n if left > right:\n if is_palindromic(current):\n result.append(current);\n return;\n helper(left + 1, right, current + left, result);\n helper(left, right - 1, current + right, result);\n helper(0, mid - 1, '', result);\n helper(mid, len(s) - 1, '', result);\n return result\ns = 'abc'\nprint(palindromicPermutation(s))```", "most_similar": {"Given a string s, return the number of palindromic substrings in it.": 0.4444444444444444, "Given a string s, return the longest palindromic substring in s.": 0.4, "Given a string, return the number of vowels used in the text.": 0.3333333333333333, "Given a string s, return true if the s can be palindrome after deleting at most one character from it.": 0.31818181818181823, "Given a string `s`, find the length of the longest substring without repeating characters.": 0.3157894736842105, "Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.": 0.30434782608695654, "Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.": 0.2978723404255319, "Write a Python program to generate all permutations of a given list.": 0.2777777777777778, "Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words.": 0.27586206896551724, "Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s.": 0.27450980392156865}, "avg_similarity_score": 0.11801829648557138} -{"instruction": "Calculate the total cost for this order.\nPrice Per Pound\tWeight\tCost\n$0.50\t3\t$1.50\n$1.00\t1\t$1.00\n$2.00\t0.25\t$0.50\n$2.50\t0.75\t$1.88\n$3.00\t0.125\t$0.38\n$3.50\t0.625\t$2.31\n$4.00\t1.125\t$4.50\n$4.50\t0.5\t$2.25\n$5.00\t0.75\t$3.75", "input": "", "output": "Total Cost = $14.43", "most_similar": {"Write a program that prints the following pattern:\n```\n1\n2 1\n3 2 1\n4 3 2 1\n5 4 3 2 1\n6 5 4 3 2 1\n7 6 5 4 3 2 1\n```": 0.26, "How to make a python program that will print the following pattern?\n```\n1\n1 2\n1 2 3\n1 2 3 4\n1 2 3 4 5\n```": 0.2417582417582417, "Write a program that prints the following pattern:\n```\n1 2 3 4 5 6 7 8\n1 2 3 4 5 6 7\n1 2 3 4 5 6\n1 2 3 4 5\n1 2 3 4\n1 2 3\n1 2\n1\n```": 0.2222222222222222, "Sort the following list of tuples by their second item and then by their first item: ```[(4, 0), (0, 3), (0, 2), (2, 6), (3, 4), (5, 2), (1, 6)]```": 0.19148936170212766, "Find the output of this code.\n```\ndef is_prime(n):\n if n < 2:\n return False\n for i in range(2, n):\n if n % i == 0:\n return False\n return True\n\ndef prime_factorize(n):\n factors = []\n factor = 2\n while n > 1:\n if n % factor == 0:\n factors.append(factor)\n n /= factor\n elif factor == 2:\n factor = 3\n else:\n factor += 2\n return factors\n\nprint(prime_factorize(100))\n```": 0.15873015873015875, "What is the output of this code?\n```\ndef sum(numbers):\n result = 0\n for number in numbers:\n result = result + number\n return result\n\ndef len(numbers):\n result = 0\n for number in numbers:\n result = result + 1\n return result\n\ndef avg(numbers):\n sum = sum(numbers)\n length = len(numbers)\n return sum/length\n\nprint(avg([1,2,3,4,5]))\n```": 0.15254237288135594, "Given an integer n, return a list of its multiples up to n, sorted in ascending order. The items in the list should be integers and not strings. For example, if n is 7, your function should return [1, 2, 3, 4, 5, 6, 7] and not ['1', '2', '3', '4', '5', '6', '7'].": 0.15254237288135594, "What does this Python code do? ``` import random def montecarloPi(calcs): hits = 0 for i in range(calcs): x = random.random() y = random.random() if (x**2 + y**2) < 1: hits = hits + 1 return 4.0 * hits / calcs print(montecarloPi(10000)) ```": 0.1523809523809524, "Tell me the 10th term of the sequence 1, 1, 2, 3, 5, 8, 13, 21, 34, ...?": 0.14814814814814814, "Convert this list into a list of sets: [[1, 2, 3], [4, 5, 6], [7, 8, 9]]": 0.14814814814814814}, "avg_similarity_score": 0.03338257378742549} -{"instruction": "Does the following code raise an exception? Please provide the exact error message.\ndef main():\n text_file = open('some_text.txt', 'w')\n text_file.write('hello world')", "input": "", "output": "Yes, it raises a FileNotFoundError exception. ```python Traceback (most recent call last):\n File \"script.py\", line 4, in \n text_file = open('some_text.txt', 'w')\nFileNotFoundError: [Errno 2] No such file or directory: 'some_text.txt' ``` This code tries to open a file named `some_text.txt` in write mode. The `some_text.txt` file does not exist in the current directory. If this file did exist, the program would overwrite its contents with the string `hello world`.", "most_similar": {"If we have a string \"Hello, world!\", what will be the output of this code? ```py def echo(text): print(text) echo(\"Hello, world!\") ```": 0.27450980392156865, "Write a python code snippet to print the following text.\nHello World!": 0.2564102564102564, "What does the following JavaScript code print?": 0.23529411764705882, "What is the python code to print hello world?": 0.2222222222222222, "Consider the following code:\ndef f(x):\n return x + 1\nf(x) = x + 1\n\nWhat is the error in this code?": 0.20833333333333334, "In Python, what does the following code output?\n[3, 4, 5][-1]": 0.20512820512820512, "What is the output of the following code?\n```python\ndef foo():\n print(\"foo\")\n\ndef bar():\n print(\"bar\")\n\ndef main():\n foo()\n bar()\n\nmain()\n```": 0.20408163265306123, "What does the following code print?\n\n```\nfor i in range(4):\n print(i)\n```": 0.2, "What does the following python code print?\n```py\nprint(f'500:{500:08d}')\n```": 0.2, "What does the following python code do?\n```python def sum_divisible_by_three(lst):\n\treturn sum(x for x in lst if x % 3 == 0)\n ```": 0.1923076923076923}, "avg_similarity_score": 0.06673189452022434} -{"instruction": "What will be the output of the following program?\n\ndef get_hello_world():\n print(\"Hello World!\")\n\ndef main():\n get_hello_world()", "input": "", "output": "```python\n\ndef get_hello_world():\n print(\"Hello World!\")\n\ndef main():\n get_hello_world()\n\nmain()\n```\nHello World!", "most_similar": {"What is the output of the following code?\n```python\ndef foo():\n print(\"foo\")\n\ndef bar():\n print(\"bar\")\n\ndef main():\n foo()\n bar()\n\nmain()\n```": 0.46511627906976744, "What is the output of the following code?\n```py\ndef get_cube(x):\n return x * x * x\n\nprint(get_cube(get_cube(2)))\n```": 0.4545454545454545, "If we have a string \"Hello, world!\", what will be the output of this code? ```py def echo(text): print(text) echo(\"Hello, world!\") ```": 0.4444444444444445, "What is the output of the following code? ```py def a(): print(\"a\") b = a def c(): print(\"c\") b() ```": 0.4390243902439024, "What is the output of the following code?\n```python\ndef func(x):\n return x + 1\n\ndef main():\n x = 1\n y = func(x)\n print(y)\n\nmain()\n```": 0.391304347826087, "What is the output of the following code?\n```py\nnum = 3\n\ndef func(num):\n num += 4\n\nfunc(num)\nprint(num)\n```": 0.3902439024390244, "What is the output of the following code? ```py def add_five(x): x += 5 return x print(add_five(2)) ```": 0.38095238095238093, "What is the output of the following python code?\n```python\ndef function(a):\n if a > 0:\n print('Positive')\n else:\n print('Negative')\n\nfunction(0)\n```": 0.3636363636363636, "What is the output of the following code?\n```python\ndef foo():\n x = 1\n def bar():\n x = 2\n return x\n return bar()\nprint(foo())\n```": 0.3636363636363636, "What is the output of the following code?\n```py\nnum = 5\nwhile num >= 0:\n print('number is:', num)\n num -= 1\n```": 0.3414634146341463}, "avg_similarity_score": 0.09822514394219192} -{"instruction": "Please translate the following Python code into shell script.\nimport sys\n\nif __name__ == '__main__':\n for filename in sys.argv[1:]:\n with open(filename, 'r') as f:\n sys.stdout.write(f.read())", "input": "", "output": "```\n#!/bin/bash\n\nfor file in *.txt; do\n echo \"$file\"\n cat \"$file\"\ndone\n```\nHere's a summary of the changes made: 1. Changed the shebang to `python` instead of `bash`. 2. Changed the loop to use the scandir() function to iterate through the files in the current directory. 3. Added a condition to print the file name before printing the file contents. 4. Added the `with open(file, 'r') as f:` context manager to open and read the contents of the current file. 5. Added `sys.stdout.write(f.read())` to print the file contents. Make sure to test the modified code to ensure it still meets your requirements.", "most_similar": {"What is the purpose of the following code?\n```python\nif __name__ == '__main__':\n import sys\n sys.dont_write_bytecode = True\n from app import app\n app.run()\n```": 0.3214285714285714, "Translate the following code from python in Java.": 0.2564102564102564, "What does the following python code print?\n```py\nprint(f'500:{500:08d}')\n```": 0.22727272727272727, "What does the following code print?\n\n```\nfor i in range(4):\n print(i)\n```": 0.22727272727272727, "What does the following python code do?\n```python def sum_divisible_by_three(lst):\n\treturn sum(x for x in lst if x % 3 == 0)\n ```": 0.21428571428571427, "What is the output of the following Python code? ```py def f(x): return x + 1 def g(x): return x * 2 print(g(f(3))) ```": 0.21052631578947367, "Does the following code raise an exception? Please provide the exact error message.\ndef main():\n text_file = open('some_text.txt', 'w')\n text_file.write('hello world')": 0.20689655172413793, "Suggest a completion for the following python code.": 0.20512820512820512, "I am trying to run the following code in Python: ```python def f(x): return x + 1 print(f(1)) ``` I get an error. What is the problem?": 0.20338983050847456, "Given the following code, what does it print? ```python import requests url = \"https://example.com\" r = requests.get(url) if r.status_code != 200: print(\"error\") else: print(r.text) ```": 0.19672131147540983}, "avg_similarity_score": 0.07308061846679709} -{"instruction": "How can you fix the following code?\n```\ndef get_hello_world():\n print(\"Hello World!\")\n\ndef main():\n get_hello_world()\n```", "input": "", "output": "```\ndef get_hello_world():\n print(\"Hello World!\")\n\ndef main():\n get_hello_world()\n\nmain()\n```\nHere's a summary of the changes made: 1. Added `main()` to call the `main()` function. Make sure to test the modified code to ensure it still meets your requirements.", "most_similar": {"What will be the output of the following program?\n\ndef get_hello_world():\n print(\"Hello World!\")\n\ndef main():\n get_hello_world()": 0.7, "What is the python code to print hello world?": 0.35714285714285715, "What is the output of the following code?\n```python\ndef foo():\n print(\"foo\")\n\ndef bar():\n print(\"bar\")\n\ndef main():\n foo()\n bar()\n\nmain()\n```": 0.3414634146341463, "What is the output of the following code?\n```py\ndef get_cube(x):\n return x * x * x\n\nprint(get_cube(get_cube(2)))\n```": 0.3333333333333333, "What does the following JavaScript code print?": 0.3076923076923077, "What is the output of the following code? ```py def a(): print(\"a\") b = a def c(): print(\"c\") b() ```": 0.3076923076923077, "Does the following code raise an exception? Please provide the exact error message.\ndef main():\n text_file = open('some_text.txt', 'w')\n text_file.write('hello world')": 0.30434782608695654, "Rewrite the following code in Java:\n```py\nnum = 5\n\ndef func(num):\n num += 5\n\nprint(num)\n```": 0.2857142857142857, "If we have a string \"Hello, world!\", what will be the output of this code? ```py def echo(text): print(text) echo(\"Hello, world!\") ```": 0.27906976744186046, "How to make this code work? ```py def foo(): print('foo') def bar(function): function() bar(foo) ```": 0.27777777777777773}, "avg_similarity_score": 0.07812618472932557} -{"instruction": "If the input is a string, then return the reversed string. Else, if the input is an integer, then return the reversed integer.", "input": "", "output": "def solution(input_string):\n if isinstance(input_string, str):\n return input_string[::-1]\n else:\n return int(str(input_string)[::-1])", "most_similar": {"You are given a list of numbers. Return the sum of the numbers. If the input is invalid, return a user-friendly error message.": 0.3404255319148936, "Write a python program to reverse the case of a string. For example, if the string is Hello World, then the output should be hELLO wORLD.": 0.32653061224489793, "Write a Python program to compute the sum of the three given numbers, if one of the value is 13 then return 0.": 0.30434782608695654, "Write a Python program to get a string made of the first 2 and the last 2 chars from a given a string. If the string length is less than 2, return instead of the empty string.": 0.30000000000000004, "Write a function that reverses a string. The input string is given as an array of characters char[].": 0.2926829268292683, "Write a function that returns True if the string is a palindrome or False if it is not.": 0.2926829268292683, "Write a Python program to find the difference between a specified number and 13, if the number is greater than 13 return double the absolute difference.": 0.28571428571428575, "Given a string, return the number of vowels used in the text.": 0.2857142857142857, "Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.\n\nAn input string is valid if:\nOpen brackets must be closed by the same type of brackets.\nOpen brackets must be closed in the correct order.": 0.28125, "Given the `head` of a singly linked list, return the middle node of the linked list. If there are two middle nodes, return the second middle node.": 0.27999999999999997}, "avg_similarity_score": 0.12953106616000695} -{"instruction": "Is the input array already sorted? If yes, then return 1. If not, then sort the array and return the sorted array.", "input": "", "output": "def solution(array):\n if array == sorted(array):\n return 1\n else:\n return sorted(array)", "most_similar": {"If the input is a string, then return the reversed string. Else, if the input is an integer, then return the reversed integer.": 0.3555555555555555, "Write a Python program to find the first occurrence of a specified value in a given array of integers. Return -1 if the value is not found in the array.": 0.30769230769230765, "What is the difference between the `break` and the `continue` keywords?": 0.30303030303030304, "What is the difference between the `==` and the `.equals()` methods in Java?": 0.29411764705882354, "What is the difference between the if-else statement and the switch statement?": 0.2857142857142857, "What is the difference between the `os.path.isfile()` and the `os.path.exists()` functions in Python?": 0.25641025641025644, "What is the difference between the Docker and Virtual Machine?": 0.25000000000000006, "What are the major differences between the Array and List data structures?": 0.23529411764705885, "The Hamming distance between two integers is the number of positions at which the corresponding bits are different.\nGiven two integers x and y, return the Hamming distance between them.": 0.23076923076923075, "Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.": 0.22727272727272727}, "avg_similarity_score": 0.09821461516745765} -{"instruction": "What is the difference between an interface and an abstract class?", "input": "", "output": "Interfaces define what an object can do, while abstract classes define how an object can do it.", "most_similar": {"What is the difference between a class and an object?": 0.6666666666666666, "What is the difference between an ingress and a persistent volume?": 0.6363636363636364, "What is the difference between `NaN` and `Infinity`?": 0.631578947368421, "What is the difference between `val` and `var` in Kotlin?": 0.5714285714285713, "What is the difference between a relative and absolute path?": 0.5714285714285713, "What is the difference between `git pull` and `git fetch` ?": 0.5714285714285713, "What is the difference between import and from import statements?": 0.5714285714285713, "What is the difference between the Docker and Virtual Machine?": 0.5714285714285713, "What is the difference between virtual environment and conda environment?": 0.5714285714285713, "what is the difference between an angle bracket and a pipe in regular expressions?": 0.56}, "avg_similarity_score": 0.11051368782070317} -{"instruction": "The product of 123 is 729. What is the product of 1234?", "input": "", "output": "```py def product(num):\n product = 1\n for i in range(len(str(num))):\n product *= int(num[i])\n return product\n\nnum = 1234\nproduct_num = product(num)\nprint(product_num)```", "most_similar": {"What is the result of 1 + \"1\"?": 0.4210526315789474, "What is the value of a++b?": 0.4210526315789474, "What is the purpose of a hash table?": 0.4, "What is the result of 4 + 3 * 2?": 0.4, "What is the size of a short integer in c++?": 0.3636363636363636, "What is the purpose of the `float` function in Python?": 0.3636363636363636, "What is the default value of a boolean variable in java?": 0.34782608695652173, "What is the value of the following expression?\n10 + 2 * 3 / 4": 0.3333333333333333, "What is the average salary of a software engineer in the US?": 0.3333333333333333, "Write a python function that returns the sum of the elements of a list.": 0.30769230769230765}, "avg_similarity_score": 0.12961407008064266} -{"instruction": "What is the output of the following python program?", "input": "", "output": "```py class A:\n def __init__(self):\n self.x = \"Test\"\nclass B(A):\n def __init__(self):\n self.y = \"Test\"\n A.__init__(self)\nb = B()\nprint(b.x)\nprint(b.y)\n```", "most_similar": {"What is the purpose of the `float` function in Python?": 0.631578947368421, "What is the output of the code below?\n\n```python import math print(math.sqrt(16))```": 0.5833333333333334, "What is the value of the following expression?\n10 + 2 * 3 / 4": 0.5714285714285715, "What is the output of the following code?\n```python\ndef foo():\n print(\"foo\")\n\ndef bar():\n print(\"bar\")\n\ndef main():\n foo()\n bar()\n\nmain()\n```": 0.5161290322580644, "What is the result of 1 + \"1\"?": 0.5, "What is the output of the following code?\n```python\ndef foo():\n x = 1\n def bar():\n x = 2\n return x\n return bar()\nprint(foo())\n```": 0.5, "What is the value of a++b?": 0.5, "What is the output of the following python code?\n```python\ndef function(a):\n if a > 0:\n print('Positive')\n else:\n print('Negative')\n\nfunction(0)\n```": 0.5, "What is the output of the following code?\n```py\nnum = 3\n\ndef func(num):\n num += 4\n\nfunc(num)\nprint(num)\n```": 0.48275862068965514, "What is the output of the following code? ```py def a(): print(\"a\") b = a def c(): print(\"c\") b() ```": 0.48275862068965514}, "avg_similarity_score": 0.16018171644648121} -{"instruction": "Write a python function that counts the number of occurrences of a substring within a string.", "input": "", "output": "```py def count_substr(string, substring):\n count = 0\n while True:\n index = string.find(substring)\n if index != -1:\n count += 1\n string = string[index + len(substring):]\n else:\n break\n return count\n\nprint(count_substr(\"The quick brown fox jumps over the lazy dog.\", \"the\"))\n```", "most_similar": {"Write a python function that returns the number of words in a given string.": 0.6666666666666666, "Write a function that prints the reverse of a string.": 0.6153846153846154, "Write a python function that returns the sum of the elements of a list.": 0.6000000000000001, "Write a Python function that removes all occurrences of a specified item from a list.": 0.5806451612903225, "Find the number of occurrences of a given word in a string.": 0.5714285714285715, "Write a Python program to find the number of occurrences of a specified element in a given array of integers.": 0.5555555555555556, "Write a Python function that returns a specified number of elements in a list from a specified index.": 0.5294117647058824, "Write a Python function to calculate the factorial of a number.": 0.5185185185185185, "Write a Python program to compute the length of a string.": 0.5185185185185185, "Write a Python function to find the index of the first occurrence of a specified item in a list.": 0.5142857142857142}, "avg_similarity_score": 0.20016020342709195} -{"instruction": "I'm having a hard time understanding what the difference between the const and let keywords are in JavaScript. Can you help me out?", "input": "", "output": "Sure, I'm happy to help! The const keyword is used to declare a constant variable, whereas the let keyword is used to declare a variable that can be reassigned. For example, here is a variable declared with const that cannot be reassigned: ```js const x = 5; x = 10; // This will throw an error ``` If we try to reassign x, it will throw an error. Meanwhile, here's an example of a variable declared with let that can be reassigned: ```js let y = 5; y = 10; // This will not throw an error ``` There are also some differences in the scopes of const and let variables, but I'll leave those for another question.", "most_similar": {"What is the difference between the `break` and the `continue` keywords?": 0.4, "What is the difference between the `==` and the `.equals()` methods in Java?": 0.38888888888888895, "What is the difference between the Docker and Virtual Machine?": 0.35294117647058826, "What is the difference between `val` and `var` in Kotlin?": 0.35294117647058826, "What is the difference between the `os.path.isfile()` and the `os.path.exists()` functions in Python?": 0.34146341463414637, "What is the difference between static and instance variables in C++ programming?": 0.3333333333333333, "What is the difference between a list and a tuple in Python?": 0.3333333333333333, "What is the difference between string, bytes and bytearray types in Python?": 0.3333333333333333, "What are the difference between a float and an int in Python?": 0.3333333333333333, "I want to know what is the difference between abstract classes and interfaces?": 0.32432432432432434}, "avg_similarity_score": 0.12247134515505334} -{"instruction": "Please write a python function that converts a list into a dictionary.", "input": "", "output": "```python def convert_list_to_dict(lst):\n return {i: item for i, item in enumerate(lst)} ```", "most_similar": {"Write a Python function that returns a list of numbers in a specified range.": 0.6153846153846153, "Write a Python function that returns the largest item in a list.": 0.5833333333333334, "Write a python function that sorts a list from large to small.": 0.5833333333333334, "Write a Python function to concatenate all elements in a list into a string and return it.": 0.5517241379310345, "Write a python code for a queue using a dictionary": 0.5454545454545454, "Write a python function that returns a value from a list, selected at random.": 0.5384615384615384, "Write a python function that returns the sum of the elements of a list.": 0.5384615384615384, "Write a Python function that returns a specified number of elements in a list from a specified index.": 0.5333333333333333, "Write a Python function to reverse a given list of integers.": 0.5217391304347826, "Write a Python program to add a key to a dictionary.": 0.5217391304347826}, "avg_similarity_score": 0.1621325930572656} -{"instruction": "Can you explain to me the difference between the String and StringBuilder classes in Java?", "input": "", "output": "Sure! The String class represents a sequence of characters. It is an immutable class, which means that once a String object is created, it cannot be modified. The StringBuilder class is similar, but it is mutable, which means that once created, it can be modified. For example, if I want to add a new character to a String object, I need to create a new String object to represent the new sequence of characters: ```java String str = \"Hello\"; str = str + \"!\"; ``` However, with a StringBuilder object, I can just append the new character to the existing object: ```java StringBuilder str = new StringBuilder(\"Hello\"); str.append('!'); ```", "most_similar": {"What is the difference between the `==` and the `.equals()` methods in Java?": 0.5185185185185186, "What is the difference between string, bytes and bytearray types in Python?": 0.4444444444444445, "Explain the difference between a compiler and an interpreter.": 0.4166666666666667, "What is the difference between a `string` and a `char` data type in C#?": 0.4137931034482759, "What is the difference between the Docker and Virtual Machine?": 0.4, "What is the difference between `val` and `var` in Kotlin?": 0.4, "What is the difference between a pass-by-reference and a pass-by-value in Java?": 0.38709677419354843, "What is the difference between the `break` and the `continue` keywords?": 0.3846153846153846, "What is the difference between the `os.path.isfile()` and the `os.path.exists()` functions in Python?": 0.37500000000000006, "What is the difference between a list and a tuple in Python?": 0.3703703703703704}, "avg_similarity_score": 0.13372050949369946} -{"instruction": "Write me a python script, which generates a random number between 0-9 inclusive and checks if that number is even or odd.", "input": "", "output": "Here is an example script that does this: ```python import random # Generate a random number between 0 and 9 number = random.randint(0, 9) # Check if the number is even if number % 2 == 0: print(\"It's even!\") else: print(\"It's odd!\") ``` This script generates a random number between 0 and 9 and uses the modulo operator to check if the number is even or odd.", "most_similar": {"Write a Rust program that prompts the user to enter a number and then prints whether the number is even or odd.": 0.4444444444444445, "Write a Python function that takes a number as input and returns the square of that number.": 0.39999999999999997, "Write a Python function that takes a string and checks if it contains only consonants.": 0.3684210526315789, "Write a Python program to find the difference between a specified number and 13, if the number is greater than 13 return double the absolute difference.": 0.36734693877551017, "Write me a python script, which reads data from a json file and saves the data in an appropriate data structure.": 0.3636363636363636, "Write a Python function to check if a given number is a prime number or not.": 0.358974358974359, "Write a python program to check if the number is prime.": 0.3529411764705882, "How to generate a random float number between 0 and 1?": 0.3529411764705882, "Write a function in Python that takes a number and prints a right triangle with that many rows.": 0.34146341463414637, "Write a function that creates a list of the multiples of a number between 0 and a limit.": 0.34146341463414637}, "avg_similarity_score": 0.12761319904102217} -{"instruction": "Write a function that checks if an email is valid or not. If the email is valid return a string 'Valid email' else return a string 'Invalid email'.", "input": "", "output": "```python def validate_email(email):\n if '@' in email and '.' in email:\n return 'Valid email'\n else:\n return 'Invalid email' ```", "most_similar": {"Write a function that returns True if the string is a palindrome or False if it is not.": 0.391304347826087, "Write a function that prints the reverse of a string.": 0.3684210526315789, "Write a python function that counts the number of occurrences of a substring within a string.": 0.36363636363636365, "Write a function that takes a string as input and reverse only the vowels of a string.": 0.35555555555555557, "Write a Python function to check if a given number is a Keith number or not. A Keith number is a number which is one less than a perfect square.": 0.3448275862068965, "Write a Python function to check if a number is a Fibonacci number or not. A Fibonacci number is a number in the Fibonacci sequence.": 0.33962264150943394, "Write a Python function to check if a number is a Sphenic number or not. A Sphenic number is a number that can be decomposed into a product of two prime numbers.": 0.3333333333333333, "Write a Python function to check if a given number is a repdigit or not. A repdigit is a positive integer that consists of a single digit repeated one or more times.": 0.3333333333333333, "Write a Python function to check if a given number is a circular prime or not. A circular prime is a prime number that remains a prime when the digits are rotated.": 0.3333333333333333, "Write a Python function that returns true if a string contains any space character.": 0.3333333333333333}, "avg_similarity_score": 0.14565315226884812} -{"instruction": "Write a python script to convert the following dictionary to a set of dictionary keys.", "input": "", "output": "```python def get_keys(dict):\n return set(dict.keys()) ```", "most_similar": {"Write a Python program to add a key to a dictionary.": 0.5384615384615385, "Write a Python function to find the largest number in a dictionary.": 0.5185185185185186, "Write a script to output the mean of a list of integers.": 0.5185185185185186, "Write a python script that prints the following pattern:\n```\n*\n**\n***\n****\n*****\n```": 0.5, "Write a Python function to find the smallest number from a sequence of numbers.": 0.4827586206896552, "Write a script to output the factorial of an integer.": 0.48, "Write a Python program to find the highest 3 values from a list of values.": 0.4666666666666667, "Write a bash script to find the average of 4 numbers?": 0.4615384615384615, "Write a Python program to compute the length of a string.": 0.4615384615384615, "Write a Java program to convert an int to a string.": 0.4615384615384615}, "avg_similarity_score": 0.18595467964263446} -{"instruction": "How do you generate and use SSH key pairs?", "input": "", "output": "In this post, I will show you how to generate an SSH key pair and use them for authentication. An SSH key pair consists of a public key and a private key. The public key is placed on the server, and the private key is placed on the client machine. When the client connects to the server using SSH, the server sends a challenge to the client to prove its identity. The client encrypts the challenge with the private key and sends it back to the server. The server can decrypt the challenge with the public key and verify the client. The private key is used only by the client, and the public key is used only by the server. In most cases, you can use the same SSH key pair for multiple servers.\n\nHere is how to generate an SSH key pair:\n\nOpen the terminal and run the following command to generate the key pair: ```ssh-keygen -t rsa -b 4096 -C \"your_email@example.com\" ``` This will create a key pair using the RSA algorithm with a key size of 4096 bits and save them in ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub. The -C flag is used to add a comment to the public key.\n\nWhen prompted, enter a passphrase for the key pair.\n\nWhen prompted again for the same passphrase, enter the same passphrase.\n\nWhen prompted for a file name, press Enter. This will save the key pair in ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub.\n\nThe private key (~/.ssh/id_rsa) should have permissions of 0600. The public key (~/.ssh/id_rsa.pub) should have permissions of 0644.\n\nHere is how to add the key pair to your SSH agent:\n\nOpen the terminal and run the following command to start the SSH agent in the background: ``` eval \"$(ssh-agent -s)\" ``` Note: If you are using macOS, you may have to start the SSH agent each time you log in. To do that, you can add the above command to ~/.bash_profile.\n\nRun the following command to add your private key to the SSH agent: ``` ssh-add ~/.ssh/id_rsa ``` Note: If you have set a passphrase for the key, you will have to enter it once.\n\nRun the following command to copy the contents of the public key to the clipboard: ``` pbcopy < ~/.ssh/id_rsa.pub ``` Alternatively, you can run the following command to print the contents of the public key to the terminal: ``` cat ~/.ssh/id_rsa.pub ```\n\nHere is how to add your public key to a server:\n\nConnect to the server using SSH.\n\nOpen the ~/.ssh/authorized_keys file for editing using the nano command: ``` nano ~/.ssh/authorized_keys ```\n\nPaste the contents of the public key to the end of the file.\n\nSave the file and exit nano.\n\nHere is how to use the key pair for authentication:\n\nConnect to the server using SSH and your private key: ``` ssh -i ~/.ssh/id_rsa username@server_address ```\n\nHere are some useful commands to manage your SSH keys:\n\nUse the following command to list all the keys in your SSH agent: ``` ssh-add -l ```\n\nUse the following command to delete your private key from the SSH agent: ``` ssh-add -d ~/.ssh/id_rsa ```\n\nUse the following command to delete all the keys from the SSH agent: ``` ssh-add -D ```\n\nUse the following command to change the passphrase for your private key: ``` ssh-keygen -p -f ~/.ssh/id_rsa ```", "most_similar": {"If you're using Kotlin, how do you declare and initialize a variable?": 0.3636363636363637, "How do you create a variable in Python?": 0.35294117647058826, "How do you create a new virtual environment?": 0.35294117647058826, "How do you initialize an ArrayList in Java?": 0.35294117647058826, "When do you use the long type in Java?": 0.3333333333333333, "How do you sort a list of strings in Python?": 0.3157894736842105, "How do you remove duplicates from a list in Python?": 0.3157894736842105, "How do you add a link to a web page?": 0.3157894736842105, "How to define and use an enum type in Python?": 0.3157894736842105, "How do you get the first and last index of an element in a list in Python?": 0.30769230769230765}, "avg_similarity_score": 0.052156529179105945} -{"instruction": "What is the result of the following function?\nfunction main() {\n for (let i = 1; i <= 5; i++) {\n if (i % 5 === 0) {\n console.log(i);\n break;\n }\n }\n }", "input": "", "output": "The function prints 5 to the console.\n\nIn the first iteration of the loop, i = 1. Since i is not divisible by 5, the if statement is skipped, and the next iteration of the loop begins.\n\nIn the second iteration of the loop, i = 2. Since i is not divisible by 5, the if statement is skipped, and the next iteration of the loop begins.\n\nIn the third iteration of the loop, i = 3. Since i is not divisible by 5, the if statement is skipped, and the next iteration of the loop begins.\n\nIn the fourth iteration of the loop, i = 4. Since i is not divisible by 5, the if statement is skipped, and the next iteration of the loop begins.\n\nIn the fifth iteration of the loop, i = 5. Since i is divisible by 5, the if statement is executed. The console.log() method prints 5 to the console. Then, the break statement exits the loop.\n\nSo, the function prints 5 to the console.", "most_similar": {"What is the output of the following code?\n```\npublic class Test {\n public static void main(String[] args) {\n int i = 1;\n while (i <= 5) {\n System.out.println(i);\n i++;\n }\n }\n}\n```": 0.49056603773584906, "What is the output of the following code? ```py def print_odds(n): for i in range(n): if i % 2 == 0: print(i) print_odds(10) ```": 0.4615384615384615, "What is the result of 1 + \"1\"?": 0.375, "What is the output of the following python code?\n```python\ndef function(a):\n if a > 0:\n print('Positive')\n else:\n print('Negative')\n\nfunction(0)\n```": 0.37499999999999994, "What is the output of this code?\n```\nfor i in range(10):\n print(i)\n```": 0.358974358974359, "What is the output of the following code?\n```py\nnum = 5\nwhile num >= 0:\n print('number is:', num)\n num -= 1\n```": 0.35555555555555557, "What is the output of the following python program?": 0.3529411764705882, "What is the output of the following code?\n```\na = [1, 2, 3]\nb = [4, 5, 6]\nc = a + b\nprint(c)\n```": 0.34782608695652173, "What is the purpose of the `float` function in Python?": 0.34285714285714286, "What is the output of the following code?\n```js\nvar x = 2;\nvar y = 3;\nvar z = 4;\n\n(function(){\n var x = 1;\n y = 10;\n z = 100;\n console.log(x + \" \" + y + \" \" + z);\n})();\n\nconsole.log(x + \" \" + y + \" \" + z);\n```": 0.3278688524590164}, "avg_similarity_score": 0.11125420319966899} -{"instruction": "If you run the following code in the browser console, what would be the output?\n\n\n\n\n \n\n\n", "input": "", "output": "The browser console will display Hello, World!\n\nThe greet() function is defined, and then it is called with the string argument 'World'. The greet() function prints 'Hello, World!' to the console.\n\nThe declaration tells the browser to use the latest HTML standard, which is HTML5.\n\nThe element tells the browser to start the HTML document.\n\nThe element tells the browser that the HTML element following it is part of the body of the HTML document.\n\nThe