entry_func
stringlengths
3
31
solution
stringlengths
35
720
task_name
stringclasses
1 value
doc_string
stringclasses
1 value
compare_func
sequencelengths
0
0
tgt_lang
stringclasses
1 value
suffix
stringclasses
1 value
import_str
sequencelengths
0
1
src_lang
null
demos
sequencelengths
0
0
test_cases
sequencelengths
0
5
data_id
int64
11
479
prefix
stringlengths
39
252
dataset_name
stringclasses
1 value
Find_Max
def Find_Max(lst): maxList = max((x for x in lst)) return maxList
code_generation
[]
python
[]
null
[]
[ [ "[['A'],['A','B'],['A','B','C']]", "['A','B','C']" ], [ "[[1],[1,2],[1,2,3]]", "[1,2,3]" ], [ "[[1,1],[1,2,3],[1,5,6,1]]", "[1,5,6,1]" ] ]
418
Write a python function to find the element of a list having maximum length.
MBPP_sanitized
round_and_sum
def round_and_sum(list1): lenght = len(list1) round_and_sum = sum(list(map(round, list1)) * lenght) return round_and_sum
code_generation
[]
python
[]
null
[]
[ [ "[22.4, 4.0, -16.22, -9.10, 11.00, -12.22, 14.20, -5.20, 17.50]", "243" ], [ "[5,2,9,24.3,29]", "345" ], [ "[25.0,56.7,89.2]", "513" ] ]
419
Write a function to round every number of a given list of numbers and print the total sum multiplied by the length of the list.
MBPP_sanitized
cube_Sum
def cube_Sum(n): sum = 0 for i in range(1, n + 1): sum += 2 * i * (2 * i) * (2 * i) return sum
code_generation
[]
python
[]
null
[]
[ [ "2", "72" ], [ "3", "288" ], [ "4", "800" ] ]
420
Write a python function to find the cube sum of first n even natural numbers.
MBPP_sanitized
concatenate_tuple
def concatenate_tuple(test_tup): delim = '-' res = ''.join([str(ele) + delim for ele in test_tup]) res = res[:len(res) - len(delim)] return str(res)
code_generation
[]
python
[]
null
[]
[ [ "(\"ID\", \"is\", 4, \"UTS\") ", "'ID-is-4-UTS'" ], [ "(\"QWE\", \"is\", 4, \"RTY\") ", "'QWE-is-4-RTY'" ], [ "(\"ZEN\", \"is\", 4, \"OP\") ", "'ZEN-is-4-OP'" ] ]
421
Write a function to concatenate each element of tuple by the delimiter.
MBPP_sanitized
find_Average_Of_Cube
def find_Average_Of_Cube(n): sum = 0 for i in range(1, n + 1): sum += i * i * i return round(sum / n, 6)
code_generation
[]
python
[]
null
[]
[ [ "2", "4.5" ], [ "3", "12" ], [ "1", "1" ] ]
422
Write a python function to find the average of cubes of first n natural numbers.
MBPP_sanitized
extract_rear
def extract_rear(test_tuple): res = list((sub[len(sub) - 1] for sub in test_tuple)) return res
code_generation
[]
python
[]
null
[]
[ [ "('Mers', 'for', 'Vers') ", "['s', 'r', 's']" ], [ "('Avenge', 'for', 'People') ", "['e', 'r', 'e']" ], [ "('Gotta', 'get', 'go') ", "['a', 't', 'o']" ] ]
424
Write a function to extract only the rear index element of each string in the given tuple.
MBPP_sanitized
count_element_in_list
def count_element_in_list(list1, x): ctr = 0 for i in range(len(list1)): if x in list1[i]: ctr += 1 return ctr
code_generation
[]
python
[]
null
[]
[ [ "[[1, 3], [5, 7], [1, 11], [1, 15, 7]],1", "3" ], [ "[['A', 'B'], ['A', 'C'], ['A', 'D', 'E'], ['B', 'C', 'D']],'A'", "3" ], [ "[['A', 'B'], ['A', 'C'], ['A', 'D', 'E'], ['B', 'C', 'D']],'E'", "1" ] ]
425
Write a function to count the number of sublists containing a particular element.
MBPP_sanitized
filter_oddnumbers
def filter_oddnumbers(nums): odd_nums = list(filter(lambda x: x % 2 != 0, nums)) return odd_nums
code_generation
[]
python
[]
null
[]
[ [ "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]", "[1,3,5,7,9]" ], [ "[10,20,45,67,84,93]", "[45,67,93]" ], [ "[5,7,9,8,6,4,3]", "[5,7,9,3]" ] ]
426
Write a function to filter odd numbers.
MBPP_sanitized
change_date_format
import re def change_date_format(dt): return re.sub('(\\d{4})-(\\d{1,2})-(\\d{1,2})', '\\3-\\2-\\1', dt)
code_generation
[]
python
[ "import re" ]
null
[]
[ [ "\"2026-01-02\"", "'02-01-2026'" ], [ "\"2020-11-13\"", "'13-11-2020'" ], [ "\"2021-04-26\"", "'26-04-2021'" ] ]
427
Write a function to convert a date of yyyy-mm-dd format to dd-mm-yyyy format.
MBPP_sanitized
shell_sort
def shell_sort(my_list): gap = len(my_list) // 2 while gap > 0: for i in range(gap, len(my_list)): current_item = my_list[i] j = i while j >= gap and my_list[j - gap] > current_item: my_list[j] = my_list[j - gap] j -= gap my_list[j] = current_item gap //= 2 return my_list
code_generation
[]
python
[]
null
[]
[ [ "[12, 23, 4, 5, 3, 2, 12, 81, 56, 95]", "[2, 3, 4, 5, 12, 12, 23, 56, 81, 95]" ], [ "[24, 22, 39, 34, 87, 73, 68]", "[22, 24, 34, 39, 68, 73, 87]" ], [ "[32, 30, 16, 96, 82, 83, 74]", "[16, 30, 32, 74, 82, 83, 96]" ] ]
428
Write a function to sort the given array by using shell sort.
MBPP_sanitized
and_tuples
def and_tuples(test_tup1, test_tup2): res = tuple((ele1 & ele2 for (ele1, ele2) in zip(test_tup1, test_tup2))) return res
code_generation
[]
python
[]
null
[]
[ [ "(10, 4, 6, 9), (5, 2, 3, 3)", "(0, 0, 2, 1)" ], [ "(1, 2, 3, 4), (5, 6, 7, 8)", "(1, 2, 3, 0)" ], [ "(8, 9, 11, 12), (7, 13, 14, 17)", "(0, 9, 10, 0)" ] ]
429
Write a function to extract the elementwise and tuples from the given two tuples.
MBPP_sanitized
parabola_directrix
def parabola_directrix(a, b, c): directrix = int(c - (b * b + 1) * 4 * a) return directrix
code_generation
[]
python
[]
null
[]
[ [ "5,3,2", "-198" ], [ "9,8,4", "-2336" ], [ "2,4,6", "-130" ] ]
430
Write a function to find the directrix of a parabola.
MBPP_sanitized
common_element
def common_element(list1, list2): result = False for x in list1: for y in list2: if x == y: result = True return result
code_generation
[]
python
[]
null
[]
[ [ "[1,2,3,4,5], [5,6,7,8,9]", "True" ], [ "[1,2,3,4,5], [6,7,8,9]", null ], [ "['a','b','c'], ['d','b','e']", "True" ] ]
431
Write a function that takes two lists and returns true if they have at least one common element.
MBPP_sanitized
median_trapezium
def median_trapezium(base1, base2, height): median = 0.5 * (base1 + base2) return median
code_generation
[]
python
[]
null
[]
[ [ "15,25,35", "20" ], [ "10,20,30", "15" ], [ "6,9,4", "7.5" ] ]
432
Write a function to find the median length of a trapezium.
MBPP_sanitized
check_greater
def check_greater(arr, number): arr.sort() return number > arr[-1]
code_generation
[]
python
[]
null
[]
[ [ "[1, 2, 3, 4, 5], 4", "False" ], [ "[2, 3, 4, 5, 6], 8", "True" ], [ "[9, 7, 4, 8, 6, 1], 11", "True" ] ]
433
Write a function to check whether the entered number is greater than the elements of the given array.
MBPP_sanitized
text_match_one
import re def text_match_one(text): patterns = 'ab+?' if re.search(patterns, text): return True else: return False
code_generation
[]
python
[ "import re" ]
null
[]
[ [ "\"ac\"", "False" ], [ "\"dc\"", "False" ], [ "\"abba\"", "True" ] ]
434
Write a function that matches a string that has an a followed by one or more b's.
MBPP_sanitized
last_Digit
def last_Digit(n): return n % 10
code_generation
[]
python
[]
null
[]
[ [ "123", "3" ], [ "25", "5" ], [ "30", "0" ] ]
435
Write a python function to find the last digit of a given number.
MBPP_sanitized
neg_nos
def neg_nos(list1): out = [] for num in list1: if num < 0: out.append(num) return out
code_generation
[]
python
[]
null
[]
[ [ "[-1,4,5,-6]", "[-1,-6]" ], [ "[-1,-2,3,4]", "[-1,-2]" ], [ "[-7,-6,8,9]", "[-7,-6]" ] ]
436
Write a python function to return the negative numbers in a list.
MBPP_sanitized
remove_odd
def remove_odd(str1): str2 = '' for i in range(1, len(str1) + 1): if i % 2 == 0: str2 = str2 + str1[i - 1] return str2
code_generation
[]
python
[]
null
[]
[ [ "\"python\"", "(\"yhn\")" ], [ "\"program\"", "(\"rga\")" ], [ "\"language\"", "(\"agae\")" ] ]
437
Write a function to remove odd characters in a string.
MBPP_sanitized
count_bidirectional
def count_bidirectional(test_list): res = 0 for idx in range(0, len(test_list)): for iidx in range(idx + 1, len(test_list)): if test_list[iidx][0] == test_list[idx][1] and test_list[idx][1] == test_list[iidx][0]: res += 1 return res
code_generation
[]
python
[]
null
[]
[ [ "[(5, 6), (1, 2), (6, 5), (9, 1), (6, 5), (2, 1)] ", "3" ], [ "[(5, 6), (1, 3), (6, 5), (9, 1), (6, 5), (2, 1)] ", "2" ], [ "[(5, 6), (1, 2), (6, 5), (9, 2), (6, 5), (2, 1)] ", "4" ] ]
438
Write a function to count bidirectional tuple pairs.
MBPP_sanitized
multiple_to_single
def multiple_to_single(L): x = int(''.join(map(str, L))) return x
code_generation
[]
python
[]
null
[]
[ [ "[11, 33, 50]", "113350" ], [ "[-1,2,3,4,5,6]", "-123456" ], [ "[10,15,20,25]", "10152025" ] ]
439
Write a function to join a list of multiple integers into a single integer.
MBPP_sanitized
find_adverb_position
import re def find_adverb_position(text): for m in re.finditer('\\w+ly', text): return (m.start(), m.end(), m.group(0))
code_generation
[]
python
[ "import re" ]
null
[]
[ [ "\"clearly!! we can see the sky\"", "(0, 7, 'clearly')" ], [ "\"seriously!! there are many roses\"", "(0, 9, 'seriously')" ], [ "\"unfortunately!! sita is going to home\"", "(0, 13, 'unfortunately')" ] ]
440
Write a function to find the first adverb and their positions in a given sentence.
MBPP_sanitized
surfacearea_cube
def surfacearea_cube(l): surfacearea = 6 * l * l return surfacearea
code_generation
[]
python
[]
null
[]
[ [ "5", "150" ], [ "3", "54" ], [ "10", "600" ] ]
441
Write a function to find the surface area of a cube of a given size.
MBPP_sanitized
positive_count
from array import array def positive_count(nums): n = len(nums) n1 = 0 for x in nums: if x > 0: n1 += 1 else: None return round(n1 / n, 2)
code_generation
[]
python
[ "from array import array" ]
null
[]
[ [ "[0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8]", "0.54" ], [ "[2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8]", "0.69" ], [ "[2, 4, -6, -9, 11, -12, 14, -5, 17]", "0.56" ] ]
442
Write a function to find the ration of positive numbers in an array of integers.
MBPP_sanitized
largest_neg
def largest_neg(list1): max = list1[0] for x in list1: if x < max: max = x return max
code_generation
[]
python
[]
null
[]
[ [ "[1,2,3,-4,-6]", "-6" ], [ "[1,2,3,-8,-9]", "-9" ], [ "[1,2,3,4,-1]", "-1" ] ]
443
Write a python function to find the largest negative number from the given list.
MBPP_sanitized
trim_tuple
def trim_tuple(test_list, K): res = [] for ele in test_list: N = len(ele) res.append(tuple(list(ele)[K:N - K])) return str(res)
code_generation
[]
python
[]
null
[]
[ [ "[(5, 3, 2, 1, 4), (3, 4, 9, 2, 1),(9, 1, 2, 3, 5), (4, 8, 2, 1, 7)], 2", "'[(2,), (9,), (2,), (2,)]'" ], [ "[(5, 3, 2, 1, 4), (3, 4, 9, 2, 1), (9, 1, 2, 3, 5), (4, 8, 2, 1, 7)], 1", "'[(3, 2, 1), (4, 9, 2), (1, 2, 3), (8, 2, 1)]'" ], [ "[(7, 8, 4, 9), (11, 8, 12, 4),(4, 1, 7, 8), (3, 6, 9, 7)], 1", "'[(8, 4), (8, 12), (1, 7), (6, 9)]'" ] ]
444
Write a function to trim each tuple by k in the given tuple list.
MBPP_sanitized
index_multiplication
def index_multiplication(test_tup1, test_tup2): res = tuple((tuple((a * b for (a, b) in zip(tup1, tup2))) for (tup1, tup2) in zip(test_tup1, test_tup2))) return res
code_generation
[]
python
[]
null
[]
[ [ "((1, 3), (4, 5), (2, 9), (1, 10)),((6, 7), (3, 9), (1, 1), (7, 3)) ", "((6, 21), (12, 45), (2, 9), (7, 30))" ], [ "((2, 4), (5, 6), (3, 10), (2, 11)),((7, 8), (4, 10), (2, 2), (8, 4)) ", "((14, 32), (20, 60), (6, 20), (16, 44))" ], [ "((3, 5), (6, 7), (4, 11), (3, 12)),((8, 9), (5, 11), (3, 3), (9, 5)) ", "((24, 45), (30, 77), (12, 33), (27, 60))" ] ]
445
Write a function to perform index wise multiplication of tuple elements in the given two tuples.
MBPP_sanitized
count_Occurrence
from collections import Counter def count_Occurrence(tup, lst): count = 0 for item in tup: if item in lst: count += 1 return count
code_generation
[]
python
[ "from collections import Counter " ]
null
[]
[ [ "('a', 'a', 'c', 'b', 'd'),['a', 'b'] ", "3" ], [ "(1, 2, 3, 1, 4, 6, 7, 1, 4),[1, 4, 7]", "6" ], [ "(1,2,3,4,5,6),[1,2]", "2" ] ]
446
Write a python function to count the occurence of all elements of list in a tuple.
MBPP_sanitized
cube_nums
def cube_nums(nums): cube_nums = list(map(lambda x: x ** 3, nums)) return cube_nums
code_generation
[]
python
[]
null
[]
[ [ "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]", "[1, 8, 27, 64, 125, 216, 343, 512, 729, 1000]" ], [ "[10,20,30]", "([1000, 8000, 27000])" ], [ "[12,15]", "([1728, 3375])" ] ]
447
Write a function to find cubes of individual elements in a list.
MBPP_sanitized
cal_sum
def cal_sum(n): a = 3 b = 0 c = 2 if n == 0: return 3 if n == 1: return 3 if n == 2: return 5 sum = 5 while n > 2: d = a + b sum = sum + d a = b b = c c = d n = n - 1 return sum
code_generation
[]
python
[]
null
[]
[ [ "9", "49" ], [ "10", "66" ], [ "11", "88" ] ]
448
Write a function to calculate the sum of perrin numbers.
MBPP_sanitized
extract_string
def extract_string(str, l): result = [e for e in str if len(e) == l] return result
code_generation
[]
python
[]
null
[]
[ [ "['Python', 'list', 'exercises', 'practice', 'solution'] ,8", "['practice', 'solution']" ], [ "['Python', 'list', 'exercises', 'practice', 'solution'] ,6", "['Python']" ], [ "['Python', 'list', 'exercises', 'practice', 'solution'] ,9", "['exercises']" ] ]
450
Write a function to extract specified size of strings from a given list of string values.
MBPP_sanitized
remove_whitespaces
import re def remove_whitespaces(text1): return re.sub('\\s+', '', text1)
code_generation
[]
python
[ "import re" ]
null
[]
[ [ "' Google Flutter '", "'GoogleFlutter'" ], [ "' Google Dart '", "'GoogleDart'" ], [ "' iOS Swift '", "'iOSSwift'" ] ]
451
Write a function to remove all whitespaces from the given string.
MBPP_sanitized
loss_amount
def loss_amount(actual_cost, sale_amount): if sale_amount > actual_cost: amount = sale_amount - actual_cost return amount else: return 0
code_generation
[]
python
[]
null
[]
[ [ "1500,1200", "0" ], [ "100,200", "100" ], [ "2000,5000", "3000" ] ]
452
Write a function that gives loss amount on a sale if the given amount has loss else return 0.
MBPP_sanitized
sumofFactors
import math def sumofFactors(n): if n % 2 != 0: return 0 res = 1 for i in range(2, int(math.sqrt(n)) + 1): count = 0 curr_sum = 1 curr_term = 1 while n % i == 0: count = count + 1 n = n // i if i == 2 and count == 1: curr_sum = 0 curr_term = curr_term * i curr_sum = curr_sum + curr_term res = res * curr_sum if n >= 2: res = res * (1 + n) return res
code_generation
[]
python
[ "import math " ]
null
[]
[ [ "18", "26" ], [ "30", "48" ], [ "6", "8" ] ]
453
Write a python function to find the sum of even factors of a number.
MBPP_sanitized
text_match_wordz
import re def text_match_wordz(text): patterns = '\\w*z.\\w*' if re.search(patterns, text): return True else: return False
code_generation
[]
python
[ "import re" ]
null
[]
[ [ "\"pythonz.\"", "True" ], [ "\"xyz.\"", "True" ], [ "\" lang .\"", "False" ] ]
454
Write a function that matches a word containing 'z'.
MBPP_sanitized
check_monthnumb_number
def check_monthnumb_number(monthnum2): if monthnum2 == 1 or monthnum2 == 3 or monthnum2 == 5 or (monthnum2 == 7) or (monthnum2 == 8) or (monthnum2 == 10) or (monthnum2 == 12): return True else: return False
code_generation
[]
python
[]
null
[]
[ [ "5", "True" ], [ "2", "False" ], [ "6", "False" ] ]
455
Write a function to check whether the given month number contains 31 days or not.
MBPP_sanitized
reverse_string_list
def reverse_string_list(stringlist): result = [x[::-1] for x in stringlist] return result
code_generation
[]
python
[]
null
[]
[ [ "['Red', 'Green', 'Blue', 'White', 'Black']", "['deR', 'neerG', 'eulB', 'etihW', 'kcalB']" ], [ "['john','amal','joel','george']", "['nhoj','lama','leoj','egroeg']" ], [ "['jack','john','mary']", "['kcaj','nhoj','yram']" ] ]
456
Write a function to reverse each string in a given list of string values.
MBPP_sanitized
Find_Min
def Find_Min(lst): return min(lst, key=len)
code_generation
[]
python
[]
null
[]
[ [ "[[1],[1,2],[1,2,3]]", "[1]" ], [ "[[1,1],[1,1,1],[1,2,7,8]]", "[1,1]" ], [ "[['x'],['x','y'],['x','y','z']]", "['x']" ] ]
457
Write a python function to find the sublist having minimum length.
MBPP_sanitized
rectangle_area
def rectangle_area(l, b): area = l * b return area
code_generation
[]
python
[]
null
[]
[ [ "10,20", "200" ], [ "10,5", "50" ], [ "4,2", "8" ] ]
458
Write a function to find the area of a rectangle.
MBPP_sanitized
remove_uppercase
import re def remove_uppercase(str1): return re.sub('[A-Z]', '', str1)
code_generation
[]
python
[ "import re" ]
null
[]
[ [ "'cAstyoUrFavoRitETVshoWs'", "'cstyoravoitshos'" ], [ "'wAtchTheinTernEtrAdIo'", "'wtchheinerntrdo'" ], [ "'VoicESeaRchAndreComMendaTionS'", "'oiceachndreomendaion'" ] ]
459
Write a function to remove uppercase substrings from a given string.
MBPP_sanitized
Extract
def Extract(lst): return [item[0] for item in lst]
code_generation
[]
python
[]
null
[]
[ [ "[[1, 2], [3, 4, 5], [6, 7, 8, 9]]", "[1, 3, 6]" ], [ "[[1,2,3],[4, 5]]", "[1,4]" ], [ "[[9,8,1],[1,2]]", "[9,1]" ] ]
460
Write a python function to get the first element of each sublist.
MBPP_sanitized
upper_ctr
def upper_ctr(str): upper_ctr = 0 for i in range(len(str)): if str[i] >= 'A' and str[i] <= 'Z': upper_ctr += 1 return upper_ctr
code_generation
[]
python
[]
null
[]
[ [ "'PYthon'", "1" ], [ "'BigData'", "1" ], [ "'program'", "0" ] ]
461
Write a python function to count the upper case characters in a given string.
MBPP_sanitized
combinations_list
def combinations_list(list1): if len(list1) == 0: return [[]] result = [] for el in combinations_list(list1[1:]): result += [el, el + [list1[0]]] return result
code_generation
[]
python
[]
null
[]
[ [ "['orange', 'red', 'green', 'blue']", "[[], ['orange'], ['red'], ['red', 'orange'], ['green'], ['green', 'orange'], ['green', 'red'], ['green', 'red', 'orange'], ['blue'], ['blue', 'orange'], ['blue', 'red'], ['blue', 'red', 'orange'], ['blue', 'green'], ['blue', 'green', 'orange'], ['blue', 'green', 'red'], ['blue', 'green', 'red', 'orange']]" ], [ "['red', 'green', 'blue', 'white', 'black', 'orange']", "[[], ['red'], ['green'], ['green', 'red'], ['blue'], ['blue', 'red'], ['blue', 'green'], ['blue', 'green', 'red'], ['white'], ['white', 'red'], ['white', 'green'], ['white', 'green', 'red'], ['white', 'blue'], ['white', 'blue', 'red'], ['white', 'blue', 'green'], ['white', 'blue', 'green', 'red'], ['black'], ['black', 'red'], ['black', 'green'], ['black', 'green', 'red'], ['black', 'blue'], ['black', 'blue', 'red'], ['black', 'blue', 'green'], ['black', 'blue', 'green', 'red'], ['black', 'white'], ['black', 'white', 'red'], ['black', 'white', 'green'], ['black', 'white', 'green', 'red'], ['black', 'white', 'blue'], ['black', 'white', 'blue', 'red'], ['black', 'white', 'blue', 'green'], ['black', 'white', 'blue', 'green', 'red'], ['orange'], ['orange', 'red'], ['orange', 'green'], ['orange', 'green', 'red'], ['orange', 'blue'], ['orange', 'blue', 'red'], ['orange', 'blue', 'green'], ['orange', 'blue', 'green', 'red'], ['orange', 'white'], ['orange', 'white', 'red'], ['orange', 'white', 'green'], ['orange', 'white', 'green', 'red'], ['orange', 'white', 'blue'], ['orange', 'white', 'blue', 'red'], ['orange', 'white', 'blue', 'green'], ['orange', 'white', 'blue', 'green', 'red'], ['orange', 'black'], ['orange', 'black', 'red'], ['orange', 'black', 'green'], ['orange', 'black', 'green', 'red'], ['orange', 'black', 'blue'], ['orange', 'black', 'blue', 'red'], ['orange', 'black', 'blue', 'green'], ['orange', 'black', 'blue', 'green', 'red'], ['orange', 'black', 'white'], ['orange', 'black', 'white', 'red'], ['orange', 'black', 'white', 'green'], ['orange', 'black', 'white', 'green', 'red'], ['orange', 'black', 'white', 'blue'], ['orange', 'black', 'white', 'blue', 'red'], ['orange', 'black', 'white', 'blue', 'green'], ['orange', 'black', 'white', 'blue', 'green', 'red']]" ], [ "['red', 'green', 'black', 'orange']", "[[], ['red'], ['green'], ['green', 'red'], ['black'], ['black', 'red'], ['black', 'green'], ['black', 'green', 'red'], ['orange'], ['orange', 'red'], ['orange', 'green'], ['orange', 'green', 'red'], ['orange', 'black'], ['orange', 'black', 'red'], ['orange', 'black', 'green'], ['orange', 'black', 'green', 'red']]" ] ]
462
Write a function to find all possible combinations of the elements of a given list.
MBPP_sanitized
max_subarray_product
def max_subarray_product(arr): n = len(arr) max_ending_here = 1 min_ending_here = 1 max_so_far = 0 flag = 0 for i in range(0, n): if arr[i] > 0: max_ending_here = max_ending_here * arr[i] min_ending_here = min(min_ending_here * arr[i], 1) flag = 1 elif arr[i] == 0: max_ending_here = 1 min_ending_here = 1 else: temp = max_ending_here max_ending_here = max(min_ending_here * arr[i], 1) min_ending_here = temp * arr[i] if max_so_far < max_ending_here: max_so_far = max_ending_here if flag == 0 and max_so_far == 0: return 0 return max_so_far
code_generation
[]
python
[]
null
[]
[ [ "[1, -2, -3, 0, 7, -8, -2]", "112" ], [ "[6, -3, -10, 0, 2]", "180" ], [ "[-2, -40, 0, -2, -3]", "80" ] ]
463
Write a function to find the maximum product subarray of the given array.
MBPP_sanitized
check_value
def check_value(dict, n): result = all((x == n for x in dict.values())) return result
code_generation
[]
python
[]
null
[]
[ [ "{'Cierra Vega': 12, 'Alden Cantrell': 12, 'Kierra Gentry': 12, 'Pierre Cox': 12},10", "False" ], [ "{'Cierra Vega': 12, 'Alden Cantrell': 12, 'Kierra Gentry': 12, 'Pierre Cox': 12},12", "True" ], [ "{'Cierra Vega': 12, 'Alden Cantrell': 12, 'Kierra Gentry': 12, 'Pierre Cox': 12},5", "False" ] ]
464
Write a function to check if all values are same in a dictionary.
MBPP_sanitized
drop_empty
def drop_empty(dict1): dict1 = {key: value for (key, value) in dict1.items() if value is not None} return dict1
code_generation
[]
python
[]
null
[]
[ [ "{'c1': 'Red', 'c2': 'Green', 'c3':None}", "{'c1': 'Red', 'c2': 'Green'}" ], [ "{'c1': 'Red', 'c2': None, 'c3':None}", "{'c1': 'Red'}" ], [ "{'c1': None, 'c2': 'Green', 'c3':None}", "{ 'c2': 'Green'}" ] ]
465
Write a function to drop empty items from a given dictionary.
MBPP_sanitized
max_product
def max_product(arr): n = len(arr) mpis = arr[:] for i in range(n): current_prod = arr[i] j = i + 1 while j < n: if arr[j - 1] > arr[j]: break current_prod *= arr[j] if current_prod > mpis[j]: mpis[j] = current_prod j = j + 1 return max(mpis)
code_generation
[]
python
[]
null
[]
[ [ "[3, 100, 4, 5, 150, 6]", "3000" ], [ "[4, 42, 55, 68, 80]", "50265600" ], [ "[10, 22, 9, 33, 21, 50, 41, 60]", "2460" ] ]
468
Write a function to find the maximum product formed by multiplying numbers of an increasing subsequence of that array.
MBPP_sanitized
add_pairwise
def add_pairwise(test_tup): res = tuple((i + j for (i, j) in zip(test_tup, test_tup[1:]))) return res
code_generation
[]
python
[]
null
[]
[ [ "(1, 5, 7, 8, 10)", "(6, 12, 15, 18)" ], [ "(2, 6, 8, 9, 11)", "(8, 14, 17, 20)" ], [ "(3, 7, 9, 10, 12)", "(10, 16, 19, 22)" ] ]
470
Write a function to find the pairwise addition of the neighboring elements of the given tuple.
MBPP_sanitized
find_remainder
def find_remainder(arr, n): mul = 1 for i in range(len(arr)): mul = mul * (arr[i] % n) % n return mul % n
code_generation
[]
python
[]
null
[]
[ [ "[ 100, 10, 5, 25, 35, 14 ],11", "9" ], [ "[1,1,1],1", "0" ], [ "[1,2,1],2", "0" ] ]
471
Write a python function to find the product of the array multiplication modulo n.
MBPP_sanitized
check_Consecutive
def check_Consecutive(l): return sorted(l) == list(range(min(l), max(l) + 1))
code_generation
[]
python
[]
null
[]
[ [ "[1,2,3,4,5]", "True" ], [ "[1,2,3,5,6]", "False" ], [ "[1,2,1]", "False" ] ]
472
Write a python function to check whether the given list contains consecutive numbers or not.
MBPP_sanitized
tuple_intersection
def tuple_intersection(test_list1, test_list2): res = set([tuple(sorted(ele)) for ele in test_list1]) & set([tuple(sorted(ele)) for ele in test_list2]) return res
code_generation
[]
python
[]
null
[]
[ [ "[(3, 4), (5, 6), (9, 10), (4, 5)] , [(5, 4), (3, 4), (6, 5), (9, 11)]", "{(4, 5), (3, 4), (5, 6)}" ], [ "[(4, 1), (7, 4), (11, 13), (17, 14)] , [(1, 4), (7, 4), (16, 12), (10, 13)]", "{(4, 7), (1, 4)}" ], [ "[(2, 1), (3, 2), (1, 3), (1, 4)] , [(11, 2), (2, 3), (6, 2), (1, 3)]", "{(1, 3), (2, 3)}" ] ]
473
Write a function to find the tuple intersection of elements in the given tuple list irrespective of their order.
MBPP_sanitized
replace_char
def replace_char(str1, ch, newch): str2 = str1.replace(ch, newch) return str2
code_generation
[]
python
[]
null
[]
[ [ "\"polygon\",'y','l'", "(\"pollgon\")" ], [ "\"character\",'c','a'", "(\"aharaater\")" ], [ "\"python\",'l','a'", "(\"python\")" ] ]
474
Write a function to replace characters in a string.
MBPP_sanitized
sort_counter
from collections import Counter def sort_counter(dict1): x = Counter(dict1) sort_counter = x.most_common() return sort_counter
code_generation
[]
python
[ "from collections import Counter" ]
null
[]
[ [ "{'Math':81, 'Physics':83, 'Chemistry':87}", "[('Chemistry', 87), ('Physics', 83), ('Math', 81)]" ], [ "{'Math':400, 'Physics':300, 'Chemistry':250}", "[('Math', 400), ('Physics', 300), ('Chemistry', 250)]" ], [ "{'Math':900, 'Physics':1000, 'Chemistry':1250}", "[('Chemistry', 1250), ('Physics', 1000), ('Math', 900)]" ] ]
475
Write a function to sort a dictionary by value.
MBPP_sanitized
big_sum
def big_sum(nums): sum = max(nums) + min(nums) return sum
code_generation
[]
python
[]
null
[]
[ [ "[1,2,3]", "4" ], [ "[-1,2,3,4]", "3" ], [ "[2,3,6]", "8" ] ]
476
Write a python function to find the sum of the largest and smallest value in a given array.
MBPP_sanitized
is_lower
def is_lower(string): return string.lower()
code_generation
[]
python
[]
null
[]
[ [ "\"InValid\"", "\"invalid\"" ], [ "\"TruE\"", "\"true\"" ], [ "\"SenTenCE\"", "\"sentence\"" ] ]
477
Write a python function to convert the given string to lower case.
MBPP_sanitized
remove_lowercase
import re def remove_lowercase(str1): return re.sub('[a-z]', '', str1)
code_generation
[]
python
[ "import re" ]
null
[]
[ [ "\"PYTHon\"", "('PYTH')" ], [ "\"FInD\"", "('FID')" ], [ "\"STRinG\"", "('STRG')" ] ]
478
Write a function to remove lowercase substrings from a given string.
MBPP_sanitized
first_Digit
def first_Digit(n): while n >= 10: n = n / 10 return int(n)
code_generation
[]
python
[]
null
[]
[ [ "123", "1" ], [ "456", "4" ], [ "12", "1" ] ]
479
Write a python function to find the first digit of a given number.
MBPP_sanitized