file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f2476.py
def f(x1, y1, x2, y2): dist = ((x1-x2)**2 + (y1-y2)**2)**0.5 return dist assert f(2,0,0,0) == 2
benchmark_functions_edited/f12384.py
def f(energy, offset=0., gain=10.): return (energy - offset) // gain assert f(150, 150, 10) == 0
benchmark_functions_edited/f9058.py
def f(candidate, data): i = 0 for arret in data["stops"]: if candidate['properties']['nomlong'] == arret['name']: return i i += 1 return -1 assert f( {'properties': {'nomlong': 'Bretigny-sur-Orge'}}, {'stops': [{'name': 'Bretigny-sur-Orge'}, {'name': 'Bretigny-sur-Orge'}, {'name': 'Bretigny-sur-Orge'}]} ) == 0
benchmark_functions_edited/f9522.py
def f(a: int, b: int) -> int: while True: quotient, remains = divmod(a, b) if remains == 0: return b # updating remains a = b b = remains assert f(14, 21) == 7
benchmark_functions_edited/f12974.py
def f(n, coins, k): # print("n: %d, k: %d" % (n, k)) if k < 0 or n < 0: return 0 if n == 0: # Change for 0 is only empty one. return 1 # print(" n: %d, k: %d" % (n, k - 1)) # print(" n: %d, k: %d" % (n - coins[k], k)) assert f(0, [1, 5, 10], 0) == 1
benchmark_functions_edited/f9294.py
def f(p): q = list(p) # Copy to list. sign = 1 for n in range(len(p)): while n != q[n]: qn = q[n] q[n], q[qn] = q[qn], q[n] # Flip to make q[qn] = qn. sign = -sign return sign assert f([0, 1, 2, 3, 4, 5]) == 1
benchmark_functions_edited/f8360.py
def f(s, context=None): return int(s, 10) assert f(r"-0") == 0
benchmark_functions_edited/f5843.py
def f(result, stats): a, b = stats['q_25'], stats['q_75'] return (b - a) / 2 assert f(1, {'q_25': 2, 'q_75': 2}) == 0
benchmark_functions_edited/f2922.py
def f(lista): suma = 0 for numero in lista: suma += numero return suma assert f([2, 3, 4]) == 9
benchmark_functions_edited/f7532.py
def f(a, b): return min(a[1], b[1]) - max(a[0], b[0]) assert f( (10, 20), (15, 20) ) == 5
benchmark_functions_edited/f12117.py
def f(s): port = int(s) if 0 <= port <= 65535: return port raise ValueError('not a valid port number: %d' % port) assert f('0') == 0
benchmark_functions_edited/f1486.py
def f(x): if x >= 32768: x ^= 65535 x += 1 x *=-1 return x assert f(1) == 1
benchmark_functions_edited/f9996.py
def f(l): max_len = 0 obj_w_max = None for thing in l: string = len(str(thing)) if string > max_len: max_len = string obj_w_max = thing return max_len assert f(["x", "y", "z"]) == 1
benchmark_functions_edited/f12278.py
def f(learning_rate, epoch): if epoch < 80: return learning_rate elif epoch < 120: return learning_rate * 0.1 else: return learning_rate * 0.01 assert f(1, 1) == 1
benchmark_functions_edited/f14525.py
def f(n: int) -> int: fmt = "n needs to be positive integer, your input {}" assert isinstance(n, int) and n > 0, fmt.format(n) if n == 1: return 1 dp = [0] * (n + 1) dp[0], dp[1] = (1, 1) for i in range(2, n + 1): dp[i] = dp[i - 1] + dp[i - 2] return dp[n] assert f(5) == 8
benchmark_functions_edited/f9401.py
def f(_, x, k, g): dx = k * x * (g - x) return dx assert f(0, 1, 1, 1) == 0
benchmark_functions_edited/f324.py
def f(users): return users["pub"] assert f( {"pub": 1, "foo": 2, "bar": 3, "baz": 4} ) == 1
benchmark_functions_edited/f5120.py
def f(cls, *lst): return sum(lst) / len(lst) assert f(0, 0, 0, 0, 0) == 0
benchmark_functions_edited/f7592.py
def f(list_dict, in_val): n = 0 for item in list_dict: for k in item.keys(): if item[k] == in_val: n += 1 return n assert f( [{'x': 1}, {'x': 1}, {'x': 2}], 1) == 2
benchmark_functions_edited/f11196.py
def f(re, fit_re, fit_im): modulus_fit = (fit_re ** 2 + fit_im ** 2) ** (1 / 2) return (re - fit_re) / modulus_fit assert f(1, 1, 1) == 0
benchmark_functions_edited/f5453.py
def f(b,c,d): return b * c / d assert f(1,10,10) == 1
benchmark_functions_edited/f1581.py
def f(n_sec, sr): return int(n_sec*sr) assert f(2, 1) == 2
benchmark_functions_edited/f13415.py
def f(vel, acc, next_acc, h): return vel + 0.5*h*(acc + next_acc) assert f(1, 0, 0, 1) == 1
benchmark_functions_edited/f5045.py
def f(ri, rj): return sum([min(a, b) for a, b in zip(ri["texture_hist"], rj["texture_hist"])]) assert f( { "texture_hist": [1, 2, 3] }, { "texture_hist": [2, 1, 3] } ) == 5
benchmark_functions_edited/f3551.py
def f(num, nofBits): return (num & (2**nofBits-1)) ^ (2**(nofBits-1)) assert f(5, 1) == 0
benchmark_functions_edited/f4739.py
def f(number: int, start: int, limit: int) -> int: return start + ((number - start) % (limit - start)) assert f(3, 0, 10) == 3
benchmark_functions_edited/f5427.py
def f(i, j, i_n, j_n): distance = ((i - i_n)**2.0 + (j - j_n)**2.0)**0.5 return 1 if distance > 0 else 0 # return distance > 0 assert f(1, 0, 0, 2) == 1
benchmark_functions_edited/f13860.py
def f(deaths_array): len_deaths = len(deaths_array) i = 1 loop_deaths = 0 while i < 15: loop_deaths = loop_deaths + deaths_array[len_deaths - i] i = i + 1 average_deaths = round(loop_deaths/14,0) return average_deaths assert f([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0
benchmark_functions_edited/f1624.py
def f(obj): return next(iter(obj)) assert f([1, 2, 3]) == 1
benchmark_functions_edited/f9425.py
def f(obj, key): try: return obj[key] except KeyError: return None assert f((1, 2), 1) == 2
benchmark_functions_edited/f3986.py
def f(f): x = 0 while True: if f(x): return x x += 1 assert f(lambda x: x == 2) == 2
benchmark_functions_edited/f2682.py
def f(p1, p2): return (p1[0]-p2[0])**2 + (p1[1]-p2[1])**2 + (p1[2]-p2[2])**2 assert f((0,0,0), (1,1,1)) == 3
benchmark_functions_edited/f5588.py
def f(x: int) -> int: return 1 << (x - 1).bit_length() assert f(3) == 4
benchmark_functions_edited/f11673.py
def f(num: int) -> int: zero_count = 0 for c in str(num)[::-1]: if c != "0": break zero_count += 1 return zero_count assert f(26000) == 3
benchmark_functions_edited/f12627.py
def f(lprice, fprice): if lprice != 0 and lprice is not None: lpf = float(lprice) fpf = float(fprice) result = (fpf - lpf)/lpf else: result = 0 return result assert f(0, 1) == 0
benchmark_functions_edited/f14291.py
def f(k:int) -> int: return (3**k + 1)//2 assert f(2) == 5
benchmark_functions_edited/f10257.py
def f(base, exponent, modulus): return pow(base, exponent, modulus) assert f(2, 5, 3) == 2
benchmark_functions_edited/f697.py
def f(numbers: list): return float(sum(numbers)) / max(len(numbers), 1) assert f([1, 2, 3, 4, 5]) == 3
benchmark_functions_edited/f11122.py
def f(arg1: int, arg2: int) -> int: res = arg1 - arg2 return abs(res) assert f(0,0) == 0
benchmark_functions_edited/f13242.py
def f(collection, v): counter = 0 for cluster in collection: if v in cluster: counter += 1 return counter assert f([[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6]], 2) == 2
benchmark_functions_edited/f10409.py
def f( r_net, g0, h0 ): result = (r_net - g0 - h0) / (r_net - g0) return result assert f( 10, 0, 10 ) == 0
benchmark_functions_edited/f5502.py
def f(node): if node is None: return 0 return max(f(node.left), f(node.right)) + 1 assert f(None) == 0
benchmark_functions_edited/f6293.py
def f(bb): return int.from_bytes(bb, byteorder='little', signed=True) assert f(b'\x01\x00\x00') == 1
benchmark_functions_edited/f1233.py
def f(d, value): return d.get(value) assert f({"a": 1}, "a") == 1
benchmark_functions_edited/f9962.py
def f(case, rule): if len(case) != len(rule): return 0 match = 1 for i in range(len(case)): if rule[i] != "*" and case[i] != rule[i]: match = 0 break return match assert f(b"ab", b"a") == 0
benchmark_functions_edited/f13229.py
def f(arr): for i in range(len(arr)): if sum(arr[:i]) == sum(arr[i+1:]): return i return -1 assert f([1,2,3,4,3,2,1]) == 3
benchmark_functions_edited/f9687.py
def f(n): fibo = [1, 1] even = 0 if n < 2 or n > 2_000_000: return 0 while n > 2: n -= 1 f = sum(fibo) if f % 2 == 0: even += f fibo = [fibo[-1], f] return even assert f(3) == 2
benchmark_functions_edited/f10463.py
def f(cur_batch, burn_in, power): return pow(cur_batch / burn_in, power); assert f(0, 50, 3) == 0
benchmark_functions_edited/f10922.py
def f(predictions_dict): tokens_iter = enumerate(predictions_dict["predicted_tokens"]) return next(((i + 1) for i, _ in tokens_iter if _ == "SEQUENCE_END"), len(predictions_dict["predicted_tokens"])) assert f( {"predicted_tokens": ["SEQUENCE_START"]}) == 1
benchmark_functions_edited/f4734.py
def f(m,n): i = n**2 + n + m return i assert f(1,1) == 3
benchmark_functions_edited/f728.py
def f(l): return min(zip(l, range(len(l))))[1] assert f([0, 0, 0]) == 0
benchmark_functions_edited/f2440.py
def f(data, path: list): for i in path: data = data.get(i, None) return data assert f( { "a": 1, "b": { "c": 3, "d": 4, }, }, ["b", "c"], ) == 3
benchmark_functions_edited/f6931.py
def f(n: int) -> int: if not n >= 0: raise ValueError return n*(7*n - 5)//2 assert f(2) == 9
benchmark_functions_edited/f10615.py
def f(close, low, open, high): if open == low: return 1 elif close == low: return -1 else: return 0 assert f(10, 11, 12, 10) == 0
benchmark_functions_edited/f4660.py
def f(list, target): for i in range(0, len(list)): if list[i] == target: return i return None assert f([1, 2, 2, 3], 3) == 3
benchmark_functions_edited/f7118.py
def f(start, end, period_length): return (int(end)-int(start)) // period_length assert f(10, 11, 2) == 0
benchmark_functions_edited/f574.py
def f(N,R,current,livetime): return(N/(R*current*livetime)) assert f(1,1,1,1) == 1
benchmark_functions_edited/f8152.py
def f( curtm, newtm, prevtm ): if newtm >= curtm: if prevtm == None: return newtm return min( prevtm, newtm ) return prevtm assert f( 1, 1, None ) == 1
benchmark_functions_edited/f461.py
def f(iterator): return sum(1 for _ in iterator) assert f(range(5, 10)) == 5
benchmark_functions_edited/f14049.py
def f(did_we_trade, amount_influence, current_influence): if amount_influence == 0: return 0 cost = 0 if did_we_trade: cost = cost + 1 amount_influence = amount_influence - 1 current_influence = current_influence + 1 return cost + (2*current_influence + amount_influence + 1)*amount_influence/2 assert f(False, 0, 0) == 0
benchmark_functions_edited/f7321.py
def f(str1, str2): i = 0 while i < min(len(str1), len(str2)): if str1[i] != str2[i]: break i += 1 return i assert f('abc', 'a') == 1
benchmark_functions_edited/f5733.py
def f(left, right) -> int: return 1 if left is None else 1 + f(*left) + f(*right) assert f((None, (None, None)), (None, None)) == 3
benchmark_functions_edited/f10331.py
def f(m): i = m % 10 return (m // 10) + (i // 5) + i % 5 assert f(7) == 3
benchmark_functions_edited/f10753.py
def f(t): st = '' if isinstance(t, str): st = t else: st = repr(t) st = ''.join(st.split('.')) if len(st) > 16: st = st[0:16] elif len(st) < 16: st = st + '0' * (16 - len(st)) return int(st) assert f(0.0) == 0
benchmark_functions_edited/f3099.py
def f(x): if x <= 24: return 0 elif x <= 72: return 1 else: return 2 assert f(340) == 2
benchmark_functions_edited/f5442.py
def f(time): return {"day": 1, "week": 2, "month": 3, "season": 4, "year": 5}.get(time, 5) assert f("unknown") == 5
benchmark_functions_edited/f12386.py
def f(n): "*** YOUR CODE HERE ***" step = 1 print(n) while n != 1: if n % 2 == 0: n = n // 2 else: n = 3 * n + 1 step += 1 print(n) return step assert f(20) == 8
benchmark_functions_edited/f2784.py
def f(pos): return pos['c'] assert f({'c': 1, 'l': 1}) == 1
benchmark_functions_edited/f12752.py
def f( enable_abs, enable_linear_speed, enable_angular_speed, enable_steering, ): total_length = 0 if enable_linear_speed: total_length += 1 if enable_angular_speed: total_length += 1 if enable_abs: total_length += 4 if enable_steering: total_length += 1 return total_length assert f(False, True, False, True) == 2
benchmark_functions_edited/f8963.py
def f(xt, coeffs): o = len(coeffs) yt = 0 for i in range(o): yt += coeffs[i] * xt ** i return yt assert f(2, [0]) == 0
benchmark_functions_edited/f6445.py
def f(i,j): return int(i==j) assert f(0, 0) == 1
benchmark_functions_edited/f96.py
def f(data): return data.__len__() assert f(str()) == 0
benchmark_functions_edited/f5066.py
def f(x, x0, x1, y0, y1): return y0 + (y1 - y0)*((x - x0)/(x1 - x0)) assert f(0, 0, 100, 0, 100) == 0
benchmark_functions_edited/f11688.py
def f(data): if data is None: print("Something's gone horribly wrong.") return 0 total = 0 for entry in data: total += entry[0] return round(total, 2) assert f([[1], [2]]) == 3
benchmark_functions_edited/f6323.py
def f(data_filename): channel_str = data_filename.lstrip('channel_').rstrip('.dat') return int(channel_str) assert f(*['channel_7.dat']) == 7
benchmark_functions_edited/f12718.py
def f(ceiling): numbers = range(ceiling + 1) sum_squares = sum(map(lambda number: number**2, numbers)) square_sum = sum(numbers)**2 sum_square_difference = square_sum - sum_squares return sum_square_difference assert f(1) == 0
benchmark_functions_edited/f13214.py
def f(database, cursor, tableNameList): for tableName in tableNameList: cursor.execute("SELECT name FROM sqlite_master WHERE type='table' AND name=?;",(tableName,)) results = cursor.fetchall() if len(results) == 0: return -1 return 1 assert f(None, None, []) == 1
benchmark_functions_edited/f12084.py
def f(a, m): #an mod m = 1 result = a n = 1 while result != 1: n += 1 result = a * n % m while result > m: result = result % m return n assert f(3, 5) == 2
benchmark_functions_edited/f7980.py
def f(value, min=1, max=5, new_min=-2, new_max=2): return round((((value - min) / (max - min)) * (new_max - new_min)) + new_min) assert f(5, 1, 5, -2, 2) == 2
benchmark_functions_edited/f10937.py
def f(x): while isinstance(x, (list, tuple)): try: x = x[0] except (IndexError, TypeError, KeyError): break return x assert f(1) == 1
benchmark_functions_edited/f1488.py
def f(p): f = p - 1 return (f * f * f * f * f) + 1 assert f(1) == 1
benchmark_functions_edited/f1289.py
def f(number): return len(bin(number)) - len(bin(number).rstrip('0')) assert f(64) == 6
benchmark_functions_edited/f4401.py
def f(progress, period, x_range): x = int((progress / period) * x_range) return x assert f(0, 10, 10) == 0
benchmark_functions_edited/f1835.py
def f(x): rval = x while rval < 4: rval = rval * rval return rval assert f(3) == 9
benchmark_functions_edited/f11796.py
def f(value, position, length=1): binary = bin(value)[2:] size = len(binary) - 1 if position > size: return 0 else: return int(binary[size - position: size - position + length], 2) assert f(3, 7) == 0
benchmark_functions_edited/f12402.py
def f(index, event_ref_list): if index < 0: return None else: count = 0 for event_ref in event_ref_list: (private, note_list, attribute_list, ref, role) = event_ref if index == count: return ref count += 1 return None assert f(0, [(0, [], [], 1, ''), (0, [], [], 2, '')]) == 1
benchmark_functions_edited/f7574.py
def f(arr): min = arr[0] for i in range(1, len(arr)): if arr[i] < min: min = arr[i] break return min assert f( [5, 7, 10, 12, 14, 19, 21, 3, 6, 9, 15]) == 3
benchmark_functions_edited/f9902.py
def f(val): if not val and (val != 0): return None else: try: return float(val) % 360 except ValueError: return val assert f(1) == 1
benchmark_functions_edited/f6211.py
def f(seq): if seq[-1:] == "K": return 1 else: return 0 assert f('VAL') == 0
benchmark_functions_edited/f4116.py
def f(n): return ((2.0*n + 1.0)**2.0 - 1.0) / 8.0 assert f(1) == 1
benchmark_functions_edited/f5439.py
def f(a, b): c = a + b return c assert f(1.0, 2) == 3
benchmark_functions_edited/f12756.py
def f(table, dungeon_level): if isinstance(table[0], int): return table[0] for (value, level) in reversed(table): if dungeon_level >= level: return value return 0 assert f( [[1, 1], [2, 2], [3, 4]], 1) == 1
benchmark_functions_edited/f7968.py
def f(y, x): return int(x/3)+int(y/3)*3 assert f(0, 1) == 0
benchmark_functions_edited/f10465.py
def f(hex_str): val = int(hex_str, 16) if val > 0x7FFFFFFF: val = ((val+0x80000000) & 0xFFFFFFFF) - 0x80000000 return val assert f('0x00000000') == 0
benchmark_functions_edited/f8720.py
def f(product_id, sku_id): if product_id == 'Secure Firewall' and sku_id == 'Ingress network traffic': return 1 + 1 if product_id == 'Secure Firewall' and sku_id == 'Egress network traffic': return 1 * 1 return 0 assert f('Random', 'Egress network traffic') == 0
benchmark_functions_edited/f1937.py
def f(x): return sum(x) / len(x) assert f([1, 2, 3, 4, 5]) == 3
benchmark_functions_edited/f10056.py
def f(listInd): i = len(listInd)-1 while((listInd[i]==[] or listInd[i]==None) and i>=0): i=i-1 if i==0: return None else: return listInd[i][0] assert f( [ [1,2], [3,4], [5,6] ] ) == 5
benchmark_functions_edited/f4291.py
def f(arbre): if arbre is None: return 0 else: return 1 + f(arbre.get_gauche()) + f(arbre.get_droite()) assert f(None) == 0
benchmark_functions_edited/f1603.py
def f(v): return bin(v).count('1') & 1 assert f(19) == 1
benchmark_functions_edited/f12596.py
def f(num_a: int, num_b: int) -> int: if num_b == 0: return num_a print(f">>> Value of num_b: {num_b}") return f(num_b, num_a % num_b) assert f(14, 21) == 7