-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMBPP_samples.jsonl
257 lines (257 loc) · 56.3 KB
/
MBPP_samples.jsonl
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
{"task_id": 11, "completion": "def remove_Occ(s, ch):\n first_occ = s.find(ch)\n last_occ = s.rfind(ch)\n \n if first_occ != -1:\n s = s[:first_occ] + s[first_occ+1:]\n \n if last_occ != -1 and last_occ != first_occ:\n last_occ = s.rfind(ch)\n s = s[:last_occ] + s[last_occ+1:]\n \n return s"}
{"task_id": 12, "completion": "def sort_matrix(M):\n return sorted(M, key=lambda row: sum(row))"}
{"task_id": 14, "completion": "def find_Volume(l, b, h):\n base_area = 0.5 * b * h\n volume = base_area * l\n return volume"}
{"task_id": 16, "completion": "import re\ndef text_lowercase_underscore(text):\n return bool(re.fullmatch(r'[a-z]+(?:_[a-z]+)*', text))"}
{"task_id": 17, "completion": "def square_perimeter(a):\n return 4 * a"}
{"task_id": 18, "completion": "def remove_dirty_chars(string, second_string):\n # Create an array to keep track of characters in second_string\n char_presence = [False] * 256\n\n # Mark the characters present in second_string\n for char in second_string:\n char_presence[ord(char)] = True\n\n # Build the resultant string with characters not present in second_string\n result = []\n for char in string:\n if not char_presence[ord(char)]:\n result.append(char)\n\n return ''.join(result)"}
{"task_id": 19, "completion": "def test_duplicate(arraynums):\n seen = set()\n for num in arraynums:\n if num in seen:\n return True\n seen.add(num)\n return False"}
{"task_id": 20, "completion": "def is_woodall(x):\n if x <= 0:\n return False\n n = 0\n while True:\n woodall_number = (2**n) * n - 1\n if woodall_number == x:\n return True\n elif woodall_number > x:\n return False\n n += 1"}
{"task_id": 56, "completion": "def check(num):\n return int(str(num)[::-1])\n\ndef is_one_less_than_twice_its_reverse(num):\n reversed_num = check(num)\n return num == 2 * reversed_num - 1"}
{"task_id": 57, "completion": "def find_Max_Num(arr):\n from functools import cmp_to_key\n def compare(x, y):\n if x + y > y + x:\n return -1\n elif x + y < y + x:\n return 1\n else:\n return 0\n\n arr = list(map(str, arr))\n arr.sort(key=cmp_to_key(compare))\n return ''.join(arr) if arr[0] != '0' else '0'"}
{"task_id": 58, "completion": "def opposite_Signs(x, y):\n return (x < 0) != (y < 0)"}
{"task_id": 59, "completion": "def is_octagonal(n):\n if n < 1:\n return False\n num = (3 + (1 + 8 * (n - 1))**0.5) / 4\n return num.is_integer()\n\ndef nth_octagonal_number(n):\n if n < 1:\n raise ValueError(\"n must be a positive integer\")\n return n * (3 * n - 2)"}
{"task_id": 61, "completion": "def count_Substrings(s):\n def digit_sum(sub):\n return sum(int(char) for char in sub)\n \n n = len(s)\n count = 0\n \n for i in range(n):\n for j in range(i+1, n+1):\n sub = s[i:j]\n if digit_sum(sub) == len(sub):\n count += 1\n\n return count"}
{"task_id": 62, "completion": "def smallest_num(xs):\n if not xs:\n return None\n smallest = xs[0]\n for num in xs:\n if num < smallest:\n smallest = num\n return smallest"}
{"task_id": 63, "completion": "def max_difference(test_list):\n max_diff = 0\n for a, b in test_list:\n diff = abs(a - b)\n if diff > max_diff:\n max_diff = diff\n return max_diff"}
{"task_id": 64, "completion": "def subject_marks(subjectmarks):\n return sorted(subjectmarks, key=lambda x: x[1])"}
{"task_id": 65, "completion": "def recursive_list_sum(data_list):\n total = 0\n for element in data_list:\n if isinstance(element, (list, tuple)):\n total += recursive_list_sum(element)\n else:\n total += element\n return total"}
{"task_id": 66, "completion": "def pos_count(lst):\n count = 0\n for num in lst:\n if num > 0:\n count += 1\n return count"}
{"task_id": 67, "completion": "def bell_number(n):\n if n == 0:\n return 1\n\n bell = [[0 for i in range(n+1)] for j in range(n+1)]\n \n bell[0][0] = 1\n \n for i in range(1, n+1):\n bell[i][0] = bell[i-1][i-1]\n \n for j in range(1, i+1):\n bell[i][j] = bell[i-1][j-1] + bell[i][j-1]\n \n return bell[n][0]"}
{"task_id": 68, "completion": "def is_Monotonic(A):\n increasing = decreasing = True\n for i in range(1, len(A)):\n if A[i] > A[i - 1]:\n decreasing = False\n if A[i] < A[i - 1]:\n increasing = False\n return increasing or decreasing"}
{"task_id": 69, "completion": "def is_sublist(l, s):\n if not s:\n return True\n if not l:\n return False\n for i in range(len(l) - len(s) + 1):\n if l[i:i + len(s)] == s:\n return True\n return False"}
{"task_id": 70, "completion": "def get_equal(Input):\n if not Input:\n return True\n first_length = len(Input[0])\n for tup in Input:\n if len(tup) != first_length:\n return False\n return True"}
{"task_id": 71, "completion": "def comb_sort(nums):\n def get_next_gap(gap):\n gap = (gap * 10) // 13\n if gap < 1:\n return 1\n return gap\n \n n = len(nums)\n gap = n\n swapped = True\n\n while gap != 1 or swapped:\n gap = get_next_gap(gap)\n swapped = False\n\n for i in range(n - gap):\n if nums[i] > nums[i + gap]:\n nums[i], nums[i + gap] = nums[i + gap], nums[i]\n swapped = True\n \n return nums"}
{"task_id": 72, "completion": "def dif_Square(n):\n if n < 0:\n return False\n for a in range(int(n**0.5) + 1):\n b_squared = a**2 - n\n if b_squared >= 0 and int(b_squared**0.5)**2 == b_squared:\n return True\n return False"}
{"task_id": 74, "completion": "def is_samepatterns(colors, patterns):\n if len(colors) != len(patterns):\n return False\n \n color_to_pattern = {}\n pattern_to_color = {}\n \n for color, pattern in zip(colors, patterns):\n if color in color_to_pattern:\n if color_to_pattern[color] != pattern:\n return False\n else:\n color_to_pattern[color] = pattern\n \n if pattern in pattern_to_color:\n if pattern_to_color[pattern] != color:\n return False\n else:\n pattern_to_color[pattern] = color\n \n return True"}
{"task_id": 75, "completion": "def find_tuples(test_list, K):\n return [tup for tup in test_list if all(element % K == 0 for element in tup)]"}
{"task_id": 77, "completion": "def is_Diff(n):\n # Check if the absolute difference of the sum of the digits in the odd and even positions is divisible by 11\n n_str = str(n)\n odd_sum = sum(int(n_str[i]) for i in range(0, len(n_str), 2))\n even_sum = sum(int(n_str[i]) for i in range(1, len(n_str), 2))\n return (odd_sum - even_sum) % 11 == 0"}
{"task_id": 79, "completion": "def word_len(s):\n return len(s) % 2 != 0"}
{"task_id": 80, "completion": "def tetrahedral_number(n):\n return (n * (n + 1) * (n + 2)) // 6"}
{"task_id": 82, "completion": "import math\ndef volume_sphere(r):\n return (4/3) * math.pi * r**3"}
{"task_id": 83, "completion": "def get_Char(strr):\n total_ascii = sum(ord(char) for char in strr)\n modulo_26 = total_ascii % 26\n result_char = chr(modulo_26 + ord('A'))\n return result_char"}
{"task_id": 84, "completion": "def sequence(n): \n if n < 1:\n return \"Input must be a positive integer\"\n if n == 1: \n return 1 \n if n == 2: \n return 1 \n seq = [0, 1, 1] \n for i in range(3, n + 1): \n seq.append(seq[seq[i - 1]] + seq[i - seq[i - 1]]) \n return seq[n]"}
{"task_id": 85, "completion": "import math\ndef surfacearea_sphere(r):\n return 4 * math.pi * r**2"}
{"task_id": 86, "completion": "def centered_hexagonal_number(n):\n return 3 * n * (n - 1) + 1"}
{"task_id": 87, "completion": "import collections\ndef merge_dictionaries_three(dict1, dict2, dict3):\n merged_dict = collections.ChainMap(dict1, dict2, dict3)\n return dict(merged_dict)"}
{"task_id": 88, "completion": "import collections\ndef freq_count(list1):\n return dict(collections.Counter(list1))"}
{"task_id": 89, "completion": "def closest_num(N):\n for i in range(N - 1, -1, -1):\n if i < N:\n return i"}
{"task_id": 90, "completion": "def len_log(list1):\n if not list1:\n return 0\n longest_word = max(list1, key=len)\n return len(longest_word)"}
{"task_id": 91, "completion": "def find_substring(str_list, sub_str):\n return any(sub_str in s for s in str_list)"}
{"task_id": 92, "completion": "def is_undulating(n):\n num_str = str(n)\n if len(num_str) <= 1:\n return False\n a = num_str[0]\n b = num_str[1]\n if a == b:\n return False\n for i in range(2, len(num_str)):\n if i % 2 == 0 and num_str[i] != a:\n return False\n elif i % 2 == 1 and num_str[i] != b:\n return False\n return True"}
{"task_id": 93, "completion": "def power(a, b):\n return a ** b"}
{"task_id": 94, "completion": "from operator import itemgetter\ndef index_minimum(test_list):\n return min(test_list, key=itemgetter(1))[0]"}
{"task_id": 95, "completion": "def Find_Min_Length(lst):\n if not lst:\n return 0\n min_length = float('inf')\n for sublist in lst:\n if isinstance(sublist, list) and len(sublist) < min_length:\n min_length = len(sublist)\n return min_length if min_length != float('inf') else 0"}
{"task_id": 96, "completion": "def divisor(n):\n if n < 1:\n return 0\n count = 0\n for i in range(1, n + 1):\n if n % i == 0:\n count += 1\n return count"}
{"task_id": 97, "completion": "def frequency_lists(list1):\n flattened_list = [item for sublist in list1 for item in sublist]\n frequency_dict = {}\n for item in flattened_list:\n if item in frequency_dict:\n frequency_dict[item] += 1\n else:\n frequency_dict[item] = 1\n return frequency_dict"}
{"task_id": 98, "completion": "def multiply_num(numbers):\n product = 1\n for number in numbers:\n product *= number\n if len(numbers) == 0:\n return 0\n return product / len(numbers)"}
{"task_id": 99, "completion": "def decimal_to_binary(n):\n if n == 0:\n return \"0\"\n binary = \"\"\n while n > 0:\n binary = str(n % 2) + binary\n n = n // 2\n return binary"}
{"task_id": 100, "completion": "def next_smallest_palindrome(num):\n def is_palindrome(n):\n return str(n) == str(n)[::-1]\n\n num += 1\n while not is_palindrome(num):\n num += 1\n \n return num"}
{"task_id": 101, "completion": "def kth_element(arr, k):\n if k > 0 and k <= len(arr):\n return arr[k-1]\n else:\n return None"}
{"task_id": 102, "completion": "def snake_to_camel(word):\n components = word.split('_')\n return components[0] + ''.join(x.title() for x in components[1:])"}
{"task_id": 103, "completion": "def eulerian_num(n, m):\n if m >= n or m < 0:\n return 0\n if m == 0 and n == 0:\n return 1\n return (n - m) * eulerian_num(n - 1, m - 1) + (m + 1) * eulerian_num(n - 1, m)"}
{"task_id": 104, "completion": "def sort_sublists(input_list):\n return [sorted(sublist) for sublist in input_list]"}
{"task_id": 105, "completion": "def count(lst):\n return sum(bool(item) for item in lst)"}
{"task_id": 106, "completion": "def add_lists(test_list, test_tup):\n return tuple(item + tuple(test_list) for item in test_tup)"}
{"task_id": 108, "completion": "import heapq\ndef merge_sorted_list(num1, num2, num3):\n merged_list = list(heapq.merge(num1, num2, num3))\n return merged_list"}
{"task_id": 109, "completion": "def odd_Equivalent(s, n):\n def rotate_string(s, n):\n return s[-n:] + s[:-n]\n\n def is_odd(binary_str):\n return int(binary_str, 2) % 2 != 0\n\n count = 0\n s_length = len(s)\n\n for i in range(min(n, s_length)):\n rotated_s = rotate_string(s, i)\n if is_odd(rotated_s):\n count += 1\n\n return count"}
{"task_id": 111, "completion": "def common_in_nested_lists(nestedlist):\n if not nestedlist or not all(nestedlist):\n return []\n \n common_elements = set(nestedlist[0])\n \n for lst in nestedlist[1:]:\n common_elements.intersection_update(lst)\n \n return list(common_elements)"}
{"task_id": 113, "completion": "def check_integer(text):\n try:\n int(text)\n return True\n except ValueError:\n return False"}
{"task_id": 115, "completion": "def empty_dit(list1):\n return all(not d for d in list1)"}
{"task_id": 116, "completion": "def tuple_to_int(nums):\n return int(''.join(map(str, nums)))"}
{"task_id": 117, "completion": "def list_to_float(test_list):\n def try_convert(element):\n try:\n return float(element)\n except (ValueError, TypeError):\n return element\n \n return [[try_convert(item) for item in sublist] for sublist in test_list]"}
{"task_id": 118, "completion": "def string_to_list(string):\n return string.split(' ')"}
{"task_id": 119, "completion": "def search(arr):\n low, high = 0, len(arr) - 1\n while low < high:\n mid = (low + high) // 2\n if mid % 2 == 1:\n mid -= 1\n if arr[mid] == arr[mid + 1]:\n low = mid + 2\n else:\n high = mid\n return arr[low]"}
{"task_id": 120, "completion": "def max_product_tuple(list1):\n if not list1:\n return None\n max_product = float('-inf')\n for pair in list1:\n product = abs(pair[0] * pair[1])\n if product > max_product:\n max_product = product\n return max_product"}
{"task_id": 123, "completion": "def amicable_numbers_sum(limit):\n def sum_of_divisors(n):\n divisors_sum = 1\n for i in range(2, int(n**0.5)+1):\n if n % i == 0:\n divisors_sum += i\n if i != n // i:\n divisors_sum += n // i\n return divisors_sum\n\n def is_amicable(a):\n b = sum_of_divisors(a)\n return a != b and sum_of_divisors(b) == a\n\n total_sum = 0\n for num in range(2, limit):\n if is_amicable(num):\n total_sum += num\n \n return total_sum"}
{"task_id": 124, "completion": "import cmath\ndef angle_complex(a, b):\n complex_number = complex(a, b)\n return cmath.phase(complex_number)"}
{"task_id": 125, "completion": "def find_length(string):\n max_diff = float('-inf')\n current_diff = 0\n\n for char in string:\n if char == '0':\n current_diff += 1\n else:\n current_diff -= 1\n\n if current_diff > max_diff:\n max_diff = current_diff\n\n if current_diff < 0:\n current_diff = 0\n\n return max_diff if max_diff != float('-inf') else 0"}
{"task_id": 126, "completion": "def sum(a, b):\n def find_divisors(n):\n divisors = set()\n for i in range(1, int(n**0.5) + 1):\n if n % i == 0:\n divisors.add(i)\n divisors.add(n // i)\n return divisors\n\n divisors_a = find_divisors(a)\n divisors_b = find_divisors(b)\n common_divisors = divisors_a.intersection(divisors_b)\n return sum(common_divisors)"}
{"task_id": 127, "completion": "def multiply_int(x, y):\n return x * y"}
{"task_id": 128, "completion": "def long_words(n, str):\n result = [word for word in str if len(word) > n]\n return result"}
{"task_id": 129, "completion": "def magic_square_test(my_matrix):\n if not my_matrix:\n return False\n\n n = len(my_matrix)\n if any(len(row) != n for row in my_matrix):\n return False\n\n magic_sum = sum(my_matrix[0])\n\n for row in my_matrix:\n if sum(row) != magic_sum:\n return False\n\n for col in range(n):\n if sum(my_matrix[row][col] for row in range(n)) != magic_sum:\n return False\n\n if sum(my_matrix[i][i] for i in range(n)) != magic_sum:\n return False\n\n if sum(my_matrix[i][n - 1 - i] for i in range(n)) != magic_sum:\n return False\n\n return True"}
{"task_id": 130, "completion": "from collections import defaultdict\ndef max_occurrences(nums):\n freq = defaultdict(int)\n for num in nums:\n freq[num] += 1\n max_freq = 0\n max_item = None\n for item, count in freq.items():\n if count > max_freq:\n max_freq = count\n max_item = item\n return max_item"}
{"task_id": 131, "completion": "def reverse_vowels(str1):\n vowels = \"aeiouAEIOU\"\n s = list(str1)\n i, j = 0, len(s) - 1\n while i < j:\n if s[i] in vowels and s[j] in vowels:\n s[i], s[j] = s[j], s[i]\n i += 1\n j -= 1\n elif s[i] in vowels:\n j -= 1\n elif s[j] in vowels:\n i += 1\n else:\n i += 1\n j -= 1\n return \"\".join(s)"}
{"task_id": 132, "completion": "def tup_string(tup1):\n return ''.join(map(str, tup1))"}
{"task_id": 133, "completion": "def sum_negativenum(nums):\n return sum(num for num in nums if num < 0)"}
{"task_id": 135, "completion": "def hexagonal_num(n):\n return n * (2 * n - 1)"}
{"task_id": 137, "completion": "def zero_count(nums):\n zeroes = sum(1 for num in nums if num == 0)\n non_zeroes = len(nums) - zeroes\n if non_zeroes == 0:\n return float('inf')\n return zeroes / non_zeroes"}
{"task_id": 138, "completion": "def is_Sum_Of_Powers_Of_Two(n):\n while n > 0:\n if n % 2 == 0:\n n //= 2\n else:\n n -= 1\n if n == 0:\n return True\n return False"}
{"task_id": 139, "completion": "def circle_circumference(r):\n pi = 3.141592653589793\n return 2 * pi * r"}
{"task_id": 140, "completion": "def extract_singly(test_list):\n flattened_set = {item for sublist in test_list for item in sublist}\n return flattened_set"}
{"task_id": 141, "completion": "def pancake_sort(nums):\n def flip(arr, k):\n start = 0\n while start < k:\n arr[start], arr[k] = arr[k], arr[start]\n start += 1\n k -= 1\n\n for size in range(len(nums), 1, -1):\n max_index = nums.index(max(nums[:size]))\n if max_index + 1 != size:\n flip(nums, max_index)\n flip(nums, size - 1)\n \n return nums"}
{"task_id": 142, "completion": "def count_samepair(list1, list2, list3):\n return sum(1 for x, y, z in zip(list1, list2, list3) if x == y == z)"}
{"task_id": 143, "completion": "def find_lists(Input):\n return sum(isinstance(item, list) for item in Input)"}
{"task_id": 145, "completion": "def max_Abs_Diff(arr):\n if len(arr) < 2:\n return 0\n max_element = max(arr)\n min_element = min(arr)\n return max_element - min_element"}
{"task_id": 160, "completion": "def find_solution(a, b, n):\n def gcd_extended(a, b):\n if a == 0:\n return b, 0, 1\n gcd, x1, y1 = gcd_extended(b % a, a)\n x = y1 - (b // a) * x1\n y = x1\n return gcd, x, y\n\n gcd, x, y = gcd_extended(a, b)\n if n % gcd != 0:\n return None\n\n x *= n // gcd\n y *= n // gcd\n return x, y"}
{"task_id": 161, "completion": "def remove_elements(list1, list2):\n return [element for element in list1 if element not in list2]"}
{"task_id": 162, "completion": "def sum_series(n):\n total = 0\n for i in range(n // 2 + 1):\n total += (n - 2 * i)\n return total"}
{"task_id": 163, "completion": "from math import tan,pi\ndef area_polygon(s, l):\n area = (s * l**2) / (4 * tan(pi / s))\n return area"}
{"task_id": 164, "completion": "import math \ndef div_sum(n): \n total = 1\n i = 2\n\n while i * i <= n:\n if (n % i == 0):\n total = (total + i + math.floor(n / i))\n i += 1\n\n return total\n\ndef are_equivalent(num1, num2): \n return div_sum(num1) == div_sum(num2); "}
{"task_id": 165, "completion": "def count_char_position(str1):\n count = 0\n for i, char in enumerate(str1.lower()):\n if ord(char) - 97 == i:\n count += 1\n return count"}
{"task_id": 166, "completion": "def find_even_pair(A):\n def xor_even(x, y):\n return (x ^ y) % 2 == 0\n \n count = 0\n n = len(A)\n \n for i in range(n):\n for j in range(i+1, n):\n if xor_even(A[i], A[j]):\n count += 1\n \n return count"}
{"task_id": 167, "completion": "def next_power_of_2(n):\n if n <= 0:\n return 1\n power = 1\n while power < n:\n power *= 2\n return power"}
{"task_id": 168, "completion": "def frequency(a,x):\n count = 0\n for number in a:\n if number == x:\n count += 1\n return count"}
{"task_id": 170, "completion": "def sum_range_list(list1, m, n):\n if m < 0 or n >= len(list1) or m > n:\n return 'Invalid indices'\n return sum(list1[m:n+1])"}
{"task_id": 171, "completion": "def perimeter_pentagon(a):\n return 5 * a"}
{"task_id": 172, "completion": "def count_occurance(s):\n return s.count('std')"}
{"task_id": 222, "completion": "def check_type(test_tuple):\n if not test_tuple:\n return True\n first_type = type(test_tuple[0])\n return all(isinstance(i, first_type) for i in test_tuple)"}
{"task_id": 223, "completion": "def is_majority(arr, n, x):\n def find_first_occurrence(arr, n, x):\n low, high = 0, n - 1\n while low <= high:\n mid = (low + high) // 2\n if (mid == 0 or x > arr[mid - 1]) and arr[mid] == x:\n return mid\n elif x > arr[mid]:\n low = mid + 1\n else:\n high = mid - 1\n return -1\n\n first_occurrence = find_first_occurrence(arr, n, x)\n if first_occurrence == -1:\n return False\n \n if first_occurrence + n // 2 < n and arr[first_occurrence + n // 2] == x:\n return True\n else:\n return False"}
{"task_id": 224, "completion": "def count_Set_Bits(n):\n count = 0\n while n:\n count += n & 1\n n >>= 1\n return count"}
{"task_id": 226, "completion": "def odd_values_string(str):\n return ''.join([str[i] for i in range(len(str)) if i % 2 == 0])"}
{"task_id": 227, "completion": "def min_of_three(a, b, c):\n return min(a, b, c)"}
{"task_id": 228, "completion": "def all_Bits_Set_In_The_Given_Range(n, l, r):\n for i in range(l, r + 1):\n if (n & (1 << i)) != 0:\n return False\n return True"}
{"task_id": 229, "completion": "def re_arrange_array(arr, n):\n neg = [x for x in arr[:n] if x < 0]\n pos = [x for x in arr[:n] if x >= 0]\n result = neg + pos + arr[n:]\n arr[:n] = result[:n]\n return arr"}
{"task_id": 230, "completion": "def replace_blank(str1, char):\n return str1.replace(' ', char)"}
{"task_id": 232, "completion": "import heapq\ndef larg_nnum(list1, n):\n return heapq.nlargest(n, list1)"}
{"task_id": 233, "completion": "def lateralsuface_cylinder(r, h):\n return 2 * 3.141592653589793 * r * h"}
{"task_id": 234, "completion": "def volume_cube(l):\n return l ** 3"}
{"task_id": 235, "completion": "def even_bit_set_number(n):\n bit_length = n.bit_length()\n even_bit_mask = 0\n for i in range(0, bit_length, 2):\n even_bit_mask |= (1 << i)\n return n | even_bit_mask"}
{"task_id": 237, "completion": "from collections import Counter\ndef check_occurences(test_list):\n return dict(Counter(test_list))"}
{"task_id": 238, "completion": "def number_of_substrings(s):\n n = len(s)\n return (n * (n + 1)) // 2"}
{"task_id": 239, "completion": "def get_total_number_of_sequences(m, n):\n def count_sequences(prev, length):\n if length == 0:\n return 1\n total = 0\n for i in range(prev * 2, m + 1):\n total += count_sequences(i, length - 1)\n return total\n\n total_sequences = 0\n for start in range(1, m + 1):\n total_sequences += count_sequences(start, n - 1)\n\n return total_sequences"}
{"task_id": 240, "completion": "def replace_list(list1, list2):\n if list1:\n list1[-1:] = list2\n return list1"}
{"task_id": 242, "completion": "def count_charac(str1):\n return len(str1)"}
{"task_id": 244, "completion": "import math\ndef next_Perfect_Square(N):\n root = math.sqrt(N)\n next_root = math.ceil(root)\n next_perfect_square = next_root ** 2\n return next_perfect_square"}
{"task_id": 245, "completion": "def max_sum(arr):\n n = len(arr)\n \n if n == 0:\n return 0\n \n inc = [0] * n\n dec = [0] * n\n \n for i in range(n):\n inc[i] = arr[i]\n dec[i] = arr[i]\n \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\n for i in reversed(range(n-1)):\n for j in range(i+1, n):\n if arr[i] > arr[j] and dec[i] < dec[j] + arr[i]:\n dec[i] = dec[j] + arr[i]\n \n max_sum = 0\n for i in range(n):\n max_sum = max(max_sum, inc[i] + dec[i] - arr[i])\n \n return max_sum"}
{"task_id": 246, "completion": "def babylonian_squareroot(number, tolerance=1e-10):\n if number < 0:\n raise ValueError(\"Cannot compute square root of a negative number\")\n x = number\n y = 1.0\n while abs(x - y) > tolerance:\n x = (x + y) / 2\n y = number / x\n return x"}
{"task_id": 247, "completion": "def lps(str):\n n = len(str)\n dp = [[0 for _ in range(n)] for _ in range(n)]\n \n for i in range(n):\n dp[i][i] = 1\n \n for cl in range(2, n+1):\n for i in range(n - cl + 1):\n j = i + cl - 1\n if str[i] == str[j] and cl == 2:\n dp[i][j] = 2\n elif str[i] == str[j]:\n dp[i][j] = dp[i+1][j-1] + 2\n else:\n dp[i][j] = max(dp[i][j-1], dp[i+1][j])\n \n return dp[0][n-1]"}
{"task_id": 248, "completion": "def harmonic_sum(n):\n if n < 2:\n return 0\n else:\n return harmonic_sum(n - 1) + 1 / (n - 1)"}
{"task_id": 249, "completion": "def intersection_array(array_nums1, array_nums2):\n set_nums1 = set(array_nums1)\n set_nums2 = set(array_nums2)\n intersection = list(set_nums1 & set_nums2)\n return intersection"}
{"task_id": 250, "completion": "def count_X(tup, x):\n return tup.count(x)"}
{"task_id": 251, "completion": "def insert_element(lst, element):\n result = []\n for item in lst:\n result.append(element)\n result.append(item)\n return result"}
{"task_id": 252, "completion": "def convert(numbers):\n polar_coordinates = []\n for number in numbers:\n polar_coord = cmath.polar(number)\n polar_coordinates.append(polar_coord)\n return polar_coordinates"}
{"task_id": 253, "completion": "def count_integer(list1):\n count = 0\n for element in list1:\n if isinstance(element, int):\n count += 1\n return count"}
{"task_id": 255, "completion": "from itertools import combinations_with_replacement \ndef combinations_colors(l, n):\n return list(combinations_with_replacement(l, n))"}
{"task_id": 256, "completion": "def count_Primes_nums(n):\n if n <= 2:\n return 0\n sieve = [True] * n\n sieve[0] = sieve[1] = False\n for start in range(2, int(n**0.5) + 1):\n if sieve[start]:\n for multiple in range(start*start, n, start):\n sieve[multiple] = False\n return sum(sieve)"}
{"task_id": 257, "completion": "def swap_numbers(a, b):\n return (b, a)"}
{"task_id": 259, "completion": "def maximize_elements(test_tup1, test_tup2):\n if len(test_tup1) != len(test_tup2):\n raise ValueError(\"Tuples must be of the same length\")\n return tuple(max(a, b) for a, b in zip(test_tup1, test_tup2))"}
{"task_id": 260, "completion": "def newman_prime(n):\n if n == 0:\n return 1\n if n == 1:\n return 1\n ns_numbers = [1, 1]\n for i in range(2, n + 1):\n next_ns = 2 * ns_numbers[i - 1] + ns_numbers[i - 2]\n ns_numbers.append(next_ns)\n return ns_numbers[n]\n\ndef nth_newman_prime(n):\n count = 0\n i = 0\n while count <= n:\n candidate = newman_prime(i)\n i += 1\n if all(candidate % j != 0 for j in range(2, int(candidate**0.5) + 1)):\n count += 1\n nth_prime = candidate\n return nth_prime"}
{"task_id": 261, "completion": "def division_elements(test_tup1, test_tup2):\n if len(test_tup1) != len(test_tup2):\n raise ValueError(\"Input tuples must have the same length\")\n \n return tuple(a / b for a, b in zip(test_tup1, test_tup2))"}
{"task_id": 262, "completion": "def split_two_parts(list1, L):\n if L < 0 or L > len(list1):\n raise ValueError(\"L must be within the range of the list length\")\n part1 = list1[:L]\n part2 = list1[L:]\n return (part1, part2)"}
{"task_id": 264, "completion": "def dog_age(h_age):\n if h_age <= 0:\n return \"Age must be a positive number\"\n elif h_age == 1:\n return 15\n elif h_age == 2:\n return 24\n else:\n return 24 + (h_age - 2) * 5"}
{"task_id": 265, "completion": "def list_split(S, step):\n return [S[i:i + step] for i in range(0, len(S), step)]"}
{"task_id": 266, "completion": "def lateralsurface_cube(l):\n return 4 * l * l"}
{"task_id": 267, "completion": "def square_Sum(n):\n sum_of_squares = 0\n current_odd_number = 1\n for _ in range(n):\n sum_of_squares += current_odd_number ** 2\n current_odd_number += 2\n return sum_of_squares"}
{"task_id": 268, "completion": "def find_star_num(n):\n if n <= 0:\n return 0\n return 6 * n * (n - 1) // 2 + 1"}
{"task_id": 269, "completion": "def ascii_value(k):\n return ord(k)"}
{"task_id": 270, "completion": "def sum_even_and_even_index(arr):\n return sum(value for index, value in enumerate(arr) if index % 2 == 0 and value % 2 == 0)"}
{"task_id": 271, "completion": "def even_Power_Sum(n):\n return sum((2 * i) ** 5 for i in range(1, n + 1))"}
{"task_id": 272, "completion": "def rear_extract(test_list):\n return [t[-1] for t in test_list]"}
{"task_id": 273, "completion": "def substract_elements(test_tup1, test_tup2):\n if len(test_tup1) != len(test_tup2):\n raise ValueError(\"Both tuples must have the same length\")\n return tuple(a - b for a, b in zip(test_tup1, test_tup2))"}
{"task_id": 274, "completion": "import math\ndef even_binomial_Coeff_Sum(n):\n sum = 0\n for k in range(0, n + 1, 2):\n sum += math.comb(n, k)\n return sum"}
{"task_id": 276, "completion": "def volume_cylinder(r, h):\n import math\n return math.pi * r**2 * h"}
{"task_id": 277, "completion": "def dict_filter(dict, n):\n return {key: value for key, value in dict.items() if value >= n}"}
{"task_id": 278, "completion": "def count_first_elements(test_tup, element):\n if element in test_tup:\n return test_tup.index(element)\n else:\n return -1"}
{"task_id": 279, "completion": "def is_num_decagonal(n):\n if n < 1:\n return False\n for i in range(1, n + 1):\n decagonal_num = i * (4 * i - 3)\n if decagonal_num == n:\n return True\n if decagonal_num > n:\n return False\n return False\n\ndef nth_decagonal_number(n):\n if n < 1:\n return None\n return n * (4 * n - 3)"}
{"task_id": 280, "completion": "def sequential_search(dlist, item):\n for index, element in enumerate(dlist):\n if element == item:\n return (True, index)\n return (False, -1)"}
{"task_id": 281, "completion": "def all_unique(test_list):\n seen = set()\n for item in test_list:\n if item in seen:\n return False\n seen.add(item)\n return True"}
{"task_id": 282, "completion": "def sub_list(nums1, nums2):\n return [a - b for a, b in zip(nums1, nums2)]"}
{"task_id": 283, "completion": "def validate(n):\n from collections import Counter\n digit_count = Counter(str(n))\n for digit, count in digit_count.items():\n if count > int(digit):\n return False\n return True"}
{"task_id": 284, "completion": "def check_element(lst, element):\n for item in lst:\n if item != element:\n return False\n return True"}
{"task_id": 285, "completion": "import re\ndef text_match_two_three(text):\n pattern = r'ab{2,3}'\n if re.search(pattern, text):\n return True\n else:\n return False"}
{"task_id": 286, "completion": "def max_crossing_sum(a, n):\n max_left = max_right = float('-inf')\n temp_sum = 0\n for i in range(n):\n temp_sum += a[i % len(a)]\n if temp_sum > max_left:\n max_left = temp_sum\n temp_sum = 0\n for i in range(n-1, -1, -1):\n temp_sum += a[i % len(a)]\n if temp_sum > max_right:\n max_right = temp_sum\n return max_left + max_right - a[0] - a[-1]\n\ndef max_sub_array_sum_repeated(a, n, k):\n if n == 0 or k == 0:\n return 0\n kadane_sum = max_sum = curr_sum = a[0]\n for i in range(1, n):\n curr_sum = max(a[i % len(a)], curr_sum + a[i % len(a)])\n max_sum = max(max_sum, curr_sum)\n if k == 1:\n return max_sum\n prefix_sum = [0] * n\n suffix_sum = [0] * n\n prefix_sum[0] = curr_sum = a[0]\n for i in range(1, n):\n curr_sum += a[i % len(a)]\n prefix_sum[i] = max(prefix_sum[i-1], curr_sum)\n suffix_sum[n-1] = curr_sum = a[-1]\n for i in range(n-2, -1, -1):\n curr_sum += a[i % len(a)]\n suffix_sum[i] = max(suffix_sum[i+1], curr_sum)\n total_sum = sum(a)\n if total_sum > 0:\n return max(max_sum, prefix_sum[n-1] + (k-2) * total_sum + suffix_sum[0], max_crossing_sum(a, k * n))\n else:\n return max(max_sum, prefix_sum[n-1] + suffix_sum[0])"}
{"task_id": 287, "completion": "def square_Sum(n):\n return sum((2*i)**2 for i in range(1, n+1))"}
{"task_id": 290, "completion": "def max_length(list1):\n if not list1:\n return []\n max_len = max(len(lst) for lst in list1)\n return [lst for lst in list1 if len(lst) == max_len]"}
{"task_id": 291, "completion": "def count_no_of_ways(n, k):\n if n == 0:\n return 0\n if n == 1:\n return k\n same = k\n diff = k * (k - 1)\n for i in range(3, n + 1):\n prev_diff = diff\n diff = (same + diff) * (k - 1)\n same = prev_diff\n return same + diff"}
{"task_id": 292, "completion": "def find(n,m):\n return n // m"}
{"task_id": 293, "completion": "import math\ndef otherside_rightangle(w, h):\n return math.sqrt(w**2 + h**2) if min(w, h) > 0 else \"Both w and h must be positive numbers\""}
{"task_id": 294, "completion": "def max_val(listval):\n def extract_number(val):\n if isinstance(val, (int, float)):\n return val\n elif isinstance(val, str):\n try:\n return float(val)\n except ValueError:\n return float('-inf')\n else:\n return float('-inf')\n \n max_value = float('-inf')\n for item in listval:\n num = extract_number(item)\n if num > max_value:\n max_value = num\n \n return max_value"}
{"task_id": 295, "completion": "def sum_div(number):\n if number < 1:\n return 0\n total = 0\n for i in range(1, number + 1):\n if number % i == 0:\n total += i\n return total"}
{"task_id": 296, "completion": "def get_Inv_Count(arr):\n def merge_and_count(arr, temp_arr, left, mid, right):\n i = left \n j = mid + 1 \n k = left \n inv_count = 0\n\n while i <= mid and j <= right:\n if arr[i] <= arr[j]:\n temp_arr[k] = arr[i]\n i += 1\n else:\n temp_arr[k] = arr[j]\n inv_count += (mid - i + 1)\n j += 1\n k += 1\n\n while i <= mid:\n temp_arr[k] = arr[i]\n i += 1\n k += 1\n\n while j <= right:\n temp_arr[k] = arr[j]\n j += 1\n k += 1\n\n for i in range(left, right + 1):\n arr[i] = temp_arr[i]\n \n return inv_count\n\n def merge_sort_and_count(arr, temp_arr, left, right):\n inv_count = 0\n if left < right:\n mid = (left + right) // 2\n inv_count += merge_sort_and_count(arr, temp_arr, left, mid)\n inv_count += merge_sort_and_count(arr, temp_arr, mid + 1, right)\n inv_count += merge_and_count(arr, temp_arr, left, mid, right)\n \n return inv_count\n\n temp_arr = [0] * len(arr)\n return merge_sort_and_count(arr, temp_arr, 0, len(arr) - 1)"}
{"task_id": 297, "completion": "def flatten_list(list1):\n flat_list = []\n for item in list1:\n if isinstance(item, list):\n flat_list.extend(flatten_list(item))\n else:\n flat_list.append(item)\n return flat_list"}
{"task_id": 299, "completion": "from collections import defaultdict\ndef max_aggregate(stdata):\n aggregate = defaultdict(int)\n for name, score in stdata:\n aggregate[name] += score\n return max(aggregate, key=aggregate.get)"}
{"task_id": 300, "completion": "def count_binary_seq(n):\n from math import comb\n total_count = 0\n for k in range(n + 1):\n total_count += comb(n, k) ** 2\n return total_count"}
{"task_id": 301, "completion": "def dict_depth(d):\n if not isinstance(d, dict) or not d:\n return 0\n return 1 + max(dict_depth(v) for v in d.values() if isinstance(v, dict))"}
{"task_id": 304, "completion": "def find_Element(arr, ranges, rotations, index):\n total_rotations = sum((ranges[i][1] - ranges[i][0] + 1) for i in range(rotations)) % len(arr)\n rotated_index = (index - total_rotations) % len(arr)\n return arr[rotated_index]"}
{"task_id": 305, "completion": "import re\ndef start_withp(words):\n p_words = [word for word in words if re.match(r'^p', word, re.IGNORECASE)]\n return p_words[:2]"}
{"task_id": 306, "completion": "def max_sum_increasing_subseq(a, n, index, k):\n if k <= index or index >= n or k >= n:\n return 0\n\n dp = [0] * n\n\n for i in range(index + 1):\n dp[i] = a[i]\n\n max_sum = 0\n\n for i in range(1, index + 1):\n for j in range(i):\n if a[i] > a[j]:\n dp[i] = max(dp[i], dp[j] + a[i])\n\n for i in range(index + 1):\n if a[i] < a[k]:\n max_sum = max(max_sum, dp[i] + a[k])\n\n return max_sum"}
{"task_id": 307, "completion": "from copy import deepcopy\ndef colon_tuplex(tuplex, m, n):\n return tuple(deepcopy(tuplex[i][n] for i in range(m)))"}
{"task_id": 308, "completion": "def large_product(nums1, nums2, N):\n import heapq\n max_heap = []\n for a in nums1:\n for b in nums2:\n product = a * b\n if len(max_heap) < N:\n heapq.heappush(max_heap, product)\n else:\n if product > max_heap[0]:\n heapq.heapreplace(max_heap, product)\n return sorted(max_heap, reverse=True)"}
{"task_id": 309, "completion": "def maximum(a, b):\n if a > b:\n return a\n else:\n return b"}
{"task_id": 310, "completion": "def string_to_tuple(str1):\n return tuple(str1)"}
{"task_id": 311, "completion": "def set_left_most_unset_bit(n):\n if n == 0:\n return 1\n \n num_bits = n.bit_length()\n for i in range(num_bits - 1, -1, -1):\n if not (n & (1 << i)):\n return n | (1 << i)\n \n return n << 1"}
{"task_id": 312, "completion": "def volume_cone(r, h):\n return (1/3) * math.pi * r**2 * h"}
{"task_id": 388, "completion": "def highest_Power_of_2(n):\n if n < 1:\n return 0\n power = 1\n while power * 2 <= n:\n power *= 2\n return power"}
{"task_id": 389, "completion": "def find_lucas(n):\n if n == 0:\n return 2\n elif n == 1:\n return 1\n else:\n a, b = 2, 1\n for _ in range(2, n + 1):\n a, b = b, a + b\n return b"}
{"task_id": 390, "completion": "def add_string(list_, string):\n return [string.format(item) for item in list_]"}
{"task_id": 391, "completion": "def convert_list_dictionary(l1, l2, l3):\n if not(len(l1) == len(l2) == len(l3)):\n raise ValueError(\"All lists must have the same length.\")\n \n nested_dict = {}\n for i in range(len(l1)):\n if l1[i] not in nested_dict:\n nested_dict[l1[i]] = {}\n if l2[i] not in nested_dict[l1[i]]:\n nested_dict[l1[i]][l2[i]] = {}\n nested_dict[l1[i]][l2[i]] = l3[i]\n \n return nested_dict"}
{"task_id": 392, "completion": "def get_max_sum(n, memo={}):\n if n in memo:\n return memo[n]\n if n == 0:\n return 0\n memo[n] = max(get_max_sum(n//2, memo) + get_max_sum(n//3, memo) + get_max_sum(n//4, memo) + get_max_sum(n//5, memo), n)\n return memo[n]"}
{"task_id": 393, "completion": "def max_length_list(input_list):\n if not input_list or not all(isinstance(i, list) for i in input_list):\n raise ValueError(\"Input must be a list of lists\")\n \n return max(input_list, key=len)"}
{"task_id": 394, "completion": "def check_distinct(test_tup):\n return len(test_tup) == len(set(test_tup))"}
{"task_id": 395, "completion": "def first_non_repeating_character(str1):\n char_count = {}\n for char in str1:\n if char in char_count:\n char_count[char] += 1\n else:\n char_count[char] = 1\n \n for char in str1:\n if char_count[char] == 1:\n return char\n \n return None"}
{"task_id": 396, "completion": "import re \nregex = r'^[a-z]$|^([a-z]).*\\1$'\ndef check_char(string):\n return bool(re.match(regex, string, re.IGNORECASE))"}
{"task_id": 397, "completion": "def median_numbers(a, b, c):\n if (a - b) * (c - a) >= 0:\n return a\n elif (b - a) * (c - b) >= 0:\n return b\n else:\n return c"}
{"task_id": 398, "completion": "def sum_of_digits(nums):\n def digit_sum(n):\n return sum(int(digit) for digit in str(n))\n \n return [digit_sum(num) for num in nums]"}
{"task_id": 399, "completion": "def bitwise_xor(test_tup1, test_tup2):\n return tuple(a ^ b for a, b in zip(test_tup1, test_tup2))"}
{"task_id": 400, "completion": "def extract_freq(test_list):\n return len(set(test_list))"}
{"task_id": 401, "completion": "def add_nested_tuples(test_tup1, test_tup2):\n if not test_tup1 or not test_tup2:\n return ()\n return tuple(tuple(a + b for a, b in zip(tup1, tup2)) for tup1, tup2 in zip(test_tup1, test_tup2))"}
{"task_id": 404, "completion": "def minimum(a, b):\n return a if a < b else b"}
{"task_id": 405, "completion": "def check_tuplex(tuplex, tuple1):\n return tuplex in tuple1"}
{"task_id": 406, "completion": "def find_Parity(x):\n return x & 1 == 1"}
{"task_id": 407, "completion": "def rearrange_bigger(n):\n nums = list(str(n))\n i = len(nums) - 2\n while i >= 0 and nums[i] >= nums[i + 1]:\n i -= 1\n if i == -1:\n return -1\n j = len(nums) - 1\n while nums[j] <= nums[i]:\n j -= 1\n nums[i], nums[j] = nums[j], nums[i]\n nums = nums[:i + 1] + sorted(nums[i + 1:])\n return int(''.join(nums))"}
{"task_id": 408, "completion": "import heapq\ndef k_smallest_pairs(nums1, nums2, k):\n if not nums1 or not nums2 or k == 0:\n return []\n \n min_heap = []\n for i in range(min(k, len(nums1))):\n heapq.heappush(min_heap, (nums1[i] + nums2[0], i, 0))\n\n result = []\n while min_heap and len(result) < k:\n sum_val, i, j = heapq.heappop(min_heap)\n result.append((nums1[i], nums2[j]))\n if j + 1 < len(nums2):\n heapq.heappush(min_heap, (nums1[i] + nums2[j + 1], i, j + 1))\n \n return result"}
{"task_id": 409, "completion": "def min_product_tuple(list1):\n if not list1:\n return None\n min_product = float('inf')\n min_pair = None\n for i in range(len(list1)):\n for j in range(i + 1, len(list1)):\n product = list1[i][0] * list1[j][0] + list1[i][1] * list1[j][1]\n if product < min_product:\n min_product = product\n min_pair = (list1[i], list1[j])\n return min_pair"}
{"task_id": 410, "completion": "def min_val(listval):\n min_value = None\n for item in listval:\n if isinstance(item, (int, float)):\n if min_value is None or item < min_value:\n min_value = item\n return min_value"}
{"task_id": 411, "completion": "def snake_to_camel(word):\n components = word.split('_')\n return components[0] + ''.join(x.title() for x in components[1:])"}
{"task_id": 412, "completion": "def remove_odd(l):\n return [x for x in l if x % 2 == 0]"}
{"task_id": 413, "completion": "def extract_nth_element(list1, n):\n if not list1 or n < 0 or n >= len(list1[0]):\n return []\n return [tup[n] for tup in list1]"}
{"task_id": 414, "completion": "def overlapping(list1, list2):\n for item in list1:\n if item in list2:\n return True\n return False"}
{"task_id": 415, "completion": "def max_Product(arr):\n if len(arr) < 2:\n return None\n\n max1 = max2 = min1 = min2 = float('-inf')\n\n for num in arr:\n if num > max1:\n max2 = max1\n max1 = num\n elif num > max2:\n max2 = num\n \n if num < 0 and abs(num) > abs(min1):\n min2 = min1\n min1 = num\n elif num < 0 and abs(num) > abs(min2):\n min2 = num\n\n positive_product = max1 * max2\n negative_product = min1 * min2 if min1 != float('-inf') and min2 != float('-inf') else float('-inf')\n \n if positive_product >= negative_product:\n return (max1, max2)\n else:\n return (min1, min2)"}
{"task_id": 417, "completion": "def group_tuples(Input):\n from collections import defaultdict\n common_first_element = defaultdict(list)\n for element in Input:\n common_first_element[element[0]].append(element)\n return dict(common_first_element)"}
{"task_id": 418, "completion": "def Find_Max(lst):\n if not lst:\n return None\n max_length_element = lst[0]\n for element in lst:\n if len(element) > len(max_length_element):\n max_length_element = element\n return max_length_element"}
{"task_id": 419, "completion": "def round_and_sum(list1):\n rounded_numbers = [round(num) for num in list1]\n total_sum = sum(rounded_numbers)\n result = total_sum * len(list1)\n return result"}
{"task_id": 420, "completion": "def cube_Sum(n):\n sum_cubes = 0\n for i in range(1, n + 1):\n even_num = 2 * i\n sum_cubes += even_num ** 3\n return sum_cubes"}
{"task_id": 421, "completion": "def concatenate_tuple(test_tup, delimiter):\n return delimiter.join(test_tup)"}
{"task_id": 422, "completion": "def find_Average_Of_Cube(n):\r\n if n <= 0:\r\n return 0\r\n sum_of_cubes = sum(i**3 for i in range(1, n+1))\r\n average = sum_of_cubes / n\r\n return average"}
{"task_id": 424, "completion": "def extract_rear(test_tuple):\n return tuple(sub[-1] for sub in test_tuple)"}
{"task_id": 425, "completion": "def count_element_in_list(list1, x):\n count = 0\n for sublist in list1:\n if isinstance(sublist, list) and x in sublist:\n count += 1\n return count"}
{"task_id": 426, "completion": "def filter_oddnumbers(nums):\n return [num for num in nums if num % 2 != 0]"}
{"task_id": 427, "completion": "import re\ndef change_date_format(dt):\n if re.match(r'\\d{4}-\\d{2}-\\d{2}', dt):\n return dt[8:] + '-' + dt[5:7] + '-' + dt[:4]\n else:\n return \"Invalid date format\""}
{"task_id": 428, "completion": "def shell_sort(my_list):\n gap = len(my_list) // 2\n while gap > 0:\n for i in range(gap, len(my_list)):\n temp = my_list[i]\n j = i\n while j >= gap and my_list[j - gap] > temp:\n my_list[j] = my_list[j - gap]\n j -= gap\n my_list[j] = temp\n gap //= 2\n return my_list"}
{"task_id": 429, "completion": "def and_tuples(test_tup1, test_tup2):\n if not test_tup1 or not test_tup2:\n return ((),)\n return tuple(a and b for a, b in zip(test_tup1, test_tup2))"}
{"task_id": 430, "completion": "def parabola_directrix(a, b, c):\n if a == 0:\n raise ValueError(\"Coefficient 'a' must not be zero for a valid parabola.\")\n directrix_y = (1 - c) / (4 * a)\n return directrix_y"}
{"task_id": 431, "completion": "def common_element(list1, list2):\n for element in list1:\n if element in list2:\n return True\n return False"}
{"task_id": 432, "completion": "def median_trapezium(base1, base2, height):\n return (base1 + base2) / 2"}
{"task_id": 433, "completion": "def check_greater(arr, number):\n return all(number > x for x in arr)"}
{"task_id": 434, "completion": "import re\ndef text_match_one(text):\n pattern = r'^ab+'\n if re.search(pattern, text):\n return True\n else:\n return False"}
{"task_id": 435, "completion": "def last_Digit(n):\n return abs(n) % 10"}
{"task_id": 436, "completion": "def neg_nos(list1):\n return [num for num in list1 if num < 0]"}
{"task_id": 437, "completion": "def remove_odd(str1):\n return ''.join([char for i, char in enumerate(str1) if i % 2 == 0])"}
{"task_id": 438, "completion": "def count_bidirectional(test_list):\n bidirectional_pairs = set()\n count = 0\n for a, b in test_list:\n if (b, a) in bidirectional_pairs:\n count += 1\n else:\n bidirectional_pairs.add((a, b))\n return count"}
{"task_id": 439, "completion": "def multiple_to_single(L):\n return int(''.join(map(str, L)))"}
{"task_id": 440, "completion": "import re\ndef find_adverb_position(text):\n adverb_pattern = re.compile(r'\\b\\w+ly\\b')\n match = adverb_pattern.search(text)\n if match:\n return match.group(), match.start(), match.end()\n return None, None, None"}
{"task_id": 441, "completion": "def surfacearea_cube(l):\n return 6 * l * l"}
{"task_id": 442, "completion": "def positive_count(nums):\n positive_numbers = [num for num in nums if num > 0]\n if len(nums) == 0:\n return 0\n return len(positive_numbers) / len(nums)"}
{"task_id": 443, "completion": "def largest_neg(list1):\n largest_negative = None\n for number in list1:\n if number < 0:\n if largest_negative is None or number > largest_negative:\n largest_negative = number\n return largest_negative"}
{"task_id": 444, "completion": "def trim_tuple(test_list, K):\n return [tup[K:-K] if len(tup) >= 2*K else () for tup in test_list]"}
{"task_id": 445, "completion": "def index_multiplication(test_tup1, test_tup2):\n if len(test_tup1) != len(test_tup2):\n raise ValueError(\"Both tuples must be of the same length.\")\n return tuple(a * b for a, b in zip(test_tup1, test_tup2))"}
{"task_id": 446, "completion": "def count_Occurrence(tup, lst):\n counter = Counter(tup)\n return {item: counter[item] for item in lst}"}
{"task_id": 447, "completion": "def cube_nums(nums):\n return [x**3 for x in nums]"}
{"task_id": 448, "completion": "def cal_sum(n):\n if n < 0:\n return 0\n \n perrin = [3, 0, 2]\n sum_perrin = sum(perrin[:min(n + 1, 3)])\n \n for i in range(3, n + 1):\n next_perrin = perrin[i - 2] + perrin[i - 3]\n perrin.append(next_perrin)\n sum_perrin += next_perrin\n \n return sum_perrin"}
{"task_id": 450, "completion": "def extract_string(str_list, l):\n return [s for s in str_list if len(s) == l]"}
{"task_id": 451, "completion": "import re\ndef remove_whitespaces(text1):\n return re.sub(r'\\s+', '', text1)"}
{"task_id": 452, "completion": "def loss_amount(actual_cost, sale_amount):\n if sale_amount < actual_cost:\n return actual_cost - sale_amount\n else:\n return 0"}
{"task_id": 453, "completion": "import math\ndef sumofFactors(n):\n def is_even(num):\n return num % 2 == 0\n\n sum_even_factors = 0\n for i in range(1, int(math.sqrt(n)) + 1):\n if n % i == 0:\n if is_even(i):\n sum_even_factors += i\n if i != n // i and is_even(n // i):\n sum_even_factors += n // i\n return sum_even_factors"}
{"task_id": 454, "completion": "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": 455, "completion": "def check_monthnumb_number(monthnum2):\n if monthnum2 in {1, 3, 5, 7, 8, 10, 12}:\n return True\n else:\n return False"}
{"task_id": 456, "completion": "def reverse_string_list(stringlist):\n return [s[::-1] for s in stringlist]"}
{"task_id": 457, "completion": "def Find_Min(lst):\n if not lst:\n return []\n min_len = float('inf')\n min_sublist = []\n for sublist in lst:\n if len(sublist) < min_len:\n min_len = len(sublist)\n min_sublist = sublist\n return min_sublist"}
{"task_id": 458, "completion": "def rectangle_area(l, b):\n return l * b"}
{"task_id": 459, "completion": "import re\ndef remove_uppercase(str1):\n return re.sub(r'[A-Z]+', '', str1)"}
{"task_id": 460, "completion": "def Extract(lst):\n return [item[0] for item in lst]"}
{"task_id": 461, "completion": "def upper_ctr(s):\n return sum(1 for c in s if c.isupper())"}
{"task_id": 462, "completion": "def combinations_list(list1):\n from itertools import combinations\n all_combinations = []\n for r in range(1, len(list1) + 1):\n combinations_r = list(combinations(list1, r))\n all_combinations.extend(combinations_r)\n return all_combinations"}
{"task_id": 463, "completion": "def max_subarray_product(arr):\n if not arr:\n return 0\n \n max_product = arr[0]\n min_product = arr[0]\n result = arr[0]\n \n for num in arr[1:]:\n if num < 0:\n max_product, min_product = min_product, max_product\n \n max_product = max(num, max_product * num)\n min_product = min(num, min_product * num)\n \n result = max(result, max_product)\n \n return result"}
{"task_id": 464, "completion": "def check_value(dict, n):\n if n not in dict.values():\n return False\n first_value = n\n for value in dict.values():\n if value != first_value:\n return False\n return True"}
{"task_id": 465, "completion": "def drop_empty(dict1):\n return {k: v for k, v in dict1.items() if v}"}
{"task_id": 468, "completion": "def max_product(arr):\n n = len(arr)\n if n == 0:\n return 0\n \n max_prod = [0] * n\n max_prod[0] = arr[0]\n \n for i in range(1, n):\n for j in range(i):\n if arr[i] > arr[j]:\n max_prod[i] = max(max_prod[i], max_prod[j] * arr[i])\n else:\n max_prod[i] = max(max_prod[i], arr[i])\n\n return max(max_prod)"}
{"task_id": 470, "completion": "def add_pairwise(test_tup):\n return tuple(test_tup[i] + test_tup[i + 1] for i in range(len(test_tup) - 1))"}
{"task_id": 471, "completion": "def find_remainder(arr, n):\n product = 1\n for num in arr:\n product *= num\n return product % n"}
{"task_id": 472, "completion": "def check_Consecutive(l):\n if len(l) < 2:\n return False\n l_sorted = sorted(l)\n return all(l_sorted[i] + 1 == l_sorted[i + 1] for i in range(len(l_sorted) - 1))"}
{"task_id": 473, "completion": "def tuple_intersection(test_list1, test_list2):\n set1 = set(map(tuple, test_list1))\n set2 = set(map(tuple, test_list2))\n return list(set1 & set2)"}
{"task_id": 474, "completion": "def replace_char(str1, ch, newch):\n return str1.replace(ch, newch)"}
{"task_id": 475, "completion": "from collections import Counter\ndef sort_counter(dict1):\n return dict(Counter(dict1).most_common())"}
{"task_id": 476, "completion": "def big_sum(nums):\n if not nums:\n return 0\n smallest = min(nums)\n largest = max(nums)\n return smallest + largest"}
{"task_id": 477, "completion": "def is_lower(string):\n return string.lower()"}
{"task_id": 478, "completion": "import re\ndef remove_lowercase(str1):\n return re.sub(r'[a-z]+', '', str1)"}
{"task_id": 479, "completion": "def first_Digit(n) : \n while n >= 10: \n n = n / 10 \n return int(n) "}