file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f6353.py
def f(a, b): # print(a + b) return a + b assert f(1,2) == 3
benchmark_functions_edited/f12853.py
def f(n: int, m: int) -> int: i, k = 1, n while k != 1 and i < m: k = k * n % m i += 1 return i assert f(625, 7) == 3
benchmark_functions_edited/f6034.py
def f(s): return next(iter(s)) assert f(range(1, 10)) == 1
benchmark_functions_edited/f11979.py
def f(x,e,n): result = 1 # to get started s,q = x,e # s=current square, q=current quotient while q > 0: if q%2 == 1: result = (s * result) % n s = (s * s) % n # compute the next square q = q//2 # compute the next quotient return result assert f(3, 7, 5) == 2
benchmark_functions_edited/f6823.py
def f(start, end, test): while start < end: mid = (start + end) // 2 if test(mid): start = mid + 1 else: end = mid return start assert f(0, 10, lambda x: x == 2) == 3
benchmark_functions_edited/f9023.py
def f(num_str): result = 0 if '-' in num_str: val, dec = num_str.split('-') result = int(val) + int(dec)/10.0**(len(dec)) else: result = int(num_str) return result assert f('000') == 0
benchmark_functions_edited/f12544.py
def f(state): cell_id = 0 exponent = 8 for row in state: for column in row: if column == 1: cell_id += pow(2, exponent) exponent -= 1 return cell_id assert f( [[0, 0, 0, 0], [0, 0, 1, 0], [0, 0, 0, 0], [0, 0, 0, 0]]) == 4
benchmark_functions_edited/f3763.py
def f(x: float, min: float = 0, max: float = 1) -> float: return 1 if min <= x < max else 0 assert f(-1, 0, 0) == 0
benchmark_functions_edited/f11505.py
def f(l): LtoR_index = min([i for i in range(len(l)) if l[i] == 1] or [-1]) return len(l) - 1 - LtoR_index assert f([0, 1, 1]) == 1
benchmark_functions_edited/f12606.py
def f(value: int, multiple: int): # Find the division remainder mod = value % multiple # If the value is closer to the lower multiple, # round down. Otherwise, round up. if mod < multiple / 2: return value - mod else: return value + (multiple - mod) assert f(3, 3) == 3
benchmark_functions_edited/f573.py
def f(a, b): return a ^ ((a ^ b) & -(a < b)) assert f(f(f(1, 2), 1), 2) == 2
benchmark_functions_edited/f9134.py
def f(strings): if len(strings) < 2: return 0 common_elements = set(strings[0]) for s in strings[1:]: common_elements = common_elements.intersection(set(s)) return len(common_elements) assert f(["aa", "bb"]) == 0
benchmark_functions_edited/f6553.py
def f(pairs): total = 0 for c, i in pairs: if c in ["="]: total += i return total assert f(list(zip("123", [1, 0, 0]))) == 0
benchmark_functions_edited/f5102.py
def f(job_size): job_size = job_size.split('-') if len(job_size) > 1: return int(job_size[1]) else: return int(job_size[0]) assert f("1") == 1
benchmark_functions_edited/f6909.py
def f(x): # Start checking with 2, then move up one by one n = 2 while n <= x: if x % n == 0: return n n+=1 assert f(15) == 3
benchmark_functions_edited/f2425.py
def f(theta0, theta1, x): return theta0 + (theta1 * x) assert f(0, 1, 2) == 2
benchmark_functions_edited/f9570.py
def f(t, T): if(t > 0 and t < float(T/2)): return 1 elif(t == float(T/2)): return 0 elif(t > float(T/2) and t < T): return -1 raise IndexError("Out of function domain") assert f(3, 8) == 1
benchmark_functions_edited/f12005.py
def f(init_pos, coord): return max(map(lambda x, y: abs(x - y), coord, init_pos)) assert f( [1, 1, 1, 1, 1, 1, 1, 1], [1, 1, 2, 2, 2, 2, 1, 1] ) == 1
benchmark_functions_edited/f3947.py
def f(number): count = 0 while number: count += number & 1 number >>= 1 return count assert f(18) == 2
benchmark_functions_edited/f6083.py
def f(opts, default): for o in opts: if o: return o return default assert f( [False, 2, 3, 4, 5], 0) == 2
benchmark_functions_edited/f6520.py
def f(value, low1, high1, low2, high2): return float(value - low1) / (high1 - low1) * (high2 - low2) + low2 assert f(0, 0, 10, 0, 10) == 0
benchmark_functions_edited/f730.py
def f(z): return z*(1-z) assert f(0) == 0
benchmark_functions_edited/f7524.py
def f(quarters, dimes, nickles, pennies): total = 0.25 * quarters + 0.10 * dimes + 0.05 * nickles + 0.01 * pennies return total assert f(0, 0, 0, 0) == 0
benchmark_functions_edited/f9676.py
def f(iterator, default=None): try: return next(iterator) except StopIteration: return default assert f(iter([1, 2, 3])) == 1
benchmark_functions_edited/f14467.py
def f(hour, minute): slot_id = (hour - 6)*4 + int(minute/15) return slot_id assert f(6, 0) == 0
benchmark_functions_edited/f11468.py
def f(leaf_depth_sum, set_of_leaves): ave_depth = leaf_depth_sum/len(set_of_leaves) return ave_depth assert f(1, {0}) == 1
benchmark_functions_edited/f4287.py
def f(val: int) -> int: count = 0 while val > 1: count += 1 val >>= 1 assert val == 1 return count assert f(128) == 7
benchmark_functions_edited/f3962.py
def f(array: list, current_ptr: int) -> int: while len(array) <= current_ptr + 1: array.append(0) return current_ptr + 1 assert f(list(), 1) == 2
benchmark_functions_edited/f6583.py
def f(x, a, b): return a * x + b assert f(1, 0, 0) == 0
benchmark_functions_edited/f4904.py
def f(line): level = 0 for c in line: if c == "\t": level += 1 else: break return level assert f( "\t\t" ) == 2
benchmark_functions_edited/f4986.py
def f(x, y): if (x[0] <= y[-1] and x[-1] > y[0]) or (y[0] <= x[-1] and y[-1] > x[0]): return 1 else: return 0 assert f(range(10, 20), range(30, 40)) == 0
benchmark_functions_edited/f3036.py
def f(p1, p2, ofs1, ofs2): for n in range(p2): t = p1 * n - ofs1 if (t + ofs2) % p2 == 0: return t assert f(17, 21, 0, 0) == 0
benchmark_functions_edited/f9753.py
def f(target_distance: int, daily_distance: int): result_days = 0 current_distance = 0 while current_distance < target_distance: current_distance += daily_distance daily_distance *= 1.1 result_days += 1 return result_days assert f(5000, 1000) == 5
benchmark_functions_edited/f5313.py
def f(x): if (isinstance(x, str)) and ("[" in x): return x.replace("'", "").strip("][").split(", ") else: return x assert f(2) == 2
benchmark_functions_edited/f5305.py
def f(value, ifnone='~'): if value is None: return ifnone return value assert f(1) == 1
benchmark_functions_edited/f3575.py
def f(n): if n == 0: return 0 elif n == 1: return 1 else: return f(n - 1) + f(n - 2) assert f(3) == 2
benchmark_functions_edited/f7566.py
def f(dic, key): # Allow string or list keys if isinstance(key, str): return dic[key] if len(key) == 1: return dic[key[0]] else: return f(dic[key[0]], key[1:]) assert f( {'a': 1, 'b': 2}, 'a' ) == 1
benchmark_functions_edited/f11838.py
def f(someset, n, in_binary=False): if(in_binary): someset = [k for k in range(1, n + 1) if someset[k - 1]] return sum(2**(n - k) for k in someset) + 1 assert f(set(), 1) == 1
benchmark_functions_edited/f8103.py
def f(f, a, b, n): running_sum = 0 for i in range(n): running_sum += f(a + ((b-a)/float(n))*(i + .5) ) return running_sum * (b-a)/float(n) assert f(lambda x: 2, 1, 3, 4) == 4
benchmark_functions_edited/f3320.py
def f(string): product = 1 for i in string: product *= int(i) return product assert f("1") == 1
benchmark_functions_edited/f1108.py
def f(f, means, stddevs): normalized = (f/255 - means) / stddevs return normalized assert f(255, 0, 1) == 1
benchmark_functions_edited/f3500.py
def f(size=None): global _fontsize if size is not None: _fontsize = size return _fontsize assert f(1) == 1
benchmark_functions_edited/f7918.py
def f(x, y, serial=8): rackID = x + 10 level = rackID * y level += serial level *= rackID level = (level // 100) % 10 level -= 5 return level assert f(3, 5, 8) == 4
benchmark_functions_edited/f4235.py
def f(value): return round(value / 320 * 9) assert f(319.6) == 9
benchmark_functions_edited/f10656.py
def f(num, ndigits=0): if ndigits == 0: return int(num + 0.5) else: digit_value = 10 ** ndigits return int(num * digit_value + 0.5) / digit_value assert f(1.435) == 1
benchmark_functions_edited/f11448.py
def f(s): if not s or s[0] == "0": return 0 wo_last, wo_last_two = 1, 1 for i in range(1, len(s)): x = wo_last if s[i] != "0" else 0 y = wo_last_two if int(s[i-1:i+1]) < 27 and s[i-1] != "0" else 0 wo_last_two = wo_last wo_last = x+y return wo_last assert f(None) == 0
benchmark_functions_edited/f1583.py
def f(group, dones): return sum(dones[l] for l in group) assert f(frozenset((1, 3)), {1: True, 3: True, 5: True}) == 2
benchmark_functions_edited/f9918.py
def f(x, values): return values[0] * (1 - x) + values[1] * x assert f(0.5, (1, 3)) == 2
benchmark_functions_edited/f13548.py
def f(row): TWD = ['front-wheel drive', 'rear-wheel drive', 'fwd', 'rwd'] AWD = ['all-wheel drive', 'awd', '4x4', '4 x 4'] search_sources = [row['drivetrain'].lower(), row['trim'].lower(), row['description'].lower()] for search_source in search_sources: for awd in AWD: if awd in search_source: return 1 for twd in TWD: if twd in search_source: return 0 return 0 assert f( { 'drivetrain': 'AWD', 'trim': 'AWD', 'description': '4x4' } ) == 1
benchmark_functions_edited/f8015.py
def f(row, minimum, maximum): count = 0 for n in row: if minimum <= n <= maximum: count = count + 1 return count assert f(range(1, 100), 1, 1) == 1
benchmark_functions_edited/f135.py
def f(arr): return sum(arr) * 1.0 / len(arr) assert f([0, 5, 10]) == 5
benchmark_functions_edited/f4211.py
def f(pred, target): errs = (pred - target)**2 return errs assert f(0.1, 0.1) == 0
benchmark_functions_edited/f10742.py
def f(n: int, fib: list) -> int: if n == 0 or n == 1: return n if fib[n] != -1: return fib[n] fib[n] = f(n - 1, fib) + f(n - 2, fib) return fib[n] assert f(1, [0, 1]) == 1
benchmark_functions_edited/f2969.py
def f(num: int): ult_dig = num % 10 pri_dig = num // 10 return pri_dig + ult_dig assert f(2) == 2
benchmark_functions_edited/f4263.py
def f(x, gamma, mu, A, B): return 1 / (1 + (2 * (x - mu) / gamma) ** 2) * A + B assert f(0, 1, 0, 0, 1) == 1
benchmark_functions_edited/f1084.py
def f(*args): return args[-1] assert f(1,2,3,4,5) == 5
benchmark_functions_edited/f1933.py
def f(price, D, S, a, b, gamma, p_bar): return D(price, a, b) - S(price, gamma, p_bar) assert f(10, lambda p, a, b: 1, lambda p, gamma, p_bar: 1, 1, 1, 1, 1) == 0
benchmark_functions_edited/f9797.py
def f(s1, s2, i, j): if i == 0 or j == 0: return 0 elif s1[i - 1] == s2[j - 1]: return 1 + f(s1, s2, i - 1, j - 1) else: return max(f(s1, s2, i - 1, j), f(s1, s2, i, j - 1)) assert f( "hello", "hello", 5, 5) == 5
benchmark_functions_edited/f14489.py
def f(value: int) -> int: for log2_num_bytes in range(4): limit = 1 << ((1 << log2_num_bytes) * 8) if value < limit: return log2_num_bytes raise RuntimeError('Unable to calculate the number of bytes required for this value') assert f(2147483647) == 2
benchmark_functions_edited/f4433.py
def f(x, low, high): diff = high - low while x > high: x -= diff while x < low: x += diff return x assert f(0, 0, 200) == 0
benchmark_functions_edited/f10499.py
def f(start_miles, end_miles, gallons): mpg = abs(end_miles - start_miles) / gallons return mpg assert f(10, 20, 2) == 5
benchmark_functions_edited/f4833.py
def f(*parsers): if not parsers: return None for p in parsers[:-1]: p() return parsers[-1]() assert f(lambda: 1, lambda: None, lambda: 2) == 2
benchmark_functions_edited/f12253.py
def f(df_element: str, patterns: str) -> int: for pattern in patterns: if pattern.strip() in str(df_element).split(","): return 1 return 0 assert f("10", ["10", "20"]) == 1
benchmark_functions_edited/f6213.py
def f(aList, index): return (index+1) % len(aList) assert f(list(range(10)), 1) == 2
benchmark_functions_edited/f7214.py
def f(task, field): if field.startswith('data.'): result = task['data'].get(field[5:], None) else: result = task.get(field, None) return result assert f( { 'a': 1, }, 'a', ) == 1
benchmark_functions_edited/f14074.py
def f(xcoord, ycoord): xneg = bool(xcoord < 0) yneg = bool(ycoord < 0) if xneg is True: if yneg is False: return 2 return 3 if yneg is False: return 1 return 4 assert f(5, 5) == 1
benchmark_functions_edited/f8203.py
def f(i, n, m=1, annuity_due=False): base = (1 - 1 / (1 + i / m) ** (n * m)) / (i / m) return base * (1 + i / m) if annuity_due else base assert f(0.1, 0) == 0
benchmark_functions_edited/f11501.py
def f(x, derivative=False): if x > 0: if derivative: return 1 else: return x else: return 0 assert f(-1000, True) == 0
benchmark_functions_edited/f13041.py
def f(v): if v < 1: return 0 else: return 80 / (v / 5) assert f(0) == 0
benchmark_functions_edited/f5129.py
def f(a, b): if a and not b: return a elif b and not a: return b else: return max(a, b) assert f(2, 2) == 2
benchmark_functions_edited/f9680.py
def f(f, x, h): return (f(x + h) - f(x)) / h assert f(lambda x: x, 2, 0.5) == 1
benchmark_functions_edited/f9360.py
def f(stream, summary=None, comp_id="stop_count_records"): rec_counter = 0 for rec in stream: rec_counter += 1 if summary is not None: summary[comp_id] = rec_counter return rec_counter assert f([1,2,3], {"a": 4}) == 3
benchmark_functions_edited/f13501.py
def f(tp: int, fp: int, fn: int) -> float: return tp / (tp + fp + fn) assert f(100, 0, 0) == 1
benchmark_functions_edited/f11459.py
def f(a, x, lo=None, hi=None): if lo is None: lo = 0 if hi is None: hi = len(a) while lo < hi: mid = (lo + hi) // 2 if x > a[mid]: hi = mid else: lo = mid + 1 return lo assert f(range(10), 0, 0, 9) == 9
benchmark_functions_edited/f7143.py
def f(percentage: float) -> float: if percentage > 1: raise ValueError("volts expects a percentage between 0 and 1.") return percentage * 3.3 assert f(0.0) == 0
benchmark_functions_edited/f8830.py
def f(quality): if quality == "low": return 5 elif quality == "medium": return 6 elif quality == "good": return 7 elif quality == "high": return 8 return 6 assert f("low") == 5
benchmark_functions_edited/f8406.py
def f(index, *args): if index <= 0: return None try: return args[index-1] except IndexError: return None assert f(2, 1, 2, 3, 4) == 2
benchmark_functions_edited/f746.py
def f(value): return float(value.split(":")[-1]) assert f("1:2:3") == 3
benchmark_functions_edited/f6852.py
def f(s): val = 0 for c in s: val = (val << 4) + ord(c) tmp = val & 0xf0000000 if tmp != 0: val = val ^ (tmp >> 24) val = val ^ tmp return val assert f(u"") == 0
benchmark_functions_edited/f9659.py
def f(value): if value == -1: return value else: return float(value) assert f(1) == 1
benchmark_functions_edited/f2234.py
def f(label, prediction): return float((label - prediction)**2) assert f(4, 5) == 1
benchmark_functions_edited/f8215.py
def f(bots, x, y, z, grid_size): count = 0 for bot in bots: cur_distance = bot.distance_to(x, y, z) if (cur_distance - bot.radius) // grid_size <= 0: count += 1 return count assert f(list(), 0, 0, 0, 1) == 0
benchmark_functions_edited/f13856.py
def f(x, lam): return (x**lam - 1)/lam assert f(2, 1) == 1
benchmark_functions_edited/f14414.py
def f(timeline): best = 0 for value in list(timeline.values()): if value > best: best = value return best assert f( {'2020-01-01': 3, '2020-01-02': 1, '2020-01-03': 4, '2020-01-04': 1}) == 4
benchmark_functions_edited/f1786.py
def f(a): return a if a > 0 else -a assert f(-0) == 0
benchmark_functions_edited/f1850.py
def f(var1: int, var2: int) -> int: msg = "this is some string" print(msg) return var1 - var2 assert f(10, 5) == 5
benchmark_functions_edited/f3122.py
def f(x, default=0): if not x or not str(x).isdigit(): return default return int(x) assert f({}) == 0
benchmark_functions_edited/f4577.py
def f(x, y, origin, resolution, width): x = (x - origin[0]) / resolution y = (y - origin[1]) / resolution return y * width + x assert f(0.5, 0.0, (0.0, 0.0), 0.5, 2) == 1
benchmark_functions_edited/f4062.py
def f(char): if char == '0' or char == '': return 0 else: return 1 assert f(' 1') == 1
benchmark_functions_edited/f6905.py
def f(my_map, location): (current_x, current_y) = location # Map repeats infinitely on the X axis return my_map[current_y][current_x % len(my_map[current_y])] assert f( [ [0, 0, 0, 0], [0, 1, 1, 0], [0, 0, 0, 0], [0, 0, 0, 0], ], (0, 2), ) == 0
benchmark_functions_edited/f13119.py
def f(rect1, rect2): x_overlap = max(0, min(rect1[2], rect2[2]) - max(rect1[0], rect2[0])); y_overlap = max(0, min(rect1[3], rect2[3]) - max(rect1[1], rect2[1])); overlapArea = x_overlap * y_overlap; return overlapArea assert f( (1, 1, 4, 4), (5, 5, 7, 7) ) == 0
benchmark_functions_edited/f11497.py
def f(predicate, consequence, alternative=None): if predicate: return consequence else: return alternative assert f(False, 1, 0) == 0
benchmark_functions_edited/f10247.py
def f(list_id, all_lists_state): last_size = 0 for x in all_lists_state: if x['id'] == list_id: last_size = x['member_count'] return last_size assert f(123123, [{'id': 34345345,'member_count': 2}, {'id': 34345345,'member_count': 3}, {'id': 123123,'member_count': 5}]) == 5
benchmark_functions_edited/f10729.py
def f(set_one: list, set_two: list) -> int: return len(set(set_one)) * len(set(set_two)) assert f(set([]), set(["A", "B", "C"])) == 0
benchmark_functions_edited/f12949.py
def f(iterable): it = iter(iterable) first_item = next(it) try: next(it) except StopIteration: return first_item raise ValueError("iterable {!r} has more than one element.".format(iterable)) assert f(range(1)) == 0
benchmark_functions_edited/f11100.py
def f(y_true, y_pred): # initialize fp = 0 for yt, yp in zip(y_true, y_pred): if yt == 0 and yp == 1: fp += 1 return fp assert f( [1, 0, 0], [1, 0, 0] ) == 0
benchmark_functions_edited/f9526.py
def f(lst): maxlev = 0 def f(lst, level): nonlocal maxlev if isinstance(lst, list): level += 1 maxlev = max(level, maxlev) for item in lst: f(item, level) f(lst, 0) return maxlev assert f([[[[]]]]) == 4
benchmark_functions_edited/f224.py
def f(value): return value * 100 / 255 assert f(0x00) == 0
benchmark_functions_edited/f5713.py
def f(n): numStr = str(n) total = 0 for digit in numStr: total += int(digit) return total assert f('123') == 1 + 2 + 3 == 6
benchmark_functions_edited/f8789.py
def f(x,y,block_list): i=0 for block in block_list: if x>block.x and x<block.x + 20 and y>block.y and y<block.y + 20: break i+=1 return i assert f(100,100,[]) == 0