file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f2256.py
def f(l): if "?" in str(l): return 1 else: return 0 assert f("? is present? is also present") == 1
benchmark_functions_edited/f1336.py
def f(seq): return sum(map(bool, seq)) assert f(iter([])) == 0
benchmark_functions_edited/f600.py
def f(i): return 2 * i + 2 assert f(0) == 2
benchmark_functions_edited/f11804.py
def f(arg_str): arg_to_days = {'week': 7, 'month': 30, 'quarter': '120'} return arg_to_days.get(arg_str, 0) assert f(' ') == 0
benchmark_functions_edited/f103.py
def f(a, e): return a*(1+e) assert f(1, 0) == 1
benchmark_functions_edited/f14299.py
def f(outside_wave_height, max_surge): wave_height = min(outside_wave_height, 0.45*max_surge) return wave_height assert f(0, 2) == 0
benchmark_functions_edited/f10181.py
def f(C, size: int) -> int: known_numbers_sum = sum(C) expected_numbers_sum = (size/2) * (C[0] + C[-1]) return int(expected_numbers_sum - known_numbers_sum) assert f( [1, 2, 3, 5, 6], 6, ) == 4
benchmark_functions_edited/f3912.py
def f( *args ): result = 1 for arg in args: result = result and arg return int( result ) assert f(1,0,1,0) == 0
benchmark_functions_edited/f9031.py
def f(host): hostname, service = host caps = service.get("compute", {}) free_mem = caps.get("host_memory_free", 0) return free_mem assert f(("", {})) == 0
benchmark_functions_edited/f2329.py
def f(cents, denom): return denom * 2 **(cents/1200) assert f(0, 1) == 1
benchmark_functions_edited/f3078.py
def f(lst): if isinstance(lst, list): return 1 + max(f(item) for item in lst) return 0 assert f([[[True]]]) == 3
benchmark_functions_edited/f3211.py
def f(word, lst): n = 0 for elem in lst: if word == elem: n += 1 return n assert f(0, [0]) == 1
benchmark_functions_edited/f2168.py
def f(s, t): return sum([s[i] * t[i] for i in range(len(s))]) % 2 assert f(b'1', b'1') == 1
benchmark_functions_edited/f7215.py
def f(t, p0, p1, p2, p3): _p1 = p0 + (p1 - p0) * 1.5 _p2 = p3 + (p2 - p3) * 1.5 return _p1 + (_p2 - _p1) * t assert f(1, 0, 0, 2, 2) == 2
benchmark_functions_edited/f6057.py
def f(dbz): rain = ((10**(dbz/10))/200)**(5/8) if rain <= 1: return 0 else: return rain assert f(3) == 0
benchmark_functions_edited/f4282.py
def f(s1, s2): return sum(i != j for i, j in zip(s1, s2)) assert f('GGACTGA', 'GGACTGC') == 1
benchmark_functions_edited/f5287.py
def mean (p, include_zeros = True): d = s = 0 for c in p: s += c d += include_zeros or c != 0 return s//d assert f((1,1), False) == 1
benchmark_functions_edited/f11064.py
def f( x: float, r: float = 0, a: float = 0.88, l: float = 2.25 ) -> float: if x >= r: outcome = (x - r) ** a else: outcome = -l * (-(x - r)) ** a return outcome assert f(0) == 0
benchmark_functions_edited/f1194.py
def f(value, factor): return ((value) + (factor)-1) // (factor) assert f(0, 1) == 0
benchmark_functions_edited/f1115.py
def f(cb: float, cs: float) -> float: return cb + cs - 2 * cb * cs assert f(1, 0) == 1
benchmark_functions_edited/f11695.py
def f(a, b): while b: a, b = b, a%b return a assert f(99, 10) == 1
benchmark_functions_edited/f11015.py
def f(n, k): if 0 <= k <= n: ntok = 1 ktok = 1 for t in range(1, min(k, n - k) + 1): # changed from xrange ntok *= n ktok *= t n -= 1 return ntok // ktok else: return 0 assert f(10, -4) == 0
benchmark_functions_edited/f14191.py
def f(num): if num % 1 == 0: return int(num) else: raise ValueError('Expecting integer. Got: "{0}" ({1})' .format(num, type(num))) assert f(1) == 1
benchmark_functions_edited/f13829.py
def f(rating): #Uses a simple averaging formula. A refinement could be to replace this with #a weighted formula. For instance giving greater weight for more popular options. cumulative = 0 weight = 0 for i in range(1,6): cumulative += rating[i] * i weight += rating[i] if weight > 0 and cumulative > 0: return cumulative / weight return 0 assert f( [3,3,3,3,3,3] ) == 3
benchmark_functions_edited/f8478.py
def f(self, other): return self if isinstance(other, self.__class__) else self.value assert f(1, 2) == 1
benchmark_functions_edited/f2153.py
def f(array): return sum(array) / len(array) assert f([1, 2, 3, 4, 5]) == 3
benchmark_functions_edited/f1019.py
def f(lst): return max(set(lst), key=lst.count) assert f( [2,3,4,5] ) == 2
benchmark_functions_edited/f4762.py
def f(a: str, b: str) -> int: assert len(a) == len(b) return sum(int(i == j) for i, j in zip(a, b)) assert f( "GATTACA", "TATAGAT", ) == 2
benchmark_functions_edited/f4253.py
def f(i, k, l): if i == 65535: return 1 return 5 assert f(13, 0, 0) == 5
benchmark_functions_edited/f14276.py
def f(left, right): return left() or right() assert f(lambda: True, lambda: 1) == 1
benchmark_functions_edited/f3828.py
def f(fn, *args): try: return fn(*args) except TypeError: return fn(*args[:-1]) assert f(lambda a, b: a + b, 1, 2) == 3
benchmark_functions_edited/f13610.py
def f(key, task_directives, cloud_args_key='cloud_args'): return task_directives.get(cloud_args_key, dict()).get(key) assert f( 'arg_1', {'cloud_args': {'arg_1': 1, 'arg_2': 2}}, ) == 1
benchmark_functions_edited/f11415.py
def f(row): if row == 1: row = 2 elif row == 2: row =1 return row assert f(9) == 9
benchmark_functions_edited/f9136.py
def f(strand_a, strand_b): if len(strand_a) != len(strand_b): raise ValueError("Strands must be of equal length.") return [strand_a[index] != strand_b[index] for index in range(len(strand_b))].count(True) assert f("G", "C") == 1
benchmark_functions_edited/f9322.py
def f(queue, index=-1): x = queue.pop(index) queue.insert(0, x) return x assert f([1, 2]) == 2
benchmark_functions_edited/f8151.py
def f(s): index_list=[i for i in range(len(s)) if s[i] != " "] if not index_list: return 0 for i in range(len(index_list)-1,-1,-1): if index_list[i]-1 != index_list[i-1]: return index_list[-1]-index_list[i]+1 assert f(" Hello World ") == 5
benchmark_functions_edited/f12264.py
def f(db_list): if 'RefSeq' in db_list: return db_list.index('RefSeq') else: return None assert f(['not_refseq', 'RefSeq', 'not_refseq_either', 'RefSeq']) == 1
benchmark_functions_edited/f2274.py
def f(value, min_val, max_val): return max(min_val, min(value, max_val)) assert f(6, 3, 5) == 5
benchmark_functions_edited/f11932.py
def f(a): return (a[0][0] * (a[1][1] * a[2][2] - a[2][1] * a[1][2]) - a[1][0] * (a[0][1] * a[2][2] - a[2][1] * a[0][2]) + a[2][0] * (a[0][1] * a[1][2] - a[1][1] * a[0][2])) assert f( [[1, 2, 3], [4, 5, 6], [7, 8, 9.00000000000000000003]]) == 0
benchmark_functions_edited/f10819.py
def f(items, value): lo = 0 hi = len(items) - 1 while lo <= hi: mid = int((lo + hi) / 2) if items[mid] == value: return mid elif items[mid] < value: lo = mid + 1 else: hi = mid - 1 return -1 assert f([1, 4, 6, 7, 9], 9) == 4
benchmark_functions_edited/f3854.py
def f(num: int) -> int: total = 0 while num: total, num = total + num % 10, num // 10 return total assert f(124) == 7
benchmark_functions_edited/f8193.py
def f(c, RK, KdA=0.017, KdI=0.002, Kswitch=5.8): numer = RK * (1+(c/KdA))**2 denom = (1+(c/KdA))**2 + Kswitch * (1 + (c/KdI))**2 fc = (1 + (numer/denom))**-1 return fc assert f(0.5, 0, 0.017, 0.002, 5.8) == 1
benchmark_functions_edited/f937.py
def f(x, n): # type: (int, int) -> int return x // n * n assert f(0, 100) == 0
benchmark_functions_edited/f12483.py
def f(i,dx): integral = 0 for k in range(len(i)-1): if i == []: return 0 else: rect_area = i[k]*dx integral += rect_area return integral assert f([], 1) == 0
benchmark_functions_edited/f720.py
def f(zeta_2, zeta_1): return 2*zeta_2/(zeta_2+zeta_1) assert f(0, 1) == 0
benchmark_functions_edited/f2389.py
def f(base, expo): if expo == 0: return 1 return base * f(base, expo - 1) assert f(0, 5) == 0
benchmark_functions_edited/f13424.py
def f( available_space: int, vertical_direction: bool ) -> int: # For horizontal direction (x axis) preferred_number_of_labels = int(available_space / 15) if vertical_direction: # for y axis preferred_number_of_labels = int(available_space / 5) return max(2, min(20, preferred_number_of_labels)) assert f(20, False) == 2
benchmark_functions_edited/f3324.py
def f(data): n = len(data) if n < 1: raise ValueError('len < 1') return sum(data)/float(n) assert f([1]) == 1
benchmark_functions_edited/f2687.py
def f(a): if isinstance(a, (int, float)): return 1 else: return 0 assert f(set()) == 0
benchmark_functions_edited/f9381.py
def f(snippets, compiler_args=None, make_target=None): errs = 0 for snippet in snippets: errs += snippet.preprocess( user_args=compiler_args, make_target=make_target, ) return errs assert f( [], #compiler_args=[], #make_target=None, ) == 0
benchmark_functions_edited/f9021.py
def f(A): def count(A): ans = [0] * 52 for i, letter in enumerate(A): ans[ord(letter) - ord('a') + 26 * (i%2)] += 1 return tuple(ans) return len({count(word) for word in A}) assert f(["abcd", "cdab", "adcb", "cbad"]) == 1
benchmark_functions_edited/f4350.py
def f(n): i = 2 while i * i <= n: q, r = divmod(n, i) if r == 0: return i i += 1 return n assert f(7) == 7
benchmark_functions_edited/f5262.py
def f(return_t, risk_free_rate, sigma_t): return return_t - risk_free_rate + 1/2 * sigma_t assert f(0, 0, 0) == 0
benchmark_functions_edited/f8968.py
def f(L, value): val = next(iter( filter(lambda x: x[1] == value, reversed(list(enumerate(L)))))) if val: return(val[0]) else: raise(ValueError("{} is not in the list.".format(value))) assert f(list(range(5)), 3) == 3
benchmark_functions_edited/f8100.py
def f(arg): if arg is None: return None if isinstance(arg, str) and arg.lower() in ['none', 'null']: return None return int(arg) assert f(0) == 0
benchmark_functions_edited/f11378.py
def f(time, hop_size=3072, win_len=4096) -> int: return round((time - win_len / 2) / hop_size) assert f(4, 3, 2) == 1
benchmark_functions_edited/f13867.py
def f(lst): if len(lst) == 0: return None elif len(lst) == 1: return lst[0] elif all([entry is None for entry in lst]): return None return min([entry for entry in lst if entry is not None]) assert f(list(range(10))) == 0
benchmark_functions_edited/f3410.py
def f(genes, isoforms): return len(list(set([isoforms.get(gene) for gene in genes]))) assert f( ['gene1', 'gene2', 'gene3', 'gene4'], {'gene1': 'isoform1', 'gene2': 'isoform1', 'gene3': 'isoform1', 'gene4': 'isoform2'}) == 2
benchmark_functions_edited/f12129.py
def f(task: str) -> int: current_index = 0 steps = 0 data = [int(item) for item in task.strip().split("\n")] while 0 <= current_index < len(data): next_index = current_index + data[current_index] data[current_index] += 1 current_index = next_index steps += 1 return steps assert f( ) == 5
benchmark_functions_edited/f6993.py
def f(a, i): if getattr(a, '__getitem__'): try: return a[i] except KeyError: pass except IndexError: pass return None assert f((1, 2), 1) == 2
benchmark_functions_edited/f6537.py
def f( x ): if isinstance( x, tuple ): return x[ 0 ] else: return x assert f( 1 ) == 1
benchmark_functions_edited/f5014.py
def f(x, y): if x >= y: return 1.0 else: return 0.0 assert f('hello', 'hll') == 0
benchmark_functions_edited/f1744.py
def f(x: str) -> int: return int(x, base=0) assert f("0o0") == 0
benchmark_functions_edited/f368.py
def f(val, width): return val & ((1 << width) - 1) assert f(0, 10) == 0
benchmark_functions_edited/f10551.py
def f(d1, d2): if d1[2] > d2[2]: return 10000 if d1[2] == d2[2] and d1[1] > d2[1]: return 500 * (d1[1] - d2[1]) if d1[2] == d2[2] and d1[1] == d2[1] and d1[0] > d2[0]: return 15 * (d1[0] - d2[0]) return 0 assert f(list(map(int, "2015-07-01".split("-"))), list(map(int, "2015-07-11".split("-")))) == 0
benchmark_functions_edited/f2243.py
def f(side): # You have to code here # REMEMBER: Tests first!!! return pow(side,2) assert f(2) == 4
benchmark_functions_edited/f527.py
def f(n): return int(('{:.8f}'.format(n)).replace('0.', '')) assert f(0.0) == 0
benchmark_functions_edited/f3265.py
def f(n, precision): correction = 0.5 if n >= 0 else -0.5 return int(n / precision + correction) * precision assert f(4, 1) == 4
benchmark_functions_edited/f8028.py
def f(predicate, iterable): count = 0 for character in iterable: if predicate(character): count += 1 else: break return count assert f(lambda c: c == 'c', 'cccc') == 4
benchmark_functions_edited/f14123.py
def f(x): return \ -1 if x == '~' \ else 0 if x.isdigit() \ else 0 if not x \ else ord(x) if x.isalpha() \ else ord(x) + 256 assert f('6') == 0
benchmark_functions_edited/f12839.py
def f(string): if string is None: return 0 dict = {} max_length = 0 j = 0 for i in range(len(string)): if string[i] in dict: j = max(dict[string[i]], j) dict[string[i]] = i + 1 max_length = max(max_length, i - j + 1) return max_length assert f("abcdef") == 6
benchmark_functions_edited/f2613.py
def f(dry_run, fct, *args, **kwargs): if not dry_run: return fct(*args, **kwargs) assert f(False, lambda x: x + 1, 3) == 4
benchmark_functions_edited/f7257.py
def f(n: int) -> int: return (n.bit_length() + 7) // 8 assert f(7) == 1
benchmark_functions_edited/f2830.py
def f(a, b, mod): return a * pow(b, mod - 2, mod) % mod assert f(3, 2, 3) == 0
benchmark_functions_edited/f12014.py
def f(atNum): if atNum<=2: return 1 elif atNum<=10: return 2 elif atNum<=18: return 3 elif atNum<=36: return 4 elif atNum<=54: return 5 elif atNum<=86: return 6 else: return 7 assert f(4) == 2
benchmark_functions_edited/f152.py
def f(n): return len(str(n)) assert f(2000) == 4
benchmark_functions_edited/f5348.py
def f(N, i, j): return i + N * j assert f(5, 0, 0) == 0
benchmark_functions_edited/f1646.py
def f(x, a, b): return a*x + b assert f(-1, 1, 1) == 0
benchmark_functions_edited/f9123.py
def f(x, y0, y1, y2, y3): a2 = 3 * (y0 + y2 - y1 - y1) a3 = 3 * (y1 - y2) + y3 - y0 a1 = -a3 + 3 * (y2 - y0) return y1 + x * (a1 + x * (a2 + x * a3)) * 0.166666666666666666666666 assert f( 2, 0, 1, 2, 3) == 3
benchmark_functions_edited/f14332.py
def f(numA, numB): if numA > numB: return 1 if numA < numB: return -1 if numA == numB: return 0 assert f(5, 5) == 0
benchmark_functions_edited/f14383.py
def f(string1: str, string2: str) -> float: common = len([x for x, y in zip(string1, string2) if x == y]) return common / max([len(string1), len(string2)]) assert f( 'abcdefghij', 'xyza', ) == 0
benchmark_functions_edited/f10988.py
def f(a,b): if a == b: return 1 else: return 0 assert f(2, 3) == 0
benchmark_functions_edited/f14026.py
def f(x, y, dir=0): ux = x[1] - x[0] vx = x[2] - x[0] uy = y[1] - y[0] vy = y[2] - y[0] A = 0.5 * (ux * vy - uy * vx) if not dir: A = abs(A) return A assert f((0, 0, 0), (0, 0, 1), (0, 1, 0)) == 0
benchmark_functions_edited/f14005.py
def f(m, nidx): nv = -1 for i, v in m.items(): if i >= nidx: m[i] += 1 elif v > nv: nv = v m[nidx] = nv + 1 return nv + 1 assert f({}, 1) == 0
benchmark_functions_edited/f7224.py
def f(list): minv = list[0] for x in list: if x < minv: minv = x return minv assert f([3, 1, 2]) == 1
benchmark_functions_edited/f7824.py
def f(iterable, default=None): for x in iterable: if hasattr(iterable, "values"): return iterable[x] else: return x return default assert f(iter([1,2,3,4])) == 1
benchmark_functions_edited/f11460.py
def f(period): return 360 - 360/(23*3600+56*60+4)*period assert f(23*3600+56*60+4) == 0
benchmark_functions_edited/f2305.py
def f(radius, thickness, length): return (radius+thickness)**2/((radius+thickness)**2 - radius**2) assert f(0, 1, 1) == 1
benchmark_functions_edited/f658.py
def f(val): value = max(val, 0) return value assert f(1.0) == 1
benchmark_functions_edited/f8609.py
def f(f): def blocks(files, size=65536): while True: b = files.read(size) if not b: break yield b return sum(bl.count("\n") for bl in blocks(f)) assert f(open('test4.txt')) == 1
benchmark_functions_edited/f1885.py
def f(baudrate): CLOCK_HZ = 50e6 return round(CLOCK_HZ / baudrate) assert f(125e6) == 0
benchmark_functions_edited/f14027.py
def f(pos: int, text: str) -> int: ret = text.split() search = 0 argnum = 0 for i, elem in enumerate(ret): elem_start = text.find(elem, search) elem_end = elem_start + len(elem) search = elem_end if elem_start <= pos < elem_end: return i argnum = i return argnum + 1 assert f(3, "a b") == 2
benchmark_functions_edited/f8967.py
def f(inverse_substrate: float, vmax: float = 1., km: float = 5., ki: float = 5., conc_i: float = 5) -> float: return ((km*(1+(conc_i/ki)))/vmax)*inverse_substrate+(1/vmax) assert f(0, 1, 1, 1) == 1
benchmark_functions_edited/f6482.py
def f(distance, view): return 0 if distance > view else 1 assert f(0.01, 0.2) == 1
benchmark_functions_edited/f11876.py
def f(n): fibs = [0, 1] for i in range(2, n+1): fibs.append(fibs[i-1] + fibs[i-2]) return fibs[n] assert f(1) == 1
benchmark_functions_edited/f10384.py
def f(n): assert n >= 0 total = 0 current_term = 1 last_term = 1 while current_term <= n: if not current_term%2: total += current_term current_term, last_term = current_term + last_term, current_term return total assert f(3) == 2
benchmark_functions_edited/f9888.py
def f(set_one: list, set_two: list) -> int: return len(set(set_one) & set(set_two)) assert f( ["A", "B", "C"], ["C", "B", "A"]) == 3
benchmark_functions_edited/f11532.py
def f(cash: float, list: dict) -> float: total=float() for key,value in list.items(): total = total + value return (cash-total) assert f(1, {}) == 1
benchmark_functions_edited/f4377.py
def f(pos1: tuple, pos2: tuple) -> int: x1, y1 = pos1 x2, y2 = pos2 return abs(x1 - x2) + abs(y1 - y2) assert f( (0, 0), (1, 1) ) == 2
benchmark_functions_edited/f1162.py
def f(value, arg): return (value) * (arg - 1) assert f(1, 2) == 1