file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f10964.py
def f(x, m, M=None): if M is None: M = m[1] m = m[0] # bound x between min (m) and Max (M) return min(max(x, m), M) assert f(5, [1, 5]) == 5
benchmark_functions_edited/f12344.py
def f(ystar, mini, maxi): return ystar*(maxi - mini) + mini assert f(0, 0, 0.5) == 0
benchmark_functions_edited/f9592.py
def f(n): if n == 0: return 0 elif n == 1: return 1 else: return f(n-1) + f(n-2) assert f(5) == 5
benchmark_functions_edited/f14449.py
def f(a, x): e = "Item Not Found" for i in a: if i == x: print('Item found at index:', a.index(i)) return a.index(i) elif i != a: print(e) assert f([3, 5, 9, 12, 15], 12) == 3
benchmark_functions_edited/f13442.py
def f(front, left, right): change_direction = 0 F = (0 < front < 4) L = (0 < left < 4) R = (0 < right < 4) if 0 < front < 3: change_direction = -10 elif 1.0 <= left <= 2.0: # we're good change_direction = 0 elif 0 < left < 1.0: change_direction = -10 elif left > 2.0: change_direction = 10 return change_direction assert f(0, 2.0, 0) == 0
benchmark_functions_edited/f13162.py
def f(x): if x % 1 >= 0.5: return int(x) + 1 else: return int(x) assert f(3.0) == 3
benchmark_functions_edited/f4440.py
def f(s): r = 0 for c in s: r = (r << 8) | ord(c) return r assert f(b"") == 0
benchmark_functions_edited/f1410.py
def f(a): if(a == 0): return 1 else: return 0 assert f(0) == 1
benchmark_functions_edited/f14431.py
def f(a, b): def interleave(args): return "".join([x for t in zip(*args) for x in t]) return int("".join(interleave(format(x, "016b") for x in (a, b))), base=2) assert f(0, 0) == 0
benchmark_functions_edited/f2406.py
def f(value, default): if value is None: return default return value assert f(4, 12) == 4
benchmark_functions_edited/f7597.py
def f(string): try: return float(string) except ValueError: return string except: raise TypeError("Unknown error while trying to convert string into number.") assert f(1) == 1
benchmark_functions_edited/f6330.py
def f(i, n): return (i // 10**n) % 10 assert f(9, 2) == 0
benchmark_functions_edited/f2009.py
def f(cp): return cp if isinstance(cp, int) else cp[1] - 1 assert f(0) == 0
benchmark_functions_edited/f8570.py
def f(tup): if len(tup) == 2: i, j = tup return j-i if len(tup) == 3: i, j, k = tup return (j-i)*(k-i)*(k-j)/2 else: raise NotImplementedError assert f( (1,2) ) == 1
benchmark_functions_edited/f8502.py
def f(M, A_1, A_2, b, c_b_1): return (1/3)*(((1-A_1) - (1-A_2)*b) *M + (1-A_2)*b)*c_b_1 assert f(0, 1, 1, 1, 0.5) == 0
benchmark_functions_edited/f3543.py
def f(iterable): result = 1 for x in iterable: result *= x return result assert f([]) == 1
benchmark_functions_edited/f12328.py
def f(n: int, x: int) -> int: if n < 1: return 0 if x == 1: return 1 total: int = 2 if x <= n else 0 for i in range(2, n + 1): if x % i == 0: total += 1 return total assert f(5, 6) == 2
benchmark_functions_edited/f528.py
def f(line): return int(line.split(" ")[1]) assert f( "123456 2 3" ) == 2
benchmark_functions_edited/f13668.py
def f(coeff, x): f = 0 xi = 1 for ai in coeff: f += ai * xi xi *= x return f assert f([1], 2) == 1
benchmark_functions_edited/f13484.py
def f(D): # Runtime: O(n^2) n = len(D) if n == 0: return 0 L=[] for i in range(0,n): maxAppend = [] for j in range(0,i): if D[i] >= D[j]: if len(L[j]) > len(maxAppend): maxAppend = L[j] L.append(maxAppend + [D[i]]) return max(map(lambda s: len(s), L)) assert f([]) == 0
benchmark_functions_edited/f11221.py
def f(md): iaf = md.get("iaf", "tc") if iaf in ("tc", "ct"): return 2 elif iaf == "diff": return 1 elif iaf == "mp": return md.get("nphases", 8) elif iaf == "ve": return md.get("nenc", 8) assert f( {"iaf": "ve", "nenc": 8} ) == 8
benchmark_functions_edited/f314.py
def f(l_a): # return return 1 if l_a > 0 else -1 assert f(5) == 1
benchmark_functions_edited/f5565.py
def f(s): try: return int(s) except Exception: return ord(s) assert f(0) == 0
benchmark_functions_edited/f3985.py
def f(data: bytes) -> int: res = 0 for x in data: res = (res << 8) | x return res assert f(bytes()) == 0
benchmark_functions_edited/f9541.py
def f(ci, li, conc='ini19'): # import pdb; pdb.set_trace() if conc in ['ini19', 'reg19']: si = li*((1 + ci)**0.5) else: raise ValueError('Not implemented for this concurso: {}.'.format(conc)) return si assert f(0.3, 0) == 0
benchmark_functions_edited/f6598.py
def f(alist): answer = 0 temp = alist temp.reverse() for i in range(len(temp)): answer += 2**int(temp[i]) temp.reverse() return answer assert f(list("0110")) == 6
benchmark_functions_edited/f14380.py
def f(g): def dfs(g, t, seen): for v in g[t]: if v not in seen: seen.add(v) dfs(g, v, seen) seen = set() cnt = 0 for v in range(len(g)): if v in seen: continue dfs(g, v, seen) cnt += 1 return cnt assert f( [[1, 4], [0], [3, 6, 7], [2, 7], [0, 8, 9], [], [2, 10], [2, 3, 10, 11], [4, 9], [4, 8], [6, 7, 11], [10, 7]] ) == 3
benchmark_functions_edited/f7747.py
def f(m, off, length): clearNUm = 0 for i in range(off+1, length): clearNUm += 2**(i) return m & clearNUm assert f(2, 0, 4) == 2
benchmark_functions_edited/f3961.py
def f(avg_bias, sentences, k=4): avg_bias = round(float(avg_bias) / float(len(sentences)), k) return avg_bias assert f(1, [1]) == 1
benchmark_functions_edited/f7053.py
def f(dictionary, key): if not dictionary: return 0 if key in dictionary.keys(): return dictionary[key] else: return 0 assert f({1:1}, 1) == 1
benchmark_functions_edited/f329.py
def f(dns_name): return dns_name.count(".") assert f(u"") == 0
benchmark_functions_edited/f8525.py
def f(flux,index,emin,emax,escale): Denomin = pow(emax,-abs(index)+1.) -pow(emin,-abs(index)+1.) return flux*(-abs(index)+1)*pow(escale,-abs(index)) / Denomin assert f(1, 0, 0, 1, 1) == 1
benchmark_functions_edited/f13388.py
def f(row): a = max(0, len(row) - 1) a += sum(len(cell) for cell in row) return a assert f([]) == 0
benchmark_functions_edited/f3657.py
def f(value: str) -> float: try: int(value) except ValueError as e: return 0.0 return 1.0 assert f('0') == 1
benchmark_functions_edited/f5463.py
def f(a, b): return int((a or b) and not (a and b)) assert f(0, 1) == 1
benchmark_functions_edited/f10501.py
def f(month): months = { "Jan":1, "Feb":2, "Mar":3, "Apr":4, "May":5, "Jun":6, "Jul":7, "Aug":8, "Sep":9, "Oct":10, "Nov":11, "Dec":12 } return months[month] assert f("May") == 5
benchmark_functions_edited/f13795.py
def f(x0, x1, x2, y0, y1, y2): return (y0 * ((x1 - x2) / ((x0 - x1) * (x0 - x2))) + y1 * ((2 * x1 - x0 - x2) / ((x1 - x0) * (x1 - x2))) + y2 * ((x1 - x0) / ((x2 - x0) * (x2 - x1)))) assert f(0, 1, 2, 1, 2, 3) == 1
benchmark_functions_edited/f1997.py
def f(list1): length = len(list1) mid = length // 2 return mid assert f([1]) == 0
benchmark_functions_edited/f7858.py
def f(l): l_int = {'1': 0, '2': 1, '3': 2} return l_int[l] assert f("3") == 2
benchmark_functions_edited/f9009.py
def f(ip, prefix): return ip & (0xffffffff << (32 - prefix)) assert f(1, 32) == 1
benchmark_functions_edited/f4375.py
def f(y1, x1, y2, x2): distance = ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5 return distance assert f(10, 10, 10, 10) == 0
benchmark_functions_edited/f13706.py
def f(pattern, buf, iterator, start=0): while len(buf) <= start + len(pattern): buf.extend(next(iterator)) while True: pos = buf.find(pattern, start) if pos >= 0: assert pos >= start return pos else: start = len(buf) - len(pattern) - 1 buf.extend(next(iterator)) assert f(b'1', b'21', iter([])) == 1
benchmark_functions_edited/f8607.py
def f(partition): score = 0 total = 0 for hint in partition: score += len(partition[hint])**2 total += len(partition[hint]) return score / total assert f( {"b": {"c", "a", "d"}, "a": {"c", "b", "d"}, "d": {"c", "b", "a"}} ) == 3
benchmark_functions_edited/f1086.py
def f(vector1, vector2): return vector1[1] - vector2[1] assert f( ( 3, 4), (-3, -4)) == 8
benchmark_functions_edited/f13878.py
def f(string): i = 0 while string[i].isdigit(): i += 1 return int(string[0:i]) assert f( '0.001 c/s' ) == 0
benchmark_functions_edited/f6144.py
def f(link_counters): for processor in link_counters.values(): if 'send' in processor: return processor['send'] assert f({'a': {'send': 3}}) == 3
benchmark_functions_edited/f13133.py
def f(p_min,p_max,slope): upper_bound = 1/(slope+1)*p_max**(slope+1) lower_bound = 1/(slope+1)*p_min**(slope+1) return upper_bound-lower_bound assert f(1,2,0) == 1
benchmark_functions_edited/f12737.py
def f(time): if not time: return 0 return int(sum(abs(int(x)) * 60 ** i for i, x in enumerate(reversed(time.replace(',', '').split(':')))) * (-1 if time[0] == '-' else 1)) assert f('-0:0:0') == 0
benchmark_functions_edited/f14217.py
def f(iterable, wanted_object): for i, value in enumerate(iterable): if value is wanted_object: return i assert f((1, 2, 3, 1), 1) == 0
benchmark_functions_edited/f9169.py
def f(parameter, value): # if parameter is None: # return value # else: # return parameter return parameter or value assert f(2, 1) == 2
benchmark_functions_edited/f6595.py
def f(arr): sort = sorted(arr) if (sort[0] < sort[len(sort) - 1] and sort[0] < sort[len(sort) - 2]): n = sort[0] else: n = sort[len(sort) - 1] return n assert f([0, 1, 0]) == 1
benchmark_functions_edited/f8060.py
def f(hand): count=0 for i in hand: if hand[i]>0: count=count+hand[i] return count assert f({}) == 0
benchmark_functions_edited/f13294.py
def f(inputs, condition): return inputs[::-1] if condition else inputs assert f(1, 0) == 1
benchmark_functions_edited/f5421.py
def f(input): return round(input if input else 0.0, 2) assert f(0) == 0
benchmark_functions_edited/f13658.py
def f(val, divisor, round_up_bias=0.9): assert 0.0 <= round_up_bias < 1.0 new_val = max(divisor, int(val + divisor / 2.0) // divisor * divisor) return new_val if new_val >= round_up_bias * val else new_val + divisor assert f(2.9, 2) == 4
benchmark_functions_edited/f3331.py
def f(x): if x < 0: return -1 elif 0 < x: return +1 else: return 0 assert f(0.0) == 0
benchmark_functions_edited/f10984.py
def f(number): factorials = {0: 1, 1: 1, 2: 2, 3: 6, 4: 24, 5: 120, 6: 720, 7: 5040, 8: 40320, 9: 362880} number = str(number) result = 0 for char in number: result += factorials[int(char)] return result assert f(1) == 1
benchmark_functions_edited/f12837.py
def f(z, p): degree = len(p) - len(z) if degree < 0: raise ValueError("Improper transfer function. " "Must have at least as many poles as zeros.") return degree assert f(range(1), range(2)) == 1
benchmark_functions_edited/f14099.py
def f(x, k, p=None, Verbose=False): b = bin(k).lstrip('0b') r = 1 for i in b: rBuffer = r r = r**2 if i == '1': r = r * x if p: r %= p if Verbose: print(f"{rBuffer}^2 = {r} mod {p}") return r assert f(3, 0) == 1
benchmark_functions_edited/f3506.py
def f(shuf): return ["none", "edge", "be04", "be08", "be16", "smsh", "dist", "agno", ].index(shuf) assert f("agno") == 7
benchmark_functions_edited/f6049.py
def f(filename="", text=""): with open(filename, 'a') as f: return f.write(text) assert f( 'hello.txt', '' ) == 0
benchmark_functions_edited/f6441.py
def f(data): try: totrup = data['totrup'] except ValueError: # engine older than 2.9 totrup = 0 return totrup assert f( {'totrup': 1} ) == 1
benchmark_functions_edited/f2991.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/f6062.py
def f(point_a,control_a,control_b,point_b,t): return (1-t)**3*point_a + 3*(1.-t)**2*t*control_a + 3*(1-t)*t**2*control_b + t**3*point_b assert f(1,2,3,4,1) == 4
benchmark_functions_edited/f13924.py
def f(x: int, y: int = 1, *, subtract: bool = False) -> int: return x - y if subtract else x + y assert f(3, 4) == 7
benchmark_functions_edited/f2290.py
def f(n_bits): return 0 if n_bits >= 0 else -(2 ** (abs(n_bits))) assert f(1) == 0
benchmark_functions_edited/f7853.py
def f(number: int, bits: int) -> int: return number & ((1 << bits) - 1) assert f(3, 2) == 3
benchmark_functions_edited/f9214.py
def f(element): # If there's only one result in the list, then return that single result. if isinstance(element, list) and len(element) == 1: return element[0] else: return element assert f([0]) == 0
benchmark_functions_edited/f8384.py
def f(fst, snd): while snd > 0: fst, snd = snd, fst % snd return fst assert f(1, 6) == 1
benchmark_functions_edited/f11033.py
def f(arr, value): low = 0 high = len(arr) - 1 found = len(arr) while(low <= high): mid = (low + high) // 2 if arr[mid] < value: low = mid + 1 else: found = mid high = mid - 1 return found assert f([3, 5, 6, 7, 8, 9], 1) == 0
benchmark_functions_edited/f280.py
def f(box): return (box[2]-box[0])*(box[3]-box[1]) assert f( (0,1,1,2) ) == 1
benchmark_functions_edited/f3239.py
def f(z, u, v): return 3 * z * u * v - 2 * (z * u + u * v + z * v) + z + u + v assert f(1, 0, 1) == 0
benchmark_functions_edited/f3214.py
def f(n, minv=0): return max(n-1, minv) assert f(3) == 2
benchmark_functions_edited/f7876.py
def f(R, H, h): if 0 <= h <= H: r = R - (R * h) / H return r else: print("radius function: height is not in range") assert f(1, 3, 3) == 0
benchmark_functions_edited/f10617.py
def f(x, *funcs): for func in funcs: x = func(x) return x assert f(1, lambda x: x + 1, lambda x: x + 1) == 3
benchmark_functions_edited/f11714.py
def f(number: int = 36) -> int: reverse = 0 while number > 0: temp = number % 10 reverse = reverse * 10 + temp number = number // 10 return reverse assert f(1) == 1
benchmark_functions_edited/f8011.py
def f(x, coeffs): y = 0 for i in range(len(coeffs)): y += coeffs[i]*x**i return y assert f(1, [1]) == 1
benchmark_functions_edited/f2404.py
def f(intensity, efficiency): return intensity / (efficiency * 683) assert f(0, 0.8) == 0
benchmark_functions_edited/f12509.py
def f(c_max, step, iteration_threshold): return min(c_max * 1., c_max * 1. * (step) / iteration_threshold) assert f(0, 10, 1) == 0
benchmark_functions_edited/f10663.py
def f(str1, str2): assert(len(str1)==len(str2)) str1 = str1.upper() str2 = str2.upper() editDist = 0 for c1, c2 in zip(str1, str2): if c1!=c2: editDist +=1 return editDist assert f( "ABD", "ABC" ) == 1
benchmark_functions_edited/f7975.py
def f(args): if len(args) == 0: return None elif len(args) == 1: return args[0] else: return args assert f( [1]) == 1
benchmark_functions_edited/f4763.py
def f(x1, y1, x2, y2): return int(((x2-x1)**2 + (y2-y1)**2)**0.5 + 0.5) assert f(0, 0, 1, 2) == 2
benchmark_functions_edited/f14188.py
def f(frequencies): sec_dict = { 'minute': 60, 'hourly': 3600, 'daily': 86400, 'weekly': 604800, 'monthly': 2592000, 'quarterly': 7776000, 'yearly': 31536000 } secs = [] for freq, freq_data in frequencies.items(): secs.append(sec_dict[freq] * freq_data['retention']) if not secs: secs = [0] return max(secs) assert f({}) == 0
benchmark_functions_edited/f3850.py
def f(x, y): # NOTE: integer division with floor return x + (y - x) // 2 assert f(3, 7) == 5
benchmark_functions_edited/f5340.py
def f(seq): if (seq is None): return seq return len(seq) assert f(set([1,2])) == 2
benchmark_functions_edited/f10817.py
def f(row_num, col_num): row_group_num = row_num // 3 col_group_num = col_num // 3 box_num = 3 * row_group_num + col_group_num return box_num assert f(0, 4) == 1
benchmark_functions_edited/f13862.py
def f(a, b): if a is None: if b is None: return 0 return -1 if b is None: return 1 if a < b: return -1 if a > b: return 1 return 0 assert f(12, 12.0) == 0
benchmark_functions_edited/f2038.py
def f(coord, dmn, dpi): return int(round(coord * dmn * dpi)) assert f(0, 10, 20) == 0
benchmark_functions_edited/f12715.py
def f(gold_ote_sequence, pred_ote_sequence): n_hit = 0 for t in pred_ote_sequence: if t in gold_ote_sequence: n_hit += 1 return n_hit assert f( [1, 2, 3, 4, 5, 6, 7, 8], [1, 2, 3, 4, 5, 6, 7, 8] ) == 8
benchmark_functions_edited/f675.py
def f(c: int) -> float: return 1. / 3. * (c + 1) * (c - 1) assert f(1) == 0
benchmark_functions_edited/f4180.py
def f(x, y): dist = 0.0 for i in range(len(x)): dist += (x[i] - y[i])**2 return dist**0.5 assert f([1, 0], [0, 0]) == 1
benchmark_functions_edited/f7989.py
def f(ids, curdepth, maxdepth): assert curdepth <= maxdepth if isinstance(ids[0], list): res = max([f(k, curdepth + 1, maxdepth) for k in ids]) else: res = len(ids) return res assert f([1,2,[3],4], 0, 3) == 4
benchmark_functions_edited/f2255.py
def volAdjust ( vol, nPeriods = 252, alpha=2 ): return vol * nPeriods **(1/alpha) assert f(1, 1, 1.5) == 1
benchmark_functions_edited/f8029.py
def f(month): if month in [1,2,3]: return 1 elif month in [4,5,6]: return 2 elif month in [7,8,9]: return 3 else: return 4 assert f(12) == 4
benchmark_functions_edited/f9022.py
def f(p): return "?" if p is None else int(round(p * 10)) assert f(0.1) == 1
benchmark_functions_edited/f4796.py
def f(alist, key): for i in range(len(alist)): if alist[i] == key: return i return -1 assert f( [1, 1, 2, 3, 4, 5, 6, 6], 1 ) == 0
benchmark_functions_edited/f7400.py
def f(tree, seq): if len(seq) == 0: return None if len(seq) == 1: return tree[seq[0]] return f(tree[seq[0]], seq[1:]) assert f([1, 2], [-2]) == 1
benchmark_functions_edited/f9747.py
def f(cappa, head): npsh_req = .25 * cappa**(4/3) * head return npsh_req assert f(10, 0) == 0
benchmark_functions_edited/f5000.py
def f(json_file): try: return int(json_file['points']) except KeyError: return 0 assert f({'points': 2}) == 2
benchmark_functions_edited/f6528.py
def f(arr): if len(arr) == 0: return 0 if len(arr) == 1: return int(arr[0]) else: return int("".join(arr)) assert f(list("3")) == 3