file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f13737.py
def f(time, period, width) -> float: cur_time = time % period half_width = width//2 if cur_time < half_width: return float(cur_time) / half_width elif cur_time < width: return 1 - float(cur_time - half_width) / half_width else: return 0 assert f(0, 1000, 500) == 0
benchmark_functions_edited/f1218.py
def f(shape): ret = 1 for s in shape: ret *= s return ret assert f((1, 2)) == 2
benchmark_functions_edited/f7756.py
def f(x,y): return len(set(x) & set(y)) / len(set(x) | set(y)) assert f(set([1, 2]), set([1, 2])) == 1
benchmark_functions_edited/f12054.py
def f(e, p): assert p >= 1 if e >= 0: return pow(2, e, p) elif p & 1: return pow((p + 1) >> 1, -e, p) else: raise ZeroDivisionError("Cannot invert 2 mod %d" % p) assert f(1, 7) == 2
benchmark_functions_edited/f549.py
def f(val, offs): return val & ~(1 << offs) assert f(3, 0) == 2
benchmark_functions_edited/f13048.py
def f(version): if version is None: return 1 return int(version.split(".")[0]) assert f('3') == 3
benchmark_functions_edited/f13005.py
def f(clip_info, clip_list): media_id_list = [item["media_id"] for item in clip_list] try: output = media_id_list.index(clip_info["media_id"]) except ValueError: return None else: return output assert f( {"media_id": "1"}, [{"media_id": "1", "video_url": "1"}]) == 0
benchmark_functions_edited/f9172.py
def f(b): result = 0 round = 0 for byte in b: round += 1 if round > 1: result <<= 8 result |= byte return result assert f(b'\x00\x00') == 0
benchmark_functions_edited/f7204.py
def f(source, target, base, alpha): alpha /= 255.0 alpha_inverse = 1.0 - alpha return abs(target - alpha * source - alpha_inverse * base) assert f(0, 0, 0, 0) == 0
benchmark_functions_edited/f4730.py
def f(n: int, n_bits: int = 10) -> int: return int(format(n, '0' + str(n_bits) + 'b')[::-1], 2) assert f(0, 10) == 0
benchmark_functions_edited/f11777.py
def f(label, prediction): return (label-prediction)**2 assert f(1, 2) == 1
benchmark_functions_edited/f1704.py
def f(value): try: return int(value) except ValueError: return None assert f('1') == 1
benchmark_functions_edited/f7130.py
def f(text): return int(text) if text.isdigit() else text assert f('0') == 0
benchmark_functions_edited/f3143.py
def f(a, b): return sum(letter_a != letter_b for letter_a, letter_b in zip(a, b)) assert f( "", "") == 0
benchmark_functions_edited/f1100.py
def f(X): C = sum(X)/len(X) return C assert f(set([1, 1, 1])) == 1
benchmark_functions_edited/f5306.py
def f(array: list, n: int) -> int: if len(array) <= n: ans = -1 else: ans = array[n] ** n return ans assert f(list(range(10)), 1) == 1
benchmark_functions_edited/f5291.py
def f(val): try: return int(float(val) * 0.868976) except (TypeError, ValueError): return val * 0.868976 assert f("0") == 0
benchmark_functions_edited/f5107.py
def f(row): count = 0 for i, c in enumerate(row): if not c.empty: count = i + 1 return count assert f([]) == 0
benchmark_functions_edited/f9816.py
def f(occ_num: int) -> int: return (1 << occ_num) - 1 assert f(0) == 0
benchmark_functions_edited/f1918.py
def f(i): n = 1 while n < i: n *= 2 return n assert f(2) == 2
benchmark_functions_edited/f802.py
def f(topo): return len(topo) - topo.rfind('M') assert f('MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM') == 1
benchmark_functions_edited/f11925.py
def f(coordinates1, coordinates2): absolute_distance = max( abs(coordinates1[0]-coordinates2[0]), abs(coordinates1[1]-coordinates2[1]), abs(coordinates1[0]+coordinates1[1]-coordinates2[0]-coordinates2[1]) ) return absolute_distance + 2 assert f((0, 0), (-3, 3)) == 5
benchmark_functions_edited/f392.py
def f(a, b): if b: return a / b return 0 assert f(0, 0) == 0
benchmark_functions_edited/f7720.py
def f(n, m): if n < 1 or m < 1: return -1 last = 0 for i in range(2, n + 1): last = (last + m) % i return last assert f(16, 2) == 0
benchmark_functions_edited/f6058.py
def f(a, b): return sum([i*j for (i, j) in zip(a, b)]) assert f(list(range(5)), [0]*5) == 0
benchmark_functions_edited/f6284.py
def f(curr, end): curr_x, curr_y = curr end_x, end_y = end return abs(curr_x-end_x) + abs(curr_y-end_y) assert f((0, 0), (0, 1)) == 1
benchmark_functions_edited/f9507.py
def f(x, delta_f, L_o): return delta_f * (x / L_o) ** 3 * (4 - 3 * x / L_o) assert f(0, 1, 0.5) == 0
benchmark_functions_edited/f8189.py
def f(recipe, total_weight): total_liquid = sum(recipe["liquid"][i] for i in recipe["liquid"]) flour = total_weight / (1 + total_liquid / 100) return flour assert f( {"solid": {"milk": 25, "yeast": 200, "wholewheat flour": 200}, "liquid": {"water": 200}}, 0 ) == 0
benchmark_functions_edited/f6617.py
def f(inp, padding, dilation, kernel, stride): numerator = inp + (2*padding) - (dilation*(kernel-1)) - 1 return int((numerator/stride) + 1) assert f(5, 1, 1, 3, 1) == 5
benchmark_functions_edited/f5256.py
def f(file_list): n = 0 for item in file_list: if item[-7:-4] == 'ssp': n = n+1 return n assert f( ['f1.fits', 'f2.fits', 'f3.fits', 'f4.fits', 'f5.fits', 'f6.fits']) == 0
benchmark_functions_edited/f3179.py
def f(seq, ind, defVal=None): try: return seq[ind] except LookupError: return defVal assert f([1, 2], 2, 3) == 3
benchmark_functions_edited/f5601.py
def f(seq, mod): if seq.startswith(mod): return 1 else: return 0 assert f( "YC[K.Nplc:11]", "C" ) == 0
benchmark_functions_edited/f4455.py
def f(xs, target): for i in range(len(xs)): if xs[i]== target: return i return -1 assert f([1], 1) == 0
benchmark_functions_edited/f4612.py
def f(list): # Returns the length of the list divided by 8 as an integer (no remainder) return int(len(list) / 8) assert f(list(range(0, 16))) == 2
benchmark_functions_edited/f2491.py
def f(u, v): a, b = u c, d = v return a*d - b*c assert f( (1,1), (0,1) ) == 1
benchmark_functions_edited/f12309.py
def f(a: int, power: int, modulo: int) -> int: result = 1 while power > 0: if (power & 1) == 1: result = (result * a) % modulo power //= 2 a = (a * a) % modulo return result assert f(2, 0, 5) == 1
benchmark_functions_edited/f8469.py
def f(distribution_or_values): if hasattr(distribution_or_values, 'measurements'): return [x.value for x in distribution_or_values.measurements] return distribution_or_values assert f(1) == 1
benchmark_functions_edited/f4647.py
def f(line): i, n = 0, len(line) while i < n and line[i] == " ": i += 1 return i assert f(r" a = 2") == 2
benchmark_functions_edited/f3968.py
def f(vertices: int, colors: int) -> int: return (colors - 1)**vertices + (-1)**vertices * (colors - 1) assert f(3, 3) == 6
benchmark_functions_edited/f12991.py
def f(x0,p,fprime,epsilon,*args): f2 = fprime(*((x0+epsilon*p,)+args)) f1 = fprime(*((x0,)+args)) return (f2 - f1)/epsilon assert f(0, 1, lambda x: 1, 1e-6) == 0
benchmark_functions_edited/f12662.py
def f(i, j): if i == 0 and j == 0: return 0 if i == 1 and j == 1: return 1 if i == 2 and j == 2: return 2 if (i == 1 and j == 2) or (i == 2 and j == 1): return 3 if (i == 0 and j == 2) or (i == 2 and j == 0): return 4 if (i == 0 and j == 1) or (i == 1 and j == 0): return 5 assert f(1, 0) == 5
benchmark_functions_edited/f1095.py
def f(x1, y1, x2, y2): return abs(x2 - x1) + abs(y2 - y1) assert f(10, 0, 1, 0) == 9
benchmark_functions_edited/f3006.py
def f(value): count = 0 while value: value &= value - 1 count += 1 return count assert f(0b1111) == 4
benchmark_functions_edited/f7990.py
def f(flipper_length, weight_flipper_length, intercept_body_mass): body_mass = weight_flipper_length * flipper_length + intercept_body_mass return body_mass assert f(1, 2, 1) == 3
benchmark_functions_edited/f12536.py
def f(label, equivList): minVal = min(equivList[label]) while label != minVal: label = minVal minVal = min(equivList[label]) return minVal assert f(1, [[2], [1, 3], [1, 3, 4], [1]]) == 1
benchmark_functions_edited/f4958.py
def f(name, value): # ...check_value(fix_name(negate_value(my_decorated_function))) print("name:", name, "value:", value) return value assert f(*("test", 1)) == 1
benchmark_functions_edited/f8829.py
def f(luminosity): if luminosity < 0: val = 0 elif luminosity > 255: val = 255 else: val = luminosity return round(val) assert f(-256) == 0
benchmark_functions_edited/f6925.py
def f(string): count = 0 for each in string: if each >= '\u4e00' and each <= '\u9fff': count += 1 return count assert f(u"abc 你好") == 2
benchmark_functions_edited/f4223.py
def f(num1, num2): result = 0 for n in range(num1, num2 + 1): result = result + n return result assert f(1, 2) == 3
benchmark_functions_edited/f3557.py
def f(int_): c = 0 while int_ != 0: int_ &= int_ - 1 c = c + 1 return c assert f(0b00000011) == 2
benchmark_functions_edited/f2819.py
def f(x): if x >= 0: return x ** 0.5 return (x + 0j) ** 0.5 assert f(0) == 0
benchmark_functions_edited/f10517.py
def f(x, y): return max(x, y) assert f(1, 2) == 2
benchmark_functions_edited/f14003.py
def f(n, current_max): # get positive int if n < 0: n *= -1 # get last digit num digit_num = n - (n // 10) * 10 if 0 < digit_num <= 9 and digit_num > current_max: current_max = digit_num # base case if n // 10 == 0: return current_max # recursive case else: return f(n // 10, current_max) assert f(12, 0) == 2
benchmark_functions_edited/f2878.py
def f(queryset, default=None): if queryset: return queryset[0] return default assert f([1, 2, 3]) == 1
benchmark_functions_edited/f3160.py
def f(shape): out = 1 for item in shape: out *= item return out assert f((1,)) == 1
benchmark_functions_edited/f12809.py
def f(n, k) -> int: if n == 1 and k == 1: return 0 mid = (2 ** (n - 1)) // 2 if k <= mid: return f(n - 1, k) else: tmp = f(n - 1, k - mid) return 1 if tmp == 0 else 0 assert f(1, 1) == 0
benchmark_functions_edited/f12081.py
def f(set1, set2): if not isinstance(set1, set): set1 = set(set1) if not isinstance(set2, set): set2 = set(set2) return len(set1.intersection(set2)) assert f({1, 2, 3, 4}, {1, 2, 3}) == 3
benchmark_functions_edited/f1807.py
def f(x): return x[0](*x[1:]) assert f( [lambda a, b: a + b, 1, 2] ) == 3
benchmark_functions_edited/f13673.py
def f(char): translator = { "A": 0, "B": 1, "C": 2, "D": 3, "E": 4, "F": 5, "G": 6, "H": 7, "I": 8, "J": 9, "K": 10, "L": 11, "M": 12, "N": 13, "O": 14, "P": 15, "Q": 16, "R": 17, "S": 18, "T": 19, "U": 20, "V": 21, "W": 22, "X": 23, "Y": 24, "Z": 25, } return translator[char.upper()] assert f("g") == 6
benchmark_functions_edited/f3366.py
def f(text): return int(text, 0) assert f(str(0x1)) == 1
benchmark_functions_edited/f12224.py
def f(e): numerator = 1 + (73/24)*e**2 + (37/96)*e**4 denominator = (1 - e**2)**(7/2) f = numerator / denominator return f assert f(0) == 1
benchmark_functions_edited/f11681.py
def f(array, blank): count = 0 for i, tile1 in enumerate(array[:-1]): if tile1 is not blank: for tile2 in array[i + 1 :]: if tile2 is not blank: if tile1 > tile2: count += 1 return count assert f(list(range(10)), 5) == 0
benchmark_functions_edited/f12738.py
def f(s, t): if not s: return len(t) if not t: return len(s) if s[0] == t[0]: return f(s[1:], t[1:]) l1 = f(s, t[1:]) # Deletion. l2 = f(s[1:], t) # Insertion. l3 = f(s[1:], t[1:]) # Substitution. return 1 + min(l1, l2, l3) assert f('sunday','saturday') == 3
benchmark_functions_edited/f9686.py
def f(arr): uniq = set() for tri in arr: tri = list(tri) tri.sort() # key = ":".join([str(s) for s in tri]) key = tuple(tri) uniq.add(key) print(uniq) count = len(uniq) return count assert f( [(0, 0), (0, 0), (0, 0), (0, 0)] ) == 1
benchmark_functions_edited/f4187.py
def f(x, y): if x.lower() < y.lower(): return -1 elif x.lower() > y.lower(): return 1 else: return 0 assert f("ab c", "ab c") == 0
benchmark_functions_edited/f14077.py
def f(entry, responses): if responses.get(entry) != None: return responses[entry] else: return len(responses) assert f( "Why would I want to go?", {"Why would I want to go?": 0}) == 0
benchmark_functions_edited/f11152.py
def f(x: float) -> float: return 1 if x <= 0.5 else 0 assert f(0.75) == 0
benchmark_functions_edited/f10534.py
def f(entry, valid, default): if valid[0] <= entry <= valid[1]: result = entry else: result = default return result assert f(1, (0, 3), 0) == 1
benchmark_functions_edited/f13827.py
def f(TP, TN, FP, FN): num = (TP*TN)-(FP*FN) denom = ((TP+FP)*(TP+FN)*(TN+FP)*(TN+FN))**0.5 if denom != 0: MCC = num / denom else: MCC = None return MCC assert f(10, 10, 0, 0) == 1
benchmark_functions_edited/f13147.py
def f(x, f): if x is None: return None return f(x) assert f(2, lambda x: x + 1) == 3
benchmark_functions_edited/f11421.py
def f(termsA, termsB): nA = len(termsA) nB = len(termsB) if nA == 0 or nB == 0: ro = 0 else: nOvr = len(set(termsA).intersection(set(termsB))) oA = nOvr / nA oB = nOvr / nB ro = min([oA, oB]) return ro assert f(["A", "B"], ["B", "A"]) == 1
benchmark_functions_edited/f1969.py
def f(range_1, range_2): return min(range_1[2], range_2[2]) - max(range_1[1], range_2[1]) assert f( (25, 50, 100), (0, 100, 100) ) == 0
benchmark_functions_edited/f11953.py
def f(a, n): t1, t2 = 0, 1 r1, r2 = n, a while r2 != 0: q = r1 // r2 t1, t2 = t2, t1 - q * t2 r1, r2 = r2, r1 - q * r2 if r1 > 1: return None if t1 < 0: t1 += n return t1 assert f(1, 11) == 1
benchmark_functions_edited/f10058.py
def f(area_of_base: float, height: float) -> float: return float(area_of_base * height) assert f(1, 2) == 2
benchmark_functions_edited/f9203.py
def f(mod_seq, mod_str="Oxidation"): return mod_seq.count(mod_str) assert f("K.L.V.W.X.Y.Z.K", "Dioxidation") == 0
benchmark_functions_edited/f3015.py
def f(ue_throughput, ue_required_bandwidth): return int(ue_throughput >= ue_required_bandwidth) assert f(10, 5) == 1
benchmark_functions_edited/f12621.py
def f(str): frequency = {} unique_chars = [] for index, char in enumerate(str): if char in frequency: frequency[char] += 1 unique_chars = [item for item in unique_chars if item[1] != char] else: frequency[char] = 1 unique_chars.append((index, char)) return unique_chars[0][0] assert f( "abcdefg" ) == 0
benchmark_functions_edited/f4487.py
def f(number): weights = (9, 1, 4, 8, 3, 10, 2, 5, 7, 6, 1) return sum(w * int(n) for w, n in zip(weights, number)) % 11 assert f('1234567891') == 0
benchmark_functions_edited/f9718.py
def f(arr, value): if value == None: return -1 for i,ele in enumerate(arr): value = float(str(value).replace(',', '.')) if ele > value: return i - 1 return len(arr)-1 assert f(list(range(0, 10)), 9) == 9
benchmark_functions_edited/f11685.py
def f(number: int) -> int: number = abs(number) return 1 if number < 10 else 1 + f(number // 10) assert f(10000) == 5
benchmark_functions_edited/f1976.py
def f(s): if not s: return 0 try: return len(s.split()[-1]) except: return 0 assert f('hello world ') == 5
benchmark_functions_edited/f7971.py
def f(a, b, n): return min((a-b) % n, (b-a) % n) assert f(0, 0, 3) == 0
benchmark_functions_edited/f9901.py
def f(mol_1_x, mol_1_y, mol_1_z, mol_2_x, mol_2_y, mol_2_z): return ( pow((mol_1_x - mol_2_x), 2) + pow((mol_1_y - mol_2_y), 2) + pow((mol_1_z - mol_2_z), 2) ) assert f(0, 0, 1, 0, 0, 0) == 1
benchmark_functions_edited/f2815.py
def f(file): return sum(1 for _ in open(file)) assert f(0) == 0
benchmark_functions_edited/f12707.py
def f(n): return sum(1 for x in bin(n) if x == "1") assert f(4) == 1
benchmark_functions_edited/f11011.py
def f(pitch): size = 0 # add for the pitchname size += 1 # add for the accidental if not pitch[1] == "None": size += 1 # add for the tie if pitch[2]: size += 1 return size assert f( ("B","#",False) ) == 2
benchmark_functions_edited/f2335.py
def f(x: int) -> int: return 1 if x > 5 else 0 assert f(10) == 1
benchmark_functions_edited/f13549.py
def f(sortedList:list, value:float)->int: for i in range(len(sortedList)-1,-1,-1): if(sortedList[i] <= value): return i+1 else: return 0 assert f([0, 1, 2, 3, 4, 5], 6) == 6
benchmark_functions_edited/f14038.py
def f(a, b, z, w0, w1, N): for i in range(N): tmp = w1 w1 = -((z*(b - a))*w0 + b*(1 - b - z)*w1) / (b*(b - 1)) w0 = tmp b -= 1 return w1 assert f(2, 5, 0, 0, 1, 3) == 1
benchmark_functions_edited/f13441.py
def f(riddle): win = 0 for i in range(len(riddle)): # check whether any character other than alphabet exist if str.isalpha(riddle[i]): win += 0 else: # for each un-found alphabet -> count one win += 1 return win assert f('HAPPY') == 0
benchmark_functions_edited/f12415.py
def f(value: float, mini: float, maxi: float) -> float: return mini if value < mini else value if value < maxi else maxi assert f(5, 3, 4) == 4
benchmark_functions_edited/f1605.py
def f(pos, list_): return sum([abs(pos - i) for i in list_]) assert f(1, [0]) == 1
benchmark_functions_edited/f705.py
def f(dscp): tos = int(bin(dscp * 4), 2) return tos assert f(0) == 0
benchmark_functions_edited/f2553.py
def f(column): try: return int(column.weight) except AttributeError: return 0 assert f(object()) == 0
benchmark_functions_edited/f2629.py
def f(val1, val2): return int(val1 + int(val2[0])) assert f(3, "1") == 4
benchmark_functions_edited/f2654.py
def f(a, b, n): for _ in range(2, n): a, b = b, a + b * b return b assert f(0, 1, 1) == 1
benchmark_functions_edited/f10835.py
def f(key_hash: str, rec: list) -> int: for r in rec: if r[0]["key hash"] != key_hash: continue rew_amount = 0 for sr in r[1]: rew_amount += sr["rewardAmount"] return rew_amount return 0 assert f(1, [ [{"key hash": 1, "key purpose": "payment key"}, []], [{"key hash": 0, "key purpose": "stake key"}, [{"rewardAmount": 1}]], ]) == 0
benchmark_functions_edited/f2721.py
def f(h3_address): return int(h3_address[1], 16) assert f('8976543210abc9f0') == 9
benchmark_functions_edited/f9044.py
def f(dictionary): max_length = 1 for _ in dictionary: if len(_) > max_length: max_length = len(_) return max_length assert f({''}) == 1
benchmark_functions_edited/f1735.py
def f(x, y): while y != 0: x, y = y, x % y return x assert f(27, 15) == 3