task_name
stringclasses
1 value
src_lang
stringclasses
1 value
tgt_lang
stringclasses
1 value
data_id
stringlengths
10
12
demos
listlengths
0
0
compare_func
listlengths
0
0
dataset_name
stringclasses
1 value
suffix
stringlengths
0
672
test_cases
listlengths
0
5
entry_func
stringlengths
3
31
import_str
listlengths
0
1
doc_string
stringlengths
39
252
prefix
stringlengths
80
786
solution
stringlengths
11
142
code_infilling
python
python
MBPP/285/L4
[]
[]
MBPP_Infilling
return True else: return False
[ [ "\"ac\"", "(False)" ], [ "\"dc\"", "(False)" ], [ "\"abbbba\"", "(True)" ] ]
text_match_two_three
[ "import re" ]
Write a function that checks whether a string contains the 'a' character followed by two or three 'b' characters.
import re def text_match_two_three(text): """Write a function that checks whether a string contains the 'a' character followed by two or three 'b' characters. """ patterns = 'ab{2,3}'
if re.search(patterns, text):
code_infilling
python
python
MBPP/285/L5
[]
[]
MBPP_Infilling
else: return False
[ [ "\"ac\"", "(False)" ], [ "\"dc\"", "(False)" ], [ "\"abbbba\"", "(True)" ] ]
text_match_two_three
[ "import re" ]
Write a function that checks whether a string contains the 'a' character followed by two or three 'b' characters.
import re def text_match_two_three(text): """Write a function that checks whether a string contains the 'a' character followed by two or three 'b' characters. """ patterns = 'ab{2,3}' if re.search(patterns, text):
return True
code_infilling
python
python
MBPP/285/L6
[]
[]
MBPP_Infilling
return False
[ [ "\"ac\"", "(False)" ], [ "\"dc\"", "(False)" ], [ "\"abbbba\"", "(True)" ] ]
text_match_two_three
[ "import re" ]
Write a function that checks whether a string contains the 'a' character followed by two or three 'b' characters.
import re def text_match_two_three(text): """Write a function that checks whether a string contains the 'a' character followed by two or three 'b' characters. """ patterns = 'ab{2,3}' if re.search(patterns, text): return True
else:
code_infilling
python
python
MBPP/285/L7
[]
[]
MBPP_Infilling
[ [ "\"ac\"", "(False)" ], [ "\"dc\"", "(False)" ], [ "\"abbbba\"", "(True)" ] ]
text_match_two_three
[ "import re" ]
Write a function that checks whether a string contains the 'a' character followed by two or three 'b' characters.
import re def text_match_two_three(text): """Write a function that checks whether a string contains the 'a' character followed by two or three 'b' characters. """ patterns = 'ab{2,3}' if re.search(patterns, text): return True else:
return False
code_infilling
python
python
MBPP/286/L1
[]
[]
MBPP_Infilling
max_ending_here = 0 for i in range(n * k): max_ending_here = max_ending_here + a[i % n] if max_so_far < max_ending_here: max_so_far = max_ending_here if max_ending_here < 0: max_ending_here = 0 return max_so_far
[ [ "[10, 20, -30, -1], 4, 3", "30" ], [ "[-1, 10, 20], 3, 2", "59" ], [ "[-1, -2, -3], 3, 3", "-1" ] ]
max_sub_array_sum_repeated
[]
Write a function to find the largest sum of a contiguous array in the modified array which is formed by repeating the given array k times.
def max_sub_array_sum_repeated(a, n, k): """Write a function to find the largest sum of a contiguous array in the modified array which is formed by repeating the given array k times. """
max_so_far = -2147483648
code_infilling
python
python
MBPP/286/L2
[]
[]
MBPP_Infilling
for i in range(n * k): max_ending_here = max_ending_here + a[i % n] if max_so_far < max_ending_here: max_so_far = max_ending_here if max_ending_here < 0: max_ending_here = 0 return max_so_far
[ [ "[10, 20, -30, -1], 4, 3", "30" ], [ "[-1, 10, 20], 3, 2", "59" ], [ "[-1, -2, -3], 3, 3", "-1" ] ]
max_sub_array_sum_repeated
[]
Write a function to find the largest sum of a contiguous array in the modified array which is formed by repeating the given array k times.
def max_sub_array_sum_repeated(a, n, k): """Write a function to find the largest sum of a contiguous array in the modified array which is formed by repeating the given array k times. """ max_so_far = -2147483648
max_ending_here = 0
code_infilling
python
python
MBPP/286/L3
[]
[]
MBPP_Infilling
max_ending_here = max_ending_here + a[i % n] if max_so_far < max_ending_here: max_so_far = max_ending_here if max_ending_here < 0: max_ending_here = 0 return max_so_far
[ [ "[10, 20, -30, -1], 4, 3", "30" ], [ "[-1, 10, 20], 3, 2", "59" ], [ "[-1, -2, -3], 3, 3", "-1" ] ]
max_sub_array_sum_repeated
[]
Write a function to find the largest sum of a contiguous array in the modified array which is formed by repeating the given array k times.
def max_sub_array_sum_repeated(a, n, k): """Write a function to find the largest sum of a contiguous array in the modified array which is formed by repeating the given array k times. """ max_so_far = -2147483648 max_ending_here = 0
for i in range(n * k):
code_infilling
python
python
MBPP/286/L4
[]
[]
MBPP_Infilling
if max_so_far < max_ending_here: max_so_far = max_ending_here if max_ending_here < 0: max_ending_here = 0 return max_so_far
[ [ "[10, 20, -30, -1], 4, 3", "30" ], [ "[-1, 10, 20], 3, 2", "59" ], [ "[-1, -2, -3], 3, 3", "-1" ] ]
max_sub_array_sum_repeated
[]
Write a function to find the largest sum of a contiguous array in the modified array which is formed by repeating the given array k times.
def max_sub_array_sum_repeated(a, n, k): """Write a function to find the largest sum of a contiguous array in the modified array which is formed by repeating the given array k times. """ max_so_far = -2147483648 max_ending_here = 0 for i in range(n * k):
max_ending_here = max_ending_here + a[i % n]
code_infilling
python
python
MBPP/286/L5
[]
[]
MBPP_Infilling
max_so_far = max_ending_here if max_ending_here < 0: max_ending_here = 0 return max_so_far
[ [ "[10, 20, -30, -1], 4, 3", "30" ], [ "[-1, 10, 20], 3, 2", "59" ], [ "[-1, -2, -3], 3, 3", "-1" ] ]
max_sub_array_sum_repeated
[]
Write a function to find the largest sum of a contiguous array in the modified array which is formed by repeating the given array k times.
def max_sub_array_sum_repeated(a, n, k): """Write a function to find the largest sum of a contiguous array in the modified array which is formed by repeating the given array k times. """ max_so_far = -2147483648 max_ending_here = 0 for i in range(n * k): max_ending_here = max_ending_here + a[i % n]
if max_so_far < max_ending_here:
code_infilling
python
python
MBPP/286/L6
[]
[]
MBPP_Infilling
if max_ending_here < 0: max_ending_here = 0 return max_so_far
[ [ "[10, 20, -30, -1], 4, 3", "30" ], [ "[-1, 10, 20], 3, 2", "59" ], [ "[-1, -2, -3], 3, 3", "-1" ] ]
max_sub_array_sum_repeated
[]
Write a function to find the largest sum of a contiguous array in the modified array which is formed by repeating the given array k times.
def max_sub_array_sum_repeated(a, n, k): """Write a function to find the largest sum of a contiguous array in the modified array which is formed by repeating the given array k times. """ max_so_far = -2147483648 max_ending_here = 0 for i in range(n * k): max_ending_here = max_ending_here + a[i % n] if max_so_far < max_ending_here:
max_so_far = max_ending_here
code_infilling
python
python
MBPP/286/L7
[]
[]
MBPP_Infilling
max_ending_here = 0 return max_so_far
[ [ "[10, 20, -30, -1], 4, 3", "30" ], [ "[-1, 10, 20], 3, 2", "59" ], [ "[-1, -2, -3], 3, 3", "-1" ] ]
max_sub_array_sum_repeated
[]
Write a function to find the largest sum of a contiguous array in the modified array which is formed by repeating the given array k times.
def max_sub_array_sum_repeated(a, n, k): """Write a function to find the largest sum of a contiguous array in the modified array which is formed by repeating the given array k times. """ max_so_far = -2147483648 max_ending_here = 0 for i in range(n * k): max_ending_here = max_ending_here + a[i % n] if max_so_far < max_ending_here: max_so_far = max_ending_here
if max_ending_here < 0:
code_infilling
python
python
MBPP/286/L8
[]
[]
MBPP_Infilling
return max_so_far
[ [ "[10, 20, -30, -1], 4, 3", "30" ], [ "[-1, 10, 20], 3, 2", "59" ], [ "[-1, -2, -3], 3, 3", "-1" ] ]
max_sub_array_sum_repeated
[]
Write a function to find the largest sum of a contiguous array in the modified array which is formed by repeating the given array k times.
def max_sub_array_sum_repeated(a, n, k): """Write a function to find the largest sum of a contiguous array in the modified array which is formed by repeating the given array k times. """ max_so_far = -2147483648 max_ending_here = 0 for i in range(n * k): max_ending_here = max_ending_here + a[i % n] if max_so_far < max_ending_here: max_so_far = max_ending_here if max_ending_here < 0:
max_ending_here = 0
code_infilling
python
python
MBPP/286/L9
[]
[]
MBPP_Infilling
[ [ "[10, 20, -30, -1], 4, 3", "30" ], [ "[-1, 10, 20], 3, 2", "59" ], [ "[-1, -2, -3], 3, 3", "-1" ] ]
max_sub_array_sum_repeated
[]
Write a function to find the largest sum of a contiguous array in the modified array which is formed by repeating the given array k times.
def max_sub_array_sum_repeated(a, n, k): """Write a function to find the largest sum of a contiguous array in the modified array which is formed by repeating the given array k times. """ max_so_far = -2147483648 max_ending_here = 0 for i in range(n * k): max_ending_here = max_ending_here + a[i % n] if max_so_far < max_ending_here: max_so_far = max_ending_here if max_ending_here < 0: max_ending_here = 0
return max_so_far
code_infilling
python
python
MBPP/287/L1
[]
[]
MBPP_Infilling
[ [ "2", "20" ], [ "3", "56" ], [ "4", "120" ] ]
square_Sum
[]
Write a python function takes in an integer n and returns the sum of squares of first n even natural numbers.
def square_Sum(n): """Write a python function takes in an integer n and returns the sum of squares of first n even natural numbers. """
return int(2 * n * (n + 1) * (2 * n + 1) / 3)
code_infilling
python
python
MBPP/290/L1
[]
[]
MBPP_Infilling
max_list = max((x for x in list1)) return (max_length, max_list)
[ [ "[[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]]", "(3, [13, 15, 17])" ], [ "[[1], [5, 7], [10, 12, 14,15]]", "(4, [10, 12, 14,15])" ], [ "[[5], [15,20,25]]", "(3, [15,20,25])" ] ]
max_length
[]
Write a function to find the list of maximum length in a list of lists.
def max_length(list1): """Write a function to find the list of maximum length in a list of lists. """
max_length = max((len(x) for x in list1))
code_infilling
python
python
MBPP/290/L2
[]
[]
MBPP_Infilling
return (max_length, max_list)
[ [ "[[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]]", "(3, [13, 15, 17])" ], [ "[[1], [5, 7], [10, 12, 14,15]]", "(4, [10, 12, 14,15])" ], [ "[[5], [15,20,25]]", "(3, [15,20,25])" ] ]
max_length
[]
Write a function to find the list of maximum length in a list of lists.
def max_length(list1): """Write a function to find the list of maximum length in a list of lists. """ max_length = max((len(x) for x in list1))
max_list = max((x for x in list1))
code_infilling
python
python
MBPP/290/L3
[]
[]
MBPP_Infilling
[ [ "[[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]]", "(3, [13, 15, 17])" ], [ "[[1], [5, 7], [10, 12, 14,15]]", "(4, [10, 12, 14,15])" ], [ "[[5], [15,20,25]]", "(3, [15,20,25])" ] ]
max_length
[]
Write a function to find the list of maximum length in a list of lists.
def max_length(list1): """Write a function to find the list of maximum length in a list of lists. """ max_length = max((len(x) for x in list1)) max_list = max((x for x in list1))
return (max_length, max_list)
code_infilling
python
python
MBPP/291/L1
[]
[]
MBPP_Infilling
total = k mod = 1000000007 dp[1] = k dp[2] = k * k for i in range(3, n + 1): dp[i] = (k - 1) * (dp[i - 1] + dp[i - 2]) % mod return dp[n]
[ [ "2, 4", "16" ], [ "3, 2", "6" ], [ "4, 4", "228" ] ]
count_no_of_ways
[]
Write a function to find out the number of ways of painting the fence such that at most 2 adjacent posts have the same color for the given fence with n posts and k colors.
def count_no_of_ways(n, k): """Write a function to find out the number of ways of painting the fence such that at most 2 adjacent posts have the same color for the given fence with n posts and k colors. """
dp = [0] * (n + 1)
code_infilling
python
python
MBPP/291/L2
[]
[]
MBPP_Infilling
mod = 1000000007 dp[1] = k dp[2] = k * k for i in range(3, n + 1): dp[i] = (k - 1) * (dp[i - 1] + dp[i - 2]) % mod return dp[n]
[ [ "2, 4", "16" ], [ "3, 2", "6" ], [ "4, 4", "228" ] ]
count_no_of_ways
[]
Write a function to find out the number of ways of painting the fence such that at most 2 adjacent posts have the same color for the given fence with n posts and k colors.
def count_no_of_ways(n, k): """Write a function to find out the number of ways of painting the fence such that at most 2 adjacent posts have the same color for the given fence with n posts and k colors. """ dp = [0] * (n + 1)
total = k
code_infilling
python
python
MBPP/291/L3
[]
[]
MBPP_Infilling
dp[1] = k dp[2] = k * k for i in range(3, n + 1): dp[i] = (k - 1) * (dp[i - 1] + dp[i - 2]) % mod return dp[n]
[ [ "2, 4", "16" ], [ "3, 2", "6" ], [ "4, 4", "228" ] ]
count_no_of_ways
[]
Write a function to find out the number of ways of painting the fence such that at most 2 adjacent posts have the same color for the given fence with n posts and k colors.
def count_no_of_ways(n, k): """Write a function to find out the number of ways of painting the fence such that at most 2 adjacent posts have the same color for the given fence with n posts and k colors. """ dp = [0] * (n + 1) total = k
mod = 1000000007
code_infilling
python
python
MBPP/291/L4
[]
[]
MBPP_Infilling
dp[2] = k * k for i in range(3, n + 1): dp[i] = (k - 1) * (dp[i - 1] + dp[i - 2]) % mod return dp[n]
[ [ "2, 4", "16" ], [ "3, 2", "6" ], [ "4, 4", "228" ] ]
count_no_of_ways
[]
Write a function to find out the number of ways of painting the fence such that at most 2 adjacent posts have the same color for the given fence with n posts and k colors.
def count_no_of_ways(n, k): """Write a function to find out the number of ways of painting the fence such that at most 2 adjacent posts have the same color for the given fence with n posts and k colors. """ dp = [0] * (n + 1) total = k mod = 1000000007
dp[1] = k
code_infilling
python
python
MBPP/291/L5
[]
[]
MBPP_Infilling
for i in range(3, n + 1): dp[i] = (k - 1) * (dp[i - 1] + dp[i - 2]) % mod return dp[n]
[ [ "2, 4", "16" ], [ "3, 2", "6" ], [ "4, 4", "228" ] ]
count_no_of_ways
[]
Write a function to find out the number of ways of painting the fence such that at most 2 adjacent posts have the same color for the given fence with n posts and k colors.
def count_no_of_ways(n, k): """Write a function to find out the number of ways of painting the fence such that at most 2 adjacent posts have the same color for the given fence with n posts and k colors. """ dp = [0] * (n + 1) total = k mod = 1000000007 dp[1] = k
dp[2] = k * k
code_infilling
python
python
MBPP/291/L6
[]
[]
MBPP_Infilling
dp[i] = (k - 1) * (dp[i - 1] + dp[i - 2]) % mod return dp[n]
[ [ "2, 4", "16" ], [ "3, 2", "6" ], [ "4, 4", "228" ] ]
count_no_of_ways
[]
Write a function to find out the number of ways of painting the fence such that at most 2 adjacent posts have the same color for the given fence with n posts and k colors.
def count_no_of_ways(n, k): """Write a function to find out the number of ways of painting the fence such that at most 2 adjacent posts have the same color for the given fence with n posts and k colors. """ dp = [0] * (n + 1) total = k mod = 1000000007 dp[1] = k dp[2] = k * k
for i in range(3, n + 1):
code_infilling
python
python
MBPP/291/L7
[]
[]
MBPP_Infilling
return dp[n]
[ [ "2, 4", "16" ], [ "3, 2", "6" ], [ "4, 4", "228" ] ]
count_no_of_ways
[]
Write a function to find out the number of ways of painting the fence such that at most 2 adjacent posts have the same color for the given fence with n posts and k colors.
def count_no_of_ways(n, k): """Write a function to find out the number of ways of painting the fence such that at most 2 adjacent posts have the same color for the given fence with n posts and k colors. """ dp = [0] * (n + 1) total = k mod = 1000000007 dp[1] = k dp[2] = k * k for i in range(3, n + 1):
dp[i] = (k - 1) * (dp[i - 1] + dp[i - 2]) % mod
code_infilling
python
python
MBPP/291/L8
[]
[]
MBPP_Infilling
[ [ "2, 4", "16" ], [ "3, 2", "6" ], [ "4, 4", "228" ] ]
count_no_of_ways
[]
Write a function to find out the number of ways of painting the fence such that at most 2 adjacent posts have the same color for the given fence with n posts and k colors.
def count_no_of_ways(n, k): """Write a function to find out the number of ways of painting the fence such that at most 2 adjacent posts have the same color for the given fence with n posts and k colors. """ dp = [0] * (n + 1) total = k mod = 1000000007 dp[1] = k dp[2] = k * k for i in range(3, n + 1): dp[i] = (k - 1) * (dp[i - 1] + dp[i - 2]) % mod
return dp[n]
code_infilling
python
python
MBPP/292/L1
[]
[]
MBPP_Infilling
return q
[ [ "10,3", "3" ], [ "4,2", "2" ], [ "20,5", "4" ] ]
find
[]
Write a python function to find quotient of two numbers (rounded down to the nearest integer).
def find(n, m): """Write a python function to find quotient of two numbers (rounded down to the nearest integer). """
q = n // m
code_infilling
python
python
MBPP/292/L2
[]
[]
MBPP_Infilling
[ [ "10,3", "3" ], [ "4,2", "2" ], [ "20,5", "4" ] ]
find
[]
Write a python function to find quotient of two numbers (rounded down to the nearest integer).
def find(n, m): """Write a python function to find quotient of two numbers (rounded down to the nearest integer). """ q = n // m
return q
code_infilling
python
python
MBPP/293/L3
[]
[]
MBPP_Infilling
return s
[ [ "7,8", "10.63014581273465" ], [ "3,4", "5" ], [ "7,15", "16.55294535724685" ] ]
otherside_rightangle
[ "import math" ]
Write a function to find the third side of a right angled triangle.
import math def otherside_rightangle(w, h): """Write a function to find the third side of a right angled triangle. """
s = math.sqrt(w * w + h * h)
code_infilling
python
python
MBPP/293/L4
[]
[]
MBPP_Infilling
[ [ "7,8", "10.63014581273465" ], [ "3,4", "5" ], [ "7,15", "16.55294535724685" ] ]
otherside_rightangle
[ "import math" ]
Write a function to find the third side of a right angled triangle.
import math def otherside_rightangle(w, h): """Write a function to find the third side of a right angled triangle. """ s = math.sqrt(w * w + h * h)
return s
code_infilling
python
python
MBPP/294/L1
[]
[]
MBPP_Infilling
return max_val
[ [ "['Python', 3, 2, 4, 5, 'version']", "5" ], [ "['Python', 15, 20, 25]", "25" ], [ "['Python', 30, 20, 40, 50, 'version']", "50" ] ]
max_val
[]
Write a function to find the maximum value in a given heterogeneous list.
def max_val(listval): """Write a function to find the maximum value in a given heterogeneous list. """
max_val = max((i for i in listval if isinstance(i, int)))
code_infilling
python
python
MBPP/294/L2
[]
[]
MBPP_Infilling
[ [ "['Python', 3, 2, 4, 5, 'version']", "5" ], [ "['Python', 15, 20, 25]", "25" ], [ "['Python', 30, 20, 40, 50, 'version']", "50" ] ]
max_val
[]
Write a function to find the maximum value in a given heterogeneous list.
def max_val(listval): """Write a function to find the maximum value in a given heterogeneous list. """ max_val = max((i for i in listval if isinstance(i, int)))
return max_val
code_infilling
python
python
MBPP/295/L1
[]
[]
MBPP_Infilling
for i in range(2, number): if number % i == 0: divisors.append(i) return sum(divisors)
[ [ "8", "7" ], [ "12", "16" ], [ "7", "1" ] ]
sum_div
[]
Write a function to return the sum of all divisors of a number.
def sum_div(number): """Write a function to return the sum of all divisors of a number. """
divisors = [1]
code_infilling
python
python
MBPP/295/L2
[]
[]
MBPP_Infilling
if number % i == 0: divisors.append(i) return sum(divisors)
[ [ "8", "7" ], [ "12", "16" ], [ "7", "1" ] ]
sum_div
[]
Write a function to return the sum of all divisors of a number.
def sum_div(number): """Write a function to return the sum of all divisors of a number. """ divisors = [1]
for i in range(2, number):
code_infilling
python
python
MBPP/295/L3
[]
[]
MBPP_Infilling
divisors.append(i) return sum(divisors)
[ [ "8", "7" ], [ "12", "16" ], [ "7", "1" ] ]
sum_div
[]
Write a function to return the sum of all divisors of a number.
def sum_div(number): """Write a function to return the sum of all divisors of a number. """ divisors = [1] for i in range(2, number):
if number % i == 0:
code_infilling
python
python
MBPP/295/L4
[]
[]
MBPP_Infilling
return sum(divisors)
[ [ "8", "7" ], [ "12", "16" ], [ "7", "1" ] ]
sum_div
[]
Write a function to return the sum of all divisors of a number.
def sum_div(number): """Write a function to return the sum of all divisors of a number. """ divisors = [1] for i in range(2, number): if number % i == 0:
divisors.append(i)
code_infilling
python
python
MBPP/295/L5
[]
[]
MBPP_Infilling
[ [ "8", "7" ], [ "12", "16" ], [ "7", "1" ] ]
sum_div
[]
Write a function to return the sum of all divisors of a number.
def sum_div(number): """Write a function to return the sum of all divisors of a number. """ divisors = [1] for i in range(2, number): if number % i == 0: divisors.append(i)
return sum(divisors)
code_infilling
python
python
MBPP/296/L1
[]
[]
MBPP_Infilling
for i in range(len(arr)): for j in range(i + 1, len(arr)): if arr[i] > arr[j]: inv_count += 1 return inv_count
[ [ "[1,20,6,4,5]", "5" ], [ "[1,2,1]", "1" ], [ "[1,2,5,6,1]", "3" ] ]
get_Inv_Count
[]
Write a python function to count inversions in an array.
def get_Inv_Count(arr): """Write a python function to count inversions in an array. """
inv_count = 0
code_infilling
python
python
MBPP/296/L2
[]
[]
MBPP_Infilling
for j in range(i + 1, len(arr)): if arr[i] > arr[j]: inv_count += 1 return inv_count
[ [ "[1,20,6,4,5]", "5" ], [ "[1,2,1]", "1" ], [ "[1,2,5,6,1]", "3" ] ]
get_Inv_Count
[]
Write a python function to count inversions in an array.
def get_Inv_Count(arr): """Write a python function to count inversions in an array. """ inv_count = 0
for i in range(len(arr)):
code_infilling
python
python
MBPP/296/L3
[]
[]
MBPP_Infilling
if arr[i] > arr[j]: inv_count += 1 return inv_count
[ [ "[1,20,6,4,5]", "5" ], [ "[1,2,1]", "1" ], [ "[1,2,5,6,1]", "3" ] ]
get_Inv_Count
[]
Write a python function to count inversions in an array.
def get_Inv_Count(arr): """Write a python function to count inversions in an array. """ inv_count = 0 for i in range(len(arr)):
for j in range(i + 1, len(arr)):
code_infilling
python
python
MBPP/296/L4
[]
[]
MBPP_Infilling
inv_count += 1 return inv_count
[ [ "[1,20,6,4,5]", "5" ], [ "[1,2,1]", "1" ], [ "[1,2,5,6,1]", "3" ] ]
get_Inv_Count
[]
Write a python function to count inversions in an array.
def get_Inv_Count(arr): """Write a python function to count inversions in an array. """ inv_count = 0 for i in range(len(arr)): for j in range(i + 1, len(arr)):
if arr[i] > arr[j]:
code_infilling
python
python
MBPP/296/L5
[]
[]
MBPP_Infilling
return inv_count
[ [ "[1,20,6,4,5]", "5" ], [ "[1,2,1]", "1" ], [ "[1,2,5,6,1]", "3" ] ]
get_Inv_Count
[]
Write a python function to count inversions in an array.
def get_Inv_Count(arr): """Write a python function to count inversions in an array. """ inv_count = 0 for i in range(len(arr)): for j in range(i + 1, len(arr)): if arr[i] > arr[j]:
inv_count += 1
code_infilling
python
python
MBPP/296/L6
[]
[]
MBPP_Infilling
[ [ "[1,20,6,4,5]", "5" ], [ "[1,2,1]", "1" ], [ "[1,2,5,6,1]", "3" ] ]
get_Inv_Count
[]
Write a python function to count inversions in an array.
def get_Inv_Count(arr): """Write a python function to count inversions in an array. """ inv_count = 0 for i in range(len(arr)): for j in range(i + 1, len(arr)): if arr[i] > arr[j]: inv_count += 1
return inv_count
code_infilling
python
python
MBPP/297/L1
[]
[]
MBPP_Infilling
if not list1: return result_list stack = [list(list1)] while stack: c_num = stack.pop() next = c_num.pop() if c_num: stack.append(c_num) if isinstance(next, list): if next: stack.append(list(next)) else: result_list.append(next) result_list.reverse() return result_list
[ [ "[0, 10, [20, 30], 40, 50, [60, 70, 80], [90, 100, 110, 120]]", "[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]" ], [ "[[10, 20], [40], [30, 56, 25], [10, 20], [33], [40]]", "[10, 20, 40, 30, 56, 25, 10, 20, 33, 40]" ], [ "[[1,2,3], [4,5,6], [10,11,12], [7,8,9]]", "[1, 2, 3, 4, 5, 6, 10, 11, 12, 7, 8, 9]" ] ]
flatten_list
[]
Write a function to flatten a given nested list structure.
def flatten_list(list1): """Write a function to flatten a given nested list structure. """
result_list = []
code_infilling
python
python
MBPP/297/L2
[]
[]
MBPP_Infilling
return result_list stack = [list(list1)] while stack: c_num = stack.pop() next = c_num.pop() if c_num: stack.append(c_num) if isinstance(next, list): if next: stack.append(list(next)) else: result_list.append(next) result_list.reverse() return result_list
[ [ "[0, 10, [20, 30], 40, 50, [60, 70, 80], [90, 100, 110, 120]]", "[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]" ], [ "[[10, 20], [40], [30, 56, 25], [10, 20], [33], [40]]", "[10, 20, 40, 30, 56, 25, 10, 20, 33, 40]" ], [ "[[1,2,3], [4,5,6], [10,11,12], [7,8,9]]", "[1, 2, 3, 4, 5, 6, 10, 11, 12, 7, 8, 9]" ] ]
flatten_list
[]
Write a function to flatten a given nested list structure.
def flatten_list(list1): """Write a function to flatten a given nested list structure. """ result_list = []
if not list1:
code_infilling
python
python
MBPP/297/L3
[]
[]
MBPP_Infilling
stack = [list(list1)] while stack: c_num = stack.pop() next = c_num.pop() if c_num: stack.append(c_num) if isinstance(next, list): if next: stack.append(list(next)) else: result_list.append(next) result_list.reverse() return result_list
[ [ "[0, 10, [20, 30], 40, 50, [60, 70, 80], [90, 100, 110, 120]]", "[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]" ], [ "[[10, 20], [40], [30, 56, 25], [10, 20], [33], [40]]", "[10, 20, 40, 30, 56, 25, 10, 20, 33, 40]" ], [ "[[1,2,3], [4,5,6], [10,11,12], [7,8,9]]", "[1, 2, 3, 4, 5, 6, 10, 11, 12, 7, 8, 9]" ] ]
flatten_list
[]
Write a function to flatten a given nested list structure.
def flatten_list(list1): """Write a function to flatten a given nested list structure. """ result_list = [] if not list1:
return result_list
code_infilling
python
python
MBPP/297/L4
[]
[]
MBPP_Infilling
while stack: c_num = stack.pop() next = c_num.pop() if c_num: stack.append(c_num) if isinstance(next, list): if next: stack.append(list(next)) else: result_list.append(next) result_list.reverse() return result_list
[ [ "[0, 10, [20, 30], 40, 50, [60, 70, 80], [90, 100, 110, 120]]", "[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]" ], [ "[[10, 20], [40], [30, 56, 25], [10, 20], [33], [40]]", "[10, 20, 40, 30, 56, 25, 10, 20, 33, 40]" ], [ "[[1,2,3], [4,5,6], [10,11,12], [7,8,9]]", "[1, 2, 3, 4, 5, 6, 10, 11, 12, 7, 8, 9]" ] ]
flatten_list
[]
Write a function to flatten a given nested list structure.
def flatten_list(list1): """Write a function to flatten a given nested list structure. """ result_list = [] if not list1: return result_list
stack = [list(list1)]
code_infilling
python
python
MBPP/297/L5
[]
[]
MBPP_Infilling
c_num = stack.pop() next = c_num.pop() if c_num: stack.append(c_num) if isinstance(next, list): if next: stack.append(list(next)) else: result_list.append(next) result_list.reverse() return result_list
[ [ "[0, 10, [20, 30], 40, 50, [60, 70, 80], [90, 100, 110, 120]]", "[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]" ], [ "[[10, 20], [40], [30, 56, 25], [10, 20], [33], [40]]", "[10, 20, 40, 30, 56, 25, 10, 20, 33, 40]" ], [ "[[1,2,3], [4,5,6], [10,11,12], [7,8,9]]", "[1, 2, 3, 4, 5, 6, 10, 11, 12, 7, 8, 9]" ] ]
flatten_list
[]
Write a function to flatten a given nested list structure.
def flatten_list(list1): """Write a function to flatten a given nested list structure. """ result_list = [] if not list1: return result_list stack = [list(list1)]
while stack:
code_infilling
python
python
MBPP/297/L6
[]
[]
MBPP_Infilling
next = c_num.pop() if c_num: stack.append(c_num) if isinstance(next, list): if next: stack.append(list(next)) else: result_list.append(next) result_list.reverse() return result_list
[ [ "[0, 10, [20, 30], 40, 50, [60, 70, 80], [90, 100, 110, 120]]", "[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]" ], [ "[[10, 20], [40], [30, 56, 25], [10, 20], [33], [40]]", "[10, 20, 40, 30, 56, 25, 10, 20, 33, 40]" ], [ "[[1,2,3], [4,5,6], [10,11,12], [7,8,9]]", "[1, 2, 3, 4, 5, 6, 10, 11, 12, 7, 8, 9]" ] ]
flatten_list
[]
Write a function to flatten a given nested list structure.
def flatten_list(list1): """Write a function to flatten a given nested list structure. """ result_list = [] if not list1: return result_list stack = [list(list1)] while stack:
c_num = stack.pop()
code_infilling
python
python
MBPP/297/L7
[]
[]
MBPP_Infilling
if c_num: stack.append(c_num) if isinstance(next, list): if next: stack.append(list(next)) else: result_list.append(next) result_list.reverse() return result_list
[ [ "[0, 10, [20, 30], 40, 50, [60, 70, 80], [90, 100, 110, 120]]", "[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]" ], [ "[[10, 20], [40], [30, 56, 25], [10, 20], [33], [40]]", "[10, 20, 40, 30, 56, 25, 10, 20, 33, 40]" ], [ "[[1,2,3], [4,5,6], [10,11,12], [7,8,9]]", "[1, 2, 3, 4, 5, 6, 10, 11, 12, 7, 8, 9]" ] ]
flatten_list
[]
Write a function to flatten a given nested list structure.
def flatten_list(list1): """Write a function to flatten a given nested list structure. """ result_list = [] if not list1: return result_list stack = [list(list1)] while stack: c_num = stack.pop()
next = c_num.pop()
code_infilling
python
python
MBPP/297/L8
[]
[]
MBPP_Infilling
stack.append(c_num) if isinstance(next, list): if next: stack.append(list(next)) else: result_list.append(next) result_list.reverse() return result_list
[ [ "[0, 10, [20, 30], 40, 50, [60, 70, 80], [90, 100, 110, 120]]", "[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]" ], [ "[[10, 20], [40], [30, 56, 25], [10, 20], [33], [40]]", "[10, 20, 40, 30, 56, 25, 10, 20, 33, 40]" ], [ "[[1,2,3], [4,5,6], [10,11,12], [7,8,9]]", "[1, 2, 3, 4, 5, 6, 10, 11, 12, 7, 8, 9]" ] ]
flatten_list
[]
Write a function to flatten a given nested list structure.
def flatten_list(list1): """Write a function to flatten a given nested list structure. """ result_list = [] if not list1: return result_list stack = [list(list1)] while stack: c_num = stack.pop() next = c_num.pop()
if c_num:
code_infilling
python
python
MBPP/297/L9
[]
[]
MBPP_Infilling
if isinstance(next, list): if next: stack.append(list(next)) else: result_list.append(next) result_list.reverse() return result_list
[ [ "[0, 10, [20, 30], 40, 50, [60, 70, 80], [90, 100, 110, 120]]", "[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]" ], [ "[[10, 20], [40], [30, 56, 25], [10, 20], [33], [40]]", "[10, 20, 40, 30, 56, 25, 10, 20, 33, 40]" ], [ "[[1,2,3], [4,5,6], [10,11,12], [7,8,9]]", "[1, 2, 3, 4, 5, 6, 10, 11, 12, 7, 8, 9]" ] ]
flatten_list
[]
Write a function to flatten a given nested list structure.
def flatten_list(list1): """Write a function to flatten a given nested list structure. """ result_list = [] if not list1: return result_list stack = [list(list1)] while stack: c_num = stack.pop() next = c_num.pop() if c_num:
stack.append(c_num)
code_infilling
python
python
MBPP/297/L10
[]
[]
MBPP_Infilling
if next: stack.append(list(next)) else: result_list.append(next) result_list.reverse() return result_list
[ [ "[0, 10, [20, 30], 40, 50, [60, 70, 80], [90, 100, 110, 120]]", "[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]" ], [ "[[10, 20], [40], [30, 56, 25], [10, 20], [33], [40]]", "[10, 20, 40, 30, 56, 25, 10, 20, 33, 40]" ], [ "[[1,2,3], [4,5,6], [10,11,12], [7,8,9]]", "[1, 2, 3, 4, 5, 6, 10, 11, 12, 7, 8, 9]" ] ]
flatten_list
[]
Write a function to flatten a given nested list structure.
def flatten_list(list1): """Write a function to flatten a given nested list structure. """ result_list = [] if not list1: return result_list stack = [list(list1)] while stack: c_num = stack.pop() next = c_num.pop() if c_num: stack.append(c_num)
if isinstance(next, list):
code_infilling
python
python
MBPP/297/L11
[]
[]
MBPP_Infilling
stack.append(list(next)) else: result_list.append(next) result_list.reverse() return result_list
[ [ "[0, 10, [20, 30], 40, 50, [60, 70, 80], [90, 100, 110, 120]]", "[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]" ], [ "[[10, 20], [40], [30, 56, 25], [10, 20], [33], [40]]", "[10, 20, 40, 30, 56, 25, 10, 20, 33, 40]" ], [ "[[1,2,3], [4,5,6], [10,11,12], [7,8,9]]", "[1, 2, 3, 4, 5, 6, 10, 11, 12, 7, 8, 9]" ] ]
flatten_list
[]
Write a function to flatten a given nested list structure.
def flatten_list(list1): """Write a function to flatten a given nested list structure. """ result_list = [] if not list1: return result_list stack = [list(list1)] while stack: c_num = stack.pop() next = c_num.pop() if c_num: stack.append(c_num) if isinstance(next, list):
if next:
code_infilling
python
python
MBPP/297/L12
[]
[]
MBPP_Infilling
else: result_list.append(next) result_list.reverse() return result_list
[ [ "[0, 10, [20, 30], 40, 50, [60, 70, 80], [90, 100, 110, 120]]", "[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]" ], [ "[[10, 20], [40], [30, 56, 25], [10, 20], [33], [40]]", "[10, 20, 40, 30, 56, 25, 10, 20, 33, 40]" ], [ "[[1,2,3], [4,5,6], [10,11,12], [7,8,9]]", "[1, 2, 3, 4, 5, 6, 10, 11, 12, 7, 8, 9]" ] ]
flatten_list
[]
Write a function to flatten a given nested list structure.
def flatten_list(list1): """Write a function to flatten a given nested list structure. """ result_list = [] if not list1: return result_list stack = [list(list1)] while stack: c_num = stack.pop() next = c_num.pop() if c_num: stack.append(c_num) if isinstance(next, list): if next:
stack.append(list(next))
code_infilling
python
python
MBPP/297/L13
[]
[]
MBPP_Infilling
result_list.append(next) result_list.reverse() return result_list
[ [ "[0, 10, [20, 30], 40, 50, [60, 70, 80], [90, 100, 110, 120]]", "[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]" ], [ "[[10, 20], [40], [30, 56, 25], [10, 20], [33], [40]]", "[10, 20, 40, 30, 56, 25, 10, 20, 33, 40]" ], [ "[[1,2,3], [4,5,6], [10,11,12], [7,8,9]]", "[1, 2, 3, 4, 5, 6, 10, 11, 12, 7, 8, 9]" ] ]
flatten_list
[]
Write a function to flatten a given nested list structure.
def flatten_list(list1): """Write a function to flatten a given nested list structure. """ result_list = [] if not list1: return result_list stack = [list(list1)] while stack: c_num = stack.pop() next = c_num.pop() if c_num: stack.append(c_num) if isinstance(next, list): if next: stack.append(list(next))
else:
code_infilling
python
python
MBPP/297/L14
[]
[]
MBPP_Infilling
result_list.reverse() return result_list
[ [ "[0, 10, [20, 30], 40, 50, [60, 70, 80], [90, 100, 110, 120]]", "[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]" ], [ "[[10, 20], [40], [30, 56, 25], [10, 20], [33], [40]]", "[10, 20, 40, 30, 56, 25, 10, 20, 33, 40]" ], [ "[[1,2,3], [4,5,6], [10,11,12], [7,8,9]]", "[1, 2, 3, 4, 5, 6, 10, 11, 12, 7, 8, 9]" ] ]
flatten_list
[]
Write a function to flatten a given nested list structure.
def flatten_list(list1): """Write a function to flatten a given nested list structure. """ result_list = [] if not list1: return result_list stack = [list(list1)] while stack: c_num = stack.pop() next = c_num.pop() if c_num: stack.append(c_num) if isinstance(next, list): if next: stack.append(list(next)) else:
result_list.append(next)
code_infilling
python
python
MBPP/297/L15
[]
[]
MBPP_Infilling
return result_list
[ [ "[0, 10, [20, 30], 40, 50, [60, 70, 80], [90, 100, 110, 120]]", "[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]" ], [ "[[10, 20], [40], [30, 56, 25], [10, 20], [33], [40]]", "[10, 20, 40, 30, 56, 25, 10, 20, 33, 40]" ], [ "[[1,2,3], [4,5,6], [10,11,12], [7,8,9]]", "[1, 2, 3, 4, 5, 6, 10, 11, 12, 7, 8, 9]" ] ]
flatten_list
[]
Write a function to flatten a given nested list structure.
def flatten_list(list1): """Write a function to flatten a given nested list structure. """ result_list = [] if not list1: return result_list stack = [list(list1)] while stack: c_num = stack.pop() next = c_num.pop() if c_num: stack.append(c_num) if isinstance(next, list): if next: stack.append(list(next)) else: result_list.append(next)
result_list.reverse()
code_infilling
python
python
MBPP/297/L16
[]
[]
MBPP_Infilling
[ [ "[0, 10, [20, 30], 40, 50, [60, 70, 80], [90, 100, 110, 120]]", "[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120]" ], [ "[[10, 20], [40], [30, 56, 25], [10, 20], [33], [40]]", "[10, 20, 40, 30, 56, 25, 10, 20, 33, 40]" ], [ "[[1,2,3], [4,5,6], [10,11,12], [7,8,9]]", "[1, 2, 3, 4, 5, 6, 10, 11, 12, 7, 8, 9]" ] ]
flatten_list
[]
Write a function to flatten a given nested list structure.
def flatten_list(list1): """Write a function to flatten a given nested list structure. """ result_list = [] if not list1: return result_list stack = [list(list1)] while stack: c_num = stack.pop() next = c_num.pop() if c_num: stack.append(c_num) if isinstance(next, list): if next: stack.append(list(next)) else: result_list.append(next) result_list.reverse()
return result_list
code_infilling
python
python
MBPP/299/L3
[]
[]
MBPP_Infilling
for (name, marks) in stdata: temp[name] += marks return max(temp.items(), key=lambda x: x[1])
[ [ "[('Juan Whelan',90),('Sabah Colley',88),('Peter Nichols',7),('Juan Whelan',122),('Sabah Colley',84)]", "('Juan Whelan', 212)" ], [ "[('Juan Whelan',50),('Sabah Colley',48),('Peter Nichols',37),('Juan Whelan',22),('Sabah Colley',14)]", "('Juan Whelan', 72)" ], [ "[('Juan Whelan',10),('Sabah Colley',20),('Peter Nichols',30),('Juan Whelan',40),('Sabah Colley',50)]", "('Sabah Colley', 70)" ] ]
max_aggregate
[ "from collections import defaultdict" ]
Write a function to calculate the maximum aggregate from the list of tuples.
from collections import defaultdict def max_aggregate(stdata): """Write a function to calculate the maximum aggregate from the list of tuples. """
temp = defaultdict(int)
code_infilling
python
python
MBPP/299/L4
[]
[]
MBPP_Infilling
temp[name] += marks return max(temp.items(), key=lambda x: x[1])
[ [ "[('Juan Whelan',90),('Sabah Colley',88),('Peter Nichols',7),('Juan Whelan',122),('Sabah Colley',84)]", "('Juan Whelan', 212)" ], [ "[('Juan Whelan',50),('Sabah Colley',48),('Peter Nichols',37),('Juan Whelan',22),('Sabah Colley',14)]", "('Juan Whelan', 72)" ], [ "[('Juan Whelan',10),('Sabah Colley',20),('Peter Nichols',30),('Juan Whelan',40),('Sabah Colley',50)]", "('Sabah Colley', 70)" ] ]
max_aggregate
[ "from collections import defaultdict" ]
Write a function to calculate the maximum aggregate from the list of tuples.
from collections import defaultdict def max_aggregate(stdata): """Write a function to calculate the maximum aggregate from the list of tuples. """ temp = defaultdict(int)
for (name, marks) in stdata:
code_infilling
python
python
MBPP/299/L5
[]
[]
MBPP_Infilling
return max(temp.items(), key=lambda x: x[1])
[ [ "[('Juan Whelan',90),('Sabah Colley',88),('Peter Nichols',7),('Juan Whelan',122),('Sabah Colley',84)]", "('Juan Whelan', 212)" ], [ "[('Juan Whelan',50),('Sabah Colley',48),('Peter Nichols',37),('Juan Whelan',22),('Sabah Colley',14)]", "('Juan Whelan', 72)" ], [ "[('Juan Whelan',10),('Sabah Colley',20),('Peter Nichols',30),('Juan Whelan',40),('Sabah Colley',50)]", "('Sabah Colley', 70)" ] ]
max_aggregate
[ "from collections import defaultdict" ]
Write a function to calculate the maximum aggregate from the list of tuples.
from collections import defaultdict def max_aggregate(stdata): """Write a function to calculate the maximum aggregate from the list of tuples. """ temp = defaultdict(int) for (name, marks) in stdata:
temp[name] += marks
code_infilling
python
python
MBPP/299/L6
[]
[]
MBPP_Infilling
[ [ "[('Juan Whelan',90),('Sabah Colley',88),('Peter Nichols',7),('Juan Whelan',122),('Sabah Colley',84)]", "('Juan Whelan', 212)" ], [ "[('Juan Whelan',50),('Sabah Colley',48),('Peter Nichols',37),('Juan Whelan',22),('Sabah Colley',14)]", "('Juan Whelan', 72)" ], [ "[('Juan Whelan',10),('Sabah Colley',20),('Peter Nichols',30),('Juan Whelan',40),('Sabah Colley',50)]", "('Sabah Colley', 70)" ] ]
max_aggregate
[ "from collections import defaultdict" ]
Write a function to calculate the maximum aggregate from the list of tuples.
from collections import defaultdict def max_aggregate(stdata): """Write a function to calculate the maximum aggregate from the list of tuples. """ temp = defaultdict(int) for (name, marks) in stdata: temp[name] += marks
return max(temp.items(), key=lambda x: x[1])
code_infilling
python
python
MBPP/300/L1
[]
[]
MBPP_Infilling
res = 1 for r in range(1, n + 1): nCr = nCr * (n + 1 - r) / r res += nCr * nCr return res
[]
count_binary_seq
[]
Write a function to find the count of all binary sequences of length 2n such that sum of first n bits is same as sum of last n bits.
def count_binary_seq(n): """Write a function to find the count of all binary sequences of length 2n such that sum of first n bits is same as sum of last n bits. """
nCr = 1
code_infilling
python
python
MBPP/300/L2
[]
[]
MBPP_Infilling
for r in range(1, n + 1): nCr = nCr * (n + 1 - r) / r res += nCr * nCr return res
[]
count_binary_seq
[]
Write a function to find the count of all binary sequences of length 2n such that sum of first n bits is same as sum of last n bits.
def count_binary_seq(n): """Write a function to find the count of all binary sequences of length 2n such that sum of first n bits is same as sum of last n bits. """ nCr = 1
res = 1
code_infilling
python
python
MBPP/300/L3
[]
[]
MBPP_Infilling
nCr = nCr * (n + 1 - r) / r res += nCr * nCr return res
[]
count_binary_seq
[]
Write a function to find the count of all binary sequences of length 2n such that sum of first n bits is same as sum of last n bits.
def count_binary_seq(n): """Write a function to find the count of all binary sequences of length 2n such that sum of first n bits is same as sum of last n bits. """ nCr = 1 res = 1
for r in range(1, n + 1):
code_infilling
python
python
MBPP/300/L4
[]
[]
MBPP_Infilling
res += nCr * nCr return res
[]
count_binary_seq
[]
Write a function to find the count of all binary sequences of length 2n such that sum of first n bits is same as sum of last n bits.
def count_binary_seq(n): """Write a function to find the count of all binary sequences of length 2n such that sum of first n bits is same as sum of last n bits. """ nCr = 1 res = 1 for r in range(1, n + 1):
nCr = nCr * (n + 1 - r) / r
code_infilling
python
python
MBPP/300/L5
[]
[]
MBPP_Infilling
return res
[]
count_binary_seq
[]
Write a function to find the count of all binary sequences of length 2n such that sum of first n bits is same as sum of last n bits.
def count_binary_seq(n): """Write a function to find the count of all binary sequences of length 2n such that sum of first n bits is same as sum of last n bits. """ nCr = 1 res = 1 for r in range(1, n + 1): nCr = nCr * (n + 1 - r) / r
res += nCr * nCr
code_infilling
python
python
MBPP/300/L6
[]
[]
MBPP_Infilling
[]
count_binary_seq
[]
Write a function to find the count of all binary sequences of length 2n such that sum of first n bits is same as sum of last n bits.
def count_binary_seq(n): """Write a function to find the count of all binary sequences of length 2n such that sum of first n bits is same as sum of last n bits. """ nCr = 1 res = 1 for r in range(1, n + 1): nCr = nCr * (n + 1 - r) / r res += nCr * nCr
return res
code_infilling
python
python
MBPP/301/L1
[]
[]
MBPP_Infilling
return 1 + (max(map(dict_depth, d.values())) if d else 0) return 0
[ [ "{'a':1, 'b': {'c': {'d': {}}}}", "4" ], [ "{'a':1, 'b': {'c':'python'}}", "2" ], [ "{1: 'Sun', 2: {3: {4:'Mon'}}}", "3" ] ]
dict_depth
[]
Write a function to find the depth of a dictionary.
def dict_depth(d): """Write a function to find the depth of a dictionary. """
if isinstance(d, dict):
code_infilling
python
python
MBPP/301/L2
[]
[]
MBPP_Infilling
return 0
[ [ "{'a':1, 'b': {'c': {'d': {}}}}", "4" ], [ "{'a':1, 'b': {'c':'python'}}", "2" ], [ "{1: 'Sun', 2: {3: {4:'Mon'}}}", "3" ] ]
dict_depth
[]
Write a function to find the depth of a dictionary.
def dict_depth(d): """Write a function to find the depth of a dictionary. """ if isinstance(d, dict):
return 1 + (max(map(dict_depth, d.values())) if d else 0)
code_infilling
python
python
MBPP/301/L3
[]
[]
MBPP_Infilling
[ [ "{'a':1, 'b': {'c': {'d': {}}}}", "4" ], [ "{'a':1, 'b': {'c':'python'}}", "2" ], [ "{1: 'Sun', 2: {3: {4:'Mon'}}}", "3" ] ]
dict_depth
[]
Write a function to find the depth of a dictionary.
def dict_depth(d): """Write a function to find the depth of a dictionary. """ if isinstance(d, dict): return 1 + (max(map(dict_depth, d.values())) if d else 0)
return 0
code_infilling
python
python
MBPP/304/L1
[]
[]
MBPP_Infilling
left = ranges[i][0] right = ranges[i][1] if left <= index and right >= index: if index == left: index = right else: index = index - 1 return arr[index]
[ [ "[1,2,3,4,5],[[0,2],[0,3]],2,1", "3" ], [ "[1,2,3,4],[[0,1],[0,2]],1,2", "3" ], [ "[1,2,3,4,5,6],[[0,1],[0,2]],1,1", "1" ] ]
find_Element
[]
Write a python function to find element at a given index after number of rotations.
def find_Element(arr, ranges, rotations, index): """Write a python function to find element at a given index after number of rotations. """
for i in range(rotations - 1, -1, -1):
code_infilling
python
python
MBPP/304/L2
[]
[]
MBPP_Infilling
right = ranges[i][1] if left <= index and right >= index: if index == left: index = right else: index = index - 1 return arr[index]
[ [ "[1,2,3,4,5],[[0,2],[0,3]],2,1", "3" ], [ "[1,2,3,4],[[0,1],[0,2]],1,2", "3" ], [ "[1,2,3,4,5,6],[[0,1],[0,2]],1,1", "1" ] ]
find_Element
[]
Write a python function to find element at a given index after number of rotations.
def find_Element(arr, ranges, rotations, index): """Write a python function to find element at a given index after number of rotations. """ for i in range(rotations - 1, -1, -1):
left = ranges[i][0]
code_infilling
python
python
MBPP/304/L3
[]
[]
MBPP_Infilling
if left <= index and right >= index: if index == left: index = right else: index = index - 1 return arr[index]
[ [ "[1,2,3,4,5],[[0,2],[0,3]],2,1", "3" ], [ "[1,2,3,4],[[0,1],[0,2]],1,2", "3" ], [ "[1,2,3,4,5,6],[[0,1],[0,2]],1,1", "1" ] ]
find_Element
[]
Write a python function to find element at a given index after number of rotations.
def find_Element(arr, ranges, rotations, index): """Write a python function to find element at a given index after number of rotations. """ for i in range(rotations - 1, -1, -1): left = ranges[i][0]
right = ranges[i][1]
code_infilling
python
python
MBPP/304/L4
[]
[]
MBPP_Infilling
if index == left: index = right else: index = index - 1 return arr[index]
[ [ "[1,2,3,4,5],[[0,2],[0,3]],2,1", "3" ], [ "[1,2,3,4],[[0,1],[0,2]],1,2", "3" ], [ "[1,2,3,4,5,6],[[0,1],[0,2]],1,1", "1" ] ]
find_Element
[]
Write a python function to find element at a given index after number of rotations.
def find_Element(arr, ranges, rotations, index): """Write a python function to find element at a given index after number of rotations. """ for i in range(rotations - 1, -1, -1): left = ranges[i][0] right = ranges[i][1]
if left <= index and right >= index:
code_infilling
python
python
MBPP/304/L5
[]
[]
MBPP_Infilling
index = right else: index = index - 1 return arr[index]
[ [ "[1,2,3,4,5],[[0,2],[0,3]],2,1", "3" ], [ "[1,2,3,4],[[0,1],[0,2]],1,2", "3" ], [ "[1,2,3,4,5,6],[[0,1],[0,2]],1,1", "1" ] ]
find_Element
[]
Write a python function to find element at a given index after number of rotations.
def find_Element(arr, ranges, rotations, index): """Write a python function to find element at a given index after number of rotations. """ for i in range(rotations - 1, -1, -1): left = ranges[i][0] right = ranges[i][1] if left <= index and right >= index:
if index == left:
code_infilling
python
python
MBPP/304/L6
[]
[]
MBPP_Infilling
else: index = index - 1 return arr[index]
[ [ "[1,2,3,4,5],[[0,2],[0,3]],2,1", "3" ], [ "[1,2,3,4],[[0,1],[0,2]],1,2", "3" ], [ "[1,2,3,4,5,6],[[0,1],[0,2]],1,1", "1" ] ]
find_Element
[]
Write a python function to find element at a given index after number of rotations.
def find_Element(arr, ranges, rotations, index): """Write a python function to find element at a given index after number of rotations. """ for i in range(rotations - 1, -1, -1): left = ranges[i][0] right = ranges[i][1] if left <= index and right >= index: if index == left:
index = right
code_infilling
python
python
MBPP/304/L7
[]
[]
MBPP_Infilling
index = index - 1 return arr[index]
[ [ "[1,2,3,4,5],[[0,2],[0,3]],2,1", "3" ], [ "[1,2,3,4],[[0,1],[0,2]],1,2", "3" ], [ "[1,2,3,4,5,6],[[0,1],[0,2]],1,1", "1" ] ]
find_Element
[]
Write a python function to find element at a given index after number of rotations.
def find_Element(arr, ranges, rotations, index): """Write a python function to find element at a given index after number of rotations. """ for i in range(rotations - 1, -1, -1): left = ranges[i][0] right = ranges[i][1] if left <= index and right >= index: if index == left: index = right
else:
code_infilling
python
python
MBPP/304/L8
[]
[]
MBPP_Infilling
return arr[index]
[ [ "[1,2,3,4,5],[[0,2],[0,3]],2,1", "3" ], [ "[1,2,3,4],[[0,1],[0,2]],1,2", "3" ], [ "[1,2,3,4,5,6],[[0,1],[0,2]],1,1", "1" ] ]
find_Element
[]
Write a python function to find element at a given index after number of rotations.
def find_Element(arr, ranges, rotations, index): """Write a python function to find element at a given index after number of rotations. """ for i in range(rotations - 1, -1, -1): left = ranges[i][0] right = ranges[i][1] if left <= index and right >= index: if index == left: index = right else:
index = index - 1
code_infilling
python
python
MBPP/304/L9
[]
[]
MBPP_Infilling
[ [ "[1,2,3,4,5],[[0,2],[0,3]],2,1", "3" ], [ "[1,2,3,4],[[0,1],[0,2]],1,2", "3" ], [ "[1,2,3,4,5,6],[[0,1],[0,2]],1,1", "1" ] ]
find_Element
[]
Write a python function to find element at a given index after number of rotations.
def find_Element(arr, ranges, rotations, index): """Write a python function to find element at a given index after number of rotations. """ for i in range(rotations - 1, -1, -1): left = ranges[i][0] right = ranges[i][1] if left <= index and right >= index: if index == left: index = right else: index = index - 1
return arr[index]
code_infilling
python
python
MBPP/305/L3
[]
[]
MBPP_Infilling
m = re.match('(P\\w+)\\W(P\\w+)', w) if m: return m.groups()
[ [ "[\"Python PHP\", \"Java JavaScript\", \"c c++\"]", "('Python', 'PHP')" ], [ "[\"Python Programming\",\"Java Programming\"]", "('Python','Programming')" ], [ "[\"Pqrst Pqr\",\"qrstuv\"]", "('Pqrst','Pqr')" ] ]
start_withp
[ "import re" ]
Write a function to return two words from a list of words starting with letter 'p'.
import re def start_withp(words): """Write a function to return two words from a list of words starting with letter 'p'. """
for w in words:
code_infilling
python
python
MBPP/305/L4
[]
[]
MBPP_Infilling
if m: return m.groups()
[ [ "[\"Python PHP\", \"Java JavaScript\", \"c c++\"]", "('Python', 'PHP')" ], [ "[\"Python Programming\",\"Java Programming\"]", "('Python','Programming')" ], [ "[\"Pqrst Pqr\",\"qrstuv\"]", "('Pqrst','Pqr')" ] ]
start_withp
[ "import re" ]
Write a function to return two words from a list of words starting with letter 'p'.
import re def start_withp(words): """Write a function to return two words from a list of words starting with letter 'p'. """ for w in words:
m = re.match('(P\\w+)\\W(P\\w+)', w)
code_infilling
python
python
MBPP/305/L5
[]
[]
MBPP_Infilling
return m.groups()
[ [ "[\"Python PHP\", \"Java JavaScript\", \"c c++\"]", "('Python', 'PHP')" ], [ "[\"Python Programming\",\"Java Programming\"]", "('Python','Programming')" ], [ "[\"Pqrst Pqr\",\"qrstuv\"]", "('Pqrst','Pqr')" ] ]
start_withp
[ "import re" ]
Write a function to return two words from a list of words starting with letter 'p'.
import re def start_withp(words): """Write a function to return two words from a list of words starting with letter 'p'. """ for w in words: m = re.match('(P\\w+)\\W(P\\w+)', w)
if m:
code_infilling
python
python
MBPP/305/L6
[]
[]
MBPP_Infilling
[ [ "[\"Python PHP\", \"Java JavaScript\", \"c c++\"]", "('Python', 'PHP')" ], [ "[\"Python Programming\",\"Java Programming\"]", "('Python','Programming')" ], [ "[\"Pqrst Pqr\",\"qrstuv\"]", "('Pqrst','Pqr')" ] ]
start_withp
[ "import re" ]
Write a function to return two words from a list of words starting with letter 'p'.
import re def start_withp(words): """Write a function to return two words from a list of words starting with letter 'p'. """ for w in words: m = re.match('(P\\w+)\\W(P\\w+)', w) if m:
return m.groups()
code_infilling
python
python
MBPP/306/L1
[]
[]
MBPP_Infilling
for i in range(n): if a[i] > a[0]: dp[0][i] = a[i] + a[0] else: dp[0][i] = a[i] for i in range(1, n): for j in range(n): if a[j] > a[i] and j > i: if dp[i - 1][i] + a[j] > dp[i - 1][j]: dp[i][j] = dp[i - 1][i] + a[j] else: dp[i][j] = dp[i - 1][j] else: dp[i][j] = dp[i - 1][j] return dp[index][k]
[ [ "[1, 101, 2, 3, 100, 4, 5 ], 7, 4, 6", "11" ], [ "[1, 101, 2, 3, 100, 4, 5 ], 7, 2, 5", "7" ], [ "[11, 15, 19, 21, 26, 28, 31], 7, 2, 4", "71" ] ]
max_sum_increasing_subseq
[]
Write a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i .
def max_sum_increasing_subseq(a, n, index, k): """Write a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i . """
dp = [[0 for i in range(n)] for i in range(n)]
code_infilling
python
python
MBPP/306/L2
[]
[]
MBPP_Infilling
if a[i] > a[0]: dp[0][i] = a[i] + a[0] else: dp[0][i] = a[i] for i in range(1, n): for j in range(n): if a[j] > a[i] and j > i: if dp[i - 1][i] + a[j] > dp[i - 1][j]: dp[i][j] = dp[i - 1][i] + a[j] else: dp[i][j] = dp[i - 1][j] else: dp[i][j] = dp[i - 1][j] return dp[index][k]
[ [ "[1, 101, 2, 3, 100, 4, 5 ], 7, 4, 6", "11" ], [ "[1, 101, 2, 3, 100, 4, 5 ], 7, 2, 5", "7" ], [ "[11, 15, 19, 21, 26, 28, 31], 7, 2, 4", "71" ] ]
max_sum_increasing_subseq
[]
Write a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i .
def max_sum_increasing_subseq(a, n, index, k): """Write a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i . """ dp = [[0 for i in range(n)] for i in range(n)]
for i in range(n):
code_infilling
python
python
MBPP/306/L3
[]
[]
MBPP_Infilling
dp[0][i] = a[i] + a[0] else: dp[0][i] = a[i] for i in range(1, n): for j in range(n): if a[j] > a[i] and j > i: if dp[i - 1][i] + a[j] > dp[i - 1][j]: dp[i][j] = dp[i - 1][i] + a[j] else: dp[i][j] = dp[i - 1][j] else: dp[i][j] = dp[i - 1][j] return dp[index][k]
[ [ "[1, 101, 2, 3, 100, 4, 5 ], 7, 4, 6", "11" ], [ "[1, 101, 2, 3, 100, 4, 5 ], 7, 2, 5", "7" ], [ "[11, 15, 19, 21, 26, 28, 31], 7, 2, 4", "71" ] ]
max_sum_increasing_subseq
[]
Write a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i .
def max_sum_increasing_subseq(a, n, index, k): """Write a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i . """ dp = [[0 for i in range(n)] for i in range(n)] for i in range(n):
if a[i] > a[0]:
code_infilling
python
python
MBPP/306/L4
[]
[]
MBPP_Infilling
else: dp[0][i] = a[i] for i in range(1, n): for j in range(n): if a[j] > a[i] and j > i: if dp[i - 1][i] + a[j] > dp[i - 1][j]: dp[i][j] = dp[i - 1][i] + a[j] else: dp[i][j] = dp[i - 1][j] else: dp[i][j] = dp[i - 1][j] return dp[index][k]
[ [ "[1, 101, 2, 3, 100, 4, 5 ], 7, 4, 6", "11" ], [ "[1, 101, 2, 3, 100, 4, 5 ], 7, 2, 5", "7" ], [ "[11, 15, 19, 21, 26, 28, 31], 7, 2, 4", "71" ] ]
max_sum_increasing_subseq
[]
Write a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i .
def max_sum_increasing_subseq(a, n, index, k): """Write a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i . """ dp = [[0 for i in range(n)] for i in range(n)] for i in range(n): if a[i] > a[0]:
dp[0][i] = a[i] + a[0]
code_infilling
python
python
MBPP/306/L5
[]
[]
MBPP_Infilling
dp[0][i] = a[i] for i in range(1, n): for j in range(n): if a[j] > a[i] and j > i: if dp[i - 1][i] + a[j] > dp[i - 1][j]: dp[i][j] = dp[i - 1][i] + a[j] else: dp[i][j] = dp[i - 1][j] else: dp[i][j] = dp[i - 1][j] return dp[index][k]
[ [ "[1, 101, 2, 3, 100, 4, 5 ], 7, 4, 6", "11" ], [ "[1, 101, 2, 3, 100, 4, 5 ], 7, 2, 5", "7" ], [ "[11, 15, 19, 21, 26, 28, 31], 7, 2, 4", "71" ] ]
max_sum_increasing_subseq
[]
Write a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i .
def max_sum_increasing_subseq(a, n, index, k): """Write a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i . """ dp = [[0 for i in range(n)] for i in range(n)] for i in range(n): if a[i] > a[0]: dp[0][i] = a[i] + a[0]
else:
code_infilling
python
python
MBPP/306/L6
[]
[]
MBPP_Infilling
for i in range(1, n): for j in range(n): if a[j] > a[i] and j > i: if dp[i - 1][i] + a[j] > dp[i - 1][j]: dp[i][j] = dp[i - 1][i] + a[j] else: dp[i][j] = dp[i - 1][j] else: dp[i][j] = dp[i - 1][j] return dp[index][k]
[ [ "[1, 101, 2, 3, 100, 4, 5 ], 7, 4, 6", "11" ], [ "[1, 101, 2, 3, 100, 4, 5 ], 7, 2, 5", "7" ], [ "[11, 15, 19, 21, 26, 28, 31], 7, 2, 4", "71" ] ]
max_sum_increasing_subseq
[]
Write a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i .
def max_sum_increasing_subseq(a, n, index, k): """Write a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i . """ dp = [[0 for i in range(n)] for i in range(n)] for i in range(n): if a[i] > a[0]: dp[0][i] = a[i] + a[0] else:
dp[0][i] = a[i]
code_infilling
python
python
MBPP/306/L7
[]
[]
MBPP_Infilling
for j in range(n): if a[j] > a[i] and j > i: if dp[i - 1][i] + a[j] > dp[i - 1][j]: dp[i][j] = dp[i - 1][i] + a[j] else: dp[i][j] = dp[i - 1][j] else: dp[i][j] = dp[i - 1][j] return dp[index][k]
[ [ "[1, 101, 2, 3, 100, 4, 5 ], 7, 4, 6", "11" ], [ "[1, 101, 2, 3, 100, 4, 5 ], 7, 2, 5", "7" ], [ "[11, 15, 19, 21, 26, 28, 31], 7, 2, 4", "71" ] ]
max_sum_increasing_subseq
[]
Write a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i .
def max_sum_increasing_subseq(a, n, index, k): """Write a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i . """ dp = [[0 for i in range(n)] for i in range(n)] for i in range(n): if a[i] > a[0]: dp[0][i] = a[i] + a[0] else: dp[0][i] = a[i]
for i in range(1, n):
code_infilling
python
python
MBPP/306/L8
[]
[]
MBPP_Infilling
if a[j] > a[i] and j > i: if dp[i - 1][i] + a[j] > dp[i - 1][j]: dp[i][j] = dp[i - 1][i] + a[j] else: dp[i][j] = dp[i - 1][j] else: dp[i][j] = dp[i - 1][j] return dp[index][k]
[ [ "[1, 101, 2, 3, 100, 4, 5 ], 7, 4, 6", "11" ], [ "[1, 101, 2, 3, 100, 4, 5 ], 7, 2, 5", "7" ], [ "[11, 15, 19, 21, 26, 28, 31], 7, 2, 4", "71" ] ]
max_sum_increasing_subseq
[]
Write a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i .
def max_sum_increasing_subseq(a, n, index, k): """Write a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i . """ dp = [[0 for i in range(n)] for i in range(n)] for i in range(n): if a[i] > a[0]: dp[0][i] = a[i] + a[0] else: dp[0][i] = a[i] for i in range(1, n):
for j in range(n):
code_infilling
python
python
MBPP/306/L9
[]
[]
MBPP_Infilling
if dp[i - 1][i] + a[j] > dp[i - 1][j]: dp[i][j] = dp[i - 1][i] + a[j] else: dp[i][j] = dp[i - 1][j] else: dp[i][j] = dp[i - 1][j] return dp[index][k]
[ [ "[1, 101, 2, 3, 100, 4, 5 ], 7, 4, 6", "11" ], [ "[1, 101, 2, 3, 100, 4, 5 ], 7, 2, 5", "7" ], [ "[11, 15, 19, 21, 26, 28, 31], 7, 2, 4", "71" ] ]
max_sum_increasing_subseq
[]
Write a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i .
def max_sum_increasing_subseq(a, n, index, k): """Write a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i . """ dp = [[0 for i in range(n)] for i in range(n)] for i in range(n): if a[i] > a[0]: dp[0][i] = a[i] + a[0] else: dp[0][i] = a[i] for i in range(1, n): for j in range(n):
if a[j] > a[i] and j > i:
code_infilling
python
python
MBPP/306/L10
[]
[]
MBPP_Infilling
dp[i][j] = dp[i - 1][i] + a[j] else: dp[i][j] = dp[i - 1][j] else: dp[i][j] = dp[i - 1][j] return dp[index][k]
[ [ "[1, 101, 2, 3, 100, 4, 5 ], 7, 4, 6", "11" ], [ "[1, 101, 2, 3, 100, 4, 5 ], 7, 2, 5", "7" ], [ "[11, 15, 19, 21, 26, 28, 31], 7, 2, 4", "71" ] ]
max_sum_increasing_subseq
[]
Write a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i .
def max_sum_increasing_subseq(a, n, index, k): """Write a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i . """ dp = [[0 for i in range(n)] for i in range(n)] for i in range(n): if a[i] > a[0]: dp[0][i] = a[i] + a[0] else: dp[0][i] = a[i] for i in range(1, n): for j in range(n): if a[j] > a[i] and j > i:
if dp[i - 1][i] + a[j] > dp[i - 1][j]:
code_infilling
python
python
MBPP/306/L11
[]
[]
MBPP_Infilling
else: dp[i][j] = dp[i - 1][j] else: dp[i][j] = dp[i - 1][j] return dp[index][k]
[ [ "[1, 101, 2, 3, 100, 4, 5 ], 7, 4, 6", "11" ], [ "[1, 101, 2, 3, 100, 4, 5 ], 7, 2, 5", "7" ], [ "[11, 15, 19, 21, 26, 28, 31], 7, 2, 4", "71" ] ]
max_sum_increasing_subseq
[]
Write a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i .
def max_sum_increasing_subseq(a, n, index, k): """Write a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i . """ dp = [[0 for i in range(n)] for i in range(n)] for i in range(n): if a[i] > a[0]: dp[0][i] = a[i] + a[0] else: dp[0][i] = a[i] for i in range(1, n): for j in range(n): if a[j] > a[i] and j > i: if dp[i - 1][i] + a[j] > dp[i - 1][j]:
dp[i][j] = dp[i - 1][i] + a[j]
code_infilling
python
python
MBPP/306/L12
[]
[]
MBPP_Infilling
dp[i][j] = dp[i - 1][j] else: dp[i][j] = dp[i - 1][j] return dp[index][k]
[ [ "[1, 101, 2, 3, 100, 4, 5 ], 7, 4, 6", "11" ], [ "[1, 101, 2, 3, 100, 4, 5 ], 7, 2, 5", "7" ], [ "[11, 15, 19, 21, 26, 28, 31], 7, 2, 4", "71" ] ]
max_sum_increasing_subseq
[]
Write a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i .
def max_sum_increasing_subseq(a, n, index, k): """Write a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i . """ dp = [[0 for i in range(n)] for i in range(n)] for i in range(n): if a[i] > a[0]: dp[0][i] = a[i] + a[0] else: dp[0][i] = a[i] for i in range(1, n): for j in range(n): if a[j] > a[i] and j > i: if dp[i - 1][i] + a[j] > dp[i - 1][j]: dp[i][j] = dp[i - 1][i] + a[j]
else:
code_infilling
python
python
MBPP/306/L13
[]
[]
MBPP_Infilling
else: dp[i][j] = dp[i - 1][j] return dp[index][k]
[ [ "[1, 101, 2, 3, 100, 4, 5 ], 7, 4, 6", "11" ], [ "[1, 101, 2, 3, 100, 4, 5 ], 7, 2, 5", "7" ], [ "[11, 15, 19, 21, 26, 28, 31], 7, 2, 4", "71" ] ]
max_sum_increasing_subseq
[]
Write a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i .
def max_sum_increasing_subseq(a, n, index, k): """Write a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i . """ dp = [[0 for i in range(n)] for i in range(n)] for i in range(n): if a[i] > a[0]: dp[0][i] = a[i] + a[0] else: dp[0][i] = a[i] for i in range(1, n): for j in range(n): if a[j] > a[i] and j > i: if dp[i - 1][i] + a[j] > dp[i - 1][j]: dp[i][j] = dp[i - 1][i] + a[j] else:
dp[i][j] = dp[i - 1][j]
code_infilling
python
python
MBPP/306/L14
[]
[]
MBPP_Infilling
dp[i][j] = dp[i - 1][j] return dp[index][k]
[ [ "[1, 101, 2, 3, 100, 4, 5 ], 7, 4, 6", "11" ], [ "[1, 101, 2, 3, 100, 4, 5 ], 7, 2, 5", "7" ], [ "[11, 15, 19, 21, 26, 28, 31], 7, 2, 4", "71" ] ]
max_sum_increasing_subseq
[]
Write a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i .
def max_sum_increasing_subseq(a, n, index, k): """Write a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i . """ dp = [[0 for i in range(n)] for i in range(n)] for i in range(n): if a[i] > a[0]: dp[0][i] = a[i] + a[0] else: dp[0][i] = a[i] for i in range(1, n): for j in range(n): if a[j] > a[i] and j > i: if dp[i - 1][i] + a[j] > dp[i - 1][j]: dp[i][j] = dp[i - 1][i] + a[j] else: dp[i][j] = dp[i - 1][j]
else:
code_infilling
python
python
MBPP/306/L15
[]
[]
MBPP_Infilling
return dp[index][k]
[ [ "[1, 101, 2, 3, 100, 4, 5 ], 7, 4, 6", "11" ], [ "[1, 101, 2, 3, 100, 4, 5 ], 7, 2, 5", "7" ], [ "[11, 15, 19, 21, 26, 28, 31], 7, 2, 4", "71" ] ]
max_sum_increasing_subseq
[]
Write a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i .
def max_sum_increasing_subseq(a, n, index, k): """Write a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i . """ dp = [[0 for i in range(n)] for i in range(n)] for i in range(n): if a[i] > a[0]: dp[0][i] = a[i] + a[0] else: dp[0][i] = a[i] for i in range(1, n): for j in range(n): if a[j] > a[i] and j > i: if dp[i - 1][i] + a[j] > dp[i - 1][j]: dp[i][j] = dp[i - 1][i] + a[j] else: dp[i][j] = dp[i - 1][j] else:
dp[i][j] = dp[i - 1][j]
code_infilling
python
python
MBPP/306/L16
[]
[]
MBPP_Infilling
[ [ "[1, 101, 2, 3, 100, 4, 5 ], 7, 4, 6", "11" ], [ "[1, 101, 2, 3, 100, 4, 5 ], 7, 2, 5", "7" ], [ "[11, 15, 19, 21, 26, 28, 31], 7, 2, 4", "71" ] ]
max_sum_increasing_subseq
[]
Write a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i .
def max_sum_increasing_subseq(a, n, index, k): """Write a function to find the maximum sum of increasing subsequence from prefix until ith index and also including a given kth element which is after i, i.e., k > i . """ dp = [[0 for i in range(n)] for i in range(n)] for i in range(n): if a[i] > a[0]: dp[0][i] = a[i] + a[0] else: dp[0][i] = a[i] for i in range(1, n): for j in range(n): if a[j] > a[i] and j > i: if dp[i - 1][i] + a[j] > dp[i - 1][j]: dp[i][j] = dp[i - 1][i] + a[j] else: dp[i][j] = dp[i - 1][j] else: dp[i][j] = dp[i - 1][j]
return dp[index][k]