prompt
stringlengths
108
530
output
stringclasses
3 values
code
stringlengths
47
388
def first_repeated_char(str1): #1 for index,c in enumerate(str1): #2 if str1[:index+1].count(c) > 1: #3 return c #4 <data_flow_edges> index--2 and index--3 are related by
last read
def first_repeated_char(str1): for index,c in enumerate(str1): if str1[:index+1].count(c) > 1: return c
def get_ludic(n): #1 ludics = [] #2 for i in range(1, n + 1): #3 ludics.append(i) #4 index = 1 #5 while(index != len(ludics)): #6 first_ludic = ludics[index] #7 remove_index = index + first_ludic #8 while(remove_index < len(ludics)): #9 ludics.remove(ludics[remove_index]) #10 remove_index = remove_index + first_ludic - 1 #11 index += 1 #12 return ludics #13 <data_flow_edges> first_ludic--7 and ludics--7 are related by
computed from
def get_ludic(n): ludics = [] for i in range(1, n + 1): ludics.append(i) index = 1 while(index != len(ludics)): first_ludic = ludics[index] remove_index = index + first_ludic while(remove_index < len(ludics)): ludics.remove(ludics[remove_index]) remove_index = remove_index + first_ludic - 1 index += 1 return ludics
def reverse_words(s): #1 return ' '.join(reversed(s.split())) #2 <data_flow_edges> s--2 and s--1 are related by
last wrote
def reverse_words(s): return ' '.join(reversed(s.split()))
def prime_num(num): #1 if num >=1: #2 for i in range(2, num//2): #3 if (num % i) == 0: #4 return False #5 else: #6 return True #7 else: #8 return False #9 <data_flow_edges> num--3 and num--1 are related by
last wrote
def prime_num(num): if num >=1: for i in range(2, num//2): if (num % i) == 0: return False else: return True else: return False
import math #1 def radian_degree(degree): #2 radian = degree*(math.pi/180) #3 return radian #4 <data_flow_edges> degree--3 and degree--2 are related by
last wrote
import math def radian_degree(degree): radian = degree*(math.pi/180) return radian
import re #1 #2 def find_literals(text, pattern): #3 match = re.search(pattern, text) #4 s = match.start() #5 e = match.end() #6 return (match.re.pattern, s, e) #7 <data_flow_edges> match--6 and match--5 are related by
last read
import re def find_literals(text, pattern): match = re.search(pattern, text) s = match.start() e = match.end() return (match.re.pattern, s, e)
def remove_kth_element(list1, L): #1 return list1[:L-1] + list1[L:] #2 <data_flow_edges> L--2 and L--2 are related by
last read
def remove_kth_element(list1, L): return list1[:L-1] + list1[L:]
def max_of_nth(test_list, N): #1 res = max([sub[N] for sub in test_list]) #2 return (res) #3 <data_flow_edges> sub--2 and sub--2 are related by
last read
def max_of_nth(test_list, N): res = max([sub[N] for sub in test_list]) return (res)
def merge(lst): #1 return [list(ele) for ele in list(zip(*lst))] #2 <data_flow_edges> ele--2 and ele--2 are related by
last read
def merge(lst): return [list(ele) for ele in list(zip(*lst))]
def cummulative_sum(test_list): #1 res = sum(map(sum, test_list)) #2 return (res) #3 <data_flow_edges> res--2 and test_list--2 are related by
computed from
def cummulative_sum(test_list): res = sum(map(sum, test_list)) return (res)
def average_tuple(nums): #1 result = [sum(x) / len(x) for x in zip(*nums)] #2 return result #3 <data_flow_edges> result--2 and nums--2 are related by
computed from
def average_tuple(nums): result = [sum(x) / len(x) for x in zip(*nums)] return result
def tuple_modulo(test_tup1, test_tup2): #1 res = tuple(ele1 % ele2 for ele1, ele2 in zip(test_tup1, test_tup2)) #2 return (res) #3 <data_flow_edges> res--2 and ele2--2 are related by
computed from
def tuple_modulo(test_tup1, test_tup2): res = tuple(ele1 % ele2 for ele1, ele2 in zip(test_tup1, test_tup2)) return (res)
def div_list(nums1,nums2): #1 result = map(lambda x, y: x / y, nums1, nums2) #2 return list(result) #3 <data_flow_edges> x--2 and x--2 are related by
last wrote
def div_list(nums1,nums2): result = map(lambda x, y: x / y, nums1, nums2) return list(result)
def move_num(test_str): #1 res = '' #2 dig = '' #3 for ele in test_str: #4 if ele.isdigit(): #5 dig += ele #6 else: #7 res += ele #8 res += dig #9 return (res) #10 <data_flow_edges> ele--4 and ele--6 are related by
last read
def move_num(test_str): res = '' dig = '' for ele in test_str: if ele.isdigit(): dig += ele else: res += ele res += dig return (res)
def get_median(arr1, arr2, n): #1 i = 0 #2 j = 0 #3 m1 = -1 #4 m2 = -1 #5 count = 0 #6 while count < n + 1: #7 count += 1 #8 if i == n: #9 m1 = m2 #10 m2 = arr2[0] #11 break #12 elif j == n: #13 m1 = m2 #14 m2 = arr1[0] #15 break #16 if arr1[i] <= arr2[j]: #17 m1 = m2 #18 m2 = arr1[i] #19 i += 1 #20 else: #21 m1 = m2 #22 m2 = arr2[j] #23 j += 1 #24 return (m1 + m2)/2 #25 <data_flow_edges> m2--25 and m2--10 are related by
last read
def get_median(arr1, arr2, n): i = 0 j = 0 m1 = -1 m2 = -1 count = 0 while count < n + 1: count += 1 if i == n: m1 = m2 m2 = arr2[0] break elif j == n: m1 = m2 m2 = arr1[0] break if arr1[i] <= arr2[j]: m1 = m2 m2 = arr1[i] i += 1 else: m1 = m2 m2 = arr2[j] j += 1 return (m1 + m2)/2
def nth_nums(nums,n): #1 nth_nums = list(map(lambda x: x ** n, nums)) #2 return nth_nums #3 <data_flow_edges> nth_nums--2 and x--2 are related by
computed from
def nth_nums(nums,n): nth_nums = list(map(lambda x: x ** n, nums)) return nth_nums
def is_upper(string): #1 return (string.upper()) #2 <data_flow_edges> string--2 and string--1 are related by
last wrote
def is_upper(string): return (string.upper())
def triangle_area(r) : #1 if r < 0 : #2 return None #3 return r * r #4 <data_flow_edges> r--2 and r--1 are related by
last wrote
def triangle_area(r) : if r < 0 : return None return r * r
def replace_spaces(string): #1 return string.replace(" ", "%20") #2 <data_flow_edges> string--2 and string--1 are related by
last wrote
def replace_spaces(string): return string.replace(" ", "%20")
def Split(list): #1 return [num for num in list if num % 2 == 0] #2 <data_flow_edges> num--2 and num--2 are related by
last read
def Split(list): return [num for num in list if num % 2 == 0]
def adjac(ele, sub = []): #1 if not ele: #2 yield sub #3 else: #4 yield from [idx for j in range(ele[0] - 1, ele[0] + 2) #5 for idx in adjac(ele[1:], sub + [j])] #6 def get_coordinates(test_tup): #7 return list(adjac(test_tup)) #8 <data_flow_edges> sub--6 and sub--1 are related by
last wrote
def adjac(ele, sub = []): if not ele: yield sub else: yield from [idx for j in range(ele[0] - 1, ele[0] + 2) for idx in adjac(ele[1:], sub + [j])] def get_coordinates(test_tup): return list(adjac(test_tup))
def replace_spaces(text): #1 return "".join(" " if c == "_" else ("_" if c == " " else c) for c in text) #2 <data_flow_edges> c--2 and c--2 are related by
last read
def replace_spaces(text): return "".join(" " if c == "_" else ("_" if c == " " else c) for c in text)
def move_zero(num_list): #1 a = [0 for i in range(num_list.count(0))] #2 x = [i for i in num_list if i != 0] #3 return x + a #4 <data_flow_edges> num_list--2 and num_list--1 are related by
last wrote
def move_zero(num_list): a = [0 for i in range(num_list.count(0))] x = [i for i in num_list if i != 0] return x + a
def pair_xor_Sum(arr,n) : #1 ans = 0 #2 for i in range(0,n) : #3 for j in range(i + 1,n) : #4 ans = ans + (arr[i] ^ arr[j]) #5 return ans #6 <data_flow_edges> ans--5 and arr--5 are related by
computed from
def pair_xor_Sum(arr,n) : ans = 0 for i in range(0,n) : for j in range(i + 1,n) : ans = ans + (arr[i] ^ arr[j]) return ans
import heapq as hq #1 def heap_sort(iterable): #2 h = [] #3 for value in iterable: #4 hq.heappush(h, value) #5 return [hq.heappop(h) for i in range(len(h))] #6 <data_flow_edges> h--6 and h--3 are related by
last wrote
import heapq as hq def heap_sort(iterable): h = [] for value in iterable: hq.heappush(h, value) return [hq.heappop(h) for i in range(len(h))]
def noprofit_noloss(actual_cost,sale_amount): #1 if(sale_amount == actual_cost): #2 return True #3 else: #4 return False #5 <data_flow_edges> actual_cost--2 and actual_cost--1 are related by
last wrote
def noprofit_noloss(actual_cost,sale_amount): if(sale_amount == actual_cost): return True else: return False
import math #1 def wind_chill(v,t): #2 windchill = 13.12 + 0.6215*t - 11.37*math.pow(v, 0.16) + 0.3965*t*math.pow(v, 0.16) #3 return int(round(windchill, 0)) #4 <data_flow_edges> windchill--3 and v--3 are related by
computed from
import math def wind_chill(v,t): windchill = 13.12 + 0.6215*t - 11.37*math.pow(v, 0.16) + 0.3965*t*math.pow(v, 0.16) return int(round(windchill, 0))
import re #1 def remove_parenthesis(items): #2 for item in items: #3 return (re.sub(r" ?\([^)]+\)", "", item)) #4 <data_flow_edges> item--4 and item--3 are related by
last wrote
import re def remove_parenthesis(items): for item in items: return (re.sub(r" ?\([^)]+\)", "", item))
def is_nonagonal(n): #1 return int(n * (7 * n - 5) / 2) #2 <data_flow_edges> n--2 and n--2 are related by
last read
def is_nonagonal(n): return int(n * (7 * n - 5) / 2)
import re #1 def text_match_wordz_middle(text): #2 return bool(re.search(r'\Bz\B', text)) #3 <data_flow_edges> text--3 and text--2 are related by
last wrote
import re def text_match_wordz_middle(text): return bool(re.search(r'\Bz\B', text))
def reverse_Array_Upto_K(input, k): #1 return (input[k-1::-1] + input[k:]) #2 <data_flow_edges> k--2 and k--1 are related by
last wrote
def reverse_Array_Upto_K(input, k): return (input[k-1::-1] + input[k:])
def add_dict_to_tuple(test_tup, test_dict): #1 test_tup = list(test_tup) #2 test_tup.append(test_dict) #3 test_tup = tuple(test_tup) #4 return (test_tup) #5 <data_flow_edges> test_tup--4 and test_tup--4 are related by
last read
def add_dict_to_tuple(test_tup, test_dict): test_tup = list(test_tup) test_tup.append(test_dict) test_tup = tuple(test_tup) return (test_tup)
from operator import eq #1 def count_same_pair(nums1, nums2): #2 result = sum(map(eq, nums1, nums2)) #3 return result #4 <data_flow_edges> result--3 and nums2--3 are related by
computed from
from operator import eq def count_same_pair(nums1, nums2): result = sum(map(eq, nums1, nums2)) return result
def power_base_sum(base, power): #1 return sum([int(i) for i in str(pow(base, power))]) #2 <data_flow_edges> i--2 and i--2 are related by
last read
def power_base_sum(base, power): return sum([int(i) for i in str(pow(base, power))])
import re #1 def extract_quotation(text1): #2 return (re.findall(r'"(.*?)"', text1)) #3 <data_flow_edges> text1--3 and text1--2 are related by
last wrote
import re def extract_quotation(text1): return (re.findall(r'"(.*?)"', text1))
def multiply_elements(test_tup): #1 res = tuple(i * j for i, j in zip(test_tup, test_tup[1:])) #2 return (res) #3 <data_flow_edges> res--2 and test_tup--2 are related by
computed from
def multiply_elements(test_tup): res = tuple(i * j for i, j in zip(test_tup, test_tup[1:])) return (res)
def sum_list(lst1,lst2): #1 res_list = [lst1[i] + lst2[i] for i in range(len(lst1))] #2 return res_list #3 <data_flow_edges> res_list--2 and lst2--2 are related by
computed from
def sum_list(lst1,lst2): res_list = [lst1[i] + lst2[i] for i in range(len(lst1))] return res_list
from itertools import groupby #1 def consecutive_duplicates(nums): #2 return [key for key, group in groupby(nums)] #3 <data_flow_edges> key--3 and key--3 are related by
last read
from itertools import groupby def consecutive_duplicates(nums): return [key for key, group in groupby(nums)]
import math #1 def lateralsurface_cone(r,h): #2 l = math.sqrt(r * r + h * h) #3 LSA = math.pi * r * l #4 return LSA #5 <data_flow_edges> h--3 and h--3 are related by
last read
import math def lateralsurface_cone(r,h): l = math.sqrt(r * r + h * h) LSA = math.pi * r * l return LSA
import re #1 def replace_specialchar(text): #2 return (re.sub("[ ,.]", ":", text)) #3 #4 <data_flow_edges> text--3 and text--2 are related by
last wrote
import re def replace_specialchar(text): return (re.sub("[ ,.]", ":", text))
def sum_Of_Subarray_Prod(arr): #1 ans = 0 #2 res = 0 #3 i = len(arr) - 1 #4 while (i >= 0): #5 incr = arr[i]*(1 + res) #6 ans += incr #7 res = incr #8 i -= 1 #9 return (ans) #10 <data_flow_edges> i--9 and i--4 are related by
last wrote
def sum_Of_Subarray_Prod(arr): ans = 0 res = 0 i = len(arr) - 1 while (i >= 0): incr = arr[i]*(1 + res) ans += incr res = incr i -= 1 return (ans)
import bisect #1 def left_insertion(a, x): #2 i = bisect.bisect_left(a, x) #3 return i #4 <data_flow_edges> i--4 and i--3 are related by
last wrote
import bisect def left_insertion(a, x): i = bisect.bisect_left(a, x) return i
import re #1 regex = '^[aeiouAEIOU][A-Za-z0-9_]*' #2 def check_str(string): #3 return re.search(regex, string) #4 <data_flow_edges> string--4 and string--3 are related by
last wrote
import re regex = '^[aeiouAEIOU][A-Za-z0-9_]*' def check_str(string): return re.search(regex, string)
import math #1 def find_Index(n): #2 x = math.sqrt(2 * math.pow(10,(n - 1))) #3 return round(x) #4 <data_flow_edges> x--3 and math--3 are related by
computed from
import math def find_Index(n): x = math.sqrt(2 * math.pow(10,(n - 1))) return round(x)
def tuple_to_dict(test_tup): #1 res = dict(test_tup[idx : idx + 2] for idx in range(0, len(test_tup), 2)) #2 return (res) #3 <data_flow_edges> res--3 and res--2 are related by
last wrote
def tuple_to_dict(test_tup): res = dict(test_tup[idx : idx + 2] for idx in range(0, len(test_tup), 2)) return (res)
def all_Characters_Same(s) : #1 n = len(s) #2 for i in range(1,n) : #3 if s[i] != s[0] : #4 return False #5 return True #6 <data_flow_edges> i--4 and i--3 are related by
last wrote
def all_Characters_Same(s) : n = len(s) for i in range(1,n) : if s[i] != s[0] : return False return True
import math #1 def area_tetrahedron(side): #2 area = math.sqrt(3)*(side*side) #3 return area #4 <data_flow_edges> area--3 and side--3 are related by
computed from
import math def area_tetrahedron(side): area = math.sqrt(3)*(side*side) return area
def rotate_right(list, m): #1 result = list[-m:] + list[:-m] #2 return result #3 <data_flow_edges> m--2 and m--1 are related by
last wrote
def rotate_right(list, m): result = list[-m:] + list[:-m] return result
def check_none(test_tup): #1 res = any(map(lambda ele: ele is None, test_tup)) #2 return res #3 <data_flow_edges> res--3 and res--2 are related by
last wrote
def check_none(test_tup): res = any(map(lambda ele: ele is None, test_tup)) return res
import math #1 def sector_area(r,a): #2 if a > 360: #3 return None #4 return (math.pi*r**2) * (a/360) #5 <data_flow_edges> a--5 and a--3 are related by
last read
import math def sector_area(r,a): if a > 360: return None return (math.pi*r**2) * (a/360)
import re #1 def capital_words_spaces(str1): #2 return re.sub(r"(\w)([A-Z])", r"\1 \2", str1) #3 <data_flow_edges> str1--3 and str1--2 are related by
last wrote
import re def capital_words_spaces(str1): return re.sub(r"(\w)([A-Z])", r"\1 \2", str1)
def sort_numeric_strings(nums_str): #1 result = [int(x) for x in nums_str] #2 result.sort() #3 return result #4 <data_flow_edges> result--2 and nums_str--2 are related by
computed from
def sort_numeric_strings(nums_str): result = [int(x) for x in nums_str] result.sort() return result
def add_tuple(test_list, test_tup): #1 test_list += test_tup #2 return test_list #3 <data_flow_edges> test_list--2 and test_list--1 are related by
last wrote
def add_tuple(test_list, test_tup): test_list += test_tup return test_list
def min_k(test_list, K): #1 res = sorted(test_list, key = lambda x: x[1])[:K] #2 return (res) #3 <data_flow_edges> test_list--2 and test_list--1 are related by
last wrote
def min_k(test_list, K): res = sorted(test_list, key = lambda x: x[1])[:K] return (res)
def extract_index_list(l1, l2, l3): #1 result = [] #2 for m, n, o in zip(l1, l2, l3): #3 if (m == n == o): #4 result.append(m) #5 return result #6 <data_flow_edges> m--4 and m--5 are related by
last read
def extract_index_list(l1, l2, l3): result = [] for m, n, o in zip(l1, l2, l3): if (m == n == o): result.append(m) return result
def second_smallest(numbers): #1 unique_numbers = list(set(numbers)) #2 unique_numbers.sort() #3 if len(unique_numbers) < 2: #4 return None #5 else: #6 return unique_numbers[1] #7 <data_flow_edges> numbers--2 and numbers--1 are related by
last wrote
def second_smallest(numbers): unique_numbers = list(set(numbers)) unique_numbers.sort() if len(unique_numbers) < 2: return None else: return unique_numbers[1]
import re #1 def text_match_zero_one(text): #2 patterns = 'ab+?' #3 if re.search(patterns, text): #4 return True #5 else: #6 return False #7 <data_flow_edges> text--4 and text--2 are related by
last wrote
import re def text_match_zero_one(text): patterns = 'ab+?' if re.search(patterns, text): return True else: return False
def count_reverse_pairs(test_list): #1 res = sum([1 for idx in range(0, len(test_list)) for idxn in range(idx, len( #2 test_list)) if test_list[idxn] == str(''.join(list(reversed(test_list[idx]))))]) #3 return res #4 <data_flow_edges> test_list--3 and test_list--3 are related by
last read
def count_reverse_pairs(test_list): res = sum([1 for idx in range(0, len(test_list)) for idxn in range(idx, len( test_list)) if test_list[idxn] == str(''.join(list(reversed(test_list[idx]))))]) return res
def is_decimal(num): #1 import re #2 dnumre = re.compile(r"""^[0-9]+(\.[0-9]{1,2})?$""") #3 result = dnumre.search(num) #4 return bool(result) #5 <data_flow_edges> num--4 and num--1 are related by
last wrote
def is_decimal(num): import re dnumre = re.compile(r"""^[0-9]+(\.[0-9]{1,2})?$""") result = dnumre.search(num) return bool(result)
def unique_Element(arr): #1 s = set(arr) #2 return len(s) == 1 #3 <data_flow_edges> arr--2 and arr--1 are related by
last wrote
def unique_Element(arr): s = set(arr) return len(s) == 1
def find_min_diff(arr,n): #1 arr = sorted(arr) #2 diff = 10**20 #3 for i in range(n-1): #4 if arr[i+1] - arr[i] < diff: #5 diff = arr[i+1] - arr[i] #6 return diff #7 <data_flow_edges> diff--6 and diff--5 are related by
last read
def find_min_diff(arr,n): arr = sorted(arr) diff = 10**20 for i in range(n-1): if arr[i+1] - arr[i] < diff: diff = arr[i+1] - arr[i] return diff
import math #1 def is_polite(n): #2 n = n + 1 #3 return (int)(n+(math.log((n + math.log(n, 2)), 2))) #4 <data_flow_edges> n--3 and n--2 are related by
last wrote
import math def is_polite(n): n = n + 1 return (int)(n+(math.log((n + math.log(n, 2)), 2)))
def get_pairs_count(arr, sum): #1 count = 0 #2 for i in range(len(arr)): #3 for j in range(i + 1,len(arr)): #4 if arr[i] + arr[j] == sum: #5 count += 1 #6 return count #7 <data_flow_edges> arr--4 and arr--3 are related by
last read
def get_pairs_count(arr, sum): count = 0 for i in range(len(arr)): for j in range(i + 1,len(arr)): if arr[i] + arr[j] == sum: count += 1 return count
def Diff(li1,li2): #1 return list(set(li1)-set(li2)) + list(set(li2)-set(li1)) #2 #3 <data_flow_edges> li1--2 and li1--1 are related by
last wrote
def Diff(li1,li2): return list(set(li1)-set(li2)) + list(set(li2)-set(li1))
def odd_num_sum(n) : #1 j = 0 #2 sm = 0 #3 for i in range(1,n + 1) : #4 j = (2*i-1) #5 sm = sm + (j*j*j*j) #6 return sm #7 <data_flow_edges> i--5 and i--4 are related by
last wrote
def odd_num_sum(n) : j = 0 sm = 0 for i in range(1,n + 1) : j = (2*i-1) sm = sm + (j*j*j*j) return sm
def remove_length(test_str, K): #1 temp = test_str.split() #2 res = [ele for ele in temp if len(ele) != K] #3 res = ' '.join(res) #4 return (res) #5 <data_flow_edges> res--4 and res--3 are related by
last wrote
def remove_length(test_str, K): temp = test_str.split() res = [ele for ele in temp if len(ele) != K] res = ' '.join(res) return (res)
import re #1 def occurance_substring(text,pattern): #2 for match in re.finditer(pattern, text): #3 s = match.start() #4 e = match.end() #5 return (text[s:e], s, e) #6 <data_flow_edges> s--6 and s--4 are related by
last wrote
import re def occurance_substring(text,pattern): for match in re.finditer(pattern, text): s = match.start() e = match.end() return (text[s:e], s, e)
def odd_position(nums): #1 return all(nums[i]%2==i%2 for i in range(len(nums))) #2 <data_flow_edges> nums--2 and nums--1 are related by
last wrote
def odd_position(nums): return all(nums[i]%2==i%2 for i in range(len(nums)))
def find_sum(arr): #1 arr.sort() #2 sum = arr[0] #3 for i in range(len(arr)-1): #4 if (arr[i] != arr[i+1]): #5 sum = sum + arr[i+1] #6 return sum #7 <data_flow_edges> arr--4 and arr--3 are related by
last read
def find_sum(arr): arr.sort() sum = arr[0] for i in range(len(arr)-1): if (arr[i] != arr[i+1]): sum = sum + arr[i+1] return sum
from itertools import groupby #1 def pack_consecutive_duplicates(list1): #2 return [list(group) for key, group in groupby(list1)] #3 <data_flow_edges> list1--3 and list1--2 are related by
last wrote
from itertools import groupby def pack_consecutive_duplicates(list1): return [list(group) for key, group in groupby(list1)]
from itertools import combinations #1 def find_combinations(test_list): #2 res = [(b1 + a1, b2 + a2) for (a1, a2), (b1, b2) in combinations(test_list, 2)] #3 return (res) #4 <data_flow_edges> res--3 and a2--3 are related by
computed from
from itertools import combinations def find_combinations(test_list): res = [(b1 + a1, b2 + a2) for (a1, a2), (b1, b2) in combinations(test_list, 2)] return (res)
import math #1 def count_divisors(n) : #2 count = 0 #3 for i in range(1, (int)(math.sqrt(n)) + 2) : #4 if (n % i == 0) : #5 if( n // i == i) : #6 count = count + 1 #7 else : #8 count = count + 2 #9 return count % 2 == 0 #10 <data_flow_edges> count--7 and count--7 are related by
last read
import math def count_divisors(n) : count = 0 for i in range(1, (int)(math.sqrt(n)) + 2) : if (n % i == 0) : if( n // i == i) : count = count + 1 else : count = count + 2 return count % 2 == 0
def odd_length_sum(arr): #1 Sum = 0 #2 l = len(arr) #3 for i in range(l): #4 Sum += ((((i + 1) *(l - i) + 1) // 2) * arr[i]) #5 return Sum #6 <data_flow_edges> arr--5 and arr--1 are related by
last wrote
def odd_length_sum(arr): Sum = 0 l = len(arr) for i in range(l): Sum += ((((i + 1) *(l - i) + 1) // 2) * arr[i]) return Sum
def mul_even_odd(list1): #1 first_even = next((el for el in list1 if el%2==0),-1) #2 first_odd = next((el for el in list1 if el%2!=0),-1) #3 return (first_even*first_odd) #4 <data_flow_edges> first_odd--3 and el--3 are related by
computed from
def mul_even_odd(list1): first_even = next((el for el in list1 if el%2==0),-1) first_odd = next((el for el in list1 if el%2!=0),-1) return (first_even*first_odd)
def tuple_str_int(test_str): #1 res = tuple(int(num) for num in test_str.replace('(', '').replace(')', '').replace('...', '').split(', ')) #2 return (res) #3 <data_flow_edges> res--2 and num--2 are related by
computed from
def tuple_str_int(test_str): res = tuple(int(num) for num in test_str.replace('(', '').replace(')', '').replace('...', '').split(', ')) return (res)
import bisect #1 def right_insertion(a, x): #2 return bisect.bisect_right(a, x) #3 <data_flow_edges> a--3 and a--2 are related by
last wrote
import bisect def right_insertion(a, x): return bisect.bisect_right(a, x)
import re #1 def text_match_three(text): #2 patterns = 'ab{3}?' #3 return re.search(patterns, text) #4 <data_flow_edges> patterns--4 and patterns--3 are related by
last wrote
import re def text_match_three(text): patterns = 'ab{3}?' return re.search(patterns, text)
def new_tuple(test_list, test_str): #1 return tuple(test_list + [test_str]) #2 <data_flow_edges> test_str--2 and test_str--1 are related by
last wrote
def new_tuple(test_list, test_str): return tuple(test_list + [test_str])
def even_position(nums): #1 return all(nums[i]%2==i%2 for i in range(len(nums))) #2 <data_flow_edges> i--2 and i--2 are related by
last read
def even_position(nums): return all(nums[i]%2==i%2 for i in range(len(nums)))
def remove_nested(test_tup): #1 res = tuple() #2 for count, ele in enumerate(test_tup): #3 if not isinstance(ele, tuple): #4 res = res + (ele, ) #5 return (res) #6 <data_flow_edges> res--6 and res--5 are related by
last wrote
def remove_nested(test_tup): res = tuple() for count, ele in enumerate(test_tup): if not isinstance(ele, tuple): res = res + (ele, ) return (res)
def count_list(input_list): #1 return len(input_list) #2 <data_flow_edges> input_list--2 and input_list--1 are related by
last wrote
def count_list(input_list): return len(input_list)
def last(arr,x): #1 n = len(arr) #2 low = 0 #3 high = n - 1 #4 res = -1 #5 while (low <= high): #6 mid = (low + high) // 2 #7 if arr[mid] > x: #8 high = mid - 1 #9 elif arr[mid] < x: #10 low = mid + 1 #11 else: #12 res = mid #13 low = mid + 1 #14 return res #15 <data_flow_edges> mid--9 and mid--7 are related by
last wrote
def last(arr,x): n = len(arr) low = 0 high = n - 1 res = -1 while (low <= high): mid = (low + high) // 2 if arr[mid] > x: high = mid - 1 elif arr[mid] < x: low = mid + 1 else: res = mid low = mid + 1 return res
import re #1 def text_starta_endb(text): #2 patterns = 'a.*?b$' #3 return re.search(patterns, text) #4 <data_flow_edges> patterns--4 and patterns--3 are related by
last wrote
import re def text_starta_endb(text): patterns = 'a.*?b$' return re.search(patterns, text)
def return_sum(dict): #1 sum = 0 #2 for i in dict.values(): #3 sum = sum + i #4 return sum #5 <data_flow_edges> i--4 and i--3 are related by
last wrote
def return_sum(dict): sum = 0 for i in dict.values(): sum = sum + i return sum
def _sum(arr): #1 sum=0 #2 for i in arr: #3 sum = sum + i #4 return(sum) #5 <data_flow_edges> i--3 and i--4 are related by
last read
def _sum(arr): sum=0 for i in arr: sum = sum + i return(sum)
def left_rotate(n,d): #1 INT_BITS = 32 #2 return (n << d)|(n >> (INT_BITS - d)) #3 <data_flow_edges> d--3 and d--1 are related by
last wrote
def left_rotate(n,d): INT_BITS = 32 return (n << d)|(n >> (INT_BITS - d))
import re #1 def remove_all_spaces(text): #2 return (re.sub(r'\s+', '',text)) #3 <data_flow_edges> text--3 and text--2 are related by
last wrote
import re def remove_all_spaces(text): return (re.sub(r'\s+', '',text))
def test_three_equal(x,y,z): #1 result = set([x,y,z]) #2 if len(result)==3: #3 return 0 #4 else: #5 return 4-len(result) #6 <data_flow_edges> z--2 and z--1 are related by
last wrote
def test_three_equal(x,y,z): result = set([x,y,z]) if len(result)==3: return 0 else: return 4-len(result)
def count_rotation(arr): #1 for i in range (1,len(arr)): #2 if (arr[i] < arr[i - 1]): #3 return i #4 return 0 #5 <data_flow_edges> i--4 and i--2 are related by
last wrote
def count_rotation(arr): for i in range (1,len(arr)): if (arr[i] < arr[i - 1]): return i return 0
def is_product_even(arr): #1 for i in range(len(arr)): #2 if (arr[i] & 1) == 0: #3 return True #4 return False #5 <data_flow_edges> arr--3 and arr--1 are related by
last wrote
def is_product_even(arr): for i in range(len(arr)): if (arr[i] & 1) == 0: return True return False
def max_sum_list(lists): #1 return max(lists, key=sum) #2 <data_flow_edges> lists--2 and lists--1 are related by
last wrote
def max_sum_list(lists): return max(lists, key=sum)
def max_run_uppercase(test_str): #1 cnt = 0 #2 res = 0 #3 for idx in range(0, len(test_str)): #4 if test_str[idx].isupper(): #5 cnt += 1 #6 else: #7 res = cnt #8 cnt = 0 #9 if test_str[len(test_str) - 1].isupper(): #10 res = cnt #11 return (res) #12 <data_flow_edges> test_str--5 and test_str--4 are related by
last read
def max_run_uppercase(test_str): cnt = 0 res = 0 for idx in range(0, len(test_str)): if test_str[idx].isupper(): cnt += 1 else: res = cnt cnt = 0 if test_str[len(test_str) - 1].isupper(): res = cnt return (res)
def first_odd(nums): #1 first_odd = next((el for el in nums if el%2!=0),-1) #2 return first_odd #3 <data_flow_edges> first_odd--2 and el--2 are related by
computed from
def first_odd(nums): first_odd = next((el for el in nums if el%2!=0),-1) return first_odd
def check_K(test_tup, K): #1 res = False #2 for ele in test_tup: #3 if ele == K: #4 res = True #5 break #6 return res #7 <data_flow_edges> res--7 and res--5 are related by
last wrote
def check_K(test_tup, K): res = False for ele in test_tup: if ele == K: res = True break return res
def check_smaller(test_tup1, test_tup2): #1 return all(x > y for x, y in zip(test_tup1, test_tup2)) #2 <data_flow_edges> test_tup1--2 and test_tup1--1 are related by
last wrote
def check_smaller(test_tup1, test_tup2): return all(x > y for x, y in zip(test_tup1, test_tup2))

Dataset Card for "dfg_augmented_mbpp"

More Information needed

Downloads last month
38