file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f12242.py
def f(a): N = len(a) i = 0 # row j = 0 # column first_d = 0 while i < N and j < N: first_d += a[i][j] i += 1 j += 1 j = N - 1 i = 0 second_d = 0 while i < N and j >= 0: second_d += a[i][j] i += 1 j -= 1 return abs(first_d - sec...
benchmark_functions_edited/f10657.py
def f(n, r): if 0 <= r <= n: ntok = 1 rtok = 1 for t in range(1, min(r, n - r) + 1): ntok *= n rtok *= t n -= 1 return ntok // rtok # bit-wise operation else: return 0 assert f(0, 5) == 0
benchmark_functions_edited/f2765.py
def f(num: int) -> int: return sum([int(digit) for digit in str(2 ** num)]) assert f(0) == 1
benchmark_functions_edited/f8208.py
def f(times): n = len(times) diffs = [times[i+1] - times[i] for i in range(n - 1)] return sum(diffs)/len(diffs) assert f([1,2]) == 1
benchmark_functions_edited/f13710.py
def f(lst, i, dist): while i >= 0: if lst[i] < dist: break i -= 1 return i assert f(list(range(10)), 4, 6) == 4
benchmark_functions_edited/f12782.py
def f(number, alphabet='0123456789'): n = len(alphabet) number = tuple(alphabet.index(i) for i in reversed(str(number))) return (sum(number[::2]) + sum(sum(divmod(i * 2, n)) for i in number[1::2])) % n assert f(12) == 4
benchmark_functions_edited/f1401.py
def f(tup): x, _y = tup return x assert f((1, ())) == 1
benchmark_functions_edited/f3873.py
def f(encrypted_credit_card) -> int: return int(round(encrypted_credit_card**(1./3.))) assert f(1.0) == 1
benchmark_functions_edited/f3853.py
def f(seq): return max(enumerate(seq), key=lambda s: s[1])[0] assert f([1,3,2,3,1]) == 1
benchmark_functions_edited/f1604.py
def f(i): n = 1 while n < i: n *= 2 return n assert f(1) == 1
benchmark_functions_edited/f5899.py
def f(a, b, c): assert 0 <= c <= 1, "c must be between 0 and 1" return (b*c) + ((1-c) * a) assert f(0, 1, 0) == 0
benchmark_functions_edited/f2105.py
def f(int_str, default=0): try: return (int)(int_str) except ValueError: return default assert f(1.0) == 1
benchmark_functions_edited/f7314.py
def f(op, tensor): # _check_tensor_shapes([tensor]) rval = op(tensor, tensor) return rval # return op(tf.expand_dims(tensor, 2), tf.expand_dims(tensor, 1)) assert f(lambda x, y: x * y, 1) == 1
benchmark_functions_edited/f12630.py
def f(s): return s.count("\n") + 1 assert f("a\nb\nc") == 3
benchmark_functions_edited/f3899.py
def f(x,x0,A,tau, offset): from numpy import exp func = A*exp(-(x-x0)/tau)+offset return func assert f(1, 1, 1, 1, 1) == 2
benchmark_functions_edited/f3970.py
def f(length, start=1, step=1): real_length = length - (start - 1) return (real_length // step) + (real_length % step) assert f(0) == 0
benchmark_functions_edited/f7023.py
def f(a, b, p, limit = False): i = a + (b - a) * p if limit and i < a: return a elif limit and i > b: return b else: return i assert f(-1, 1, 1) == 1
benchmark_functions_edited/f6229.py
def f(val_str, bytes): import sys val = int(val_str, 2) b = val.to_bytes(bytes, byteorder=sys.byteorder, signed=False) return int.from_bytes(b, byteorder=sys.byteorder, signed=True) assert f(bin(1), 2) == 1
benchmark_functions_edited/f1965.py
def f(rho, mu, char_length, char_velocity): return rho * char_velocity * char_length / mu assert f(1, 1, 1, 5) == 5
benchmark_functions_edited/f14142.py
def f(o): if isinstance(o, str): try: return int(o) except ValueError: return o elif isinstance(o, dict): return {f(k): f(v) for k, v in o.items()} elif isinstance(o, list): return [f(v) for v in o] else: return o assert f('1') == 1
benchmark_functions_edited/f8036.py
def f(c): c_int = {'a': 0, 'b': 1, 'c': 2} return c_int[c] assert f('b') == 1
benchmark_functions_edited/f9069.py
def f(x, y, rho, sens, spec, cov): return x * ((rho * cov * (1 - sens)) + cov - 1) + y * (((1 - rho) * cov * (1 - spec)) + cov - 1) + 1 - cov assert f(1, 1, 1, 1, 0, 1) == 0
benchmark_functions_edited/f1450.py
def f(value, low=0.0, high=1.0): return min(max(value, low), high) assert f(3, 0, 1) == 1
benchmark_functions_edited/f8956.py
def f(x, y, op): if op == '+': return x + y elif op == '-': return x - y if op == '*': return x * y elif op == '/': return float(x) / float(y) else: return "unknown value" assert f(2, 1, '-') == 1
benchmark_functions_edited/f6718.py
def f(word1, word2): matches = 0 for i in range(len(word1)): if word1[i] == word2[i]: matches += 1 return matches assert f( 'aa', 'aa') == 2
benchmark_functions_edited/f9470.py
def f(value): try: value = int(value) except ValueError: if value.lower().strip() in ["true", "t", "1", "yes"]: value = True elif value.lower().strip() in ["false", "f", "no", "0"]: value = False return value assert f(1.0) == 1
benchmark_functions_edited/f6092.py
def f(string, location, tokens): # pylint: disable=eval-used return eval(str(tokens[2]) +" if " + str(tokens[0]) + " else " + str(tokens[4])) assert f(None, None, (False, 1, 2, 3, 4)) == 4
benchmark_functions_edited/f2829.py
def f(x, shift): assert 0 < shift < 32 return (x >> (32 - shift)) | ((x << shift) & 0xffffffff) assert f(0, 1) == 0
benchmark_functions_edited/f10173.py
def f(item, typ=None, strip=' '): item = item.strip(strip) type_candidates = [int, float] if typ is None else [typ] for type_candidate in type_candidates: try: return type_candidate(item) except ValueError: pass return item assert f(' 1') == 1
benchmark_functions_edited/f2509.py
def f(n): if n == 0: return n elif n < 0: return -1 else: return 1 assert f(3) == 1
benchmark_functions_edited/f2756.py
def f(n): if n == 0 or n == 1: return 1 else: return f(n-1) + f(n-2) assert f(4) == 5
benchmark_functions_edited/f12246.py
def f(num): result = '' counter = 1 while len(result) < 9: result += str(num * counter) counter += 1 if len(result) > 9: result = 0 return result assert f(20) == 0
benchmark_functions_edited/f3089.py
def f(value): return sum([i for i, c in enumerate(value) if c in ["(", ")"]]) assert f("abc") == 0
benchmark_functions_edited/f10198.py
def f(start: int, size: int) -> int: assert start < 0 # noqa: S101 return max(0, start + size) assert f(-1, 1) == 0
benchmark_functions_edited/f6633.py
def f(n): fib_pp = 1 fib_p = 1 fib_cur = 1 for _ in range(3, n + 1): fib_cur = fib_pp + fib_p fib_pp = fib_p fib_p = fib_cur return fib_cur assert f(6) == 8
benchmark_functions_edited/f14076.py
def f(freq_counts, rare_threshold, gamma=False): n_rare = 0 if gamma: for i, j in enumerate(freq_counts[:rare_threshold + 1]): n_rare = n_rare + (i * j) * (i - 1) else: for i, j in enumerate(freq_counts[:rare_threshold + 1]): n_rare = n_rare + (i * j) return n_r...
benchmark_functions_edited/f4764.py
def f(locations): occupied = 0 for location in locations: if location == '#': occupied += 1 return occupied assert f(list('.......#...')) == 1
benchmark_functions_edited/f3667.py
def f(user): return sum([1 if hw['status'] == 'success' else 0 for hw in user['homeworks']]) assert f( { 'homeworks': [ {'status':'success'}, {'status':'success'}, {'status':'success'}, {'status':'success'} ] } ) == 4
benchmark_functions_edited/f2956.py
def f(elem): leng=len(elem[0]) if leng!=0: return leng return 99 assert f( ('dog',) ) == 3
benchmark_functions_edited/f12614.py
def f(binary): reversed_binary = binary[::-1] # i = correct power when reversed decimal = 0 for i, value in enumerate(reversed_binary): if value == "0": continue # ignore 0 because no value decimal += 2**i # multiply 2 by i b/c index = power, add this value to decimal variab...
benchmark_functions_edited/f3152.py
def f(s_i: int) -> int: return 3 * (s_i // 27) + (s_i % 9) // 3 assert f(28) == 3
benchmark_functions_edited/f10492.py
def f(n, n_max): # Set the stopping rule of the recursion algorithm. if n < 10: return n_max n = n // 10 if n > 0: # Explore n_mode = n % 10 if n_mode > n_max: n_max = n_mode # Explore max_ = f(n, n_max) return max_ assert f(1111, 0) == 1
benchmark_functions_edited/f5211.py
def f(data): return 1.0*sum(data)/len(data) assert f([1, 2, 3]) == 2
benchmark_functions_edited/f7596.py
def f(values): if len(values) > 0: product = 1.0 exponent = 1.0 / len(values) for value in values: product *= value ** exponent return product assert f( [1, 1] ) == 1
benchmark_functions_edited/f3383.py
def f(s: str) -> int: return 0 if s.startswith("\033[") else len(s) assert f(u"\033[1m\033[4m") == 0
benchmark_functions_edited/f2831.py
def f(seconds): return seconds * (10 ** 9) assert f(0) == 0
benchmark_functions_edited/f4776.py
def f(raw_val): if isinstance(raw_val, list): return len(raw_val) else: return None assert f(['a', 'b']) == 2
benchmark_functions_edited/f12700.py
def f(n): n = str(n) if int(n) < 10: return 1 else: return f(n[:-1]) + 1 assert f(0) == 1
benchmark_functions_edited/f4500.py
def f(a, b): (x1, y1) = a (x2, y2) = b return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5 assert f( (0, 0), (0, 1) ) == 1
benchmark_functions_edited/f1369.py
def f(v1, v2): return v1[0]*v2[0] + v1[1]*v2[1] assert f( (1,1), (1,1) ) == 2
benchmark_functions_edited/f1634.py
def f(int_a, int_b): if int_a < int_b: return int_a else: return int_b assert f(2, 1) == 1
benchmark_functions_edited/f12919.py
def f(num_list): index, control = 0, 1 for i in range(1, len(num_list)): if num_list[index] == num_list[i]: control += 1 else: control -= 1 if control == 0: index = i control = 1 return num_list[index] assert f([1, 2, 3, ...
benchmark_functions_edited/f6180.py
def f(var): try: return int(var) except ValueError: return None assert f(4) == 4
benchmark_functions_edited/f10893.py
def f(flags): # type flag : bits 1 to 3 return flags & 7 assert f(0x10) == 0
benchmark_functions_edited/f13915.py
def f(nh, nv, row, col, spin): return 2 * nh * row + 2 * col + spin assert f(2, 2, 1, 1, 0) == 6
benchmark_functions_edited/f10142.py
def f(windows_timestamp): magic_number = 11644473600 return int((windows_timestamp / 10000000) - magic_number) assert f(116444736000000000) == 0
benchmark_functions_edited/f14549.py
def f(input_array, value): min_index = 0 max_index = len(input_array)-1 while (min_index<=max_index): midle = (min_index+max_index)//2 if input_array[midle]==value: return midle elif value > input_array[midle]: min_index = midle+1 else : ...
benchmark_functions_edited/f8651.py
def f(x, coeff): w = coeff[0] + coeff[1] * x + coeff[2] * x**2 + coeff[3] * x**3 return w assert f(-100, (100, 1, 0, 0)) == 0
benchmark_functions_edited/f3895.py
def f(my_list=[]): result = 0 for x in set(my_list): result += x return (result) assert f([]) == 0
benchmark_functions_edited/f14020.py
def f(xrandr_val: float): return int(xrandr_val * 10 - 1) assert f(1.0) == 9
benchmark_functions_edited/f12636.py
def f(obj_list, feat): sum = 0 for obj in obj_list: sum += eval('obj.'+feat) return sum assert f([], 'n') == 0
benchmark_functions_edited/f12901.py
def f(t, t_reference, unit_conversion=int(1e9)): return (t - t_reference) / unit_conversion assert f(1, 1) == 0
benchmark_functions_edited/f7872.py
def f(cards): if sum(cards) == 21 and len(cards) == 2: return 0 if 11 in cards and sum(cards) > 21: cards.remove(11) cards.append(1) return sum(cards) assert f( [2,3,4] ) == 9
benchmark_functions_edited/f8776.py
def get_position (pair, s_mention) : antd_index=int(pair[0][-1])-1 if antd_index == 0 : return 0 if antd_index == len(s_mention) -1 : return 2 return 1 assert f(('C-3', 'T-1'), ['he', 'is', 'awesome']) == 2
benchmark_functions_edited/f7490.py
def f(data, item, last_index): for index in range(last_index + 1, len(data)): if data[index] == item: last_index = index break return last_index assert f(range(10), 9, 4) == 9
benchmark_functions_edited/f6468.py
def f(n, leading_zeros=False): return 10**((n-1)//2)*(9+leading_zeros) assert f(1) == 9
benchmark_functions_edited/f755.py
def f(public, q, p): return 1 == pow(public, q, p) assert f(2, 2, 3) == 1
benchmark_functions_edited/f12724.py
def f(v, divisor, min_val=None): if min_val is None: min_val = divisor new_v = max(min_val, int(v + divisor / 2) // divisor * divisor) # Make sure that round down does not go down by more than 10%. if new_v < 0.9 * v: new_v += divisor return new_v assert f(3, 8) == 8
benchmark_functions_edited/f1838.py
def f( *vals ): for v in vals: if v is not None: return v return None assert f( None, 1, None, 2 ) == 1
benchmark_functions_edited/f5837.py
def f(ACC): try: return 1 - ACC except TypeError: return "None" assert f(1) == 0
benchmark_functions_edited/f651.py
def f(width, fs): return int(width / (0.6 * fs)) assert f(20, 20) == 1
benchmark_functions_edited/f13866.py
def f(sales_period_1, sales_period_2): return ((sales_period_2 - sales_period_1) / sales_period_1) * 100 assert f(1000, 1000) == 0
benchmark_functions_edited/f11708.py
def f(longitude: float) -> float: time_median_longitude = int(longitude/15)*15 longitude_deg = longitude / abs(longitude) * (abs(int(longitude)) + abs(longitude) % 1 * 100 / 60) local_time_constant = 4 * (time_median_longitude - longitude_deg) return local_time_constant assert f(-1) == 4
benchmark_functions_edited/f7251.py
def f(x, oneBasedBitNumber): if oneBasedBitNumber < 1 or oneBasedBitNumber > 32: raise ValueError('invalid bit number') return (int(x) >> (oneBasedBitNumber-1)) & 1 assert f(3, 10) == 0
benchmark_functions_edited/f682.py
def f(values): return sum(values) / len(values) assert f((1, 2, 3, 4, 5)) == 3
benchmark_functions_edited/f11307.py
def f(v, index, x): mask = 1 << index # Compute mask, an integer with just bit 'index' set. v &= ~mask # Clear the bit indicated by the mask (if x is False) if x: v |= mask # If x was True, set the bit indicated by the mask. return v assert f(1, 1, 1) == 3
benchmark_functions_edited/f12587.py
def f(passedList, elements): for i, item in enumerate(passedList): for element in elements: if str(item).lower() == str(element).lower(): return i assert f(list("abcdefghijklmnop"), "c") == 2
benchmark_functions_edited/f5133.py
def f(game_results): count = 0 for game_result in game_results: if len(game_result.winners) == 0: count += 1 return count assert f([]) == 0
benchmark_functions_edited/f13776.py
def f(value, leftMin, leftMax, rightMin, rightMax): # Figure out how 'wide' each range is leftSpan = leftMax - leftMin rightSpan = rightMax - rightMin # Convert the left range into a 0-1 range (float) valueScaled = float(value - leftMin) / float(leftSpan) # Convert the 0-1 range into a value i...
benchmark_functions_edited/f7950.py
def f(current_day, launch_day): day=launch_day - current_day return( day if day >= 0 else 0) assert f(1, 1) == 0
benchmark_functions_edited/f2061.py
def f(stats): return sum(n.packets for n in stats) assert f([]) == 0
benchmark_functions_edited/f7248.py
def f(base, exp): if exp == 0: return 1 return base * f(base, exp - 1) assert f(2, 1) == 2
benchmark_functions_edited/f4599.py
def f(total_frames, frame_rate, curr_frame): # return (total_frames * frame_rate) / curr_frame return curr_frame / frame_rate assert f(100, 10, 10) == 1
benchmark_functions_edited/f8107.py
def f(dictionary, default, *keys): try: res = dictionary for k in keys: res = res[k] return res except (KeyError, IndexError) as e: return default assert f({'a': {'b': 1}}, 0, 'c', 'a', 'b') == 0
benchmark_functions_edited/f7728.py
def f(y_pred, y, center_to_border_dict=None): return abs(y_pred - y) assert f(-1, 0) == 1
benchmark_functions_edited/f7372.py
def f(repr): # transform state to a 3-based number hash = 0 for i in repr: hash = hash*3 + i return hash assert f(tuple([0,0,0,0,0,0,0,0,0])) == 0
benchmark_functions_edited/f6064.py
def f(tem, l): min = l if tem < l: return tem return l assert f(3, 4) == 3
benchmark_functions_edited/f10824.py
def f(molecular_barcodes): return len(molecular_barcodes.keys()) assert f({1:100, 2:100, 3:100, 4:100}) == 4
benchmark_functions_edited/f6850.py
def f(target, *args): current = target for level in args: current = current[level] return current assert f( {"one": {"two": [1, 2, 3]}}, "one", "two", 0 ) == 1
benchmark_functions_edited/f818.py
def f(n): return float(n) * 3.28084 assert f(0) == 0
benchmark_functions_edited/f5908.py
def f(text): return sum([char.isupper() for char in text]) assert f("aBcD") == 2
benchmark_functions_edited/f56.py
def f(z, z0): return z + z0**2 / z assert f(2, 0) == 2
benchmark_functions_edited/f5112.py
def f(base_minor, base_major, height): # You have to code here # REMEMBER: Tests first!!! return ((base_minor + base_major )* height)/2 assert f(1, 2, 0) == 0
benchmark_functions_edited/f2077.py
def f(listed): count = 0 for item in listed: count += 1 return count assert f(list([1,2,3])) == 3
benchmark_functions_edited/f9494.py
def f(quizn): return quizn - 1 if quizn >= 2 else quizn assert f(4) == 3
benchmark_functions_edited/f13142.py
def f(priority): try: return [4, 3, 2, 1][priority - 1] except (IndexError, TypeError): return 1 assert f(object()) == 1
benchmark_functions_edited/f4076.py
def f(val): if val == 'None': return None else: return int(val) assert f(2) == 2
benchmark_functions_edited/f11535.py
def f(savedmodel_path): if savedmodel_path == "": next_epoch = 1 else: next_epoch = int(savedmodel_path[savedmodel_path.rfind("-")+1:]) + 1 return next_epoch assert f('tmp/savedmodel-5') == 6
benchmark_functions_edited/f6360.py
def f(f, xs): return min(xs, key=f) assert f(lambda x: x, [3,2,1]) == 1
benchmark_functions_edited/f1796.py
def f(n: int) -> int: p = 1 while p**2 <= n < (p+1)**2: p += 1 return p assert f(2) == 2