file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f1993.py
def f(axis): return {0: 0, 1: 2, 2: 3, 3: 1}.get(axis) assert f(3) == 1
benchmark_functions_edited/f2802.py
def f(choice_1, choice_2): return choice_1 if choice_1 is not None else choice_2 assert f(1, 2) == 1
benchmark_functions_edited/f10836.py
def f(s: str) -> int: roman_dict = { 'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000, 'IV': 4, 'XL': 40, 'XC': 90, 'CD': 400, 'CM': 900, } return True assert f('one') == 1
benchmark_functions_edited/f10623.py
def f(p1, p2, p3): # Compute the z-coordinate of the vectorial product p1p2 x p2p3 z = (p2[0] - p1[0]) * (p3[1] - p1[1]) - (p2[1] - p1[1]) * (p3[0]- p1[0]) return 0 if z == 0 else int(z / abs(z)) assert f((1, 2), (2, 3), (3, 4)) == 0
benchmark_functions_edited/f10208.py
def f(N, p): v = 1 i = 1 tosum = [] _N = float(N) while v >= 1: v = int(_N / float(p ** i)) if v < 1: break tosum.append(v) i += 1 return sum(tosum) assert f(0, 1) == 0
benchmark_functions_edited/f11169.py
def f(h, kr, rho, cp, r): py = h / (kr * rho * cp * r) return py assert f(1, 1, 1, 1, 1) == 1
benchmark_functions_edited/f4045.py
def f(iterable, pred=bool): return sum(map(pred, iterable)) assert f([True, False, True]) == 2
benchmark_functions_edited/f7767.py
def f(values, precision=1e-16): for i in range(1, len(values)): difference = values[i] - values[i-1] if difference > precision: return difference assert f( [0, 1, 2, 3, 4, 5, 6, 7, 8] ) == 1
benchmark_functions_edited/f11111.py
def f(n, lar): if n < lar: return lar else: if n % 10 > lar: lar = n % 10 return f(int(n/10), lar) assert f(9876, 0) == 9
benchmark_functions_edited/f9992.py
def f(corpus, keywords): mark = 0 for keyword in keywords: if keyword in corpus: mark += corpus[keyword] return(mark) assert f( {"python": 1, "java": 3, "go": 1, "c++": 2}, ["python", "java", "go"] ) == 5
benchmark_functions_edited/f11360.py
def f(knapsack_max_weight, items): values = [0 for _ in range(knapsack_max_weight+1)] for item in items: for weight in range(knapsack_max_weight, item.weight-1, -1): values[weight] = max(values[weight], values[weight - item.weight] + item.value) return values[-1] assert f(0, []) == 0
benchmark_functions_edited/f2125.py
def f(row): return int(row[0].split('_')[0].split('/')[1]) assert f(['1/2', '2/3', '2/4']) == 2
benchmark_functions_edited/f5237.py
def f(character): if(character == ' '): return 0 elif(character == '+'): return 1 elif(character == '#'): return 2 assert f("+") == 1
benchmark_functions_edited/f7649.py
def f(x: int, y: int = 0, width: int = 0, z: int = 0, height: int = 0): return (z * width * height) + (y * width) + x assert f(1, 0, 0) == 1
benchmark_functions_edited/f8462.py
def f(range_1, range_2): range_1 = range_1 if range_1[1] > range_1[0] else range_1[::-1] range_2 = range_2 if range_2[1] > range_2[0] else range_2[::-1] return min(range_1[1], range_2[1]) - max(range_1[0], range_2[0]) assert f( (1, 5), (1, 5) ) == 4
benchmark_functions_edited/f8439.py
def f(n, memoize): if n < 3: return n if memoize[n] >= 0: return memoize[n] else: memoize[n] = f(n-1, memoize) + f(n-2, memoize) return memoize[n] assert f(0, []) == 0
benchmark_functions_edited/f4393.py
def f(features, sequence_length = 1): if sequence_length == 1: return len(features) return len(features) // sequence_length assert f( [1, 2, 3, 4] ) == 4
benchmark_functions_edited/f12029.py
def f(string1, string2): if len(string1) != len(string2): raise ValueError("Undefined for sequences of unequal length") return sum([bin(b1 ^ b2).count('1') for b1, b2 in zip(string1, string2)]) assert f(b"", b"") == 0
benchmark_functions_edited/f10954.py
def f(v, unit_size=2): return (v + unit_size - 1) // unit_size * unit_size assert f(5, 4) == 8
benchmark_functions_edited/f12761.py
def f(arr, key): for i in range(len(arr)): if arr[i] == key: return i return -1 assert f(list(range(10)), 1) == 1
benchmark_functions_edited/f3831.py
def f(Aniso, Fluo): return (2/3)*Fluo*(Aniso+0.5) assert f(0, 0) == 0
benchmark_functions_edited/f2982.py
def f(diff): if diff['action'] == 'delete': return 1 else: return 2 assert f( {'action': 'delete', 'path': '/a/c', 'data': None} ) == 1
benchmark_functions_edited/f7052.py
def f(x, y): return (x**2 + y - 11)**2 + (x + y**2 - 7)**2 assert f(3, 2) == 0
benchmark_functions_edited/f554.py
def f(arr): return sum([elem for elem in arr if elem >0]) assert f([-10, -10, -10, -10, -10, -10, -10, -10, -10, -10]) == 0
benchmark_functions_edited/f10121.py
def f(n): x = 1 # This Will Be 0 If Not Prime for i in range(2, n): # Divide By Any Number if n % i == 0: # If Divisible By Any Number x = 0 # Take x As 0 break else: x = 1 # else Take x As 1 return x assert f(2) == 1
benchmark_functions_edited/f6259.py
def f(subidx, subncol, cellsize, ncol): r = (subidx // subncol) // cellsize c = (subidx % subncol) // cellsize return r * ncol + c assert f(0, 3, 3, 3) == 0
benchmark_functions_edited/f12957.py
def f(argumentValues,l,h): nOcc = argumentValues.count(1) if nOcc >= l and nOcc <= h: outcome = 1 else: outcome = 0 return outcome assert f( [1, 1, 1], 1, 3) == 1
benchmark_functions_edited/f6080.py
def f(x): try: ret = len(x) except TypeError: ret = False return ret assert f(False) == 0
benchmark_functions_edited/f8909.py
def myMax (L): # INSERT CODE HERE maxint = L[0] for i in range (1,len(L)): if L[i] > maxint: maxint = L[i] return maxint print(f(randList())) assert f([1, 2, 3, 4]) == 4
benchmark_functions_edited/f13468.py
def f(coord_a, coord_b): diff_x = abs(float(coord_a[0]) / coord_b[0] - 1) diff_y = abs(float(coord_a[1]) / coord_b[1] - 1) # print coord_a, coord_b, diff_x, diff_y return max(diff_x, diff_y) assert f( [0, 0], [2, 1]) == 1
benchmark_functions_edited/f12586.py
def f(bw, bf, nodes=1, depth=1, max_depth=16, total=1): if depth == max_depth: return total n = nodes * bf total += n n = min(n, bw) return f(bw, bf, n, depth + 1, max_depth, total) assert f(2, 1, 1, 1, 2, 1) == 2
benchmark_functions_edited/f10078.py
def f(elemento, lista): index = 0 while True: try: if lista[index] == elemento: return index except IndexError: return -1 index += 1 assert f(1, [1]) == 0
benchmark_functions_edited/f11991.py
def f(in_list): size = len(in_list) i = 0 steps = 0 while True: next_step = i + in_list[i] if in_list[i] >= 3: in_list[i] -= 1 else: in_list[i] += 1 if size <= next_step or next_step < 0: return steps + 1 steps += 1 i = next_step assert f(list(range(1, 20))) == 5
benchmark_functions_edited/f13918.py
def f(s): if s.step not in (None, 1): raise ValueError("Slices may not define a step other than 1 or None.") if s.stop < s.start: raise ValueError("Slice must not be decreasing.") return s.stop - s.start assert f(slice(6, 7)) == 1
benchmark_functions_edited/f810.py
def f(plato): return 259.0 / (259.0 - float(plato)) assert f(0) == 1
benchmark_functions_edited/f7955.py
def f(x): a = 10 b = 0.5 s = 0.2 g = 0.18*x + s f = (1/(b*g)**2 - a/(b*g)) * 0.1 *(1-x) / a return min(1, - 4.82*f) assert f(1) == 0
benchmark_functions_edited/f12505.py
def f(n: int, m: int) -> int: if not n: return m if not m: return n while n: n, m = m % n, n return m assert f(2, 4) == 2
benchmark_functions_edited/f2962.py
def f(a, b): if b > a: return f(b, a) if a % b == 0: return b return f(b, a % b) assert f(36, 30) == 6
benchmark_functions_edited/f2768.py
def f(dist: int) -> float: return ((1 + 8 * dist) ** 0.5 - 1) / 2 assert f(0) == 0
benchmark_functions_edited/f7449.py
def f(num1, num2): return(num1 + num2) assert f(2, 3) == 5
benchmark_functions_edited/f2488.py
def f(m: int) -> int: return ((m - 1) // 3) + 1 assert f(5) == 2
benchmark_functions_edited/f3877.py
def f(x, *p): return p[0] * x + p[1] assert f(0, -1, 1) == 1
benchmark_functions_edited/f12412.py
def f(r3d_kpc, n0, r_c, beta): return n0 * (1 + (r3d_kpc / r_c)**2)**(-3.0*beta/2.0) assert f(0, 1, 1, 1) == 1
benchmark_functions_edited/f6749.py
def f(s): s_lower = s.lower() return \ s_lower.startswith('ldap://') or \ s_lower.startswith('ldaps://') or \ s_lower.startswith('ldapi://') assert f(u'https://foo') == 0
benchmark_functions_edited/f1143.py
def f(pos): return int(sum(x ** 2 for x in pos) <= 1) assert f((-1, 0)) == 1
benchmark_functions_edited/f6459.py
def f(action): # An action is an (a, b, arrow) tuple; a and b are # times; arrow is a string. a, b, arrow = action return max(a,b) assert f( (0,1,'<-') ) == 1
benchmark_functions_edited/f9005.py
def f(object_name, __entries={}): if object_name not in __entries: maxval = 0 if not __entries else max(__entries.values()) __entries[object_name] = 1 + maxval return __entries[object_name] assert f(None) == 1
benchmark_functions_edited/f9261.py
def f(mcu, vol_gal): return 1.49 * (mcu / vol_gal) ** 0.69 assert f(0, 1) == 0
benchmark_functions_edited/f7807.py
def f(T_hi, T_lo, exact=False): if exact: from numpy import log return (T_hi-T_lo)/log(T_hi/T_lo) else: d = T_hi - T_lo return T_hi - d/2*(1 + d/6/T_hi*(1 + d/2/T_hi)) assert f(2, 2) == 2
benchmark_functions_edited/f10138.py
def f(level: int) -> int: # https://github.com/giorgi-o level_multiplier = 750 if level >= 2 and level <= 50: return 2000 + (level - 2) * level_multiplier elif level >= 51 and level <= 55: return 36500 else: return 0 assert f(100000) == 0
benchmark_functions_edited/f4883.py
def f(letter): letter = letter[0].lower() return ord(letter) - ord('a') assert f('a') == 0
benchmark_functions_edited/f4805.py
def f(row, field): if str(row[field]).__contains__('NON'): return 0 else: return 1 assert f( {'permission_statement': 'NON'}, 'permission_statement') == 0
benchmark_functions_edited/f10651.py
def f(source, offset): return source.encode("utf-8")[0:offset].count("\n".encode("utf-8")) + 1 assert f( 24 ) == 3
benchmark_functions_edited/f6043.py
def f(camera_type): if camera_type == 'fisheye': return 0 elif camera_type == 'perspective': return 1 else: return 2 assert f('fisheye') == 0
benchmark_functions_edited/f13060.py
def f(x_n, x, u, u_n, F, dt, params, u_c): f = F(x, u, params) f_n = F(x_n, u_n, params) x_c = (x + x_n) / 2 + dt / 8 * (f - f_n) f_c = F(x_c, u_c, params) res = x + dt / 6 * (f + 4 * f_c + f_n) - x_n return res assert f(*(0, 0, 0, 0, lambda x, u, p: x, 0.01, 0, 0)) == 0
benchmark_functions_edited/f1166.py
def f(string): return int(string) if string else None assert f("2") == 2
benchmark_functions_edited/f13928.py
def f(x: int, shift: int, n_bits: int) -> int: mask = (1 << n_bits) - 1 # Trick to create a ones mask of n bits x_base = (x << shift) & mask # Keep it in the n_bits range return x_base | (x >> (n_bits - shift)) assert f(9, 4, 4) == 9
benchmark_functions_edited/f4937.py
def f(*vars): v = 1 for i in vars: v *= i return v assert f(1, 2) == 2
benchmark_functions_edited/f12389.py
def f(a, mod): r_prev, u_prev, v_prev, r, u, v = a, 1, 0, mod, 0, 1 while r != 0: q = r_prev // r r_prev, u_prev, v_prev, r, u, v = ( r, u, v, r_prev - q * r, u_prev - q * u, v_prev - q * v, ) return u_prev assert f(1, 10) == 1
benchmark_functions_edited/f13485.py
def f(dct, path, default=None, raise_error=True): subdct = dct for i, key in enumerate(path): if not isinstance(subdct, dict) or key not in subdct: if raise_error: raise KeyError("path does not exist in dct: {}".format(path[0:i+1])) else: return default subdct = subdct[key] return subdct assert f( {"one": 1}, ["one"] ) == 1
benchmark_functions_edited/f9814.py
def f(tree_map, down, right): column = 0 trees = 0 for index, row in enumerate(tree_map[::down]): if row[column] == '#': trees += 1 column = (column + right) % len(row) return trees assert f( ['..##.......', '#...#...#..', '.#....#..#.', '..#.#...#.#', '.#...##..#.', '..#.##.....', '.#.#.#....#', '.#........#', '#.##...#...', '#...##....#', '.#..#...#.#'], 1, 5) == 3
benchmark_functions_edited/f12177.py
def f(box1, box2): A1 = (box1[2] - box1[0])*(box1[3] - box1[1]) A2 = (box2[2] - box2[0])*(box2[3] - box2[1]) xmin = max(box1[0], box2[0]) ymin = max(box1[1], box2[1]) xmax = min(box1[2], box2[2]) ymax = min(box1[3], box2[3]) if ymin >= ymax or xmin >= xmax: return 0 return ((xmax-xmin) * (ymax - ymin)) / (A1 + A2) assert f( [10, 10, 20, 20], [10, 20, 20, 20]) == 0
benchmark_functions_edited/f10017.py
def f(situation, state): if situation == 3 and state == 0: return 1 elif situation in [2, 3] and state == 1: return 1 elif situation not in [2, 3] and state == 1: return 0 else: return state assert f(0, 1) == 0
benchmark_functions_edited/f11220.py
def f(a): import re type1 = re.compile("(^[+-]?[0-9]*[.]?[0-9]+$)|(^[+-]?[0-9]+[.]?[0-9]*$)|(^[+-]?[0-9]?[.]?[0-9]+[EeDd][+-][0-9]+$)") if type1.match(a): return 1 else: return 2 assert f("asdf") == 2
benchmark_functions_edited/f5363.py
def f(somelist, function): for item in somelist: if function(item): return item return None assert f(range(5), lambda x: x == 4) == 4
benchmark_functions_edited/f12367.py
def f(collection, default=None): element = next(iter(collection), None) if element is None: element = default return element assert f(range(2)) == 0
benchmark_functions_edited/f2964.py
def f(a, p): for b in range(1, p): if (a * b) % p == 1: return b assert f(2, 5) == 3
benchmark_functions_edited/f2720.py
def f(deck_size, position, cut_value): return (position - cut_value) % deck_size assert f(10, 7, 3) == 4
benchmark_functions_edited/f7451.py
def f(size_in_bytes: float) -> int: MBFACTOR = float(1 << 20) return int(int(size_in_bytes) / MBFACTOR) assert f(123) == 0
benchmark_functions_edited/f14110.py
def f(i): if i == 1: return 1 return 0 assert f(7) == 0
benchmark_functions_edited/f6054.py
def f(n): count = 0 while n != 0: last_bit = n & 1 if last_bit == 1: count += 1 n = n >> 1 return count assert f(9) == 2
benchmark_functions_edited/f9064.py
def f(angle, eps=1e-5) -> int: if angle < -eps: return -1 elif angle > eps: return 1 else: # -eps < angle < eps return 0 assert f(1) == 1
benchmark_functions_edited/f1994.py
def f(p1, p2): return abs(p1 - p2) * 100000. <= min(abs(p1), abs(p2)) assert f(1.00000000001, 1.00000000002) == 1
benchmark_functions_edited/f7952.py
def f(a, x, lo=0, hi=None): 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((), 5) == 0
benchmark_functions_edited/f581.py
def f(R11): return R11 / (1 + R11) assert f(0) == 0
benchmark_functions_edited/f1178.py
def f(a, b): return b if a is None else a assert f(None, 0) == 0
benchmark_functions_edited/f5315.py
def fiboRec ( number ): if number > 0: return (f( number - 1 ) + f( number -2 ) ) else: return 1 assert f(0) == 1
benchmark_functions_edited/f4921.py
def f(n: int) -> int: assert n > 0 r = 0 t = 1 while 2 * t <= n: t = 2 * t r = r + 1 return r assert f(8) == 3
benchmark_functions_edited/f10889.py
def f(repo): dynamic_count = 0 if 'DYNAMIC-PATTERN' in repo['uniquePatterns']: dynamic_count += repo['uniquePatterns']['DYNAMIC-PATTERN'] return dynamic_count assert f( { 'uniquePatterns': { 'OTHER-PATTERN': 200, 'YET-ANOTHER-PATTERN': 300, }, } ) == 0
benchmark_functions_edited/f3611.py
def f(value, arg): try: return float(value) - float(arg) except (ValueError, TypeError): return '' assert f(1, 0) == 1
benchmark_functions_edited/f11170.py
def f(region): regions = { 'HK': 1, 'SG': 2, 'CN': 4, } assert region in regions, ( 'Region "%s" does not exist.' % region) return regions[region] assert f('SG') == 2
benchmark_functions_edited/f9292.py
def f(midi_note): octave = None if midi_note >= 12: octave = int((midi_note / 12) - 1) elif midi_note >= 0: octave = -1 return octave assert f(100) == 7
benchmark_functions_edited/f3029.py
def f(n, k): from math import factorial return factorial(n) // factorial(n - k) assert f(24, 0) == 1
benchmark_functions_edited/f9873.py
def f(root): if not root: return 0 if not root.left: return 1 + f(root.right) if not root.right: return 1 + f(root.left) return 1 + min(f(root.left), f(root.right)) assert f(None) == 0
benchmark_functions_edited/f409.py
def f(x): return x / (1 + abs(x)) assert f(0) == 0
benchmark_functions_edited/f11466.py
def f(capacity, items): options = list( item.value + f(capacity-item.weight, items) for item in items if item.weight <= capacity) if len(options): return max(options) else: return 0 assert f(0, []) == 0
benchmark_functions_edited/f2634.py
def f(q1, q2, c1=2, c2=1, *args): return c1 * q1 + c2 * q2 assert f(1, 1, *(), **{}) == 3
benchmark_functions_edited/f7701.py
def f(li: list, element): return len(li) - next(i for i, v in enumerate(reversed(li), 1) if v == element) assert f([None], None) == 0
benchmark_functions_edited/f2212.py
def f(byte_string): return int.from_bytes(byte_string, byteorder="big", signed=False) assert f(b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00") == 0
benchmark_functions_edited/f12340.py
def f(config, request) -> int: if config is not None: return config["user_token"] else: return request.config.getoption("--user-token") assert f({"user_token": 2}, None) == 2
benchmark_functions_edited/f1337.py
def f(gl): return -int(gl * 10) assert f(0) == 0
benchmark_functions_edited/f12629.py
def f(action): return int(action + 1) assert f(0) == 1
benchmark_functions_edited/f3810.py
def f(a: int, b: int) -> int: if b == 0: return a return f(b, a % b) assert f(3, 0) == 3
benchmark_functions_edited/f12151.py
def f(nd1, nd2): valuesd1 = list(nd1.values()) # list values of each dictionary valuesd2 = list(nd2.values()) if min(valuesd1) < min(valuesd2): #check which one is the smallest return min(valuesd1) else: return min(valuesd2) assert f( {'a': 100, 'b': 100}, {'c': 0} ) == 0
benchmark_functions_edited/f13090.py
def f(data): if len(data) < 1: raise Exception("list is empty") valMax = data[0] xOfMax = 0 for i in range(len(data)): if data[i] > valMax: valMax = data[i] xOfMax = i return xOfMax assert f( [-1, 0, 1] ) == 2
benchmark_functions_edited/f12104.py
def f(link_list): n = 0 for link in link_list: if hasattr(link, 'joint'): n += link.joint.joint_dof return n assert f([]) == 0
benchmark_functions_edited/f11518.py
def f(i): # Use the absolute largest value in its raw form if max(i) > abs(min(i)): return max(i) elif abs(min(i)) >= max(i): return min(i) else: raise ValueError() assert f(range(3,-1,-1)) == 3
benchmark_functions_edited/f3364.py
def f(test_list): return test_list[0] - (test_list[1] + test_list[2]) assert f( [0,0,0,0] ) == 0
benchmark_functions_edited/f9688.py
def f(string): try: intstring = int(string) except Exception: intstring = None return intstring assert f(1.0) == 1
benchmark_functions_edited/f6204.py
def f(n): return (n + 7) >> 3 assert f(40) == 5