codescripts / evalplus /evalplus_results /mbpp /home--aiscuser--fhw--model_weights--deepseek-coder-6.7b-instruct_vllm_temp_0.0.jsonl
f541119578's picture
Upload folder using huggingface_hub
fdf190d verified
{"task_id": "Mbpp/2", "solution": "\n# Test the function\nassert similar_elements((3, 4, 5, 6),(5, 7, 4, 10)) == set((4, 5))"}
{"task_id": "Mbpp/3", "solution": "def is_not_prime(n):\n if n <= 1:\n return True\n elif n <= 3:\n return False\n elif n % 2 == 0 or n % 3 == 0:\n return True\n i = 5\n while i * i <= n:\n if n % i == 0 or n % (i + 2) == 0:\n return True\n i += 6\n return False"}
{"task_id": "Mbpp/4", "solution": "import heapq\ndef heap_queue_largest(nums, n):\n return heapq.nlargest(n, nums)"}
{"task_id": "Mbpp/6", "solution": "def differ_At_One_Bit_Pos(x, y):\n return bin(x ^ y).count('1') == 1"}
{"task_id": "Mbpp/7", "solution": "def find_char_long(s):\n return [word for word in s.split() if len(word) >= 4]"}
{"task_id": "Mbpp/8", "solution": "def square_nums(nums):\n return [num ** 2 for num in nums]"}
{"task_id": "Mbpp/9", "solution": "def find_Rotations(s: str) -> int:\n n = len(s)\n for i in range(1, n):\n if s[i:] + s[:i] == s:\n return i\n return n"}
{"task_id": "Mbpp/11", "solution": "def remove_Occ(s, ch):\n first_occurrence = s.find(ch)\n if first_occurrence != -1:\n last_occurrence = s.rfind(ch)\n return s[:first_occurrence] + s[last_occurrence+1:]\n return s"}
{"task_id": "Mbpp/12", "solution": "def sort_matrix(matrix):\n return sorted(matrix, key=sum)"}
{"task_id": "Mbpp/14", "solution": "def find_Volume(base, height, length):\n # calculate the volume of a triangular prism\n volume = (base * height * length) // 2\n return volume"}
{"task_id": "Mbpp/16", "solution": "def text_lowercase_underscore(s):\n # Split the string into words\n words = s.split(\"_\")\n\n # Check if all words are lowercase\n for word in words:\n if not word.islower():\n return False\n\n # If all words are lowercase, return True\n return True"}
{"task_id": "Mbpp/17", "solution": "def square_perimeter(side_length):\n return 4 * side_length"}
{"task_id": "Mbpp/18", "solution": "def remove_dirty_chars(s1, s2):\n return ''.join([char for char in s1 if char not in s2])"}
{"task_id": "Mbpp/19", "solution": "def test_duplicate(arr):\n return len(arr) != len(set(arr))"}
{"task_id": "Mbpp/20", "solution": "def is_woodall(n):\n # A number is a Woodall number if it is a power of 2 minus 1\n # So, we just need to check if n is a power of 2\n if n <= 0:\n return False\n while n % 2 == 0:\n n = n // 2\n return n == 1"}
{"task_id": "Mbpp/56", "solution": "def check(n):\n # Convert the number to string to reverse it\n str_n = str(n)\n # Reverse the string\n reversed_str_n = str_n[::-1]\n # Convert the reversed string back to integer\n reversed_n = int(reversed_str_n)\n # Check if the number is one less than twice its reverse\n return n == (2 * reversed_n) - 1"}
{"task_id": "Mbpp/57", "solution": "def find_Max_Num(lst):\n # Convert each element in the list to string\n str_lst = [str(i) for i in lst]\n # Sort the list in descending order\n str_lst.sort(reverse=True)\n # Join the elements in the list to form a string and convert it to integer\n max_num = int(''.join(str_lst))\n return max_num"}
{"task_id": "Mbpp/58", "solution": "def opposite_Signs(num1, num2):\n return (num1 ^ num2) < 0"}
{"task_id": "Mbpp/59", "solution": "def nth_octagonal(n):\n return n*(3*n-2)\ndef is_octagonal(n):\n return nth_octagonal(n)"}
{"task_id": "Mbpp/61", "solution": "def count_Substrings(s):\n count = 0\n for length in range(1, len(s) + 1):\n for start in range(0, len(s)):\n if start + length > len(s):\n break\n substring = s[start:start + length]\n if sum(int(digit) for digit in substring) == length:\n count += 1\n return count"}
{"task_id": "Mbpp/62", "solution": "def smallest_num(lst):\n return min(lst)"}
{"task_id": "Mbpp/63", "solution": "def max_difference(tuples):\n max_diff = 0\n for i in range(len(tuples)):\n for j in range(i+1, len(tuples)):\n diff = abs(tuples[i][0] - tuples[j][1])\n if diff > max_diff:\n max_diff = diff\n return max_diff"}
{"task_id": "Mbpp/64", "solution": "def sort_tuples(tuples):\n return sorted(tuples, key=lambda x: x[1])\n\ndef test_sort_tuples():\n assert sort_tuples([('English', 88), ('Science', 90), ('Maths', 97), ('Social sciences', 82)]) == [('Social sciences', 82), ('English', 88), ('Science', 90), ('Maths', 97)]\n print(\"All tests pass\")\n\ntest_sort_tuples()"}
{"task_id": "Mbpp/65", "solution": "def recursive_list_sum(lst):\n total = 0\n for element in lst:\n if type(element) is list:\n total += recursive_list_sum(element)\n else:\n total += element\n return total"}
{"task_id": "Mbpp/66", "solution": "def pos_count(lst):\n count = 0\n for num in lst:\n if num > 0:\n count += 1\n return count"}
{"task_id": "Mbpp/67", "solution": "def bell_number(n):\n bell = [[0 for i in range(n+1)] for j in range(n+1)]\n bell[0][0] = 1\n for i in range(1, n+1):\n bell[i][0] = bell[i-1][i-1]\n for j in range(1, i+1):\n bell[i][j] = bell[i-1][j-1] + bell[i][j-1]\n return bell[n][0]"}
{"task_id": "Mbpp/68", "solution": "def is_Monotonic(arr):\n return all(arr[i] <= arr[i + 1] for i in range(len(arr) - 1)) or all(arr[i] >= arr[i + 1] for i in range(len(arr) - 1))"}
{"task_id": "Mbpp/69", "solution": "def is_sublist(main_list, sublist):\n return sublist in main_list"}
{"task_id": "Mbpp/70", "solution": "def get_equal(tuples):\n length = len(tuples[0])\n for t in tuples:\n if len(t) != length:\n return False\n return True"}
{"task_id": "Mbpp/71", "solution": "def comb_sort(lst):\n gap = len(lst)\n shrink = 1.3\n sorted = False\n\n while not sorted:\n gap = int(gap / shrink)\n if gap <= 1:\n gap = 1\n sorted = True\n i = 0\n while i + gap < len(lst):\n if lst[i] > lst[i + gap]:\n lst[i], lst[i + gap] = lst[i + gap], lst[i]\n i += 1\n return lst"}
{"task_id": "Mbpp/72", "solution": "def dif_Square(n):\n i = 0\n while i*i <= n:\n j = 0\n while j*j <= n:\n if i*i - j*j == n:\n return True\n j += 1\n i += 1\n return False"}
{"task_id": "Mbpp/74", "solution": "def is_samepatterns(patterns1, patterns2):\n return patterns1 == patterns2"}
{"task_id": "Mbpp/75", "solution": "def find_tuples(tuples_list, k):\n result = []\n for tup in tuples_list:\n if all(i % k == 0 for i in tup):\n result.append(tup)\n return result"}
{"task_id": "Mbpp/77", "solution": "def is_divisible_by_11(n):\n return n % 11 == 0\n\n# Test cases\nassert is_divisible_by_11(12345) == False"}
{"task_id": "Mbpp/79", "solution": "def word_len(word):\n return len(word) % 2 == 1"}
{"task_id": "Mbpp/80", "solution": "def tetrahedral_number(n):\n return n * (n + 1) * (n + 2) // 6"}
{"task_id": "Mbpp/82", "solution": "import math\ndef volume_sphere(radius):\n return (4/3) * math.pi * radius**3"}
{"task_id": "Mbpp/84", "solution": "def newman_conway(n):\n if n == 1:\n return \"1\"\n if n == 2:\n return \"1 1\"\n sequence = [1, 1]\n for i in range(2, n):\n sequence.append(sequence[sequence[i-1]-1] + sequence[i-sequence[i-1]])\n return ' '.join(map(str, sequence))\ndef sequence(n):\n return int(newman_conway(n).split()[-1])"}
{"task_id": "Mbpp/85", "solution": "import math\ndef surfacearea_sphere(radius):\n return 4 * math.pi * radius ** 2"}
{"task_id": "Mbpp/86", "solution": "def centered_hexagonal_number(n):\n return n*(7*n-5)//2 + 1"}
{"task_id": "Mbpp/87", "solution": "def merge_dictionaries_three(dict1, dict2, dict3):\n merged_dict = {**dict1, **dict2, **dict3}\n return merged_dict\ndict1 = { \"R\": \"Red\", \"B\": \"Black\", \"P\": \"Pink\" }\ndict2 = { \"G\": \"Green\", \"W\": \"White\" }\ndict3 = { \"O\": \"Orange\", \"W\": \"White\", \"B\": \"Black\" }"}
{"task_id": "Mbpp/88", "solution": "def freq_count(lst):\n freqs = {}\n for item in lst:\n if item in freqs:\n freqs[item] += 1\n else:\n freqs[item] = 1\n return freqs"}
{"task_id": "Mbpp/89", "solution": "def closest_num(n):\n # Convert the number to a string\n num_str = str(n)\n # Split the string into a list of characters\n num_list = list(num_str)\n # Iterate over the list from the end to the beginning\n for i in range(len(num_list) - 1, -1, -1):\n # If the current digit is greater than the next one\n if num_list[i] > num_list[i - 1]:\n # Decrease the next digit by 1\n num_list[i - 1] = str(int(num_list[i - 1]) - 1)\n # Set the current digit to 9\n num_list[i] = '9'\n # If the first digit is 0, remove it\n if num_list[0] == '0':\n num_list = num_list[1:]\n # Join the list back into a string\n result_str = ''.join(num_list)\n # Convert the string back to an integer\n result = int(result_str)\n return result"}
{"task_id": "Mbpp/90", "solution": "def len_longest_word(words):\n return max(len(word) for word in words)\n\nassert len_longest_word([\"python\",\"PHP\",\"bigdata\"]) == 7"}
{"task_id": "Mbpp/91", "solution": "def find_substring(lst, substr):\n for item in lst:\n if substr in item:\n return True\n return False"}
{"task_id": "Mbpp/92", "solution": "def is_undulating(n):\n n = str(n)\n if len(n) < 3:\n return False\n diff1 = int(n[1]) - int(n[0])\n for i in range(2, len(n)):\n diff = int(n[i]) - int(n[i-1])\n if diff != diff1:\n return False\n diff1 = diff\n return True"}
{"task_id": "Mbpp/93", "solution": "def power(a, b):\n return a ** b"}
{"task_id": "Mbpp/94", "solution": "def index_minimum(lst):\n return min(lst, key=lambda x: x[1])[0]"}
{"task_id": "Mbpp/95", "solution": "def Find_Min_Length(lst):\n return min(len(sub_lst) for sub_lst in lst)"}
{"task_id": "Mbpp/96", "solution": "def divisor(n):\n count = 0\n for i in range(1, n + 1):\n if n % i == 0:\n count += 1\n return count"}
{"task_id": "Mbpp/97", "solution": "def flatten(lst):\n return [item for sublist in lst for item in sublist]\ndef frequency_lists(lst):\n flattened_list = flatten(lst)\n frequency_dict = {}\n for i in flattened_list:\n if i in frequency_dict:\n frequency_dict[i] += 1\n else:\n frequency_dict[i] = 1\n return frequency_dict"}
{"task_id": "Mbpp/98", "solution": "import math\ndef multiply_num(lst):\n if len(lst) == 0:\n return 0\n product = 1\n for num in lst:\n product *= num\n return product / len(lst)"}
{"task_id": "Mbpp/99", "solution": "def decimal_to_binary(n):\n return bin(n).replace(\"0b\", \"\")"}
{"task_id": "Mbpp/100", "solution": "def next_smallest_palindrome(n):\n while True:\n n += 1\n if str(n) == str(n)[::-1]: # Check if the number is a palindrome\n return n"}
{"task_id": "Mbpp/101", "solution": "def kth_element(arr, k):\n \"\"\"\n This function takes in a list and an integer k as arguments.\n It returns the kth element in the list using 1-based indexing.\n \"\"\"\n return arr[k-1]"}
{"task_id": "Mbpp/102", "solution": "def snake_to_camel(snake_str):\n components = snake_str.split('_')\n return ''.join(x.title() for x in components)"}
{"task_id": "Mbpp/103", "solution": "def eulerian_num(n, m):\n if m == 0 or m == n:\n return 1\n if n == 0:\n return 0\n return eulerian_num(n - 1, m) + eulerian_num(n, m - 1)"}
{"task_id": "Mbpp/104", "solution": "def sort_sublists(lst):\n return [sorted(sublist) for sublist in lst]"}
{"task_id": "Mbpp/105", "solution": "def count(lst):\n return sum(lst)"}
{"task_id": "Mbpp/106", "solution": "def add_lists(lst, tpl):\n return tpl + tuple(lst)"}
{"task_id": "Mbpp/108", "solution": "def merge_sorted_list(list1, list2, list3):\n # Merge the lists\n merged_list = list1 + list2 + list3\n # Sort the merged list\n merged_list.sort()\n return merged_list"}
{"task_id": "Mbpp/109", "solution": "def odd_Equivalent(binary_string, rotations):\n # Create a list to store the binary strings after each rotation\n rotated_strings = []\n\n # Perform the rotations\n for _ in range(rotations):\n binary_string = binary_string[-1:] + binary_string[:-1]\n rotated_strings.append(binary_string)\n\n # Count the number of odd equivalent binary strings\n count = 0\n for string in rotated_strings:\n if int(string, 2) % 2 != 0:\n count += 1\n\n return count"}
{"task_id": "Mbpp/111", "solution": "def common_in_nested_lists(nested_lists):\n # Convert the first list to a set\n common_set = set(nested_lists[0])\n\n # Iterate over the rest of the lists\n for lst in nested_lists[1:]:\n # Update the common set with the intersection of the current list and the common set\n common_set = common_set.intersection(set(lst))\n\n # Convert the common set back to a list and return it\n return list(common_set)"}
{"task_id": "Mbpp/113", "solution": "def check_integer(s):\n try:\n int(s)\n return True\n except ValueError:\n return False"}
{"task_id": "Mbpp/116", "solution": "def tuple_to_int(tup):\n return int(''.join(map(str, tup)))"}
{"task_id": "Mbpp/118", "solution": "def string_to_list(s):\n return s.split(\" \")"}
{"task_id": "Mbpp/119", "solution": "def search(nums):\n left, right = 0, len(nums) - 1\n while left < right:\n mid = (left + right) // 2\n if nums[mid] == nums[mid ^ 1]:\n left = mid + 1\n else:\n right = mid\n return nums[left]"}
{"task_id": "Mbpp/120", "solution": "def max_product_tuple(lst):\n max_product = float('-inf')\n for tup in lst:\n product = abs(tup[0] * tup[1])\n if product > max_product:\n max_product = product\n return max_product"}
{"task_id": "Mbpp/123", "solution": "def d(n):\n \"\"\"\n Function to calculate the sum of proper divisors of a number\n \"\"\"\n sum = 1\n i = 2\n while i * i <= n:\n if n % i:\n i += 1\n else:\n if i * (n // i) == n:\n sum = sum + i + n//i\n else:\n sum = sum + i\n i += 1\n return sum\ndef amicable_numbers_sum(limit):\n \"\"\"\n Function to calculate the sum of all amicable numbers up to a specified limit\n \"\"\"\n sum = 0\n for i in range(1, limit):\n if d(d(i)) == i and d(i) != i:\n sum += i\n return sum"}
{"task_id": "Mbpp/124", "solution": "import cmath\nimport math\ndef angle_complex(z):\n \"\"\"\n This function calculates the angle of a complex number.\n \"\"\"\n return cmath.phase(z)"}
{"task_id": "Mbpp/125", "solution": "def find_length(binary_string):\n max_diff = 0\n count_zero = 0\n count_one = 0\n\n for char in binary_string:\n if char == '0':\n count_zero += 1\n else:\n count_one += 1\n diff = count_one - count_zero\n if diff > max_diff:\n max_diff = diff\n return max_diff"}
{"task_id": "Mbpp/126", "solution": "def sum_common_divisors(num1, num2):\n def get_divisors(n):\n divisors = [1]\n for i in range(2, n // 2 + 1):\n if n % i == 0:\n divisors.append(i)\n divisors.append(n)\n return divisors\n\n return sum(set(get_divisors(num1)) & set(get_divisors(num2)))\n\n# Test the function\nassert sum_common_divisors(10, 15) == 6"}
{"task_id": "Mbpp/127", "solution": "def multiply_int(a, b):\n return a * b"}
{"task_id": "Mbpp/128", "solution": "def long_words(n, sentence):\n words = sentence.split()\n long_words = [word for word in words if len(word) > n]\n return long_words"}
{"task_id": "Mbpp/129", "solution": "def magic_square_test(matrix):\n # Get the size of the matrix\n size = len(matrix)\n\n # Calculate the sum of the first row\n magic_constant = sum(matrix[0])\n\n # Check rows\n for row in matrix:\n if sum(row) != magic_constant:\n return False\n\n # Check columns\n for i in range(size):\n if sum(row[i] for row in matrix) != magic_constant:\n return False\n\n # Check diagonals\n if sum(matrix[i][i] for i in range(size)) != magic_constant:\n return False\n if sum(matrix[i][size - i - 1] for i in range(size)) != magic_constant:\n return False\n\n # If all checks pass, the matrix is a magic square\n return True"}
{"task_id": "Mbpp/130", "solution": "def max_occurrences(lst):\n # Create a dictionary to store the frequency of each item\n freq_dict = {}\n for item in lst:\n if item in freq_dict:\n freq_dict[item] += 1\n else:\n freq_dict[item] = 1\n\n # Find the item with maximum frequency\n max_freq_item = max(freq_dict, key=freq_dict.get)\n return max_freq_item"}
{"task_id": "Mbpp/131", "solution": "def reverse_vowels(s):\n vowels = \"aeiouAEIOU\"\n vowels_in_s = [c for c in s if c in vowels]\n return \"\".join(vowels_in_s[::-1] + [c for c in s if c not in vowels])"}
{"task_id": "Mbpp/132", "solution": "def tup_string(tup):\n return ''.join(tup)"}
{"task_id": "Mbpp/133", "solution": "def sum_negativenum(numbers):\n return sum(num for num in numbers if num < 0)"}
{"task_id": "Mbpp/135", "solution": "def hexagonal_num(n):\n return n*(2*n-1)"}
{"task_id": "Mbpp/137", "solution": "import math\ndef zero_count(arr):\n zero_count = arr.count(0)\n non_zero_count = len(arr) - zero_count\n return zero_count / non_zero_count"}
{"task_id": "Mbpp/138", "solution": "def is_Sum_Of_Powers_Of_Two(n):\n if n < 0:\n return False\n while n > 0:\n if n % 2 == 1:\n n -= 1\n else:\n n /= 2\n return n == 0"}
{"task_id": "Mbpp/139", "solution": "import math\ndef circle_circumference(radius):\n return 2 * math.pi * radius"}
{"task_id": "Mbpp/140", "solution": "def extract_singly(lst):\n result = []\n for sublist in lst:\n for item in sublist:\n result.append(item)\n return result"}
{"task_id": "Mbpp/141", "solution": "def pancake_sort(lst):\n for i in range(len(lst), 0, -1):\n max_idx = lst.index(max(lst[:i]))\n if max_idx != i - 1:\n if max_idx != 0:\n lst[:i] = lst[max_idx::-1] + lst[i:]\n lst[:i] = lst[i - 1::-1] + lst[i:]\n return lst"}
{"task_id": "Mbpp/142", "solution": "def count_samepair(list1, list2, list3):\n count = 0\n for i in range(len(list1)):\n if list1[i] == list2[i] == list3[i]:\n count += 1\n return count"}
{"task_id": "Mbpp/145", "solution": "def max_Abs_Diff(arr):\n return max(abs(a - b) for a, b in zip(arr, arr[1:]))"}
{"task_id": "Mbpp/160", "solution": "def find_solution(a, b, n):\n for x in range(n+1):\n for y in range(n+1):\n if a*x + b*y == n:\n return (x, y)\n return None"}
{"task_id": "Mbpp/161", "solution": "def remove_elements(lst1, lst2):\n return [i for i in lst1 if i not in lst2]"}
{"task_id": "Mbpp/162", "solution": "def sum_series(n):\n total = 0\n while n > 0:\n total += n\n n -= 2\n return total"}
{"task_id": "Mbpp/165", "solution": "def count_char_position(s):\n s = s.lower()\n return sum(1 for i in range(len(s)) if s[i] == chr(97 + i))"}
{"task_id": "Mbpp/166", "solution": "def find_even_pair(lst):\n count = 0\n for i in range(len(lst)):\n for j in range(i+1, len(lst)):\n if lst[i] ^ lst[j] % 2 == 0:\n count += 1\n return count"}
{"task_id": "Mbpp/167", "solution": "def next_power_of_2(n):\n if n <= 0:\n return 1\n else:\n return 2 ** (n - 1).bit_length()"}
{"task_id": "Mbpp/168", "solution": "def frequency(lst, num):\n return lst.count(num)"}
{"task_id": "Mbpp/170", "solution": "def sum_range_list(lst, start, end):\n return sum(lst[start:end+1])"}
{"task_id": "Mbpp/171", "solution": "def perimeter_pentagon(side_length):\n return 5 * side_length"}
{"task_id": "Mbpp/172", "solution": "def count_occurance(s):\n return s.count('std')"}
{"task_id": "Mbpp/222", "solution": "def check_type(tup):\n return all(isinstance(x, type(tup[0])) for x in tup)"}
{"task_id": "Mbpp/223", "solution": "def is_majority(arr, n, elm):\n count = arr.count(elm)\n if count > n / 2:\n return True\n else:\n return False"}
{"task_id": "Mbpp/224", "solution": "def count_Set_Bits(n):\n return bin(n).count('1')"}
{"task_id": "Mbpp/226", "solution": "def odd_values_string(s):\n return s[::2]"}
{"task_id": "Mbpp/227", "solution": "def min_of_three(a, b, c):\n return min(a, b, c)"}
{"task_id": "Mbpp/230", "solution": "def replace_blank(s, c):\n return s.replace(' ', c)"}
{"task_id": "Mbpp/232", "solution": "def larg_num(lst, n):\n # Sort the list in descending order\n lst.sort(reverse=True)\n # Return the first n elements\n return lst[:n]\n\n# Test the function\nassert set(larg_num([10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100], 2)) == set([100, 90])"}
{"task_id": "Mbpp/233", "solution": "import math"}
{"task_id": "Mbpp/234", "solution": "def volume_cube(side_length):\n \"\"\"\n This function calculates the volume of a cube given its side length.\n \"\"\"\n return side_length ** 3"}
{"task_id": "Mbpp/235", "solution": "def even_bit_set_number(n):\n binary = bin(n)[2:] # Convert to binary and remove '0b' prefix\n binary = '0' + binary # Add leading zero to make it 1-indexed\n binary = list(binary) # Convert to list for easy manipulation\n\n for i in range(0, len(binary), 2): # Go through every even index\n binary[i] = '1' # Set bit to 1\n\n return int(''.join(binary), 2) # Convert back to integer and return"}
{"task_id": "Mbpp/237", "solution": "def check_occurences(lst):\n count_dict = {}\n for tup in lst:\n if tup in count_dict:\n count_dict[tup] += 1\n else:\n count_dict[tup] = 1\n return count_dict"}
{"task_id": "Mbpp/238", "solution": "def number_of_substrings(s):\n n = len(s)\n return n * (n + 1) // 2"}
{"task_id": "Mbpp/239", "solution": "def get_total_number_of_sequences(m, n):\n # Initialize a list to store the sequences\n sequences = [[[i]] for i in range(1, min(m, n) + 1)]\n\n # Iterate over the length of the sequences\n for j in range(1, n):\n # Iterate over the possible starting numbers\n for i in range(1, m + 1):\n # Iterate over the sequences of length j\n for seq in sequences[j - 1]:\n # If the last number in the sequence is less than i, add a new sequence\n if seq[-1] < i:\n sequences[j].append(seq + [i])\n\n # Return the total number of sequences\n return len(sequences[-1])"}
{"task_id": "Mbpp/240", "solution": "def replace_list(list1, list2):\n list1[-1:] = list2\n return list1"}
{"task_id": "Mbpp/242", "solution": "def count_charac(string):\n return len(string)"}
{"task_id": "Mbpp/244", "solution": "def next_Perfect_Square(n):\n # Calculate the square root of the given number\n root = n ** 0.5\n\n # If the square root is not an integer, increment it by 1\n if not root.is_integer():\n root = int(root) + 1\n else:\n root = int(root)\n\n # Return the square of the root\n return root ** 2"}
{"task_id": "Mbpp/245", "solution": "def max_sum(arr):\n n = len(arr)\n if n < 3:\n return sum(arr)\n\n # Initialize variables\n inc = [0]*n\n dec = [0]*n\n\n # Calculate increasing subsequence values\n for i in range(1, n):\n for j in range(i):\n if arr[i] > arr[j] and inc[i] < inc[j] + arr[i]:\n inc[i] = inc[j] + arr[i]\n if inc[i] == 0:\n inc[i] = arr[i]\n\n # Calculate decreasing subsequence values\n for i in range(n-2, -1, -1):\n for j in range(n-1, i, -1):\n if arr[i] > arr[j] and dec[i] < dec[j] + arr[i]:\n dec[i] = dec[j] + arr[i]\n if dec[i] == 0:\n dec[i] = arr[i]\n\n # Find maximum sum of bitonic subsequence\n bitonic = [0]*n\n for i in range(n):\n bitonic[i] = inc[i] + dec[i] - arr[i]\n\n return max(bitonic)"}
{"task_id": "Mbpp/247", "solution": "def lps(s):\n n = len(s)\n dp = [[0]*n for _ in range(n)]\n for i in range(n-1, -1, -1):\n dp[i][i] = 1\n for j in range(i+1, n):\n if s[i] == s[j]:\n dp[i][j] = 2 + dp[i+1][j-1]\n else:\n dp[i][j] = max(dp[i+1][j], dp[i][j-1])\n return dp[0][n-1]"}
{"task_id": "Mbpp/250", "solution": "def count_X(tup, elem):\n return tup.count(elem)"}
{"task_id": "Mbpp/251", "solution": "def insert_element(lst, element):\n result = []\n for i in lst:\n result.extend([element, i])\n return result"}
{"task_id": "Mbpp/252", "solution": "import cmath\ndef convert(complex_num):\n \"\"\"\n This function converts a complex number to polar coordinates.\n \"\"\"\n # Convert the complex number to polar coordinates using cmath.polar\n r, phi = cmath.polar(complex_num)\n # Return the polar coordinates as a tuple\n return (r, phi)"}
{"task_id": "Mbpp/253", "solution": "def count_integer(lst):\n return sum(1 for i in lst if isinstance(i, int))"}
{"task_id": "Mbpp/255", "solution": "from itertools import product\ndef combinations_colors(lst, n):\n return list(product(*([lst]*n)))"}
{"task_id": "Mbpp/256", "solution": "def count_Primes_nums(n):\n if n < 2:\n return 0\n primes = [True] * n\n p = 2\n while p * p <= n:\n if primes[p]:\n for i in range(p * p, n, p):\n primes[i] = False\n p += 1\n return sum(primes) - 2 # subtract 2 to exclude 0 and 1"}
{"task_id": "Mbpp/257", "solution": "def swap_numbers(a, b):\n return b, a"}
{"task_id": "Mbpp/259", "solution": "def maximize_elements(t1, t2):\n return tuple(max(a, b) for a, b in zip(t1, t2))"}
{"task_id": "Mbpp/260", "solution": "def newman_prime(n):\n def is_prime(num):\n if num < 2:\n return False\n for i in range(2, int(num**0.5) + 1):\n if num % i == 0:\n return False\n return True\n\n count = 0\n num = 2\n while True:\n if is_prime(num):\n count += 1\n if count == n:\n return num\n num += 1"}
{"task_id": "Mbpp/261", "solution": "def division_elements(t1, t2):\n return tuple(map(lambda x, y: x / y, t1, t2))"}
{"task_id": "Mbpp/262", "solution": "def split_two_parts(lst, L):\n return (lst[:L], lst[L:])"}
{"task_id": "Mbpp/264", "solution": "def dog_age(human_years):\n if human_years <= 2:\n return human_years * 10.5\n else:\n return 21 + (human_years - 2) * 4"}
{"task_id": "Mbpp/265", "solution": "def list_split(lst, n):\n return [lst[i:i + n] for i in range(0, len(lst), n)]"}
{"task_id": "Mbpp/266", "solution": "def lateralsurface_cube(side_length):\n return 4 * side_length ** 2"}
{"task_id": "Mbpp/267", "solution": "def square_Sum(n):\n sum = 0\n for i in range(1, 2*n, 2):\n sum += i*i\n return sum"}
{"task_id": "Mbpp/268", "solution": "def find_star_num(n):\n return n*(7*n - 5)//2"}
{"task_id": "Mbpp/269", "solution": "def ascii_value(char):\n return ord(char)"}
{"task_id": "Mbpp/270", "solution": "def sum_even_and_even_index(lst):\n return sum(val for idx, val in enumerate(lst) if idx % 2 == 0 and val % 2 == 0)"}
{"task_id": "Mbpp/271", "solution": "def even_Power_Sum(n):\n sum = 0\n for i in range(2, 2*n+1, 2):\n sum += i**5\n return sum"}
{"task_id": "Mbpp/272", "solution": "def rear_extract(lst):\n return [i[-1] for i in lst]"}
{"task_id": "Mbpp/273", "solution": "def substract_elements(t1, t2):\n return tuple(x1 - x2 for x1, x2 in zip(t1, t2))"}
{"task_id": "Mbpp/274", "solution": "def even_binomial_Coeff_Sum(n):\n # Initialize the sum to 0\n sum = 0\n # Loop through the range of n\n for i in range(n+1):\n # Check if the index is even\n if i % 2 == 0:\n # Calculate the binomial coefficient and add it to the sum\n sum += binomial_coefficient(n, i)\n return sum\ndef binomial_coefficient(n, k):\n # Calculate the binomial coefficient using the formula nCk = n! / [(n-k)! * k!]\n return factorial(n) / (factorial(n-k) * factorial(k))\ndef factorial(n):\n # Calculate the factorial of a number using a loop\n if n == 0:\n return 1\n else:\n fact = 1\n for i in range(1, n+1):\n fact *= i\n return fact"}
{"task_id": "Mbpp/276", "solution": "import math\ndef volume_cylinder(radius, height):\n return math.pi * radius**2 * height"}
{"task_id": "Mbpp/277", "solution": "def dict_filter(d, n):\n return {k: v for k, v in d.items() if v >= n}"}
{"task_id": "Mbpp/278", "solution": "def count_first_elements(tup):\n count = 0\n for i in tup:\n if isinstance(i, tuple):\n break\n count += 1\n return count"}
{"task_id": "Mbpp/279", "solution": "def is_num_decagonal(n):\n return n*(7*n-5)//2"}
{"task_id": "Mbpp/280", "solution": "def sequential_search(array, element):\n for i in range(len(array)):\n if array[i] == element:\n return (True, i)\n return (False, -1)"}
{"task_id": "Mbpp/281", "solution": "def all_unique(lst):\n return len(lst) == len(set(lst))"}
{"task_id": "Mbpp/282", "solution": "def sub_list(list1, list2):\n return [a - b for a, b in zip(list1, list2)]"}
{"task_id": "Mbpp/283", "solution": "def validate(n):\n # Convert the integer to a string to easily access each digit\n str_n = str(n)\n # Iterate over each digit in the string representation of the integer\n for digit in str_n:\n # Count the number of times the digit appears in the string representation of the integer\n count = str_n.count(digit)\n # If the count is greater than the digit itself, return False\n if count > int(digit):\n return False\n # If we've gone through all the digits without finding a count that's greater than the digit, return True\n return True"}
{"task_id": "Mbpp/284", "solution": "def check_element(lst, elm):\n return all(i == elm for i in lst)"}
{"task_id": "Mbpp/285", "solution": "import re\ndef text_match_two_three(text):\n pattern = 'ab{2,3}'\n if re.search(pattern, text):\n return True\n else:\n return False"}
{"task_id": "Mbpp/286", "solution": "def max_sub_array_sum_repeated(arr, k, n):\n # Calculate the sum of the array\n total_sum = sum(arr)\n\n # Calculate the sum of the array repeated k times\n repeated_sum = total_sum * k\n\n # Calculate the maximum subarray sum using Kadane's algorithm\n max_sum = current_sum = repeated_sum\n for i in range(n):\n current_sum = max(arr[i], current_sum + arr[i])\n max_sum = max(max_sum, current_sum)\n\n return max_sum"}
{"task_id": "Mbpp/287", "solution": "def square_Sum(n):\n sum = 0\n for i in range(1, n+1):\n sum += i*i\n return sum*2"}
{"task_id": "Mbpp/290", "solution": "def max_length(lst):\n max_len = max(len(sub_lst) for sub_lst in lst)\n max_sub_lst = [sub_lst for sub_lst in lst if len(sub_lst) == max_len]\n return max_len, max_sub_lst[0]"}
{"task_id": "Mbpp/292", "solution": "def find(num1, num2):\n return num1 // num2"}
{"task_id": "Mbpp/293", "solution": "import math\ndef otherside_rightangle(base, height):\n \"\"\"\n This function calculates the length of the third side of a right-angled triangle.\n It takes two arguments: base and height of the right-angled triangle.\n It returns the length of the third side.\n \"\"\"\n return math.sqrt(base**2 + height**2)"}
{"task_id": "Mbpp/294", "solution": "def max_val(lst):\n max_value = None\n for item in lst:\n if isinstance(item, int) or isinstance(item, float):\n if max_value is None or item > max_value:\n max_value = item\n return max_value"}
{"task_id": "Mbpp/296", "solution": "def get_Inv_Count(arr):\n inv_count = 0\n for i in range(len(arr)):\n for j in range(i + 1, len(arr)):\n if arr[i] > arr[j]:\n inv_count += 1\n return inv_count"}
{"task_id": "Mbpp/297", "solution": "def flatten_list(nested_list):\n flat_list = []\n for i in nested_list:\n if isinstance(i, list):\n flat_list.extend(flatten_list(i))\n else:\n flat_list.append(i)\n return flat_list"}
{"task_id": "Mbpp/299", "solution": "def max_aggregate(lst):\n # Create a dictionary to store the sum of scores for each name\n scores = {}\n for name, score in lst:\n if name in scores:\n scores[name] += score\n else:\n scores[name] = score\n\n # Find the name with the maximum score\n max_score = max(scores.values())\n max_name = [name for name, score in scores.items() if score == max_score][0]\n\n return (max_name, max_score)"}
{"task_id": "Mbpp/300", "solution": "def count_binary_seq(n):\n # Initialize a list to store the count of binary sequences\n # for each possible sum of the first n bits\n counts = [0] * (2*n + 1)\n\n # Initialize the count of binary sequences for n=0\n counts[0] = 1\n\n # Iterate over each bit position from 0 to 2n-1\n for _ in range(2*n):\n # Iterate over each possible sum of the first n bits\n for j in range(2*n, -1, -1):\n # Update the count of binary sequences for the next bit position\n counts[j] = counts[j] * 2 + (counts[j-1] if j > 0 else 0)\n\n # Return the count of binary sequences where the sum of the first n bits is the same as the sum of the last n bits\n return counts[n]"}
{"task_id": "Mbpp/301", "solution": "def dict_depth(d):\n if not isinstance(d, dict) or not d:\n return 1\n return 1 + max(dict_depth(v) for v in d.values())"}
{"task_id": "Mbpp/305", "solution": "def start_withp(words_list):\n for words in words_list:\n for word in words.split():\n if word.lower().startswith('p'):\n return word,"}
{"task_id": "Mbpp/306", "solution": "def max_sum_increasing_subseq(arr, n, k, i):\n # Initialize the dp array with the given array values\n dp = arr[:]\n # Initialize the max_sum variable with the value at the kth index\n max_sum = arr[k]\n # Iterate over the array from the (i+1)th index to the end\n for j in range(i+1, n):\n # Iterate over the array from the 0th index to the (i-1)th index\n for x in range(0, i):\n # If the current element is greater than the (i-1)th element and the sum of the dp[x] and the current element is greater than the dp[j]\n if arr[j] > arr[x] and dp[x] + arr[j] > dp[j]:\n # Update the dp[j] with the new sum\n dp[j] = dp[x] + arr[j]\n # Update the max_sum with the maximum of the current max_sum and the dp[j]\n max_sum = max(max_sum, dp[j])\n # Return the max_sum\n return max_sum"}
{"task_id": "Mbpp/308", "solution": "def large_product(list1, list2, n):\n products = [(x * y) for x in list1 for y in list2]\n products.sort(reverse=True)\n return products[:n]"}
{"task_id": "Mbpp/309", "solution": "def maximum(num1, num2):\n if num1 > num2:\n return num1\n else:\n return num2"}
{"task_id": "Mbpp/310", "solution": "def string_to_tuple(s):\n return tuple(s)"}
{"task_id": "Mbpp/311", "solution": "def set_left_most_unset_bit(n):\n if n == 0:\n return 1\n if n % 2 == 1:\n return n\n else:\n return n + 1"}
{"task_id": "Mbpp/312", "solution": "import math\ndef volume_cone(radius, height):\n return (1/3) * math.pi * radius**2 * height"}
{"task_id": "Mbpp/388", "solution": "def highest_Power_of_2(n):\n i = 0\n while 2 ** i <= n:\n i += 1\n return 2 ** (i - 1)"}
{"task_id": "Mbpp/389", "solution": "def find_lucas(n):\n if n == 0:\n return 2\n if n == 1:\n return 1\n lucas_numbers = [2, 1]\n for i in range(2, n + 1):\n lucas_numbers.append(lucas_numbers[i - 1] + lucas_numbers[i - 2])\n return lucas_numbers[n]"}
{"task_id": "Mbpp/390", "solution": "def add_string(lst, fmt_str):\n return [fmt_str.format(i) for i in lst]"}
{"task_id": "Mbpp/391", "solution": "def convert_list_dictionary(keys, names, values):\n result = []\n for i in range(len(keys)):\n temp_dict = {keys[i]: {names[i]: values[i]}}\n result.append(temp_dict)\n return result\nkeys = [\"S001\", \"S002\", \"S003\", \"S004\"]\nnames = [\"Adina Park\", \"Leyton Marsh\", \"Duncan Boyle\", \"Saim Richards\"]\nvalues = [85, 98, 89, 92]"}
{"task_id": "Mbpp/392", "solution": "def get_max_sum(n):\n if n <= 1:\n return n\n else:\n return max(get_max_sum(n/2) + get_max_sum(n/3) + get_max_sum(n/4) + get_max_sum(n/5), n)"}
{"task_id": "Mbpp/394", "solution": "def check_distinct(tup):\n return len(tup) == len(set(tup))"}
{"task_id": "Mbpp/395", "solution": "def first_non_repeating_character(s):\n char_count = {}\n for char in s:\n if char in char_count:\n char_count[char] += 1\n else:\n char_count[char] = 1\n for char in s:\n if char_count[char] == 1:\n return char\n return None"}
{"task_id": "Mbpp/397", "solution": "def median_numbers(a, b, c):\n \"\"\"\n This function takes three numbers as input and returns their median.\n \"\"\"\n # Sort the numbers\n numbers = sorted([a, b, c])\n \n # Return the middle number\n return numbers[1]"}
{"task_id": "Mbpp/398", "solution": "def sum_of_digits(lst):\n return [sum(int(digit) for digit in str(num)) for num in lst]"}
{"task_id": "Mbpp/404", "solution": "def minimum(a, b):\n if a < b:\n return a\n else:\n return b"}
{"task_id": "Mbpp/405", "solution": "def check_tuplex(tuplex, element):\n return element in tuplex"}
{"task_id": "Mbpp/406", "solution": "def find_Parity(n):\n return n % 2 != 0"}
{"task_id": "Mbpp/409", "solution": "def min_product_tuple(lst):\n return min(x*y for x, y in lst)"}
{"task_id": "Mbpp/410", "solution": "def min_val(lst):\n # Filter out non-numeric values and find the minimum\n min_val = min([i for i in lst if isinstance(i, (int, float))])\n return min_val"}
{"task_id": "Mbpp/412", "solution": "def remove_odd(numbers):\n return [num for num in numbers if num % 2 == 0]"}
{"task_id": "Mbpp/413", "solution": "def extract_nth_element(lst, n):\n return [x[n] for x in lst]"}
{"task_id": "Mbpp/414", "solution": "def overlapping(seq1, seq2):\n for i in seq1:\n if i in seq2:\n return True\n return False"}
{"task_id": "Mbpp/415", "solution": "def max_Product(arr):\n arr.sort()\n return (arr[-1], arr[-2]) if arr[-1] * arr[-2] > arr[0] * arr[1] else (arr[0], arr[1])"}
{"task_id": "Mbpp/418", "solution": "def Find_Max(lst):\n max_len = max(len(sublist) for sublist in lst)\n for sublist in lst:\n if len(sublist) == max_len:\n return sublist"}
{"task_id": "Mbpp/419", "solution": "def round_and_sum(numbers):\n rounded_numbers = [round(num) for num in numbers]\n total_sum = sum(rounded_numbers)\n result = total_sum * len(rounded_numbers)\n return result"}
{"task_id": "Mbpp/420", "solution": "def cube_Sum(n):\n sum = 0\n for i in range(1, n+1):\n sum += i*2*i\n return sum"}
{"task_id": "Mbpp/421", "solution": "def concatenate_tuple(tup):\n return '-'.join(str(i) for i in tup)"}
{"task_id": "Mbpp/422", "solution": "def find_Average_Of_Cube(n):\n sum_of_cubes = sum([i**3 for i in range(1, n+1)])\n average = sum_of_cubes / n\n return average"}
{"task_id": "Mbpp/424", "solution": "def extract_rear(tup):\n return [s[-1] for s in tup]"}
{"task_id": "Mbpp/425", "solution": "def count_element_in_list(lst, element):\n count = 0\n for sublist in lst:\n if element in sublist:\n count += 1\n return count"}
{"task_id": "Mbpp/426", "solution": "def filter_oddnumbers(numbers):\n return [num for num in numbers if num % 2 == 0]"}
{"task_id": "Mbpp/427", "solution": "def change_date_format(date):\n # Split the date into year, month, and day\n year, month, day = date.split('-')\n # Return the date in the desired format\n return '{}-{}-{}'.format(day, month, year)"}
{"task_id": "Mbpp/428", "solution": "def shell_sort(arr):\n n = len(arr)\n gap = n//2\n\n while gap > 0:\n for i in range(gap,n):\n temp = arr[i]\n j = i\n while j >= gap and arr[j-gap] >temp:\n arr[j] = arr[j-gap]\n j -= gap\n arr[j] = temp\n gap //= 2\n return arr"}
{"task_id": "Mbpp/429", "solution": "def and_tuples(t1, t2):\n return tuple(x & y for x, y in zip(t1, t2))"}
{"task_id": "Mbpp/430", "solution": "def parabola_directrix(a, h, k):\n \"\"\"\n Function to find the directrix of a parabola.\n The directrix of a parabola is the line that is perpendicular to the x-axis and intersects the parabola at its vertex.\n The equation of a parabola is y = a*(x-h)^2 + k.\n The equation of the directrix is x = h.\n The function takes three parameters: a, h, and k.\n It returns the y-coordinate of the directrix.\n \"\"\"\n return a * (h - h) ** 2 + k"}
{"task_id": "Mbpp/432", "solution": "def median_trapezium(a, b, c):\n \"\"\"\n This function calculates the median length of a trapezium.\n The median of a trapezium is the length of the line segment that divides the trapezium into two equal parts.\n The lengths of the parallel sides of the trapezium are given by a, b, and c.\n The median is calculated as (a+b+c)/2.\n \"\"\"\n return (a + b + c) / 2"}
{"task_id": "Mbpp/433", "solution": "def check_greater(arr, num):\n for i in arr:\n if i <= num:\n return False\n return True"}
{"task_id": "Mbpp/435", "solution": "def last_Digit(n):\n return n % 10"}
{"task_id": "Mbpp/436", "solution": "def neg_nos(lst):\n return [num for num in lst if num < 0]"}
{"task_id": "Mbpp/437", "solution": "def remove_odd(s):\n return s[::2]"}
{"task_id": "Mbpp/439", "solution": "def multiple_to_single(nums):\n return int(''.join(map(str, nums)))"}
{"task_id": "Mbpp/440", "solution": "import nltk\nfrom nltk.tokenize import word_tokenize\nfrom nltk.corpus import stopwords\ndef find_adverb_position(sentence):\n stop_words = set(stopwords.words('english'))\n words = word_tokenize(sentence)\n pos_tags = nltk.pos_tag(words)\n\n for i in range(len(pos_tags)):\n word, tag = pos_tags[i]\n if tag in ['RB', 'RBR', 'RBS', 'WRB'] and word not in stop_words:\n return i, i+1, word\n\n return None"}
{"task_id": "Mbpp/441", "solution": "def surfacearea_cube(side_length):\n return 6 * side_length ** 2"}
{"task_id": "Mbpp/445", "solution": "def index_multiplication(tuples):\n tuple1, tuple2 = tuples\n result = []\n for i in range(len(tuple1)):\n result.append(tuple(a*b for a, b in zip(tuple1[i], tuple2[i])))\n return tuple(result)"}
{"task_id": "Mbpp/446", "solution": "def count_Occurrence(tup, lst):\n count = 0\n for element in lst:\n count += tup.count(element)\n return count"}
{"task_id": "Mbpp/447", "solution": "def cube_nums(nums):\n return [num**3 for num in nums]"}
{"task_id": "Mbpp/448", "solution": "def cal_sum(n):\n # Initialize the first three Perrin numbers\n perrin = [3, 0, 2]\n \n # Calculate the rest of the Perrin numbers\n for i in range(3, n):\n perrin.append(perrin[i-2] + perrin[i-1] + 1)\n \n # Return the sum of the first n Perrin numbers\n return sum(perrin[:n])"}
{"task_id": "Mbpp/450", "solution": "def extract_string(lst, size):\n return [s for s in lst if len(s) == size]"}
{"task_id": "Mbpp/451", "solution": "def remove_whitespaces(input_string):\n return input_string.replace(\" \", \"\")"}
{"task_id": "Mbpp/453", "solution": "def sumofFactors(n):\n sum = 0\n for i in range(1, n+1):\n if n % i == 0 and i % 2 == 0:\n sum += i\n return sum"}
{"task_id": "Mbpp/454", "solution": "import re\ndef text_match_wordz(text):\n pattern = r'\\b\\w*z\\w*\\b'\n if re.search(pattern, text):\n return True\n else:\n return False"}
{"task_id": "Mbpp/455", "solution": "def check_month_number(month_number):\n # Months with 31 days: January, March, May, July, August, October, December\n thirty_one_days_months = [1, 3, 5, 7, 8, 10, 12]\n if month_number in thirty_one_days_months:\n return True\n else:\n return False\n\n# Test the function\nassert check_month_number(5) == True"}
{"task_id": "Mbpp/456", "solution": "def reverse_string_list(lst):\n return [s[::-1] for s in lst]"}
{"task_id": "Mbpp/457", "solution": "def Find_Min(lst):\n return min(lst, key=len)"}
{"task_id": "Mbpp/458", "solution": "def rectangle_area(length, width):\n \"\"\"\n This function calculates the area of a rectangle.\n \"\"\"\n return length * width"}
{"task_id": "Mbpp/459", "solution": "def remove_uppercase(s):\n return ''.join([c for c in s if not c.isupper()])"}
{"task_id": "Mbpp/460", "solution": "def Extract(lst):\n return [sublist[0] for sublist in lst]"}
{"task_id": "Mbpp/462", "solution": "from itertools import chain, combinations\ndef combinations_list(lst):\n return list(chain(*[combinations(lst, i) for i in range(len(lst) + 1)]))"}
{"task_id": "Mbpp/463", "solution": "def max_subarray_product(nums):\n if not nums:\n return 0\n\n max_product = min_product = result = nums[0]\n\n for i in range(1, len(nums)):\n if nums[i] < 0:\n max_product, min_product = min_product, max_product\n\n max_product = max(nums[i], max_product * nums[i])\n min_product = min(nums[i], min_product * nums[i])\n\n result = max(result, max_product)\n\n return result"}
{"task_id": "Mbpp/465", "solution": "def drop_empty(d):\n return {k: v for k, v in d.items() if v is not None}"}
{"task_id": "Mbpp/468", "solution": "def max_product(arr):\n n = len(arr)\n if n < 2:\n return None\n\n max_ending_here = max_ending_so_far = arr[0]\n for i in range(1, n):\n if arr[i] < 0:\n max_ending_here, max_ending_so_far = max_ending_so_far, max_ending_here\n max_ending_here = max(arr[i], max_ending_here * arr[i])\n max_ending_so_far = max(max_ending_so_far, max_ending_here)\n\n return max_ending_so_far"}
{"task_id": "Mbpp/470", "solution": "def add_pairwise(tup):\n return tuple(tup[i] + tup[i + 1] for i in range(len(tup) - 1))"}
{"task_id": "Mbpp/471", "solution": "def find_remainder(arr, n):\n product = 1\n for num in arr:\n product = (product * num) % n\n return product"}
{"task_id": "Mbpp/472", "solution": "def check_Consecutive(lst):\n return sorted(lst) == list(range(min(lst), max(lst)+1))"}
{"task_id": "Mbpp/473", "solution": "def tuple_intersection(tuples1, tuples2):\n # Convert tuples to sets and find intersection\n set1 = set(tuples1)\n set2 = set(tuples2)\n intersection = set1 & set2\n\n # Convert sets back to tuples and return\n return set(intersection)"}
{"task_id": "Mbpp/474", "solution": "def replace_char(s, old_char, new_char):\n return s.replace(old_char, new_char)"}
{"task_id": "Mbpp/475", "solution": "def sort_dict_by_value(d):\n return sorted(d.items(), key=lambda x: x[1], reverse=True)\n\nassert sort_dict_by_value({'Math':81, 'Physics':83, 'Chemistry':87})==[('Chemistry', 87), ('Physics', 83), ('Math', 81)]"}
{"task_id": "Mbpp/476", "solution": "def big_sum(arr):\n return max(arr) + min(arr)"}
{"task_id": "Mbpp/477", "solution": "def to_lower(s):\n return s.lower()\n\nassert to_lower(\"InValid\") == \"invalid\""}
{"task_id": "Mbpp/478", "solution": "def remove_lowercase(s):\n return ''.join([c for c in s if c.isupper()])"}
{"task_id": "Mbpp/479", "solution": "def first_Digit(n):\n while n >= 10:\n n /= 10\n return int(n)"}
{"task_id": "Mbpp/554", "solution": "def get_odd_numbers(numbers):\n return [num for num in numbers if num % 2 != 0]\n\nassert get_odd_numbers([1,2,3,4,5,6]) == [1,3,5]"}
{"task_id": "Mbpp/555", "solution": "def difference(n):\n sum_of_cubes = sum([i**3 for i in range(1, n+1)])\n sum_of_numbers = sum([i for i in range(1, n+1)])\n return sum_of_cubes - sum_of_numbers"}
{"task_id": "Mbpp/556", "solution": "def find_Odd_Pair(arr, n):\n # Initialize count of odd pairs\n odd_count = 0\n\n # Traverse through all pairs of arr[i] and arr[j]\n for i in range(0, n):\n for j in range(i + 1, n):\n\n # If XOR of arr[i] and arr[j] is odd\n if (arr[i] ^ arr[j]) & 1:\n odd_count += 1\n\n return odd_count"}
{"task_id": "Mbpp/557", "solution": "def toggle_string(s):\n return s.swapcase()"}
{"task_id": "Mbpp/558", "solution": "def digit_distance_nums(num1, num2):\n # Convert numbers to strings to easily access digits\n num1, num2 = str(num1), str(num2)\n # Initialize sum of digit differences\n sum_diff = 0\n # Iterate over each digit in the numbers\n for digit1, digit2 in zip(num1, num2):\n # Add the absolute difference between the digits to the sum\n sum_diff += abs(int(digit1) - int(digit2))\n return sum_diff"}
{"task_id": "Mbpp/559", "solution": "def max_sub_array_sum(lst, n):\n max_sum = 0\n for i in range(n):\n for j in range(i+1, n+1):\n sub_array_sum = sum(lst[i:j])\n if sub_array_sum > max_sum:\n max_sum = sub_array_sum\n return max_sum"}
{"task_id": "Mbpp/560", "solution": "def union_elements(t1, t2):\n return tuple(sorted(set(t1 + t2)))"}
{"task_id": "Mbpp/562", "solution": "def Find_Max_Length(lst):\n return max(len(sublist) for sublist in lst)"}
{"task_id": "Mbpp/563", "solution": "import re\ndef extract_values(s):\n return re.findall(r'\"([^\"]*)\"', s)"}
{"task_id": "Mbpp/564", "solution": "def count_Pairs(lst, n):\n count = 0\n for i in range(n):\n for j in range(i+1, n):\n if lst[i] != lst[j]:\n count += 1\n return count"}
{"task_id": "Mbpp/565", "solution": "def split_string(s):\n return list(s)\n\nassert split_string('python') == ['p','y','t','h','o','n']"}
{"task_id": "Mbpp/566", "solution": "def sum_digits(n):\n return sum(int(digit) for digit in str(n))"}
{"task_id": "Mbpp/567", "solution": "def is_sorted_list(lst):\n return all(lst[i] <= lst[i + 1] for i in range(len(lst) - 1))\n\n# Test the function\nassert is_sorted_list([1,2,4,6,8,10,12,14,16,17]) == True"}
{"task_id": "Mbpp/568", "solution": "def empty_list(n):\n return [{} for _ in range(n)]"}
{"task_id": "Mbpp/569", "solution": "def sort_sublists(lst):\n return [sorted(sublist) for sublist in lst]"}
{"task_id": "Mbpp/572", "solution": "def two_unique_nums(lst):\n unique_nums = []\n for num in lst:\n if num not in unique_nums:\n unique_nums.append(num)\n return unique_nums"}
{"task_id": "Mbpp/573", "solution": "def unique_product(lst):\n unique_nums = set(lst)\n product = 1\n for num in unique_nums:\n product *= num\n return product"}
{"task_id": "Mbpp/576", "solution": "def is_Sub_Array(main_list, sub_list):\n return sub_list in main_list"}
{"task_id": "Mbpp/577", "solution": "def last_Digit_Factorial(n):\n if n == 0:\n return 1\n else:\n last_digit = 1\n for i in range(1, n + 1):\n last_digit *= i\n while last_digit % 10 == 0:\n last_digit //= 10\n last_digit %= 10\n return last_digit"}
{"task_id": "Mbpp/578", "solution": "def interleave_lists(list1, list2, list3):\n return [val for pair in zip(list1, list2, list3) for val in pair]"}
{"task_id": "Mbpp/579", "solution": "def find_dissimilar(t1, t2):\n return tuple(set(t1).symmetric_difference(set(t2)))"}
{"task_id": "Mbpp/580", "solution": "def extract_even(tup):\n result = []\n for item in tup:\n if isinstance(item, tuple):\n new_item = extract_even(item)\n if new_item:\n result.append(new_item)\n elif item % 2 == 0:\n result.append(item)\n return tuple(result)"}
{"task_id": "Mbpp/581", "solution": "def surface_Area(base_edge, height):\n # Calculate the surface area of a square pyramid\n # Formula: A = 1/3 * base_area * height + 1/2 * base_perimeter * height\n base_area = base_edge ** 2\n base_perimeter = 4 * base_edge\n surface_area = 1/3 * base_area * height + 1/2 * base_perimeter * height\n return surface_area"}
{"task_id": "Mbpp/583", "solution": "def catalan_number(n):\n if n <= 1:\n return 1\n\n catalan = [0 for _ in range(n+1)]\n catalan[0] = 1\n catalan[1] = 1\n\n for i in range(2, n+1):\n for j in range(i):\n catalan[i] += catalan[j] * catalan[i-j-1]\n\n return catalan[n]"}
{"task_id": "Mbpp/585", "solution": "def expensive_items(dataset, n):\n # Sort the dataset by price in descending order\n sorted_dataset = sorted(dataset, key=lambda x: x['price'], reverse=True)\n # Return the first n items from the sorted dataset\n return sorted_dataset[:n]"}
{"task_id": "Mbpp/586", "solution": "def split_Arr(arr, n):\n return arr[n:] + arr[:n]"}
{"task_id": "Mbpp/587", "solution": "def list_tuple(lst):\n return tuple(lst)"}
{"task_id": "Mbpp/588", "solution": "def big_diff(lst):\n if lst:\n return max(lst) - min(lst)\n else:\n return 0"}
{"task_id": "Mbpp/589", "solution": "def perfect_squares(start, end):\n return [i**2 for i in range(int(start**0.5), int(end**0.5)+1)]"}
{"task_id": "Mbpp/590", "solution": "import cmath\ndef polar_rect(r, theta):\n x = r * cmath.cos(theta)\n y = r * cmath.sin(theta)\n return (x.real, y.real)"}
{"task_id": "Mbpp/591", "solution": "def swap_List(lst):\n # Swap first and last elements\n lst[0], lst[-1] = lst[-1], lst[0]\n return lst"}
{"task_id": "Mbpp/592", "solution": "import math\ndef sum_Of_product(n):\n sum_product = 0\n for i in range(1, n):\n sum_product += math.comb(n, i) * math.comb(n, i+1)\n return sum_product"}
{"task_id": "Mbpp/593", "solution": "def removezero_ip(ip):\n ip_parts = ip.split('.')\n ip_parts = [str(int(part)) for part in ip_parts]\n return '.'.join(ip_parts)"}
{"task_id": "Mbpp/594", "solution": "def diff_even_odd(lst):\n even = next((x for x in lst if x % 2 == 0), None)\n odd = next((x for x in lst if x % 2 != 0), None)\n return even - odd if even and odd else None"}
{"task_id": "Mbpp/596", "solution": "import sys\ndef tuple_size(t):\n return sys.getsizeof(t)"}
{"task_id": "Mbpp/597", "solution": "def find_kth(nums1, nums2, k):\n \"\"\"\n Find kth element from the given two sorted arrays.\n \"\"\"\n # Merge the two sorted arrays\n merged = sorted(nums1 + nums2)\n # Return the kth element\n return merged[k - 1]"}
{"task_id": "Mbpp/598", "solution": "def armstrong_number(num):\n # Convert the number to string to find its length (number of digits)\n num_str = str(num)\n num_len = len(num_str)\n\n # Calculate the sum of the digits raised to the power of the number of digits\n sum_of_powers = sum(int(digit)**num_len for digit in num_str)\n\n # If the sum is equal to the original number, it's an Armstrong number\n return sum_of_powers == num"}
{"task_id": "Mbpp/599", "solution": "def sum_average(n):\n # calculate sum of first n natural numbers\n total_sum = n * (n + 1) // 2\n # calculate average of first n natural numbers\n avg = total_sum / n\n return (total_sum, avg)"}
{"task_id": "Mbpp/600", "solution": "def is_Even(n):\n return n % 2 == 0"}
{"task_id": "Mbpp/602", "solution": "def first_repeated_char(string):\n char_count = {}\n for char in string:\n if char in char_count:\n return char\n else:\n char_count[char] = 1\n return None"}
{"task_id": "Mbpp/603", "solution": "def get_ludic(n):\n def is_prime(num):\n if num < 2:\n return False\n for i in range(2, int(num**0.5) + 1):\n if num % i == 0:\n return False\n return True\n\n ludic_numbers = []\n for i in range(1, n+1):\n if is_prime(i):\n ludic_numbers.append(i)\n return ludic_numbers"}
{"task_id": "Mbpp/604", "solution": "def reverse_words(s):\n words = s.split(' ')\n reversed_words = ' '.join(reversed(words))\n return reversed_words"}
{"task_id": "Mbpp/605", "solution": "def prime_num(n):\n if n <= 1:\n return False\n elif n <= 3:\n return True\n elif n % 2 == 0 or n % 3 == 0:\n return False\n i = 5\n while i * i <= n:\n if n % i == 0 or n % (i + 2) == 0:\n return False\n i += 6\n return True"}
{"task_id": "Mbpp/606", "solution": "import math"}
{"task_id": "Mbpp/607", "solution": "import re\ndef find_literals(text, pattern):\n match = re.search(pattern, text)\n if match:\n return match.group(), match.start(), match.end()\n return None, None, None"}
{"task_id": "Mbpp/608", "solution": "def bell_Number(n):\n bell = [[0 for i in range(n+1)] for j in range(n+1)]\n bell[0][0] = 1\n for i in range(1, n+1):\n bell[i][0] = bell[i-1][i-1]\n for j in range(1, i+1):\n bell[i][j] = bell[i-1][j-1] + bell[i][j-1]\n return bell[n][0]"}
{"task_id": "Mbpp/610", "solution": "def remove_kth_element(lst, k):\n del lst[k]\n return lst"}
{"task_id": "Mbpp/611", "solution": "def max_of_nth(matrix, n):\n return max(row[n] for row in matrix)"}
{"task_id": "Mbpp/612", "solution": "def merge(lst):\n return [[sub[i] for sub in lst] for i in range(2)]"}
{"task_id": "Mbpp/614", "solution": "def cummulative_sum(tuples):\n total = 0\n for t in tuples:\n total += sum(t)\n return total"}
{"task_id": "Mbpp/615", "solution": "def average_tuple(tuples):\n averages = []\n for t in tuples:\n averages.append(sum(t)/len(t))\n return averages"}
{"task_id": "Mbpp/616", "solution": "def tuple_modulo(t1, t2):\n return tuple(map(lambda x, y: x % y, t1, t2))"}
{"task_id": "Mbpp/618", "solution": "def div_list(list1, list2):\n return [a / b for a, b in zip(list1, list2)]"}
{"task_id": "Mbpp/619", "solution": "def move_num(s):\n nums = [i for i in s if i.isdigit()]\n letters = [i for i in s if not i.isdigit()]\n return ''.join(letters + nums)"}
{"task_id": "Mbpp/620", "solution": "def largest_subset(lst):\n if not lst:\n return 0\n\n lst.sort()\n dp = [1] * len(lst)\n max_len = 1\n\n for i in range(1, len(lst)):\n for j in range(i):\n if lst[i] % lst[j] == 0 and dp[i] < dp[j] + 1:\n dp[i] = dp[j] + 1\n max_len = max(max_len, dp[i])\n\n return max_len"}
{"task_id": "Mbpp/622", "solution": "def get_median(list1, list2, n):\n merged_list = sorted(list1 + list2)\n if n % 2 == 0:\n median = (merged_list[n//2] + merged_list[n//2 - 1]) / 2\n else:\n median = merged_list[n//2]\n return median"}
{"task_id": "Mbpp/623", "solution": "def nth_nums(nums, n):\n return [num ** n for num in nums]"}
{"task_id": "Mbpp/624", "solution": "def convert_to_upper(s):\n return s.upper()\n\nassert convert_to_upper(\"person\") == \"PERSON\""}
{"task_id": "Mbpp/626", "solution": "import math"}
{"task_id": "Mbpp/628", "solution": "def replace_spaces(s):\n return s.replace(' ', '%20')"}
{"task_id": "Mbpp/629", "solution": "def find_even_numbers(numbers):\n return [num for num in numbers if num % 2 == 0]\n\nassert find_even_numbers([1,2,3,4,5]) == [2,4]"}
{"task_id": "Mbpp/630", "solution": "def get_coordinates(coordinate):\n x, y = coordinate\n adjacent_coordinates = []\n for i in range(-1, 2):\n for j in range(-1, 2):\n if not (i == 0 and j == 0):\n adjacent_coordinates.append([x + i, y + j])\n return adjacent_coordinates"}
{"task_id": "Mbpp/631", "solution": "def replace_spaces(s):\n return s.replace(' ', '_')"}
{"task_id": "Mbpp/632", "solution": "def move_zero(lst):\n # Count the number of zeros in the list\n num_zeros = lst.count(0)\n \n # Remove all zeros from the list\n lst = [num for num in lst if num != 0]\n \n # Extend the list with the number of zeros\n lst.extend([0]*num_zeros)\n \n return lst"}
{"task_id": "Mbpp/633", "solution": "def pair_xor_sum(lst, n):\n sum = 0\n for i in range(n):\n for j in range(i + 1, n):\n sum += lst[i] ^ lst[j]\n return sum\n\n# Test the function\nassert pair_xor_sum([5,9,7,6],4) == 47"}
{"task_id": "Mbpp/635", "solution": "def heap_sort(lst):\n def heapify(n, i):\n largest = i\n l = 2 * i + 1\n r = 2 * i + 2\n\n if l < n and lst[i] < lst[l]:\n largest = l\n\n if r < n and lst[largest] < lst[r]:\n largest = r\n\n if largest != i:\n lst[i], lst[largest] = lst[largest], lst[i]\n heapify(n, largest)\n\n n = len(lst)\n\n for i in range(n, -1, -1):\n heapify(n, i)\n\n for i in range(n-1, 0, -1):\n lst[i], lst[0] = lst[0], lst[i]\n heapify(i, 0)\n\n return lst"}
{"task_id": "Mbpp/637", "solution": "def noprofit_noloss(sell_price, cost_price):\n return sell_price != cost_price"}
{"task_id": "Mbpp/638", "solution": "def wind_chill(velocity, temperature):\n \"\"\"\n Calculate the wind chill index given the wind velocity in km/h and a temperature in celsius.\n \"\"\"\n # Formula for wind chill index\n wct_index = 13.12 + 0.6215*temperature - 11.37*(velocity**0.16) + 0.3965*temperature*(velocity**0.16)\n # Round to the next integer\n return round(wct_index + 0.5)"}
{"task_id": "Mbpp/639", "solution": "def sum_names(names):\n return sum(len(name) for name in names if name[0].isupper())\n\n# Test the function\nassert sum_names(['sally', 'Dylan', 'rebecca', 'Diana', 'Joanne', 'keith']) == 16"}
{"task_id": "Mbpp/641", "solution": "def is_nonagonal(n):\n return n * (7 * n - 5) // 2"}
{"task_id": "Mbpp/643", "solution": "import re\ndef text_match_wordz_middle(text):\n # Regular expression pattern to match words containing 'z' except at the start and end\n pattern = r'\\b\\w*z\\w*\\b'\n # Find all matches in the text\n matches = re.findall(pattern, text)\n # Check if any match is found\n if matches:\n # Check if each match is a word containing 'z' except at the start and end\n for match in matches:\n if match != 'z' and match[0] != 'z' and match[-1] != 'z':\n return True\n return False"}
{"task_id": "Mbpp/644", "solution": "def reverse_Array_Upto_K(arr, k):\n # Reverse the first k elements\n arr[:k] = arr[:k][::-1]\n return arr"}
{"task_id": "Mbpp/720", "solution": "def add_dict_to_tuple(tup, dic):\n return tup + (dic,)"}
{"task_id": "Mbpp/721", "solution": "def maxAverageOfPath(matrix):\n n = len(matrix)\n dp = [[0]*n for _ in range(n)]\n dp[0][0] = matrix[0][0]\n\n for i in range(1, n):\n dp[i][0] = dp[i-1][0] + matrix[i][0]\n dp[0][i] = dp[0][i-1] + matrix[0][i]\n\n for i in range(1, n):\n for j in range(1, n):\n dp[i][j] = max(dp[i-1][j], dp[i][j-1]) + matrix[i][j]\n\n return dp[-1][-1] / ((n-1) * 2)"}
{"task_id": "Mbpp/722", "solution": "def filter_data(students, min_height, min_weight):\n return {name: data for name, data in students.items() if data[0] >= min_height and data[1] >= min_weight}\nstudents = {'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)}\nmin_height = 6.0\nmin_weight = 70"}
{"task_id": "Mbpp/723", "solution": "def count_same_pair(list1, list2):\n if len(list1) != len(list2):\n raise ValueError(\"Both lists must have the same length\")\n return sum(1 for a, b in zip(list1, list2) if a == b)"}
{"task_id": "Mbpp/724", "solution": "def power_base_sum(base, power):\n return sum(int(digit) for digit in str(base ** power))"}
{"task_id": "Mbpp/725", "solution": "import re\ndef extract_quotation(s):\n return re.findall(r'\"([^\"]*)\"', s)"}
{"task_id": "Mbpp/726", "solution": "def multiply_elements(t):\n return tuple(t[i] * t[i + 1] for i in range(len(t) - 1))"}
{"task_id": "Mbpp/728", "solution": "def sum_list(list1, list2):\n return [a + b for a, b in zip(list1, list2)]"}
{"task_id": "Mbpp/730", "solution": "def consecutive_duplicates(lst):\n return [lst[i] for i in range(len(lst)) if i == 0 or lst[i] != lst[i-1]]"}
{"task_id": "Mbpp/731", "solution": "import math\ndef lateralsurface_cone(r, h):\n return math.pi * r * math.sqrt(r**2 + h**2)"}
{"task_id": "Mbpp/732", "solution": "def replace_specialchar(s):\n s = s.replace(' ', ':')\n s = s.replace(',', ':')\n s = s.replace('.', ':')\n return s"}
{"task_id": "Mbpp/733", "solution": "def find_first_occurrence(arr, target):\n left, right = 0, len(arr) - 1\n result = -1\n while left <= right:\n mid = left + (right - left) // 2\n if arr[mid] == target:\n result = mid\n right = mid - 1\n elif arr[mid] < target:\n left = mid + 1\n else:\n right = mid - 1\n return result"}
{"task_id": "Mbpp/734", "solution": "def sum_Of_Subarray_Prod(lst):\n n = len(lst)\n prod = 0\n for i in range(n):\n for j in range(i+1, n+1):\n sublist = lst[i:j]\n product = 1\n for num in sublist:\n product *= num\n prod += product\n return prod"}
{"task_id": "Mbpp/735", "solution": "def toggle_middle_bits(n):\n # Convert the number to binary and store it as a string\n binary = bin(n)[2:]\n\n # Toggle bits of the number except the first and the last bit\n for i in range(1, len(binary) - 1):\n if binary[i] == '1':\n binary = binary[:i] + '0' + binary[i+1:]\n else:\n binary = binary[:i] + '1' + binary[i+1:]\n\n # Convert the binary string back to an integer\n return int(binary, 2)"}
{"task_id": "Mbpp/736", "solution": "def left_insertion(arr, val):\n for i in range(len(arr)):\n if arr[i] >= val:\n return i\n return len(arr)"}
{"task_id": "Mbpp/737", "solution": "import re\ndef check_str(s):\n return bool(re.match(r'^[aeiou]', s, re.IGNORECASE))"}
{"task_id": "Mbpp/739", "solution": "import math\ndef find_Index(n):\n # The nth triangular number is given by the formula n*(n+1)/2\n # We can rearrange this to solve for n: n = (sqrt(8*T + 1) - 1) / 2, where T is the triangular number\n # We want to find the smallest such n that is greater than or equal to n\n # So we can use the math.ceil function to round up to the nearest integer\n return math.ceil((math.sqrt(8 * 10 ** (n-1) + 1) - 1) / 2)"}
{"task_id": "Mbpp/740", "solution": "def tuple_to_dict(tup):\n return {tup[i]: tup[i + 1] for i in range(0, len(tup), 2)}"}
{"task_id": "Mbpp/741", "solution": "def all_Characters_Same(s):\n return len(set(s)) <= 1"}
{"task_id": "Mbpp/742", "solution": "import math\ndef area_tetrahedron(edge_length):\n # The formula to calculate the area of a tetrahedron is sqrt(3) * edge_length ** 2\n return math.sqrt(3) * edge_length ** 2"}
{"task_id": "Mbpp/743", "solution": "def rotate_right(lst, k):\n # Calculate the effective rotation\n k = k % len(lst)\n # Use slicing to rotate the list\n return lst[-k:] + lst[:-k]"}
{"task_id": "Mbpp/744", "solution": "def check_none(tup):\n return None in tup"}
{"task_id": "Mbpp/745", "solution": "def divisible_by_digits(startnum, endnum):\n result = []\n for num in range(startnum, endnum+1):\n if all(digit != 0 and num % digit == 0 for digit in map(int, str(num))):\n result.append(num)\n return result"}
{"task_id": "Mbpp/748", "solution": "def capital_words_spaces(s):\n return ' '.join(s.split())"}
{"task_id": "Mbpp/749", "solution": "def sort_numeric_strings(lst):\n return sorted(int(i) for i in lst)"}
{"task_id": "Mbpp/750", "solution": "def add_tuple(lst, tup):\n return lst + list(tup)"}
{"task_id": "Mbpp/751", "solution": "def check_min_heap(arr):\n n = len(arr)\n\n # Iterate from the parent nodes to the root node\n for i in range(int(n/2)):\n # If left child is greater than parent\n if arr[i] > arr[2 * i + 1]:\n return False\n\n # If right child exists and is greater than parent\n if 2 * i + 2 < n and arr[i] > arr[2 * i + 2]:\n return False\n\n return True"}
{"task_id": "Mbpp/752", "solution": "def jacobsthal_num(n):\n if n == 0:\n return 0\n elif n == 1:\n return 1\n else:\n return 2 * jacobsthal_num(n - 1) + jacobsthal_num(n - 2)"}
{"task_id": "Mbpp/753", "solution": "def min_k(records, k):\n # Sort the records by the second element of each tuple\n sorted_records = sorted(records, key=lambda x: x[1])\n # Return the first k records\n return sorted_records[:k]"}
{"task_id": "Mbpp/754", "solution": "def extract_index_list(l1, l2, l3):\n common_elements = []\n for i in range(len(l1)):\n if l1[i] == l2[i] == l3[i]:\n common_elements.append(l1[i])\n return common_elements"}
{"task_id": "Mbpp/755", "solution": "def second_smallest(numbers):\n m1, m2 = float('inf'), float('inf')\n for x in numbers:\n if x <= m1:\n m1, m2 = x, m1\n elif x < m2:\n m2 = x\n return m2"}
{"task_id": "Mbpp/757", "solution": "def count_reverse_pairs(lst):\n count = 0\n for i in range(len(lst)):\n for j in range(i+1, len(lst)):\n if lst[i] == lst[j][::-1]:\n count += 1\n return count"}
{"task_id": "Mbpp/758", "solution": "def unique_sublists(lst):\n count_dict = {}\n for sublist in lst:\n tuple_sublist = tuple(sublist)\n if tuple_sublist in count_dict:\n count_dict[tuple_sublist] += 1\n else:\n count_dict[tuple_sublist] = 1\n return count_dict"}
{"task_id": "Mbpp/759", "solution": "def is_decimal(s):\n try:\n float(s)\n except ValueError:\n return False\n else:\n parts = s.split('.')\n if len(parts) == 2 and len(parts[1]) == 2:\n return True\n else:\n return False"}
{"task_id": "Mbpp/760", "solution": "def unique_Element(lst):\n return len(set(lst)) <= 1"}
{"task_id": "Mbpp/762", "solution": "def check_monthnumber_number(month_number):\n # Months with 30 days: 4, 6, 9, 11\n if month_number in [4, 6, 9, 11]:\n return True\n else:\n return False"}
{"task_id": "Mbpp/763", "solution": "def find_min_diff(arr, n):\n arr = sorted(arr)\n min_diff = float('inf')\n for i in range(1, n):\n diff = arr[i] - arr[i-1]\n min_diff = min(min_diff, diff)\n return min_diff"}
{"task_id": "Mbpp/764", "solution": "def number_ctr(s):\n return sum(c.isdigit() for c in s)"}
{"task_id": "Mbpp/765", "solution": "def is_polite(n):\n def is_power_of_two(n):\n return (n and (not(n & (n - 1))))\n\n def find_next_power_of_two(n):\n count = 0\n while (n):\n n >>= 1\n count += 1\n return count\n\n if (is_power_of_two(n)):\n return n << 1\n else:\n p = 1 << find_next_power_of_two(n)\n q = p >> 1\n if (n == (p + q - 1)):\n return p\n else:\n return p + q"}
{"task_id": "Mbpp/766", "solution": "def pair_wise(lst):\n return [(lst[i], lst[i + 1]) for i in range(len(lst) - 1)]"}
{"task_id": "Mbpp/767", "solution": "def get_pairs_count(lst, total):\n count = 0\n length = len(lst)\n for i in range(0, length):\n for j in range(i+1, length):\n if lst[i] + lst[j] == total:\n count += 1\n return count"}
{"task_id": "Mbpp/769", "solution": "def Diff(li1, li2): \n return [i for i in li1+li2 if i not in li1 or i not in li2]"}
{"task_id": "Mbpp/770", "solution": "def odd_num_sum(n):\n sum = 0\n for i in range(1, 2*n, 2):\n sum += i**4\n return sum"}
{"task_id": "Mbpp/771", "solution": "def check_expression(expr):\n stack = []\n brackets = {'(': ')', '{': '}', '[': ']'}\n for bracket in expr:\n if bracket in brackets:\n stack.append(bracket)\n elif len(stack) == 0 or brackets[stack.pop()] != bracket:\n return False\n return len(stack) == 0"}
{"task_id": "Mbpp/772", "solution": "def remove_length(s, k):\n words = s.split()\n words = [word for word in words if len(word) != k]\n return ' '.join(words)"}
{"task_id": "Mbpp/773", "solution": "def occurrence_substring(s, sub):\n pos = s.find(sub)\n if pos != -1:\n return (sub, pos, pos+len(sub))\n else:\n return None\n\n# Test the function"}
{"task_id": "Mbpp/775", "solution": "def odd_position(lst):\n return all(el % 2 != 0 for i, el in enumerate(lst) if i % 2 != 0)"}
{"task_id": "Mbpp/777", "solution": "def find_sum(lst):\n return sum(set(lst))"}
{"task_id": "Mbpp/778", "solution": "def pack_consecutive_duplicates(lst):\n result = []\n i = 0\n while i < len(lst):\n start = i\n while i < len(lst) - 1 and lst[i] == lst[i + 1]:\n i += 1\n result.append(lst[start:i+1])\n i += 1\n return result"}
{"task_id": "Mbpp/780", "solution": "from itertools import combinations\ndef find_combinations(tuples):\n result = []\n for i in range(2, len(tuples)+1):\n for combination in combinations(tuples, i):\n result.append(tuple(sum(x) for x in zip(*combination)))\n return result"}
{"task_id": "Mbpp/781", "solution": "def count_divisors(n):\n count = 0\n for i in range(1, n + 1):\n if n % i == 0:\n count += 1\n return count % 2 == 0"}
{"task_id": "Mbpp/782", "solution": "def odd_length_sum(arr):\n n = len(arr)\n res = 0\n for i in range(n):\n res += ((i+1)*(n-i)+1)//2*arr[i]\n return res"}
{"task_id": "Mbpp/784", "solution": "def mul_even_odd(lst):\n even_product = 1\n odd_product = 1\n for num in lst:\n if num % 2 == 0:\n even_product *= num\n else:\n odd_product *= num\n return even_product, odd_product"}
{"task_id": "Mbpp/785", "solution": "def tuple_str_int(tup_str):\n # Remove parentheses and split by comma\n str_list = tup_str[1:-1].split(',')\n # Convert each string to integer and return as tuple\n return tuple(map(int, str_list))"}
{"task_id": "Mbpp/786", "solution": "def right_insertion(arr, target):\n for i in range(len(arr)):\n if arr[i] > target:\n return i\n return len(arr)"}
{"task_id": "Mbpp/787", "solution": "import re\ndef text_match_three(text):\n pattern = 'abbb'\n if re.search(pattern, text):\n return True\n else:\n return False"}
{"task_id": "Mbpp/788", "solution": "def new_tuple(lst, string):\n return tuple(lst + [string])"}
{"task_id": "Mbpp/790", "solution": "def even_position(lst):\n for i in range(0, len(lst), 2):\n if lst[i] % 2 != 0:\n return False\n return True"}
{"task_id": "Mbpp/791", "solution": "def remove_nested(tup):\n return tuple(i for i in tup if not isinstance(i, tuple))"}
{"task_id": "Mbpp/792", "solution": "def count_list(lst):\n return len(lst)"}
{"task_id": "Mbpp/793", "solution": "def last(arr, target):\n try:\n return len(arr) - 1 - arr[::-1].index(target)\n except ValueError:\n return -1"}
{"task_id": "Mbpp/794", "solution": "import re\ndef text_starta_endb(text):\n pattern = 'a.*b$'\n if re.search(pattern, text):\n return True\n else:\n return False"}
{"task_id": "Mbpp/796", "solution": "def return_sum(dictionary):\n return sum(dictionary.values())"}
{"task_id": "Mbpp/797", "solution": "def sum_in_range(l, r):\n return sum(i for i in range(l, r+1) if i % 2 != 0)"}
{"task_id": "Mbpp/798", "solution": "def _sum(arr):\n return sum(arr)"}
{"task_id": "Mbpp/799", "solution": "def left_rotate(n, d):\n \"\"\"\n Function to rotate left bits of a number by d bits.\n \"\"\"\n # In n<<d, last d bits are 0. To put first 32-d bits of n at last, do bitwise or of n<<d and n>>(32-d)\n return (n << d)|(n >> (32 - d))"}
{"task_id": "Mbpp/800", "solution": "def remove_all_spaces(input_string):\n return input_string.replace(' ', '')"}
{"task_id": "Mbpp/801", "solution": "def test_three_equal(a, b, c):\n if a == b and b == c:\n return 3\n elif a == b or a == c or b == c:\n return 2\n else:\n return 0"}
{"task_id": "Mbpp/803", "solution": "def is_perfect_square(n):\n if n < 0:\n return False\n if n == 0 or n == 1:\n return True\n x = n // 2\n seen = set([x])\n while x * x != n:\n x = (x + (n // x)) // 2\n if x in seen:\n return False\n seen.add(x)\n return True"}
{"task_id": "Mbpp/804", "solution": "def is_product_even(lst):\n product = 1\n for num in lst:\n product *= num\n return product % 2 == 0"}
{"task_id": "Mbpp/805", "solution": "def max_sum_list(lst):\n return max(lst, key=sum)"}
{"task_id": "Mbpp/806", "solution": "def max_run_uppercase(s):\n max_length = 0\n current_length = 0\n for char in s:\n if char.isupper():\n current_length += 1\n max_length = max(max_length, current_length)\n else:\n current_length = 0\n return max_length"}
{"task_id": "Mbpp/807", "solution": "def first_odd(numbers):\n for num in numbers:\n if num % 2 != 0:\n return num\n return None"}
{"task_id": "Mbpp/808", "solution": "def check_K(tup, k):\n return k in tup"}
{"task_id": "Mbpp/809", "solution": "def check_smaller(t1, t2):\n return all(x < y for x, y in zip(t1, t2))"}