file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f12804.py
def f(n: int) -> int: # base cases if n < 1: return 1 elif n == 1: return 1 return f(n - 1) + f(n - 2) assert f(2) == 2
benchmark_functions_edited/f472.py
def f(e): if e == 1: return 0 else: return 1 assert f(0) == 1
benchmark_functions_edited/f12769.py
def f(data, left, right): temp = data[left] while left < right: while left < right and data[right] >= temp: right -= 1 data[left] = data[right] while left < right and data[left] <= temp: left += 1 data[right] = data[left] data[left] = temp return left assert f(list(range(10)), 0, 0) == 0
benchmark_functions_edited/f4539.py
def f(graystr): num = int(graystr, 2) num ^= (num >> 8) num ^= (num >> 4) num ^= (num >> 2) num ^= (num >> 1) return num assert f('000') == 0
benchmark_functions_edited/f13833.py
def f(num_single, idx): if isinstance(idx, int): return idx elif isinstance(idx, tuple): return num_single + 2 * idx[0] + idx[1] else: raise TypeError("Cannot recognize idx as single or couple") assert f(5, 1) == 1
benchmark_functions_edited/f11104.py
def f(size): if size == 0: return 1 else: number_of_bits = size.bit_length() rest = (number_of_bits % 8) if rest != 0: number_of_bits += (8 - rest) return number_of_bits // 8 assert f(511) == 2
benchmark_functions_edited/f9868.py
def f(max_dim): label_font_sizes = {1: 8, 2: 7} return label_font_sizes[max_dim] if max_dim in label_font_sizes else 6 assert f(2) == 7
benchmark_functions_edited/f8590.py
def f(s): try: s = s.strip() return int(s) if s else 0 except: return s assert f("1") == 1
benchmark_functions_edited/f9210.py
def f(lst, val): status = False for n in range(len(lst)): if lst[n] == val: status = True return n if status is False: return -1 assert f(list(range(10)), 5) == 5
benchmark_functions_edited/f6517.py
def f(crop_size, upscale_factor): return crop_size - (crop_size % upscale_factor) assert f(10, 4) == 8
benchmark_functions_edited/f350.py
def f(i): return 1 + i%3 assert f(14) == 3
benchmark_functions_edited/f3428.py
def f(s1, s2): assert len(s1) == len(s2) return sum(c1 != c2 for c1, c2 in zip(s1, s2)) assert f("", "") == 0
benchmark_functions_edited/f5664.py
def f(list, val): found = [i for i, k in enumerate(list) if k == val] if len(found) > 0: return found[0] return None assert f(list('abcdef'), 'c') == 2
benchmark_functions_edited/f13991.py
def f(obj): if obj is None: return None elif isinstance(obj, int): return obj elif hasattr(obj, "fileno") and callable(getattr(obj, "fileno")): return obj.fileno() raise TypeError("Expected None, int or fileobject with fileno method") assert f(open("README.md").fileno()) == 3
benchmark_functions_edited/f11197.py
def f(label, steps=[1, 3]): i = 0 for step in steps: if label < step: return i else: i += 1 return i assert f(5, [1, 3]) == 2
benchmark_functions_edited/f13717.py
def f(k: int) -> int: result = 1 for i in range(1, k + 1): result *= i**i return result assert f(1) == 1
benchmark_functions_edited/f10528.py
def f(type): one = ["transmission"] two = ["memory"] three = ["processing"] if type in one: return 0 if type in two: return 0 if type in three: return 0 print("type not found. Exiting.") exit() assert f("transmission") == 0
benchmark_functions_edited/f3777.py
def f(whole, total): try: pct = whole / total except ZeroDivisionError: pct = 0 else: pct * 100 return pct assert f(0, 1) == 0
benchmark_functions_edited/f3618.py
def f(dictionary): return sum(map(lambda value: len(value), dictionary.values())) assert f({}) == 0
benchmark_functions_edited/f5157.py
def f(a, b, c, d): p1 = ((a + b + c + d) ** 2 - 2 * (a ** 2 + b ** 2 + c ** 2 + d ** 2)) ** 2 p2 = 64 * a * b * c * d return p1 - p2 assert f(1, 0, 1, 0) == 0
benchmark_functions_edited/f8661.py
def f(z,psi): return (z**(1+psi))/(1+psi) assert f(0, 0.5) == 0
benchmark_functions_edited/f3136.py
def f(value, mem_split): for index, split in enumerate(mem_split): if value <= split: return index assert f(1, [1, 4, 10]) == 0
benchmark_functions_edited/f9242.py
def f(num): pos = 0 for pow_ in [16, 8, 4, 2, 1]: if num >= 2 ** pow_: num //= (2 ** pow_) pos += pow_ return pos assert f(2 ** 6) == 6
benchmark_functions_edited/f8016.py
def f(data): try: return int.from_bytes(data, byteorder='big') except: return data assert f(b'') == 0
benchmark_functions_edited/f11129.py
def f(tick_size): str_price_tick_ = str(tick_size) decimal_pos_ = str_price_tick_.find('.') if decimal_pos_ == -1 or str_price_tick_[decimal_pos_ + 1:] == '0': return 0 else: return len(str_price_tick_) - (decimal_pos_ + 1) assert f(0.01) == 2
benchmark_functions_edited/f13430.py
def f(value: int): if value < 0 or value > 215: return 0 return ((value // 36 * 0x33) << 16) + ((value // 6 % 6 * 0x33) << 8) + ((value % 6 * 0x33) & 0xFF) assert f(0) == 0
benchmark_functions_edited/f6166.py
def f(v, nbits = 32): return -(( ~v & ((1 << nbits)-1) ) + 1) if v & (1 << nbits-1) else v assert f(0) == 0
benchmark_functions_edited/f2122.py
def f(X, Y): x = set(X) y = set(Y) return float(len(x & y)) / len(x | y) assert f(set(['x']), set()) == 0
benchmark_functions_edited/f7673.py
def f(_V1, _V2): sizeV1 = len(_V1) sizeV2 = len(_V2) sizeV = sizeV1 if(sizeV1 < sizeV2) else sizeV2 res = 0 for i in range(sizeV): res += _V1[i]*_V2[i] return res assert f((0,), (0,)) == 0
benchmark_functions_edited/f2513.py
def f(x): try: return int(x) except ValueError: return x assert f(0) == 0
benchmark_functions_edited/f11762.py
def f(repo): dynamic_count = 0 if 'DYNAMIC-PATTERN' in repo['uniquePatterns']: dynamic_count += repo['uniquePatterns']['DYNAMIC-PATTERN'] return len(repo['uniquePatterns']) + dynamic_count assert f( { 'name':'repo3', 'uniquePatterns': { 'PATTERN1': 1, 'PATTERN2': 1, 'PATTERN3': 1, } } ) == 3
benchmark_functions_edited/f13809.py
def f(coord_a, coord_b): assert len(coord_a) == len(coord_b) dim = len(coord_a) sum_square_dist = 0 for a, b in zip(coord_a, coord_b): sum_square_dist += (a - b)**2 dist = sum_square_dist**(1 / dim) return dist assert f( (0, 0, 0), (1, 0, 0) ) == 1
benchmark_functions_edited/f8535.py
def f(minutes): app_points = 0. if minutes > 0: app_points = 1 if minutes >= 60: app_points += 1 return app_points assert f(2) == 1
benchmark_functions_edited/f2650.py
def f(password): if len(password) < 6: return 1 return 0 assert f(b'foo') == 1
benchmark_functions_edited/f4638.py
def f(x, n): if n == 0: return 1 else: return x * f(x, n - 1) assert f(3, 2) == 9
benchmark_functions_edited/f9236.py
def f(i, n, PV, PV0=0): return i / (1 - 1 / (1 + i) ** n) * (PV - PV0) assert f(0.1, 12, 0, 0) == 0
benchmark_functions_edited/f13033.py
def f(x): if x == 'White': return 1 elif x == 'Black': return 2 elif x == 'Amer-Indian-Eskimo': return 3 elif x == 'Asian-Pac-Islander': return 4 else: return 0 assert f(1) == 0
benchmark_functions_edited/f7682.py
def f(point1, point2): import math return math.sqrt((point1[0] - point2[0])**2 + (point1[1] - point2[1])**2) assert f( (0, 0), (0, 0) ) == 0
benchmark_functions_edited/f6580.py
def f(a, b): while b > 0: a, b = b, a % b return a assert f(4, 5) == 1
benchmark_functions_edited/f11478.py
def f(n, memo = None): if memo == None: memo = {} if n == 0 or n == 1: return 1 try: return memo[n] except KeyError: result = f(n-1, memo) + f(n-2, memo) memo[n] = result return result assert f(5) == 8
benchmark_functions_edited/f3119.py
def f(z): return 1728 * (z * (z**10 + 11 * z**5 - 1))**5 / \ (-(z**20 + 1) + 228 * (z**15 - z**5) - 494 * z**10)**3 assert f(0) == 0
benchmark_functions_edited/f7677.py
def f(x, a): if x == a: return 0 elif x < a: return x else: f(x-a, a) assert f(2, 2) == 0
benchmark_functions_edited/f916.py
def f(byte_val: int) -> int: assert 0 <= byte_val < 256 return byte_val assert f(2) == 2
benchmark_functions_edited/f6428.py
def f(t): return list(map(listit, t)) if isinstance(t, (list, tuple)) else t assert f(0) == 0
benchmark_functions_edited/f8006.py
def f(px: float, py: float, ox: float, oy: float) -> float: x = px + py * (ox - px) / (py - oy) return x assert f(0, 0, 3, 3) == 0
benchmark_functions_edited/f1311.py
def f(value, value_type): if value_type == "integer": return int(value) return value assert f(1.1, "integer") == 1
benchmark_functions_edited/f13791.py
def f(y, t, scale=0.5): assert len(y) == len(t) return scale * sum((y_i - t_i) ** 2 for y_i, t_i in zip(y, t)) assert f( [1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0] ) == 0
benchmark_functions_edited/f14339.py
def f(dek_year: int) -> int: week_day = ( ( 1 + 5 * ((dek_year) % 4) + 4 * ((dek_year) % 100) + 6 * ((dek_year) % 400) ) % 7 ) + 1 return week_day assert f(1989) == 2
benchmark_functions_edited/f13247.py
def f(flow_net, node): flow = 0 n = len(flow_net) for i in range(n): flow += flow_net[i][node] flow -= flow_net[node][i] return flow assert f( [[0, 1, 1, 0], [0, 0, 1, 0], [0, 0, 0, 1], [0, 0, 0, 0]], 2) == 1
benchmark_functions_edited/f11410.py
def f(A): n = len(A) L = [-1] + A count = 0 pos = (n + 1) // 2 candidate = L[pos] for i in range(1, n + 1): if L[i] == candidate: count = count + 1 print(count, n/2) if count > n/2: return candidate return -1 assert f( [2, 2] ) == 2
benchmark_functions_edited/f6806.py
def f(contracts: dict) -> int: return max( len(function) for contract, functions in contracts.items() for function in functions ) assert f({"A": [[]]}) == 0
benchmark_functions_edited/f5800.py
def f(n, d, m): inverse = pow(d, m-2, m) return (n*inverse) % m assert f(2, 2, 2) == 0
benchmark_functions_edited/f317.py
def f(x, y): if x < y: return 1 return 0 assert f(2, 1) == 0
benchmark_functions_edited/f9931.py
def f(module_mass): return module_mass // 3 - 2 assert f(14) == 2
benchmark_functions_edited/f9632.py
def f(filename): try: return len(open(filename, 'r').readlines()) except (EnvironmentError, TypeError): print('Exception error') return 0 assert f('abc') == 0
benchmark_functions_edited/f13969.py
def f(year, season, base=16): return 3*(year - base) + season assert f(17, 1) == 4
benchmark_functions_edited/f6625.py
def f(num): result = 1 i = iter(range(1, num + 1)) try: while True: result *= next(i) except StopIteration: pass return result assert f(1) == 1
benchmark_functions_edited/f3712.py
def f(a: int) -> int: t = 0 while a > 0: a &= a - 1 t += 1 return t assert f(25) == 3
benchmark_functions_edited/f8222.py
def f(a): if a == 9: return 1 if a == 10: return 127 - 30 # LF elif 32 <= a <= 126: return a - 30 else: return 0 assert f(12) == 0
benchmark_functions_edited/f1399.py
def f(value, mn, mx): return max(min(value, mx), mn) assert f(2, 0, 1) == 1
benchmark_functions_edited/f1176.py
def f(index): return int(float(index)) assert f("2.3") == 2
benchmark_functions_edited/f2480.py
def f(n): return (n * n) assert f(3) == 9
benchmark_functions_edited/f2174.py
def f(sc, L, ct=4): return min(abs((x-L*ct) - sc) for x in range(ct)) assert f(2, 1, 2) == 3
benchmark_functions_edited/f3779.py
def f(n): sum = 0 for i in range(n): if i % 2 == 1: sum += i return sum assert f(2) == 1
benchmark_functions_edited/f14227.py
def f(preds): batch_length = None for key, value in preds.items(): this_length = ( len(value) if isinstance(value, (list, tuple)) else value.shape[0]) batch_length = batch_length or this_length if this_length != batch_length: raise ValueError('Batch length of predictions should be same. %s has ' 'different batch length than others.' % key) return batch_length assert f( {'foo': [1, 2, 3], 'bar': [1, 2, 3]}) == 3
benchmark_functions_edited/f794.py
def f(x, a, b, c, d): return a*x**3 + b*x**2 + c*x + d assert f(2, 0, 0, 0, 0) == 0
benchmark_functions_edited/f7519.py
def f(byte_array, signed=True): return int.from_bytes(byte_array, byteorder='big', signed=signed) assert f(b'\x00\x00\x00\x00') == 0
benchmark_functions_edited/f8146.py
def f(table, targets): total = 0 for enemy in targets: table.setdefault(enemy.type_id, 1) total += table[enemy.type_id] return total assert f(None, []) == 0
benchmark_functions_edited/f7492.py
def f(l, f): vals = [f(x) for x in l] return l[vals.index(min(vals))] assert f(range(5), lambda x: abs(x)) == 0
benchmark_functions_edited/f5343.py
def f(s): return len(s) - len(s.lstrip(" ")) assert f(" a ") == 1
benchmark_functions_edited/f5319.py
def f(ingredients, ingredient_count): return sum(ingredient_count[ingredient] for ingredient in ingredients) assert f( ["noodles", "corn", "bread"], {"noodles": 1, "corn": 0, "bread": 2}) == 3
benchmark_functions_edited/f4033.py
def f(field, value, **options): try: return int(value) except (ValueError, TypeError): return value assert f(None, '0') == 0
benchmark_functions_edited/f62.py
def f(x): a = 0.5 return x * a assert f(0) == 0
benchmark_functions_edited/f10245.py
def f(pixel_x, width, distance, wavelength): from math import sin, atan distance=float(distance) if abs(distance) > 0.0: rad = 0.5 * float(pixel_x) * int(width) return float(wavelength)/(2*sin(0.5*atan(rad/distance))) else: return 0. assert f(100000000000, 10000000, 0.0, 1064.0) == 0
benchmark_functions_edited/f3997.py
def f(str_num): if str_num.isnumeric(): return int(str_num) else: return int(float(str_num)) assert f('-0.5') == 0
benchmark_functions_edited/f5350.py
def f(stringlist): maxlen = 0 for x in stringlist: if len(x) > maxlen: maxlen = len(x) return maxlen assert f(['this']) == 4
benchmark_functions_edited/f11130.py
def f(s): n = 0 for i in range(0,len(s)): a = ord(s[len(s)-i-1]) if (a >= 48) & (a <= 57): n = n | ((a-48) << (i*4)) elif (a >= 65) & (a <= 70): n = n | ((a-65+10) << (i*4)) elif (a >= 97) & (a <= 102): n = n | ((a-97+10) << (i*4)) else: return None return n assert f("0") == 0
benchmark_functions_edited/f3105.py
def f(u, a=1, b=2): return (1 - b * u * 1j)**(-a) assert f(0) == 1
benchmark_functions_edited/f6804.py
def f(value): digit_counter = 0 while value > 0: digit_counter = digit_counter + 1 value = value // 10 return digit_counter assert f(9) == 1
benchmark_functions_edited/f12416.py
def f(lifecycle, ticks): if ticks <= lifecycle: # this fish doesn't have time to reproduce # so one-fish stays one-fish return 1 else: # calculate the progeny recursively ticks -= lifecycle + 1 return f(6, ticks) + f(8, ticks) assert f(6, 9) == 2
benchmark_functions_edited/f9400.py
def f(y_true, y_pred): fn = 0 for yt, yp in zip(y_true, y_pred): if yt == 1 and yp == 0: fn += 1 return fn assert f( [1, 0, 0, 1, 1, 0, 1, 0, 0, 0], [1, 0, 0, 1, 1, 0, 1, 0, 0, 0] ) == 0
benchmark_functions_edited/f8878.py
def f(a_para_list): num_lt = [float(i) for i in a_para_list] # Arjun Mehta max_val = max(num_lt) return max_val assert f([1, 2, 3, 4]) == 4
benchmark_functions_edited/f14480.py
def f(ebit, lease_payments, interest_payments): return (ebit + lease_payments) / (interest_payments + lease_payments) assert f(0, 0, 10000) == 0
benchmark_functions_edited/f3661.py
def f(expr, mu): return expr(mu) if callable(expr) else expr assert f(5, 0) == 5
benchmark_functions_edited/f5692.py
def f(x: int, y: int) -> int: while y > 0: x, y = y, x % y return x assert f(3, 12) == 3
benchmark_functions_edited/f254.py
def f(a, b): return (a - b) ** 2 / 12 assert f(0, 0) == 0
benchmark_functions_edited/f8640.py
def f(predicate, seq): for x in seq: if predicate(x): return x return None assert f(lambda x: x % 2 == 1, [1, 2, 3, 4]) == 1
benchmark_functions_edited/f6943.py
def f( w ): w = int( ( w & 0x7fffFFFF ) | ( - ( w & 0x80000000 ) ) ) assert type(w) == int return w assert f(1) == 1
benchmark_functions_edited/f13450.py
def f(lista_palavras): freq = dict() unicas = 0 for palavra in lista_palavras: p = palavra.lower() if p in freq: if freq[p] == 1: unicas -= 1 freq[p] += 1 else: freq[p] = 1 unicas += 1 return unicas assert f(['aaaaa', 'Aaaaa', 'Aaaaaa']) == 1
benchmark_functions_edited/f8389.py
def f(x): if isinstance(x, int): return x if not x.isdecimal(): raise RuntimeError("{} is not a decimal number".format(x)) return int(x) assert f(5) == 5
benchmark_functions_edited/f2380.py
def f(x, min, max): if x < min: return min if x > max: return max return x assert f(0, 1, 3) == 1
benchmark_functions_edited/f4797.py
def f(n, t): if n < 3 or t < 1: return 0 return int(t * ((n-2) * t - (n-4)) / 2) assert f(5, 2) == 5
benchmark_functions_edited/f2825.py
def f(obj, key): try: return obj[key] except KeyError: return assert f({"a": 1, "b": 2}, "a") == 1
benchmark_functions_edited/f9059.py
def f(fn: float, tn: float) -> float: try: calc = fn / (fn + tn) except ZeroDivisionError: calc = 0 return calc assert f(0, 1) == 0
benchmark_functions_edited/f2157.py
def f(x1, y1, x2, y2): return abs(x1 - x2) + abs(y1 - y2) assert f(5, 1, 5, 5) == 4
benchmark_functions_edited/f8295.py
def f(n): if n == 2: return 2 elif n == 1: return 1 else: return n * f(n - 2) assert f(2) == 2
benchmark_functions_edited/f11544.py
def f(latency_value): return latency_value[0] - latency_value[1] assert f( (10, 1)) == 9
benchmark_functions_edited/f8073.py
def f(x, feature_grids): values = list(feature_grids) return values.index(min(values, key=lambda y: abs(y-x))) assert f(1, [2,3,4,5,6,7,8,9,10]) == 0
benchmark_functions_edited/f11797.py
def f(vector1, vector2): dot_product = 0.0 normA = 0.0 normB = 0.0 for a, b in zip(vector1, vector2): dot_product += a * b normA += a ** 2 normB += b ** 2 if normA == 0.0 or normB == 0.0: return None else: return dot_product / ((normA * normB) ** 0.5) assert f( [1, 0, 0], [0, 1, 0] ) == 0
benchmark_functions_edited/f1484.py
def f(nums): total=sum(range(len(nums)+1)) return total-sum(nums) assert f([0]) == 1