file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f2273.py
def f(r): return int(r.get("wedPunt", 0)) assert f(dict()) == 0
benchmark_functions_edited/f3048.py
def f(t: float) -> float: return 10 ** 6 / t assert f(1000000) == 1
benchmark_functions_edited/f9161.py
def f(items, predicate=None): for i, item in enumerate(items): if predicate is None or predicate(item): items.pop(i) return item assert f(list(range(4))) == 0
benchmark_functions_edited/f10130.py
def f(n: int, t: int) -> int: d = 1 << t r = n & ~(d - 1) # zero the last t bits of n if n & d != 0: return r else: return (r - 1) & ~(d - 1) assert f(2, 1) == 2
benchmark_functions_edited/f13323.py
def f(b, lend=False): if not lend: s = "".join("1" if v else "0" for v in b) else: s = "".join("1" if v else "0" for v in reversed(b)) return int(s, 2) assert f(tuple(False for _ in range(128))) == 0
benchmark_functions_edited/f13940.py
def f(t_int, n_reset, t_frame): t_ramp = t_int + (n_reset - 1)*t_frame return t_ramp assert f(0, 0, 0) == 0
benchmark_functions_edited/f13599.py
def f(set_of_tags_1, set_of_tags_2): one_and_two = len(set_of_tags_1.intersection(set_of_tags_2)) one_not_two = len(set_of_tags_1.difference(set_of_tags_2)) two_not_one = len(set_of_tags_2.difference(set_of_tags_1)) return min(one_and_two, one_not_two, two_not_one) assert f(set(), {'d', 'e', 'f'}) == 0
benchmark_functions_edited/f384.py
def f(direction): return int(abs(2 - direction) - 1) assert f(5) == 2
benchmark_functions_edited/f10724.py
def f(cfr_title): if cfr_title <= 16: return 1 elif cfr_title <= 27: return 4 elif cfr_title <= 41: return 7 else: return 10 assert f(26) == 4
benchmark_functions_edited/f11490.py
def f(param): try: # If this is a Parameter object, then return its _id attr. return param._id except AttributeError: # Otherwise, we assume it's an integer. return param assert f(0) == 0
benchmark_functions_edited/f14392.py
def f(n_territories): return max(3, n_territories // 3) assert f(16) == 5
benchmark_functions_edited/f7161.py
def f(array, ndim=1): for _ in range(ndim): assert len(array) == 1, len(array) array = array[0] return array assert f([1]) == 1
benchmark_functions_edited/f13897.py
def f(main_sign: list, text_sign: list) -> float: sign_calc = 0 for i, _ in enumerate(main_sign): sign_calc += abs(main_sign[i] - text_sign[i]) return sign_calc / 6 assert f( [1, 2, 3, 4, 5, 6], [1, 2, 3, 4, 5, 6]) == 0
benchmark_functions_edited/f7283.py
def f(num): dec = 0 while 0. < num < 1.: dec += 1 num *= 10 return dec assert f(1) == 0
benchmark_functions_edited/f4170.py
def f(angle, delta): return delta*round(angle/float(delta)) assert f(3, 4) == 4
benchmark_functions_edited/f11846.py
def f(total, x, y): shortest = min(len(x), len(y)) if not shortest: return 0 else: return total/shortest assert f(1, [1], []) == 0
benchmark_functions_edited/f85.py
def f(x, y): return (x + y) % 2 assert f(1, 0) == 1
benchmark_functions_edited/f4336.py
def f(data, size=8): parity = 0 for i in range(size): parity = parity ^ ((data >> i) & 1) return parity assert f(0x00000000) == 0
benchmark_functions_edited/f6780.py
def f(a: float, b: float) -> float: return b * b / a assert f(2, 2) == 2
benchmark_functions_edited/f852.py
def f(line: str) -> int: return line.find(line.lstrip()) assert f( "def foo():\n" ) == 0
benchmark_functions_edited/f5264.py
def f(level: int): if level == 0: return 0 xp = (5 * (level ** 2)) + (60 * level) + 100 return xp assert f(0) == 0
benchmark_functions_edited/f5148.py
def f(points): return sum((p[0]-lp[0])/100*(lp[1]+(p[1]-lp[1])/2.0)/100 for p, lp in zip(points[1:], points[:-1])) assert f(list(enumerate([0]))) == 0
benchmark_functions_edited/f13685.py
def f(v, l): for i in range(len(l)): if l[i] < v: prev = l[i - 1] prevDiff = prev - v curr = l[i] currDiff = v - curr if prevDiff < currDiff: return i-1 else: return i # If value larger than list values, return last list index return len(l) - 1 assert f(3, [3]) == 0
benchmark_functions_edited/f5161.py
def f(x_0, y_0, x_1, y_1): x_dist = x_0 - x_1 y_dist = y_0 - y_1 return(x_dist ** 2 + y_dist ** 2) ** 0.5 assert f(0, 0, 4, 0) == 4
benchmark_functions_edited/f3608.py
def f(node): if node is None: return 0 return node.value + f(node.next) assert f(None) == 0
benchmark_functions_edited/f1797.py
def f(words): return round(sum(len(word) for word in words) / len(words)) assert f(['one']) == 3
benchmark_functions_edited/f3730.py
def f(n, start=(0, 1)): def aux(n, a, b): if n > 0: return aux(n - 1, b, a + b) else: return a return aux(n, *start) assert f(0) == 0
benchmark_functions_edited/f6362.py
def f(x1, l1, x2, l2): return min([abs(x1 + l1 - x2), abs(x2 + l2 - x1), abs(x1 - x2)]) assert f(1, 1, 2, 1) == 0
benchmark_functions_edited/f5433.py
def f(num, modulus): order = 1 while True: newval = (num ** order) % modulus if newval == 1: return order order += 1 assert f(5, 3) == 2
benchmark_functions_edited/f2282.py
def f(a,b): if b == 0: return 0 return a // b assert f(0, 2) == 0
benchmark_functions_edited/f7714.py
def f(x, x_hats): return (x - x_hats)**2 assert f(0, 1) == 1
benchmark_functions_edited/f5297.py
def f(n): i = 2 while i * i <= n: if n % i: i += 1 else: n //= i return n assert f(40) == 5
benchmark_functions_edited/f8566.py
def f(base, p, mod): ans = 1 index = 0 while 1 << index <= p: if p & (1 << index): ans = (ans * base) % mod index += 1 base = (base * base) % mod return ans assert f(3, 3, 10) == 7
benchmark_functions_edited/f4745.py
def f(proportional_value, integral_value, derivative_value): return derivative_value + (proportional_value + integral_value) assert f(1, 1, 0) == 2
benchmark_functions_edited/f7146.py
def f(a, m): if a <= m // 2: return a return a - m assert f(1, 13) == 1
benchmark_functions_edited/f14254.py
def f( people, limit): people.sort() left=0 right= len(people)-1 boat_count=0 while(left<=right): if left==right: boat_count+=1 break if people[left]+people[right]<=limit: left+=1 right-=1 boat_count+=1 # print(f"left: {left} right: {right} boat_count: {boat_count}") return boat_count assert f( [1,2], 3) == 1
benchmark_functions_edited/f6467.py
def f(number1: int, number2: int) -> int: remainder: int = number1 % number2 return number2 if remainder == 0 else f(number2, remainder) assert f(5, 50) == 5
benchmark_functions_edited/f3526.py
def f(a, b): # https://docs.python.org/3.0/whatsnew/3.0.html#ordering-comparisons return (a > b) - (a < b) assert f((1, 2), (1, 2)) == 0
benchmark_functions_edited/f2299.py
def f(x=0, a0=0, a1=0, a2=0, a3=0, a4=0, a5=0) : v = a0 + x*(a1+x*(a2+x*(a3+x*(a4+a5*x)))) return v assert f(0) == 0
benchmark_functions_edited/f1016.py
def f(s): return len([x for x in s.split() if x]) assert f('one\ntwo\nthree\n\n\n\n\n\nfour\nfive\n') == 5
benchmark_functions_edited/f2635.py
def f(matrix): if type(matrix[0]) != list: return 1 return len(matrix[0]) assert f( [[1, 2, 3], [4, 5, 6]]) == 3
benchmark_functions_edited/f12144.py
def f(sortedList, target): low = 0 high = len(sortedList) - 1 while low <= high: mid = (high + low) // 2 if sortedList[mid] == target: return mid elif target < sortedList[mid]: high = mid -1 else: low = mid + 1 return low assert f(list(range(10)), 0) == 0
benchmark_functions_edited/f12086.py
def f(n) -> int: num_bits = 0 while n: num_bits += n & 1 n = n >> 1 print("n is:", n) return num_bits assert f(0b11) == 2
benchmark_functions_edited/f4598.py
def f(varray=[]): squares = map(lambda x: x*x, varray) return pow(sum(squares), 0.5) assert f([]) == 0
benchmark_functions_edited/f9010.py
def f(value: float) -> float: bbtu = value * 0.003412 return bbtu assert f(0) == 0
benchmark_functions_edited/f14189.py
def f(a: int, b: int, c: int) -> int: # pragma: no cover p = a + b - c pa = abs(p - a) pb = abs(p - b) pc = abs(p - c) if pa <= pb and pa <= pc: Pr = a elif pb <= pc: Pr = b else: Pr = c return Pr assert f(2, 0, 1) == 1
benchmark_functions_edited/f10930.py
def f(x, y, n): dist = abs(x - y) % n if dist >= 0.5 * n: dist = n - dist return dist assert f(0, 1, 3) == 1
benchmark_functions_edited/f3516.py
def f(string, sub_string): if sub_string not in string: return 0 else: return string.find(sub_string) assert f('abc', 'a') == 0
benchmark_functions_edited/f10370.py
def f(a, b, lattice, encoding): if lattice[a][b] == 1: return a elif lattice[b][a] == 1: return b else: n = len(lattice) entry = [row[a] * row[b] for row in lattice] return encoding.get(tuple(entry), n - 1) assert f(0, 1, [[1, 1], [0, 1]], {}) == 0
benchmark_functions_edited/f2796.py
def f(x): fx = x**9 + x**8 + x**7 + x**6 + x**5 + x**4 + x**3 + x**2 + x + 1 return fx assert f(-1) == 0
benchmark_functions_edited/f7036.py
def f(message, randint, exponent, modulus): return (message * pow(randint, exponent, modulus)) % modulus assert f(1, 100, 2, 3) == 1
benchmark_functions_edited/f5883.py
def f(n, mem): if n == 0: return 0 if n == 1: return 1 if mem[n] is not None: return mem[n] mem[n] = f(n-1, mem) + f(n-2, mem) return mem[n] assert f(0, [None, None, None]) == 0
benchmark_functions_edited/f8068.py
def f(path, data): with open(path, 'w') as handle: return handle.f(data) assert f('b.txt', 'bar') == 3
benchmark_functions_edited/f9605.py
def f(limit, values, weights): n = len(weights) dp = [0]*(limit+1) for i in range(n): for j in range(limit, weights[i]-1, -1): dp[j] = max(dp[j], values[i] + dp[j - weights[i]]) return dp[-1] assert f(9, [1, 2, 3], [1, 2, 3]) == 6
benchmark_functions_edited/f8119.py
def f(act): direction = (act % 18) // 6 act -= direction * 6 if direction == 1: direction = 2 elif direction == 2: direction = 1 act += direction * 6 return act assert f(f(1)) == 1
benchmark_functions_edited/f10227.py
def f(x, y, num_cols): idx = y + x * num_cols return idx assert f(0, 0, 7) == 0
benchmark_functions_edited/f11010.py
def f(value, align): if value % align != 0: return align - (value % align) else: return 0 assert f(8, 4) == 0
benchmark_functions_edited/f8160.py
def f(aps): num_classes = 0. sum_ap = 0. for _, v in aps.items(): sum_ap += v num_classes += 1 if num_classes == 0: return 0 return sum_ap/num_classes assert f({}) == 0
benchmark_functions_edited/f1639.py
def f(xind, yarr, frac): return yarr[xind] * (1 - frac) + yarr[xind + 1] * frac assert f(0, [1, 2, 3], 1) == 2
benchmark_functions_edited/f8994.py
def f(a, b, c): return abs(a[0] * (b[1] - c[1]) + b[0] * (c[1] - a[1]) + c[0] * (a[1] - b[1])) / 2 assert f( (0, 0), (0, 0), (1, 1) ) == 0
benchmark_functions_edited/f2337.py
def f(l): if ".htm" in str(l): return 1 else: return 0 assert f(b'index.rhtml') == 0
benchmark_functions_edited/f10.py
def f(x): return x/1000./3600. assert f(0) == 0
benchmark_functions_edited/f522.py
def f(value, prec=1): return round(float(value), prec) assert f('00000') == 0
benchmark_functions_edited/f1392.py
def f(metric, cutoff): if metric >= cutoff: return 1 return 0 assert f(50, 50) == 1
benchmark_functions_edited/f9517.py
def f(arr: list, left: int, mid: int, right: int) -> int: a, b, c = arr[left], arr[mid], arr[right] if (a-b)*(b-c) > 0: return mid if (a-b)*(a-c) > 0: return right return left assert f(list(range(10)), 0, 6, 3) == 3
benchmark_functions_edited/f8920.py
def f(x): return int(isinstance(x, list)) and len(x) and 1 + max(map(_depth_count, x)) assert f([[1, 2], [3, 4, [5, [6]]], 7]) == 4
benchmark_functions_edited/f5945.py
def f(b, e, MOD): if (e == 0): return 1 if e == 1: return b % MOD rec = f(b, e >> 1, MOD) return ((rec * rec * f(b, (e & 1), MOD)) % MOD) assert f(3, 2, 2) == 1
benchmark_functions_edited/f12939.py
def f(complexity): if not complexity: return 0 return min(complexity, key=lambda x: x[1])[1] assert f([(1, 1), (2, 3), (3, 4)]) == 1
benchmark_functions_edited/f7816.py
def f(start, end, divisor): result = 0 counter = start while counter <= end: if counter % divisor == 0: result += counter counter += 1 return result assert f(1, 10, 11) == 0
benchmark_functions_edited/f4504.py
def f(item): _, viewlet = item try: return int(viewlet.weight) except (TypeError, AttributeError): return 0 assert f(('', {'weight': 0})) == 0
benchmark_functions_edited/f434.py
def f(x,y): if(y==0): return 1 return x *f(x, y - 1) assert f(3, 2) == 9
benchmark_functions_edited/f13550.py
def f(key, dictionary): parts = key.split('.') first = parts.pop(0) if isinstance(dictionary, list): value = dictionary[int(first)] else: value = dictionary[first] return value if not parts else f('.'.join(parts), value) assert f(u"foo", {u"foo": 3}) == 3
benchmark_functions_edited/f12204.py
def f(POS): i = 0 no_var = 0 # As expression is standard so total no.of alphabets will be equal to alphabets before first '.' character while (POS[i]!='.'): # checking if character is alphabet if (POS[i].isalpha()): no_var+= 1 i+= 1 return no_var assert f('a...a..') == 1
benchmark_functions_edited/f8849.py
def f(value, minimum, maximum): if minimum > maximum: minimum, maximum = maximum, minimum if value < minimum: return minimum if value > maximum: return maximum return value assert f(2, 2, 1) == 2
benchmark_functions_edited/f11352.py
def f(bit_config): length_size = 0 if bit_config['field_type'] == "LLVAR": length_size = 2 elif bit_config['field_type'] == "LLLVAR": length_size = 3 return length_size assert f( {'field_type': "LLLVAR", 'length': 3}) == 3
benchmark_functions_edited/f13052.py
def f(threat_level_id: str) -> int: if threat_level_id in ('1', '2'): return 3 if threat_level_id == '3': return 2 if threat_level_id == '4': return 0 return 0 assert f('1') == 3
benchmark_functions_edited/f5440.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: 1, 1, 1) == 1
benchmark_functions_edited/f12228.py
def f(coverage, cutoffs, numColors) : numIntervals = min(numColors, len(cutoffs)+1) for c in range(numIntervals-1) : if coverage >= cutoffs[c] : return c return numIntervals-1 assert f(0.0, [0.0, 25.0], 3) == 0
benchmark_functions_edited/f1598.py
def f(num): if not num: return 0 return 1 if num > 0 else -1 assert f(float("inf")) == 1
benchmark_functions_edited/f7016.py
def f(run, deco): if run: return deco else: def do_nothing(func): return func return do_nothing assert f(True, 1) == 1
benchmark_functions_edited/f14465.py
def f(op, exp): op = op.lower() if op.startswith('vldr'): return 4 if exp.startswith('s') else 8 if op.startswith('ldr'): if len(op) < 4 or op[3] == '.': return 4 if op[3] == 'd': return 8 if op[3] == 'h' or (op[3] == 's' and op[4] == 'h'): return 2 return 1 return 4 assert f( "vldr", "s3") == 4
benchmark_functions_edited/f14330.py
def f(a,p): if p == 2: if a%2 == 0: return 0 if a%8 in (1,7): return 1 return -1 out = pow(a,(p-1)//2,p) if out == 1: return 1 if out == 0: return 0 else: return -1 assert f(9,2) == 1
benchmark_functions_edited/f3459.py
def f(x): return (1 - x[0]) ** 2 + 105 * (x[1] - x[0] ** 2) ** 4 assert f([1, 1]) == 0
benchmark_functions_edited/f2186.py
def f(argv): print("This is a boilerplate") ## NOTE: indented using two tabs or 4 species return 0 assert f(None) == 0
benchmark_functions_edited/f1870.py
def f(num): return num if num <= 1 else f(num - 1) + f(num - 2) assert f(2) == 1
benchmark_functions_edited/f1650.py
def f(seq): p = 1 for a in seq: p *= a return p assert f([1]) == 1
benchmark_functions_edited/f9854.py
def f(array, left, right): pivot = array[right] i = left - 1 for j in range(left, right): if array[j] < pivot: i += 1 array[i], array[j] = array[j], array[i] array[right], array[i + 1] = array[i + 1], array[right] return i + 1 assert f([3, 2, 1], 0, 2) == 0
benchmark_functions_edited/f997.py
def f(y,alpha): return ( pow( y, alpha ) ) assert f(1,3) == 1
benchmark_functions_edited/f6654.py
def f(code): if code in [1, 2]: cnc_loc = 0 elif code in [3, 4]: cnc_loc = 1 elif code in [5, 6]: cnc_loc = 2 else: cnc_loc = 3 return cnc_loc assert f(19) == 3
benchmark_functions_edited/f13455.py
def f(action, power): desired_power = power if 'power' in action: if action['power'] == 'toggle': # This could probably be simplified, given it's either 1 or 0 if power > 0: desired_power = 0 else: desired_power = 1 else: desired_power = int(action['power']) return desired_power assert f(dict(), 0) == 0
benchmark_functions_edited/f3057.py
def f(x: float, exp: float = 2.0, mult: float = 3) -> float: return x ** exp if x > 0 else -((x / (-mult)) ** exp) assert f(0, 1.5, 1) == 0
benchmark_functions_edited/f2711.py
def f(s): if s is not None: return int( s.strip() ) return None assert f('0') == 0
benchmark_functions_edited/f7778.py
def f(value, enum_klass): try: return enum_klass(value) except ValueError: return value assert f(5, int) == 5
benchmark_functions_edited/f3808.py
def f(left, right) -> int: common = set(left) & set(right) return len(common) assert f( [1, 2, 3], [1, 2, 3] ) == 3
benchmark_functions_edited/f13664.py
def f(start, end): return len([x for x in range(start, end+1) if "5" not in str(x)]) assert f(1, 5) == 4
benchmark_functions_edited/f8441.py
def f(op_list): ops = op_list[::-1] # reverse the list; after all, it's matrix mult. result = ops[0] for op in ops[1:]: result = result * op return result assert f([0, 0, 0, 0, 0]) == 0
benchmark_functions_edited/f8364.py
def f(v): try: return int(v) except (ValueError, TypeError): pass try: return float(v) except (ValueError, TypeError): pass return v assert f(1) == 1
benchmark_functions_edited/f11109.py
def f(stretch: float, ngates: int) -> int: return int(round(ngates * (stretch - 1.0) / 2.0)) assert f(1.0, 1) == 0
benchmark_functions_edited/f13368.py
def f(number): if number in (0,1): return number if number < 4: return 1 x = number while True : root = 0.5 * (x + (number / x)) if (abs(root - x) < 1) : return round(root) x = root assert f(0) == 0
benchmark_functions_edited/f873.py
def f(pair): return pair[0]*pair[1] assert f( (2, 3) ) == 6