file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f3380.py
def f(tup_fn, x, y): return tup_fn((x, y)) assert f(lambda tup: tup[0] + tup[1], 3, 4) == 7
benchmark_functions_edited/f13314.py
def f(combination, idx): for fc_idx, fc_set in enumerate(combination): if fc_set is None: continue if idx == fc_set[0]: return fc_idx elif idx in fc_set: # item is not first so no match raise IndexError() # @IgnoreException return None assert f( [[1, 2], [3, 4], [5], [6, 7], [8, 9]], 3) == 1
benchmark_functions_edited/f6140.py
def f(d, theta, a, alpha): T = 0 return T assert f(1, 2, 3, 4) == 0
benchmark_functions_edited/f5028.py
def f(item_list,val): error_arr=[abs(tmp-val) for tmp in item_list] error_min=min(error_arr) return error_arr.index(error_min) assert f( [0,1,2,3,4,5,6,7,8,9], -4) == 0
benchmark_functions_edited/f1554.py
def f(x, y): return (x - y) / min(x, y) assert f(1, 1) == 0
benchmark_functions_edited/f7455.py
def f(movies): ratings = [m.score for m in movies] mean = sum(ratings) / max(1, len(ratings)) return round(mean, 1) assert f([]) == 0
benchmark_functions_edited/f14533.py
def f(inp): result = 0 count = 0 if inp: if isinstance(inp, list): for t in inp: if isinstance(t, int) or isinstance(t, float): result += float(t) count += 1 result /= float(count) else: raise TypeError('Input is not a list') return result assert f([5, 4, 3, 2, 1]) == 3
benchmark_functions_edited/f659.py
def f(a, b): if a > b: return 3 * a + b return 2 * b * a assert f(0, 0) == 0
benchmark_functions_edited/f6640.py
def f(word): check = any(letter.isupper() for letter in word) return 1 if check else 0 assert f( "HELLO WORLD!" ) == 1
benchmark_functions_edited/f9738.py
def f(integers): integers.sort() min = integers[0] for integer in integers: if min > 0 and integer > min + 1: return min + 1 else: min = integer return min + 1 assert f( [3, 4, -1, 1] ) == 2
benchmark_functions_edited/f9153.py
def f( old_min: float, old_max: float, new_min: float, new_max: float, value: float, ) -> float: return ((value - old_min) / (old_max - old_min)) * (new_max - new_min) + new_min assert f(0, 1, 0, 10, 0.5) == 5
benchmark_functions_edited/f3943.py
def f(P,x): out = 0 e = 1 for coef in P: out += coef*e e *= x return out assert f( (1,3,4), 0) == 1
benchmark_functions_edited/f10048.py
def f(n, c, m): result = envelops = n // c while envelops >= m: envelops += 1 - m # Every time i give m chocolates to get a new one result += 1 # Add the new one chocolate return result assert f(6, 2, 3) == 4
benchmark_functions_edited/f3100.py
def f(red, green, blue, magic): return -((magic << 24) + (red << 16) + (green << 8) + blue) & 0xffffffff assert f(0, 0, 0, 0) == 0
benchmark_functions_edited/f5650.py
def f(seconds=0, minutes=0, hours=0, days=0, weeks=0): return seconds + minutes*60 + hours*3600 + days*86400 + weeks*604800 assert f(3) == 3
benchmark_functions_edited/f6114.py
def f(observation): score, dealer_score, usable_ace = observation return 0 if score >= 20 else 1 assert f( (19, 1, False) ) == 1
benchmark_functions_edited/f7994.py
def f(number=0): push_size = 0 for p in list(range(256, 0, -8)): if int(number / (2 ** p)) > 0: push_size = int(p / 8) break return push_size + 1 assert f(0) == 1
benchmark_functions_edited/f1202.py
def f(s): i = 0 for x in s: i += 2 ** x return i assert f({0}) == 1
benchmark_functions_edited/f10474.py
def f(out_size,current_pool): ratio=out_size/current_pool if (ratio)%1==0:#whole number return int(current_pool) else: whole_ratio=round(ratio) if whole_ratio==0: whole_ratio+=1 return int(out_size/whole_ratio) assert f(5,5) == 5
benchmark_functions_edited/f13921.py
def f(method_name, dict_name, dict_of_values, key): try: return dict_of_values[key] except KeyError: raise KeyError(f"{method_name}s {dict_name} only takes {list(dict_of_values.keys())} but found {key}") assert f( "mode", "mode", {"A": 1, "B": 2}, "A", ) == 1
benchmark_functions_edited/f2979.py
def f(n): if n in (0, 1): return n return (f(n - 2) + f(n - 1)) assert f(5) == 5
benchmark_functions_edited/f2259.py
def f(x): return x**(1/2.2) assert f(0) == 0
benchmark_functions_edited/f13910.py
def f(val): val = ''.join(c for c in str(val) if c.isdigit()) return int(val[-2:]) assert f('202106A') == 6
benchmark_functions_edited/f13936.py
def f(feature, features): return features.index(feature) - int('time' in features) assert f(3, [1, 2, 3, 4]) == 2
benchmark_functions_edited/f4793.py
def f(*values: float) -> float: result = 0 for number in values: result += number return result assert f(1, 2) == 3
benchmark_functions_edited/f13357.py
def f(s, n, d): if n in s: return s[n] else: return d assert f({'a': 1}, 'b', 2) == 2
benchmark_functions_edited/f1694.py
def f(a): t = ((a << 18) ^ a) & 0xcccc0000 return a ^ t ^ ((t >> 18) & 0x3fff) assert f(0) == 0
benchmark_functions_edited/f10164.py
def f(data, start=0): return sum((x*x for x in data), start) assert f([]) == 0
benchmark_functions_edited/f9344.py
def f(uvdist, imres): psf_angle = 1. / uvdist return psf_angle / imres assert f(1, 1) == 1
benchmark_functions_edited/f11265.py
def f(vanilla_topk, fair_topk): topk = set(fair_topk) groundtruth = set(vanilla_topk) return len(topk.intersection(groundtruth)) / len(topk) assert f( [1, 2, 3], [1]) == 1
benchmark_functions_edited/f12613.py
def f(predicates, value): for num, pred in enumerate(predicates): if pred(value): return num raise IndexError assert f( [lambda x: x % 2 == 0, lambda x: x % 2 == 1], 13 ) == 1
benchmark_functions_edited/f12499.py
def f(p_num, norm_ref): p_norm = p_num / norm_ref return p_norm assert f(0, 300) == 0
benchmark_functions_edited/f3744.py
def f(x, y): return abs(x) + abs(y) assert f(1, 1) == 2
benchmark_functions_edited/f6759.py
def f(inp, brack, count): if inp == brack: if count != 1: print("No match") return 0 else: count -= 1 return 1 assert f("}", "(", 1) == 1
benchmark_functions_edited/f9068.py
def f(n): return n * (n + 1) * (2 * n + 1) assert f(0) == 0
benchmark_functions_edited/f3939.py
def f(rank): return max(1, rank - 160) assert f(161) == 1
benchmark_functions_edited/f6983.py
def f(s): try: pid = int(s) except ValueError: pid = int(s[:-1]) return pid assert f("1") == 1
benchmark_functions_edited/f11189.py
def f(gesamt, eins, vier, feinheit): steigung = 3./(vier-eins) achsenab = 4 - steigung * vier notenwert = steigung * gesamt + achsenab if notenwert <= 1: return 1 if notenwert >= 6: return 6 return round(round(notenwert*feinheit, 0)/feinheit, 2) assert f(65, 10, 30, 1) == 6
benchmark_functions_edited/f1681.py
def f(l): if "$" in str(l): return 1 else: return 0 assert f("a $15 b $30 c $40") == 1
benchmark_functions_edited/f12656.py
def f(prices): if not prices: return 0 max_profit = 0 buying_price = prices[0] for i in range(1, len(prices)): if (prices[i]-buying_price > 0): max_profit = max(max_profit, prices[i]-buying_price) else: buying_price = prices[i] return max_profit assert f( [7,6,4,3,1] ) == 0
benchmark_functions_edited/f11828.py
def f(callback, request, args): varnames = callback.__code__.co_varnames argcount = callback.__code__.co_argcount if argcount != 0 and varnames[0] == "request": return callback(request, *args) return callback(*args) assert f(lambda x=1: x, None, [1]) == 1
benchmark_functions_edited/f3978.py
def f(delta_val, eu_min, eu_max): return delta_val / (eu_max - eu_min) assert f(0, 20, 30) == 0
benchmark_functions_edited/f4100.py
def f(word, word_dict): try: return word_dict[word] except: return len(word_dict) assert f('world', {'hello': 0}) == 1
benchmark_functions_edited/f7267.py
def f(data): return min([elem for elem in data if elem > 0]) assert f([-5,-4,-3,2]) == 2
benchmark_functions_edited/f6310.py
def f(a, b): dim, nrg = len(a), 0.0 for d in range(dim): dist = a[d] - b[d] nrg += dist * dist return nrg assert f([0, 0, 0], [1, 1, 1]) == 3
benchmark_functions_edited/f9810.py
def f(arg1, arg2): a = 1 a += 2 return a assert f('bar', 1) == 3
benchmark_functions_edited/f3030.py
def f(s_i: int) -> int: return 3 * ((s_i // 9) % 3) + s_i % 3 assert f(28) == 1
benchmark_functions_edited/f6132.py
def f(config_document): votes = 0 for member in config_document["config"]['members']: votes += member['votes'] return votes assert f({"config": {"members": []}}) == 0
benchmark_functions_edited/f11330.py
def f(arr, x): if len(arr) == 0: return 0 m = len(arr) // 2 if arr[m] < x: return m + 1 + f(arr[m + 1:], x) elif x < arr[m] or (0 < m and arr[m - 1] == x): return f(arr[:m], x) else: return m assert f(list('hello'), 'l') == 2
benchmark_functions_edited/f12142.py
def f(x, coefs, n): ans = 0 power = len(coefs) - 1 for coef in coefs: ans += coef * x**power power -= 1 return ans assert f(2, [1], 1) == 1
benchmark_functions_edited/f13108.py
def f(index, shape, strides): d = len(shape) if d == 0: return 0 elif d == 1: return index[0] * strides[0] elif d == 2: return index[0] * strides[0] + index[1] * strides[1] return sum(index[i] * strides[i] for i in range(d)) assert f((1, 0), (2, 3), (1, 2)) == 1
benchmark_functions_edited/f3602.py
def f(a: tuple, b: tuple): return (b[0] - a[0] + 1) * (b[1] - a[1] + 1) assert f( (0, 0), (0, 1) ) == 2
benchmark_functions_edited/f4613.py
def f(n): total, k = 0, 1 while k <= n: total, k = total + k, k + 1 return total assert f(*[1]) == 1
benchmark_functions_edited/f12473.py
def f(percentage: int) -> int: if percentage < 20: # The device cannot be set to speed 5 (10%), so we should turn off the device # for any value below 20 return 0 nearest_10: int = round(percentage / 10) * 10 # Round to nearest multiple of 10 return round(nearest_10 / 100 * 50) assert f(5) == 0
benchmark_functions_edited/f13290.py
def f(value): if isinstance(value, str): # strings might have been saved wrongly as booleans value = value.lower() if value == "false": value = 0 elif value == "true": value = 1 elif value: value = int(float(value)) else: raise ValueError("empty string") else: value = int(float(value)) return value assert f("1.9") == 1
benchmark_functions_edited/f8457.py
def f(s1, s2): if len(s1) != len(s2): raise ValueError("Undefined for sequences of unequal length") return sum(el1 != el2 for el1, el2 in zip(s1, s2)) assert f(b'G', b'G') == 0
benchmark_functions_edited/f7999.py
def f(array): return min(array, key=abs) assert f([0, 1, 2, 3, 4]) == 0
benchmark_functions_edited/f81.py
def f(x, y, z): return x + y + z assert f(1, 1, 1) == 3
benchmark_functions_edited/f2464.py
def f(func, Xi, Xf): return func((Xi+Xf)/2)*(Xf-Xi) assert f(lambda x: x, 0, 2) == 2
benchmark_functions_edited/f11096.py
def f(x): if x == 'Government': return 1 elif x == 'Private': return 2 elif x == 'Self-employed': return 3 else: return 0 assert f("no") == 0
benchmark_functions_edited/f8324.py
def f(k_inv, m, private_key, s_1, q): try: q = q-1 s_2 = (k_inv * (m - (private_key * s_1))) % q return s_2 except Exception as e: print("Something went wrong: ",e.__str__()) return assert f(0, 0, 2, 2, 2) == 0
benchmark_functions_edited/f14183.py
def f(number: int) -> int: if number == 0: return 0 last_nbr: int = 0 next_nbr: int = 1 for _ in range(1, number): last_nbr, next_nbr = next_nbr, last_nbr + next_nbr return next_nbr assert f(3) == 2
benchmark_functions_edited/f2092.py
def gain_ctrl (val=None): global _gain_ctrl if val is not None: _gain_ctrl = val return _gain_ctrl assert f(0) == 0
benchmark_functions_edited/f1708.py
def f(ncore): return max(0, min(ncore - 1, 4)) assert f(2) == 1
benchmark_functions_edited/f3426.py
def f(movement_speed, movement_time): return movement_time * movement_speed * 1000 / 3600 assert f(0, 2) == 0
benchmark_functions_edited/f12488.py
def f(R,s,tau,w): return R*s+tau*w assert f(1,1,1,1) == 2
benchmark_functions_edited/f6472.py
def total (initial, *positionals, **keywords): count = initial for n in positionals: count += n for n in keywords: count += keywords[n] return count assert f(1, 2, 3) == 6
benchmark_functions_edited/f7223.py
def f(val, min, max): return val * (max - min) + min assert f(1, 0, 1) == 1
benchmark_functions_edited/f5365.py
def f(n): if n < 2: return n else: return f(n - 1) + f(n - 2) assert f(2) == 1
benchmark_functions_edited/f5450.py
def f(value, vmin, vmax): return vmin if value < vmin else vmax if value > vmax else value assert f(2, 1, 2) == 2
benchmark_functions_edited/f3227.py
def f(vlist): for val in vlist: if val != 0 and val != 1: return 0 return 1 assert f( [1,1,0] ) == 1
benchmark_functions_edited/f9439.py
def f(iterable): for item in iterable: if item is not None: return item return None assert f([1, None, 3]) == 1
benchmark_functions_edited/f328.py
def f(b): return 1 if b == 0 else (-1 if b == 1 else 1) assert f(20) == 1
benchmark_functions_edited/f4280.py
def f(power): answer = sum(list(map(int, str((2 ** power))))) return answer assert f(0) == 1
benchmark_functions_edited/f12881.py
def f(x_pos: int, distance: int): return x_pos - distance + 1 assert f(8, 2) == 7
benchmark_functions_edited/f5572.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/f10675.py
def f(q, on_court_width): if on_court_width < 250: q = 1 elif 250 <= on_court_width and on_court_width < 500: q = 2 elif 500 <= on_court_width and on_court_width < 750: q = 3 else: q = 4 return q assert f(1, 300) == 2
benchmark_functions_edited/f11538.py
def f(v1, v2, vH): while vH < 0: vH += 1 while vH > 1: vH -= 1 if 6 * vH < 1: return v1 + (v2 - v1) * 6 * vH if 2 * vH < 1: return v2 if 3 * vH < 2: return v1 + (v2 - v1) * ((2.0 / 3) - vH) * 6 return v1 assert f(1, 0, 0) == 1
benchmark_functions_edited/f5666.py
def f(m,n,buffer): if ((m % n) == 0): return n else: buffer.append(-1*(m // n)) return f(n, (m % n), buffer) assert f(12, 8, [3]) == 4
benchmark_functions_edited/f8575.py
def f(value): if value is None: return None if value == "": return None return int(value) assert f("1") == 1
benchmark_functions_edited/f3477.py
def f(idx): return (idx - 1) // 2 assert f(1) == 0
benchmark_functions_edited/f14084.py
def f(value, values): # Force the values to be sorted values = list(values) values.sort() for v in values: if value <= v: return v return values[-1] assert f(10, [1, 2, 3, 4]) == 4
benchmark_functions_edited/f4602.py
def f(n): return len(str(n)) assert f(-1234) == 5
benchmark_functions_edited/f13289.py
def f(iteration, step_size, base_lr, max_lr): bump = float(max_lr - base_lr)/float(step_size) cycle = iteration % (2 * step_size) if cycle < step_size: lr = base_lr + cycle*bump else: lr = max_lr - (cycle - step_size) * bump return lr assert f(0, 4, 3, 6) == 3
benchmark_functions_edited/f13024.py
def f(sFirst, sSecond): if sFirst == sSecond: return 0; sLower1 = sFirst.lower(); sLower2 = sSecond.lower(); if sLower1 == sLower2: return 0; if sLower1 < sLower2: return -1; return 1; assert f( "ab", "ab" ) == 0
benchmark_functions_edited/f13499.py
def f(bas, exp, n): t = 1 while (exp > 0): # for cases where exponent # is not an even value if (exp % 2 != 0): t = (t * bas) % n bas = (bas * bas) % n exp = exp // 2 return t % n assert f(2, 100, 4) == 0
benchmark_functions_edited/f1384.py
def f(lower, upper): return (upper - lower) / 2. assert f(0, 0) == 0
benchmark_functions_edited/f13035.py
def f(value): if value == "auto": pass elif value in [None, "None", "none"]: value = None elif isinstance(value, int) and 1 <= value: pass elif isinstance(value, str) and value.isdigit(): value = int(value) else: raise ValueError("n_workers can either be an integer >= 1, 'auto' or None.") return value assert f(2) == 2
benchmark_functions_edited/f7468.py
def f(panel_array): non_zero_panels = list(filter(lambda x: x != 0 , panel_array)) product = 1 for x in non_zero_panels: product *= x return abs(product) assert f( [1, 0, 1, 0, 1, 0]) == 1
benchmark_functions_edited/f11158.py
def f(path, alpha=1): return len(path) + alpha * sum( pair[0] != pair[1] for pair in zip(path[:-1], path[1:]) ) assert f(["down"]) == 1
benchmark_functions_edited/f6352.py
def f(y, f, t, h): k1 = f(t, y) k2 = f(t + 0.5 * h, y + 0.5 * h * k1) k3 = f(t + 0.5 * h, y + 0.5 * h * k2) k4 = f(t + h, y + h * k3) return y + h / 6 * (k1 + 2 * k2 + 2 * k3 + k4) assert f(0, lambda t, y: y, 0, 1) == 0
benchmark_functions_edited/f4028.py
def f(binaryString): # count the number of 0s in the subnet string return binaryString.count('0') assert f(bin(0x01)) == 1
benchmark_functions_edited/f5430.py
def f(lat1, long1, lat2, long2): return (abs(lat1 - lat2) + abs(long1 - long2)) * 100 # no, like, really badly assert f(3, 3, 3, 3) == 0
benchmark_functions_edited/f8403.py
def f(kernel_size: int, stride: int = 1, dilation: int = 1, **_) -> int: padding = ((stride - 1) + dilation * (kernel_size - 1)) // 2 return padding assert f(5, 1) == 2
benchmark_functions_edited/f10277.py
def f(list, item): if list == (): return 0 else: head, tail = list if head == item: return 1 + f(tail, item) else: return f(tail, item) assert f((), 0) == 0
benchmark_functions_edited/f14364.py
def f(bre, net_income, dividend): return (bre + net_income) - dividend assert f(0, 0, 0) == 0
benchmark_functions_edited/f9375.py
def f(location): if (".." in location): return 1 elif ("/" in location): return 1 elif (len(set(location))==1 and location[0]==' '): return 0 elif (len(set(location))==0): return 0 assert f(" / . ") == 1
benchmark_functions_edited/f3773.py
def f(x0, x1, y0, y1): return ((y1 - y0) / (x1 - x0)) assert f(0, 1, 3, 3) == 0
benchmark_functions_edited/f9533.py
def f(text): cur_floor = 0 for position, floor_change in enumerate(text, start=1): cur_floor += 1 if floor_change == '(' else -1 if cur_floor < 0: return position return -1 assert f('()())') == 5
benchmark_functions_edited/f13847.py
def f(s, t): m = len(s) n = len(t) costs = list(range(m + 1)) for j in range(1, n + 1): prev = costs[0] costs[0] += 1 for i in range(1, m + 1): c = min( prev + int(s[i-1] != t[j-1]), costs[i] + 1, costs[i-1] + 1, ) prev = costs[i] costs[i] = c return costs[-1] assert f( 'cat', 'dog', ) == 3