file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f1012.py
def f(row, col): return row*9+col assert f(0, 1) == 1
benchmark_functions_edited/f942.py
def f( lst ): return sum( [ x[1] for x in lst ] ) assert f( [ ("a", 1), ("b", 2) ] ) == 3
benchmark_functions_edited/f7741.py
def f(a, b, c): diff1 = abs(a - b) diff2 = abs(b - c) diff3 = abs(c - a) return min(diff1, diff2, diff3) assert f(1, 1, 1) == 0
benchmark_functions_edited/f9075.py
def f(a): return a[0]**2 + a[1]**2 + a[2]**2 assert f([1, 0, 0]) == 1
benchmark_functions_edited/f3293.py
def f(lst, index): if index >= 0 and index < len(lst): return lst[index] return None assert f([1, 2, 3], 0) == 1
benchmark_functions_edited/f13908.py
def f(arr, element, low=0, high=None): if high == None: high = len(arr) - 1 if high < low: return -1 mid = (high + low) // 2 if arr[mid] == element: return mid elif arr[mid] > element: return f(arr, element, low, mid-1) else: return f(arr, element, mid+1, high) assert f(range(10), 8) == 8
benchmark_functions_edited/f4155.py
def f(string): try: string = string.split() return len(string) except: print("Error encountered!") assert f("foo bar") == 2
benchmark_functions_edited/f9478.py
def f(array, value): for idx, ele in enumerate(array): if ele == value: return idx return -1 assert f([5, 2, 3, 1, 4], 2) == 1
benchmark_functions_edited/f9157.py
def f(herbivore_list): stocking_density = 0 for herb_class in herbivore_list: stocking_density += herb_class.stocking_density return stocking_density assert f([]) == 0
benchmark_functions_edited/f10106.py
def f(isbn): return sum([(i + 1) * x for i, x in enumerate(isbn)]) % 11 assert f([9, 9, 9, 9, 9, 9, 9, 9, 9, 9]) == 0
benchmark_functions_edited/f12855.py
def f(start, stop): numfactors = stop - start >> 1 if not numfactors: return 1 elif numfactors == 1: return start else: mid = start + numfactors | 1 return f(start, mid) * f(mid, stop) assert f(1, 3) == 1
benchmark_functions_edited/f4601.py
def f(string): if string is not None: r = 1 else: r = 0 return r assert f(None) == 0
benchmark_functions_edited/f9875.py
def f(person, one_gene, two_genes): if person in one_gene: return 1 elif person in two_genes: return 2 else: return 0 assert f(5, {1, 2}, {3, 4}) == 0
benchmark_functions_edited/f12012.py
def f(ball_vector: list) -> int: if -0.13 <= ball_vector[1] <= 0.13: return 0 return -1 if ball_vector[1] < 0 else 1 assert f( [0.0, 0.0] ) == 0
benchmark_functions_edited/f6001.py
def f(n: int) -> int: diff = abs(n - 21) if n > 21: return diff * 2 return diff assert f(22) == 2
benchmark_functions_edited/f3156.py
def f(tokens, char): return sum(1 for token in tokens if token == char) assert f( ['a', 'b', 'a', 'c', 'a', 'd', 'c'], 'e' ) == 0
benchmark_functions_edited/f10038.py
def f(method, repeats=5, default_value=None, **kwargs): for i in range(repeats): try: return method(**kwargs) except Exception as e: pass return default_value assert f(lambda: 5) == 5
benchmark_functions_edited/f13507.py
def f(m, x, b): # multiply m and x and store the value into a variable # add the product of m and x to b and store it into a variable # return that variable daniela = m*x daniela = daniela + b return daniela assert f(2, 1, 0) == 2
benchmark_functions_edited/f10051.py
def f(username: str) -> int: retv = 0 if isinstance(username, str): print(f'Hello {username}') else: retv = 1 return retv assert f('Danny') == 0
benchmark_functions_edited/f3065.py
def f(x: float, gradient: float, y_intercept: float) -> float: return (x * gradient) + y_intercept assert f(2, 1, 1) == 3
benchmark_functions_edited/f3430.py
def f(x, lambd=1, **kwargs): return x / (1 + lambd) assert f(0) == 0
benchmark_functions_edited/f647.py
def f(x): return max([-1.0, min([1.0, x])]) assert f(2) == 1
benchmark_functions_edited/f1346.py
def f(side_pos, x_dist): return abs(side_pos - (x_dist - 2)) assert f(1, 4) == 1
benchmark_functions_edited/f315.py
def f(f): return f/(1-f) assert f(0) == 0
benchmark_functions_edited/f2126.py
def f(l): l= str(l) if l.count('.') <= 3: return 0 else: return 1 assert f('1.2.3.4.5.6.7.8.9.10.11.12') == 1
benchmark_functions_edited/f12007.py
def f(data1, data2): s1 = set(data1) s2 = set(data2) actual_jaccard = float(len(s1.intersection(s2)) / len(s1.union(s2))) return actual_jaccard assert f( [1, 2, 3], [1, 2, 3] ) == 1
benchmark_functions_edited/f4098.py
def f(outputs): if isinstance(outputs, (list, tuple)): return outputs[0] return outputs assert f([0]) == 0
benchmark_functions_edited/f2746.py
def f(word, score_dict): return sum([score_dict[letter] for letter in word]) assert f( 'chair', {'a': 1, 'c': 1, 'h': 2, 'i': 1, 'r': 1} ) == 6
benchmark_functions_edited/f11204.py
def f(operation, i): if len(str(operation)) > i + 2: mode = int(str(operation)[-i-3]) else: mode = 0 return mode assert f(1001, 1) == 1
benchmark_functions_edited/f5782.py
def f(summing_list, A): return sum(A[i] * summing_list[i] for i in range(len(summing_list))) assert f( [0, 0, 0, 0, 0, 0], [3, 4, 5, 6, 7, 8] ) == 0
benchmark_functions_edited/f14306.py
def f(interval, pos): diff_min = abs(interval[pos] - interval[pos - 1]) diff_max = abs(interval[pos] - interval[pos + 1]) if diff_min < diff_max: # the point is lower than the maximum f1-score return -1 else: # the point is higher than the maximum f1-score return 1 assert f(range(10), 8) == 1
benchmark_functions_edited/f4606.py
def f(match=lambda item: False, list=[]): for item in list: if match(item): return item assert f(lambda i: i == 3, [1,2,3]) == 3
benchmark_functions_edited/f12464.py
def f(lvl, exp_required): for i in range(len(exp_required)): if lvl < exp_required[i]: return i if lvl > exp_required[len(exp_required) - 1]: if len(exp_required) == 50: return 50 else: return 60 if lvl == exp_required[i]: return i assert f(2, (2, 4, 5, 10)) == 0
benchmark_functions_edited/f8689.py
def f(numerator, denominator): split_val = numerator // denominator rest = numerator % denominator if rest > 0: return split_val + 1 else: return split_val assert f(4, 8) == 1
benchmark_functions_edited/f12834.py
def f(index, strides): position = 0 for i, s in zip(index, strides): position += i*s return position assert f((0,), (1,)) == 0
benchmark_functions_edited/f14257.py
def f(list_one, list_two): diff = 0 for part in list_one: if part not in list_two: diff += 1 return diff assert f( ['100', 'Main', 'Street'], ['100', 'Main', 'Street', 'Apt', '123']) == 0
benchmark_functions_edited/f1198.py
def f(val): return (val & -val).bit_length() - 1 assert f(0b11111111111111111111111111111111111) == 0
benchmark_functions_edited/f3901.py
def f(lst): return sum(len(item) for item in lst) assert f([b"A", b"B", b"C", b"D", b"E"]) == 5
benchmark_functions_edited/f2496.py
def f(word, letter): return word.count(letter) assert f('hi', 'i') == 1
benchmark_functions_edited/f11772.py
def f(value): if value < 0: return -1 elif value == 0: return 0 else: return 1 assert f(0.123) == 1
benchmark_functions_edited/f1038.py
def f(lst): return sum([x*x for x in lst]) assert f( [0,0,0] ) == 0
benchmark_functions_edited/f2450.py
def f(string, char_set): return 1 in [c in string for c in char_set] assert f( 'banana', '' ) == 0
benchmark_functions_edited/f9.py
def f(l, es): return (1 + l) * es assert f(1, 0) == 0
benchmark_functions_edited/f10962.py
def f(s): res = "" n = 0 for i in s: if i not in res: res = res + i else: indexofi = res.find(i) res = res[indexofi+1::] + i k = len(res) if k > n: n = k print(res) return n assert f(" ") == 1
benchmark_functions_edited/f1375.py
def f(shape): d = 1 for size in shape: d *= size return d assert f(tuple()) == 1
benchmark_functions_edited/f9355.py
def f(iterable, *default): try: iterable = reversed(iterable) except TypeError: pass else: return next(iterable, *default) iterable = iter(iterable) x = next(iterable, *default) for x in iterable: pass return x assert f({1, 2, 3}) == 3
benchmark_functions_edited/f10176.py
def f(arg1, arg2): arg1 = arg2 return arg1 assert f(-3, 5) == 5
benchmark_functions_edited/f13709.py
def f(T, P): n, m = len(T), len(P) # introduce convenient notations for i in range(n - m + 1): # try every potential starting index within T k = 0 # an index into pattern P while k < m and T[i + k] == P[k]: # kth character of P matches k += 1 if k == m: # if we reached the end of pattern, return i # substring T[i:i+m] matches P return -1 assert f(b"abracadabra", b"abr") == 0
benchmark_functions_edited/f545.py
def f(callback, *args, **kwargs): return callback(*args, **kwargs) assert f(lambda a, b, c: a + b + c, 1, 2, 3) == 6
benchmark_functions_edited/f6690.py
def f(index, modifier, index_mod=0): return (index + index_mod) + ((index + index_mod) * modifier) assert f(0, 7) == 0
benchmark_functions_edited/f6848.py
def f(grains): grain = (grains[0] + grains[1]) / 2.0 return grain assert f([1.0, 1.0]) == 1
benchmark_functions_edited/f6394.py
def f(indices, t): memlen, itemsize, ndim, shape, strides, offset = t p = offset for i in range(ndim): p += strides[i]*indices[i] return p assert f((0, 1), (1, 1, 2, (2, 2), (4, 1), 0)) == 1
benchmark_functions_edited/f5515.py
def f(aList: list, givenV: int): abs_diff = lambda list_value: abs(list_value - givenV) return min(aList, key=abs_diff) assert f( [1, 2, 3, 4, 5, 6], 6) == 6
benchmark_functions_edited/f6019.py
def f(ufuncs, state): utility = 0 for attr, value in state.items(): if attr in ufuncs: utility += ufuncs[attr](state[attr]) return utility assert f( {"x": lambda x: x, "y": lambda y: y}, {"x": 5, "y": 3}, ) == 8
benchmark_functions_edited/f6813.py
def f(cards): vp = 0 for card in cards: vp += card.Points return vp assert f([]) == 0
benchmark_functions_edited/f6406.py
def f(iterator): cnt = 0 for _ in iterator: cnt += 1 return cnt assert f(iter("")) == 0
benchmark_functions_edited/f1767.py
def f(trajectory): return len(trajectory["action"]) assert f( {"state": [[0, 1, 0], [1, 1, 0], [1, 0, 0], [1, 0, 0]], "action": []}) == 0
benchmark_functions_edited/f5424.py
def f(a, b): end = min(len(a), len(b)) for i in range(end): if a[i] != b[i]: return i return end assert f(range(10), []) == 0
benchmark_functions_edited/f7497.py
def f(hkjkg): hbtulb = hkjkg * 0.429923 return hbtulb assert f(0) == 0
benchmark_functions_edited/f13349.py
def f(arr, value): total = 0 for element in arr: try: iter(element) total += f(element, value) except TypeError: pass total += 1 if element == value else 0 return total assert f([1, 2, 3], 2) == 1
benchmark_functions_edited/f173.py
def f(a): return int(a, 2) assert f(b"0") == 0
benchmark_functions_edited/f10763.py
def f(mean_fg, std_bg): snr = mean_fg / std_bg return snr assert f(50, 10) == 5
benchmark_functions_edited/f10476.py
def f(item): if type(item) is tuple: return item[0] return item assert f((1, 2)) == 1
benchmark_functions_edited/f1237.py
def f(n): numbers = range(1, n + 1) return sum(numbers) assert f(2) == 3
benchmark_functions_edited/f6822.py
def f(current,target): result = (abs(target[0]-current[0]) + abs(target[1]-current[1])) return result assert f( (0,0), (0,3) ) == 3
benchmark_functions_edited/f11651.py
def f(List, item): index = len(List) for i in range(0, index): if List[i] == item: return i return -1 assert f([1, 3, 5], 3) == 1
benchmark_functions_edited/f11024.py
def f(values): if type(values) == list or type(values) == tuple: return len(values) elif values is None: return 0 else: return 1 assert f(42) == 1
benchmark_functions_edited/f5624.py
def f(x : int) -> int: cnt : int = 0 while x and not x & 1: cnt += 1 x >>= 1 return cnt assert f(100000000) == 8
benchmark_functions_edited/f6913.py
def f(n): return int(2 * n**(1/3.0)) assert f(30) == 6
benchmark_functions_edited/f2522.py
def f(base, dvdby): if isinstance(dvdby, int): return base // dvdby return base / dvdby assert f(3, 4) == 0
benchmark_functions_edited/f10095.py
def f(callbacks): for callback in callbacks: try: callback() return True except Exception: # pylint: disable=broad-except pass raise Exception('All callbacks failed.') assert f( [lambda: 0, lambda: 0, lambda: 0, lambda: 1]) == 1
benchmark_functions_edited/f4816.py
def f(mlb): mkg = mlb / 2.20462 return mkg assert f(0) == 0
benchmark_functions_edited/f3282.py
def f(p, n_begin, n_end): return (p**(n_end+1) - p**n_begin) / (p - 1.0) assert f(2, 0, 0) == 1
benchmark_functions_edited/f9264.py
def f(words, start, what): i = start + 1 while i < len(words): if words[i] == what: return i i += 1 return -1 assert f( [1, 2, 3, 4, 5], 1, 3, ) == 2
benchmark_functions_edited/f8824.py
def f(state): x, y = state return 20*x + y assert f((0, 0)) == 0
benchmark_functions_edited/f11561.py
def f(n): numOnes = 0 binaryString = bin(n) for elem in binaryString: if (elem == '1'): print (elem) numOnes += 1 if (n == 0): return 0 else: if (n < 0): return (32 - numOnes) else: return (numOnes) assert f(0b00000000000000000000000000000000) == 0
benchmark_functions_edited/f4950.py
def f(n): if n < 1: return 1 else: return 1 / (pow(2, n)) + f(n - 1) assert f(0) == 1
benchmark_functions_edited/f11209.py
def f( lstRules, policy_name ): count = 0 for x in lstRules: if x.split(',')[0] == policy_name: count +=1 return count assert f( ['A,B,C', 'A,B,C', 'A,B,C'], 'A' ) == 3
benchmark_functions_edited/f9434.py
def f(value: int, min_value: int, max_value: int): return max(min(value, max_value), min_value) assert f(0, 1, 5) == 1
benchmark_functions_edited/f7830.py
def f(x, X_min, X_max, Y_min, Y_max): X_range = X_max - X_min Y_range = Y_max - Y_min XY_ratio = X_range / Y_range y = ((x - X_min) / XY_ratio + Y_min) // 1 return int(y) assert f(4, 0, 4, 0, 2) == 2
benchmark_functions_edited/f3574.py
def f(n): if n == 1: return 1 else: return n * f(n-1) assert f(1) == 1
benchmark_functions_edited/f5799.py
def f(length): return (length + 1) // 2 assert f(1) == 1
benchmark_functions_edited/f10303.py
def f(page_number, page_range): try: return page_range[page_number] except IndexError: return page_range[0] assert f(0, [0, 1, 2]) == 0
benchmark_functions_edited/f68.py
def f(x): return x**(1./3.) assert f(1) == 1
benchmark_functions_edited/f7166.py
def f(value: str): try: return int(value) except ValueError: raise ValueError("Cannot parse int from string") assert f(1) == 1
benchmark_functions_edited/f42.py
def f(x): return (x - 1.) / 2. assert f(9) == 4
benchmark_functions_edited/f10838.py
def f(func, llist, initval): while llist != None: try: initval = func([initval, llist.elt]) except: initval = func.call([initval, llist.elt]) llist = llist.next return initval assert f(lambda x: x[0] + x[1], None, 2) == 2
benchmark_functions_edited/f7007.py
def f(str_value, str_to_enum, default): str_value = str(str_value).lower() if str_value in str_to_enum: return str_to_enum[str_value] return default assert f(0, {}, 1) == 1
benchmark_functions_edited/f7855.py
def f(n): # str manipulation is slow #first_digit = int(str(n)[0]) shifted = n / 10 while shifted > 0: n = shifted shifted /= 10 first_digit = n return first_digit assert f(0) == 0
benchmark_functions_edited/f3552.py
def f(recv_ts, data): return (recv_ts - float(data.lstrip(b'0').decode())) * 1000 assert f(1500000000, b'01500000000') == 0
benchmark_functions_edited/f6461.py
def f(indices_size, index): if indices_size < 1: raise IndexError( "The tensor's index is unreasonable. index:{}".format(index)) return indices_size assert f(1, [1, 1]) == 1
benchmark_functions_edited/f834.py
def f(x): return ord(x) - ord('a') assert f('a') == 0
benchmark_functions_edited/f1322.py
def f(a, b): return abs(a[0] - b[0]) + abs(a[1] - b[1]) assert f((3, 4), (0, 0)) == 7
benchmark_functions_edited/f3033.py
def f(mesos_masters): return((len(mesos_masters) / 2) +1) assert f( [ '172.31.29.154', '172.31.13.158', '172.31.13.145', '172.31.13.145' ] ) == 3
benchmark_functions_edited/f974.py
def f(level): return 5 * level * (level + 5) assert f(0) == 0
benchmark_functions_edited/f2767.py
def f(n, k): ret = 1 while k: if k & 1: ret *= n n *= n k >>= 1 return ret assert f(3, 0) == 1
benchmark_functions_edited/f10565.py
def f(rank: int, total_ranks: int) -> int: if total_ranks % 6 != 0: raise ValueError(f"total_ranks {total_ranks} is not evenly divisible by 6") ranks_per_tile = total_ranks // 6 return rank // ranks_per_tile assert f(0, 12) == 0
benchmark_functions_edited/f514.py
def f(x, x0, gamma): return 1 / (1 + ((x - x0) / gamma)**2) assert f(1, 1, 1) == 1
benchmark_functions_edited/f9897.py
def f(x, y): if x < y: z = x x = y y = z if y == 0: print(f'gcd = {x}\n') return x else: print(f'{x} = {(x - x % y) / y}*{y} + {x % y}') return f(y, x % y) assert f(1, 2) == 1
benchmark_functions_edited/f4927.py
def f(target, prediction): if len(prediction) == 0: return 0 tp = sum(1 for p in prediction if p in target) return tp / len(prediction) assert f({'a', 'b', 'c'}, {'a', 'b', 'c'}) == 1