file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f1643.py
def f(x, start, limit): return start + (x - start) % (limit - start) assert f(3, 1, 5) == 3
benchmark_functions_edited/f9950.py
def f(d, Mv): ke = d/Mv return round(ke, 4) assert f(100, 100) == 1
benchmark_functions_edited/f4983.py
def f(input_x): return bin(input_x).count("1") assert f(0b000000000000000000000000000000000000000000000000000000000000101) == 2
benchmark_functions_edited/f4531.py
def f(filename): from os.path import getsize try: return f(filename) except OSError: return 0 assert f(1) == 0
benchmark_functions_edited/f4398.py
def f(x): if x <= 0: return 0 num_twos = 0 while x % 2 == 0: num_twos += 1 x //= 2 return num_twos assert f(80) == 4
benchmark_functions_edited/f9092.py
def f(width: int) -> int: # NOTE: Lines in BDF BITMAPs are always stored in multiples of 8 bits # (https://stackoverflow.com/a/37944252) return -((-width) // 8) * 8 assert f(8) == 8
benchmark_functions_edited/f5840.py
def f(size12, size1, size2, k12, k1, k2): return size12 - size1 - size2 assert f(10, 5, 5, 2, 5, 0) == 0
benchmark_functions_edited/f2511.py
def f(a, b): if a is None: return b else: return a assert f(3, 1) == 3
benchmark_functions_edited/f4792.py
def f(key: str) -> int: hash = 0 for char in key: hash += ord(char) hash += (hash << 13) hash ^= (hash >> 7) return hash assert f('') == 0
benchmark_functions_edited/f10366.py
def f(str): days = [ "sun", "mon", "tue", "wed", "thu", "fri", "sat" ] try: pos = days.index(str) if pos != ValueError: return pos except: try: value = int(str) return value except: return 0 assert f(1) == 1
benchmark_functions_edited/f2977.py
def f(values): if not values or None in values: return None return sum(values) / float(len(values)) assert f([1, 1, 1, 1, 1, 1]) == 1
benchmark_functions_edited/f9151.py
def f(year): if year % 4 == 0: if year % 100 == 0: if year % 400 == 0: return 1 else: return 0 else: return 1 else: return 0 assert f(2004) == 1
benchmark_functions_edited/f4630.py
def f(j): if j == 1: return 0 else: return 1 assert f(3) == 1
benchmark_functions_edited/f7919.py
def f(idx, value, n): if value == 0: return 0 value_x, value_y = idx // n, idx % n sol_x, sol_y = value // n, value % n return abs(sol_x-value_x) + abs(sol_y-value_y) assert f(0, 2, 3) == 2
benchmark_functions_edited/f13784.py
def f(x): if (x[0] == 0): if (x[1] == 0): return 0 else: return 1 else: if (x[1] == 0): return 2 else: return 3 assert f([0, 0]) == 0
benchmark_functions_edited/f4678.py
def f(f_parallel,A): sigma_shear = f_parallel/A return sigma_shear assert f(10,2)==5
benchmark_functions_edited/f10009.py
def f(hyp, dictionary): return dictionary[hyp] if hyp in dictionary else 0 assert f('-a', dict()) == 0
benchmark_functions_edited/f11790.py
def f(_from, _to, x): return _to[0] + (x - _from[0]) / (_from[1] - _from[0]) * (_to[1] - _to[0]) assert f([1, 2], [3, 4], 2) == 4
benchmark_functions_edited/f5200.py
def f(haystack, needle): for i in range(len(haystack)-len(needle)+1): if haystack[i:i+len(needle)] == needle: return i return -1 assert f('aaaaa', '') == 0
benchmark_functions_edited/f12981.py
def f(x): if 0 <= x < 0.53: return 2 * x + x ** 3 + (5 * x ** 5) / 6 elif x < 0.85: return -0.4 + 1.39 * x + 0.43 / (1 - x) else: return 1 / (x ** 3 - 4 * x ** 2 + 3 * x) assert f(0) == 0
benchmark_functions_edited/f6907.py
def f(numbers): return float(sum(numbers)) / max(len(numbers), 1) assert f( [1, 3, 5] ) == 3
benchmark_functions_edited/f1279.py
def f(arr): result = sorted(arr) return result[0] assert f( [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] ) == 0
benchmark_functions_edited/f4846.py
def f(datapoints): return sum([data["Average"] for data in datapoints]) / len(datapoints) assert f( [{"Average": 1}, {"Average": 2}, {"Average": 3}, {"Average": 4}, {"Average": 5}] ) == 3
benchmark_functions_edited/f13338.py
def f(sum: int = 36) -> int: while sum > 0: if (sum % 10) % 2 == 0: return 0 sum = sum // 10 return 1 assert f(55) == 1
benchmark_functions_edited/f9538.py
def f(set1: set, set2: set) -> int: match = 0 if set1.issuperset(set2): match += 1 for item in set2: if set1.issuperset({item}): match += 1 return match assert f(set(), {1, 2, 3}) == 0
benchmark_functions_edited/f14113.py
def f(array, start, end, pivot): pivot_index = start for i in range(start, end): if array[i] <= pivot: array[i], array[pivot_index] = array[pivot_index], array[i] pivot_index += 1 return pivot_index assert f(list('ABCD'), 0, 4, 'E') == 4
benchmark_functions_edited/f7246.py
def f(iterable, predicate): return next(filter(predicate, iterable), None) assert f([1, 2, 3], lambda x: x % 2 == 0) == 2
benchmark_functions_edited/f3498.py
def f(L_HP_d, etr_loss_TU): return L_HP_d / (1 - etr_loss_TU) assert f(0, 0) == 0
benchmark_functions_edited/f9539.py
def f(bounds): product = 1 for a, b in bounds: product *= b - a return product assert f( [(0, 1), (0, 1), (0, 1)]) == 1
benchmark_functions_edited/f10682.py
def f(pos, image_size): assert(len(pos)==3) assert(len(image_size)==3) return (pos[0] * image_size[1]*image_size[2]) + (pos[1] * image_size[2]) + pos[2]; assert f( [0,0,0], [5,5,5] ) == 0
benchmark_functions_edited/f10577.py
def f(data, *forms): for form in forms: data = form(data) return data assert f(2, lambda x, y=1: x * y, lambda y: y * 2) == 4
benchmark_functions_edited/f7920.py
def f(maybe_str, mapping, *args, **kwargs): if isinstance(maybe_str, str): return mapping[maybe_str](*args, **kwargs) # Object ready instantiated, we can just return it. return maybe_str assert f("4", { "4": lambda arg, kwarg: arg + kwarg }, 1, 2) == 3
benchmark_functions_edited/f3117.py
def f( xy1, xy2 ): return abs( xy1[0] - xy2[0] ) + abs( xy1[1] - xy2[1] ) assert f( (0, 0), (0, 0) ) == 0
benchmark_functions_edited/f11719.py
def f(data): sorted_data = sorted(data) n = len(data) + 1 q1 = int(round(0.25 * n)) - 1 q3 = int(round(0.75 * n)) - 1 return float(sorted_data[q3] - sorted_data[q1]) assert f(sorted([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])) == 6
benchmark_functions_edited/f11203.py
def f(dataset, index): if isinstance(dataset, dict): transformed = {key: data[index] for key, data in dataset.items()} else: transformed = dataset[index] return transformed assert f([0, 1], 1) == 1
benchmark_functions_edited/f8394.py
def f(bond, index): if bond[0] == index: return bond[1] elif bond[1] == index: return bond[0] else: raise ValueError("Index %s not found in bond %s" % (index, bond)) assert f( (0, 1), 0 ) == 1
benchmark_functions_edited/f8700.py
def f(seeds, leeches): return seeds * 2 + leeches assert f(1, 0) == 2
benchmark_functions_edited/f8110.py
def f(num, pos1, pos2): bit1 = (num >> pos1) & 1 bit2 = (num >> pos2) & 1 x = bit1 ^ bit2 x = (x << pos1) | (x << pos2) return num ^ x assert f(0, 2, 1) == 0
benchmark_functions_edited/f630.py
def f(value: float): return min(1, max(value, 0.01)) assert f(2) == 1
benchmark_functions_edited/f9544.py
def f(*args, mod_num=1) -> int: product = 1 for arg in args: if arg >= mod_num: arg = arg % mod_num if product >= mod_num: product = product % mod_num product *= arg return product % mod_num assert f(0, 2, 1) == 0
benchmark_functions_edited/f6447.py
def f(l:list): if len(l) < 2: return 0 if len(l) == 0 else l[0] else: i = l.pop() return i if i > max(l) else f(l) assert f( [1, 2, 3] ) == 3
benchmark_functions_edited/f5480.py
def f(s, i): return sum([1 if c == "(" else 0 for c in s[:i+1]]) - sum([1 if c == ")" else 0 for c in s[:i]]) assert f(r'()', 2) == 0
benchmark_functions_edited/f2710.py
def f(a, b, c): return (a << 40) ^ (b << 20) ^ c assert f(0, 0, 1) == 1
benchmark_functions_edited/f2686.py
def f(e): assert e >= -1650 assert e <= 1650 return (int(e) * 78913 + (2**18 - 1)) // 2**18 assert f(2) == 1
benchmark_functions_edited/f2124.py
def f( str ): try: int( str ) except ValueError: return 0 else: return 1 assert f( "1234" ) == 1
benchmark_functions_edited/f8155.py
def f(blk, p0, p1): for i in range(1, len(blk) - p1): if blk[p0:p0+i] != blk[p1:p1+i]: return i - 1 return len(blk) - p1 - 1 assert f(b'aaaab', 1, 1) == 3
benchmark_functions_edited/f2365.py
def f(q, d, c): result = 0.0 for w in set(q) & set(d): result += d[w] return result assert f(set(['a', 'b', 'c']), {'a': 1, 'b': 2}, 0) == 3
benchmark_functions_edited/f10496.py
def f(value1, value2, *args): top = max(args + (value1, value2)) percent = (value1 + value2) / 2 / top * 100 return percent assert f(-10000000000, 10000000000) == 0
benchmark_functions_edited/f1658.py
def f(hours, cost_per_hour, machines=1): return hours * cost_per_hour * machines assert f(1, 2, 3) == 6
benchmark_functions_edited/f4589.py
def f(num): result = 1 for i in range(2,num, 2): result*=i return result assert f(0) == 1
benchmark_functions_edited/f4339.py
def f(m1, m2, s1, s2): return (m1*s1 + m2*s2) / (m1 + m2) assert f(2, 1, 1, 1) == 1
benchmark_functions_edited/f8128.py
def f(initial: int, steps: int) -> int: return (initial + (initial - steps + 1)) * steps // 2 assert f(1, 2) == 1
benchmark_functions_edited/f5956.py
def f(dname): if dname == None: return 1 if dname == '' or dname == '.' or dname == './' : return 1 return 0 assert f('/home/cs210/foo') == 0
benchmark_functions_edited/f11026.py
def f(obj): if type(obj) == int: return obj if type(obj) == list: return sum([f(item) for item in obj]) if type(obj) == dict: if 'red' in obj.values(): return 0 return f(list(obj.values())) return 0 assert f({'a': {'b': {'c': {'d': {'e': [1]}}}}}) == 1
benchmark_functions_edited/f11604.py
def f(n: int) -> int: return n if n < 3 else f(n - 1) + f(n - 2) assert f(2) == 2
benchmark_functions_edited/f10092.py
def f(mask): # NB: why would anyone care? mask_str = bin(mask) mask_len = len(mask_str) right_most_set_bit = mask_str.rfind("1") if right_most_set_bit > 0: return mask_len - right_most_set_bit - 1 return mask_len assert f(0b00010000) == 4
benchmark_functions_edited/f13653.py
def f(half_life, window): # Alpha as defined in https://en.wikipedia.org/wiki/Moving_average decay = (1 / 2)**(1 / half_life) alpha = 1 - decay tau = window * ((1 - alpha) / alpha) return tau assert f(1, 1) == 1
benchmark_functions_edited/f12188.py
def f(result, base_key, count): active = 0 base_keys = base_key.split(",") for base_key in base_keys: for i in range(1, count): key = base_key.replace("[i]", str(i)) if key in result: active += str(result[key]).count('o') return active assert f( {'a[1...
benchmark_functions_edited/f3536.py
def f(x1, x2): return sum([(i1 - i2)**2 for i1, i2 in zip(x1, x2)]) assert f((0, 0, 0, 0, 0, 0), (1, 1, 1, 1, 1, 1)) == 6
benchmark_functions_edited/f2430.py
def f(n): a, b = 1, 1 while n > 1: a, b = b, a + b n -= 1 return a assert f(5) == 5
benchmark_functions_edited/f6847.py
def f(interval): coverage = 0 for i in interval: coverage = coverage + (i[1] - i[0]) return coverage assert f([]) == 0
benchmark_functions_edited/f6415.py
def f(board, n): return sum(k for row in board for k, v in row.items() if not v) * n assert f([], 100) == 0
benchmark_functions_edited/f5976.py
def f(peptide, motif): for i in range(len(motif)): if peptide[-(i+1)]!=motif[-(i+1)] and motif[-(i+1)]!='x': return 0 return 1 assert f( 'GATTACA', 'TACA') == 1
benchmark_functions_edited/f3951.py
def f(h, w): return min(512 / max(h, w), 1) assert f(256, 256) == 1
benchmark_functions_edited/f4219.py
def f(puzzle: str) -> int: return len(puzzle.split('\n')[0]) assert f("abc\n") == 3
benchmark_functions_edited/f6475.py
def f(predicate, collection, default=None): for e in collection: if predicate(e): return e return default assert f(lambda x: x > 1, [1, 2, 3]) == 2
benchmark_functions_edited/f8252.py
def f(n, k, fdict): if n > 0 and k > 0: nFact = fdict[n] kFact = fdict[k] nkFact = fdict[n - k] return nFact - kFact - nkFact else: return 0 assert f(2, 1, {3: 1, 2: 1, 1: 0, 0: 0}) == 1
benchmark_functions_edited/f14461.py
def f(step_f, norm_L2, N=1, M=1): # Nominally: minimum step size is step_f * norm_L2 # see Parikh 2013, sect. 4.4.2 # # BUT: For multiple constraints, need to multiply by M. # AND: For multiple variables, need to multiply by N. # Worst case of constraints being totally correlated, otherwise Z-up...
benchmark_functions_edited/f4110.py
def f(value): if not (0 <= value < 65535): value = min(max(value, 0), 65535) return value >> 8 assert f(256) == 1
benchmark_functions_edited/f11662.py
def f(l, target): i = 0 j = len(l) while j>i: m = (j-i)//2 + i if l[m] == target: return m elif l[m] < target: i = m+1 else: j = m return None assert f([1,2,3,4], 1) == 0
benchmark_functions_edited/f8486.py
def f(x): if x < 0: return 0 # uniform random is never less than 0 elif x < 1: return x # e.g. P(X <= 0.4) = 0.4 else: return 1 # uniform random is always less than 1 assert f(-5) == 0
benchmark_functions_edited/f1809.py
def f(dist:int) -> int: return int((abs(dist) * (abs(dist) + 1)) / 2) assert f(0) == 0
benchmark_functions_edited/f2385.py
def f(age, player): if age in player['ages']: return player['ages'][age] assert f(5, {'ages': {0: 0, 1: 2, 2: 4, 3: 6, 4: 8, 5: 9}}) == 9
benchmark_functions_edited/f4125.py
def f(ratio: float): return int((round(ratio, 2) * 100)) assert f(0.03) == 3
benchmark_functions_edited/f12171.py
def f(lo, hi, f): reference = f(lo) while lo + 1 < hi: mid = (lo + hi) // 2 if f(mid) == reference: lo = mid else: hi = mid return lo assert f(0, 1, lambda x: 5 ** x) == 0
benchmark_functions_edited/f2029.py
def f(l, idx, default): try: return l[idx] except IndexError: return default assert f(range(10), 4, 100) == 4
benchmark_functions_edited/f9220.py
def f(angle: float) -> int: # two_x = round(angle) assert not two_x % 2 return two_x // 2 assert f(4) == 2
benchmark_functions_edited/f10900.py
def f(filename): allowed_format = [".fa", ".fasta", ".fa.gz", ".fasta.gz"] if any([f for f in allowed_format if filename.endswith(f)]): return 0 else: msg = "file format is not in %s" % allowed_format raise Exception(msg) assert f('data/sample.fasta') == 0
benchmark_functions_edited/f11816.py
def f(value,x,y): if x <= value <= y: return 1 else: return 0 assert f(5,6,6) == 0
benchmark_functions_edited/f11934.py
def f(s): stub = -1 max_len = 0 cache = {} for i, v in enumerate(s): if v in cache and cache[v] > stub: stub = cache[v] cache[v] = i else: cache[v] = i if i - stub > max_len: max_len = i - stub return max_len assert f(...
benchmark_functions_edited/f4749.py
def f(a, b, c): return a * b * c assert f(1, 2, 3) == 6
benchmark_functions_edited/f14388.py
def f(taxonomy): count = 0 keys = [x for x in list(taxonomy.keys()) if x != "data"] for i in keys: if set(taxonomy[i]) == set(list({"data"})): if i == keys[-1]: count += 1 return count else: count += 1 else: ...
benchmark_functions_edited/f12751.py
def f(data, key, default=None, cls=None): if key in data: value = data[key] if cls and value.__class__ != cls: raise Exception("Protocol field has wrong data type: '%s' type=%r expected=%r" % (key, value.__class__, cls)) return value return default assert f([], "a", 1) == 1
benchmark_functions_edited/f7632.py
def f(Vgpm): Vlps = Vgpm * 3.7854118 / 60 return Vlps assert f(0) == 0
benchmark_functions_edited/f4120.py
def f(i, j, n): return n*i - i*(i + 1) // 2 + j - i - 1 assert f(1, 2, 3) == 2
benchmark_functions_edited/f4492.py
def f(*callbacks): retval = None for callback in callbacks: retval = callback() return retval assert f(lambda: 2, lambda: 3) == 3
benchmark_functions_edited/f79.py
def f(col, dpi): return 1000.*col/dpi assert f(0, 300) == 0
benchmark_functions_edited/f5592.py
def f(in_pixel, in_size, out_range): res = 2.0 * out_range / in_size return out_range - (in_pixel + 0.5) * res assert f(0, 10, 10) == 9
benchmark_functions_edited/f12545.py
def f(number): import math if number < 0: # nao existe return 0 elif number <= 1: return 1 digits = (number * math.log10(number / math.e)) + (math.log10(2 * math.pi * number) / 2) return math.floor(digits) + 1 assert f(1) == 1
benchmark_functions_edited/f11689.py
def f(seq, items): found = None for s in seq: if s not in items: found = s return found assert f(range(3), [0]) == 2
benchmark_functions_edited/f10810.py
def f(a, b): # noqa: WPS111 while True: remainder = a % b if remainder == 0: return b a, b = b, remainder assert f(21, 5) == 1
benchmark_functions_edited/f14416.py
def f(board, object, start, ray): x, y = start while True: if x < 0 or y < 0 or x >= len(board[0]) or y >= len(board): return -1 if board[y][x] == object: return (x-start[0])**2 + (y-start[1])**2 else: x += ray[0] y += ray[1] assert f( ...
benchmark_functions_edited/f7573.py
def f(numbers): numbers = list(numbers) if not numbers: return 0 mean = sum(numbers) / len(numbers) return (sum((n - mean) ** 2 for n in numbers) / len(numbers)) ** .5 assert f([0, 0, 0]) == 0
benchmark_functions_edited/f9474.py
def f(port): return abs(port[0]) + abs(port[1]) assert f( (-2,-2) ) == 4
benchmark_functions_edited/f13200.py
def f(rpedwi): if rpedwi == 0: return 0 elif 1 <= rpedwi <= 7: return 1 elif rpedwi == 8: return 88 else: raise KeyError('rpedwi: %s' % rpedwi) assert f(5) == 1
benchmark_functions_edited/f4879.py
def f(p): return len(p.split('.')) assert f("a.b.c.d.e") == 5
benchmark_functions_edited/f6677.py
def f(n): if n <= 1: return n else: return f(n - 1) + f(n - 2) assert f(1) == 1
benchmark_functions_edited/f5734.py
def f(binary): string = int(binary, 2) return string assert f(bin(1)) == 1
benchmark_functions_edited/f6766.py
def f(x, m, k): return m*x + k assert f(0, 0, 2) == 2
benchmark_functions_edited/f14387.py
def f(weekday: str): res = -1 if weekday.lower() == 'mon': res = 0 if weekday.lower() == 'tue': res = 1 if weekday.lower() == 'wed': res = 2 if weekday.lower() == 'thu': res = 3 if weekday.lower() == 'fri': res = 4 if weekday.lower() == 'sat': ...