file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f11862.py
def f(current_min, input_score): if current_min != 0 and current_min < input_score: return current_min return input_score assert f(3, 7) == 3
benchmark_functions_edited/f11947.py
def f(b): return (2 ** b) - 1 assert f(2) == 3
benchmark_functions_edited/f7358.py
def f(n): assert type(n) == int and n >= 0 if n == 0: return 1 else: return n * f(n-1) assert f(2) == 2
benchmark_functions_edited/f108.py
def f(n): return 1 if n <= 1 else f(n-1) + f(n-2) assert f(5) == 8
benchmark_functions_edited/f4065.py
def f(time_used): return (time_used/60/60) assert f(0) == 0
benchmark_functions_edited/f12417.py
def f(n, counter): if n < 10 ** counter: return counter else: return f(n, counter + 1) assert f(123, 0) == 3
benchmark_functions_edited/f14448.py
def f(i,j,k,l): if i<j: i,j = j,i if k<l: k,l = l,k ij = (i*(i+1))//2+j kl = (k*(k+1))//2+l if ij < kl: ij,kl = kl,ij return (ij*(ij+1))//2+kl assert f(0,1,0,0) == 1
benchmark_functions_edited/f10376.py
def f(rating): rating = int(rating) if rating > 5 or rating < 1: raise ValueError("Rating must be (inclusively) in between 1 and 5") return rating assert f(4) == 4
benchmark_functions_edited/f11540.py
def f(console, alerts): errors = 0 for alert in alerts: console.printout(f'* [{alert.severity}] [{alert.kind}] - {alert.title}') errors = errors + 1 if alert.is_error else 0 return errors assert f(None, []) == 0
benchmark_functions_edited/f13590.py
def f(sentence, length): long_words = 0 words = sentence.split() for word in words: if len(word) >= length: long_words += 1 return long_words assert f( "This sentence doesn't have any words at all.", 10 ) == 0
benchmark_functions_edited/f11397.py
def f(current_fib: int, previous_fib: int, fibonacci_number: int) -> int: if abs(previous_fib - fibonacci_number) <= abs(current_fib - fibonacci_number): return previous_fib else: return current_fib assert f(2, 1, 1) == 1
benchmark_functions_edited/f5299.py
def f(lst, char): n = 0 l = len(lst) while n < l and lst[n] == char: n += 1 return n assert f(b'xyz', b'') == 0
benchmark_functions_edited/f10443.py
def f(raw_value, pad): return (pad - (raw_value % pad)) % pad assert f(101, 4) == 3
benchmark_functions_edited/f5094.py
def f(preferred_responses, ortho_responses): return ((preferred_responses - ortho_responses) / (preferred_responses + ortho_responses)) assert f(0.85, 0.85) == 0
benchmark_functions_edited/f4576.py
def f(src: str) -> int: return sum(1 for line in src.splitlines() if line.strip()) assert f( ) == 3
benchmark_functions_edited/f5678.py
def f(list, target): for i in range(0, len(list)): if list[i] == target: return i return None assert f([1,2,3,4], 3) == 2
benchmark_functions_edited/f1928.py
def f(x, y): return int( y * ( ( x // y) + (x % y > 0) ) ) assert f(1, 3) == 3
benchmark_functions_edited/f3802.py
def f(E, x): zeta_induced_quasisteady = E*x return zeta_induced_quasisteady assert f(0, 1) == 0
benchmark_functions_edited/f598.py
def f(n): return 3*(n//2)*n assert f(0) == 0
benchmark_functions_edited/f14239.py
def f(side_length: float) -> float: if side_length < 0: raise ValueError("f() only accepts non-negative values") return 6 * side_length ** 2 assert f(0) == 0
benchmark_functions_edited/f9350.py
def f(value): value = value & 0xFFFFFFFF if value & 0x80000000: value = ~value + 1 & 0xFFFFFFFF return -value else: return value assert f(-1 << 32) == 0
benchmark_functions_edited/f6582.py
def f(start, end, minutes): return (end - start)/(minutes/60) assert f(0, 0, 10) == 0
benchmark_functions_edited/f1813.py
def f(list_of_string): return max(map(int, list_of_string)) assert f(list("134567")) == 7
benchmark_functions_edited/f110.py
def f(n): k = n + 4 s = k + n return s assert f(1) == 6
benchmark_functions_edited/f2252.py
def f(Q_m3s, A_catch): Q_mmd = Q_m3s * 86400/(1000*A_catch) return Q_mmd assert f(0, 200) == 0
benchmark_functions_edited/f13699.py
def f(num_wins, party, num_contiguous): num_elections_won = num_wins[party] return num_elections_won / num_contiguous * 100 assert f( {'Democratic': 1, 'Republican': 2, 'Libertarian': 0, 'Other': 0}, 'Libertarian', 3) == 0
benchmark_functions_edited/f10318.py
def f(sib, paging): t = min(sib['defaultPagingCycle'], paging['PagingDRX']) n = min(t, int(sib['nB'] * t)) return int((t / n) * (paging['UEIdentityIndexValue'] % n)) assert f( {'defaultPagingCycle': 10, 'nB': 3, 't': 1}, {'PagingDRX': 2, 'UEIdentityIndexValue': 0} ) == 0
benchmark_functions_edited/f11903.py
def f(x): (i, b) = x # input bounds are in the range 0-4096 by default: https://github.com/tilezen/mapbox-vector-tile # we want them to match our fixed imagery size of 256 pixel = round(b * 255. / 4096) # convert to tile pixels return pixel if (i % 2 == 0) else 255 - pixel assert f( (4, 0) ) == 0
benchmark_functions_edited/f12848.py
def f(y_pos: int, distance: int): return y_pos + distance - 1 assert f(0, 1) == 0
benchmark_functions_edited/f9420.py
def f(mention: str) -> int: result = 0 try: result = int( mention.replace("<", "").replace(">", "").replace("!", "").replace("@", "") ) except (AttributeError, ValueError): pass return result assert f("<@:123>") == 0
benchmark_functions_edited/f1132.py
def f(x_bytes: bytes) -> int: return int.from_bytes(x_bytes, "big") assert f(b"\x00" * 5) == 0
benchmark_functions_edited/f4197.py
def f(t): d=0 for i in range(24): d*=10 d+=t[i] return d%99991 assert f((0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) == 0
benchmark_functions_edited/f5408.py
def f(n): assert n > 0 return n.bit_length() - 1 assert f(15) == 3
benchmark_functions_edited/f9756.py
def f(m: int, n: int) -> int: if m == 0: return n + 1 elif n == 0: return f(m - 1, 1) else: return f(m - 1, f(m, n - 1)) assert f(1, 3) == 5
benchmark_functions_edited/f1281.py
def f(num_list): a = num_list[0] b = num_list[-1] return int(b * (a + b)/2) assert f([3, 2, 1]) == 2
benchmark_functions_edited/f10450.py
def f(build_args): i = 0 while i < len(build_args): if build_args[i] == "-o": return i + 1 i += 1 return -1 assert f( ["-o", "a.out", "test.cpp"] ) == 1
benchmark_functions_edited/f6342.py
def f(n: int) -> int: if n == 0: return 0 digits: list = [] while n: n, r = divmod(n, 3) digits += str(r) o = "".join(reversed(digits)) return int(o) assert f(0) == 0
benchmark_functions_edited/f5611.py
def f(my_cities, other_cities): return len(list(set(my_cities) ^ set(other_cities))) assert f(['Toronto', 'London'], ['Toronto']) == 1
benchmark_functions_edited/f4616.py
def f(leechs, seeds): try: ratio = float(seeds) / float(leechs) except ZeroDivisionError: ratio = int(seeds) return ratio assert f(100, 0) == 0
benchmark_functions_edited/f9094.py
def f(val): if val in [5,6]: return 0 else: return 1 assert f(4) == 1
benchmark_functions_edited/f10059.py
def f(v): try: int_v = int(v) return int_v except ValueError: return v assert f('1') == 1
benchmark_functions_edited/f10112.py
def f(a, b): sum = a ^ b carry = a & b while carry: sum ^= carry carry <<= 1 return sum assert f(0, 1) == 1
benchmark_functions_edited/f7599.py
def f(spec): total = 0 for f in spec["cfiles"]: for ff in spec["cfiles"][f]["functions"]: total += len(spec["cfiles"][f]["functions"][ff]["ppos"]) return total assert f({"cfiles": {"file1": {"functions": {"func1": {"ppos": []}}}}}) == 0
benchmark_functions_edited/f7656.py
def f(value, from_min=0, from_max=1, to_min=0, to_max=1): return ((to_max-to_min)*(value - from_min) / (from_max - from_min)) + to_min assert f(0, 0, 1, 0, 100) == 0
benchmark_functions_edited/f8985.py
def f(rgb): c_max = max(rgb) / 255 c_min = min(rgb) / 255 d = c_max - c_min return 0 if d == 0 else d / (1 - abs(c_max + c_min - 1)) assert f((255, 0, 0)) == 1
benchmark_functions_edited/f8473.py
def f(arr, f): m = None i = None for idx, item in enumerate(arr): if item is not None: if m is None or f(item) < m: m = f(item) i = idx return i assert f( [2, None, 5], lambda x: x ) == 0
benchmark_functions_edited/f9924.py
def f(value, to_type, default=None): try: return to_type(value) except (ValueError, TypeError): return default assert f("5", int) == 5
benchmark_functions_edited/f5376.py
def f(data): return max(map(len, data)) assert f({"a" : 1, "abc" : 2}) == 3
benchmark_functions_edited/f6338.py
def f(is_in_support): if 248 <= is_in_support <= 256: return 1 elif 48 <= is_in_support <= 55: return 0 assert f(250) == 1
benchmark_functions_edited/f8021.py
def f(s): try: return int(s) except ValueError: return s assert f(1) == 1
benchmark_functions_edited/f14503.py
def f(string: str) -> int: index = 0 find = False for char in str(string): if not find: if char.isdigit(): find = True else: index = index + 1 if not find: return -1 return index assert f('b234b234') == 1
benchmark_functions_edited/f11833.py
def f(url): if "groups" in url: if "permalink" in url: return 3 else: return 2 elif "posts" in url: return 1 else: return 0 assert f( 'https://www.facebook.com/groups/free.code.camp.Los.Angeles/permalink/856344855183179/') == 3
benchmark_functions_edited/f13821.py
def f(target, heading): error = heading - target abs_error = abs(target - heading) if abs_error == 180: return abs_error elif abs_error < 180: return error elif heading > target: return abs_error - 360 else: return 360 - abs_error assert f(70, 70) == 0
benchmark_functions_edited/f1848.py
def f(x, y=0, z=0): return x ** 2 + y + z assert f(1, 1) == 2
benchmark_functions_edited/f11655.py
def f(R_n, rho_inf, rho_s): delta = R_n * (rho_inf / rho_s) return delta assert f(0, 1.2, 1.2) == 0
benchmark_functions_edited/f11612.py
def f(target): steps = 0 number = target while number > 0: if number % 2 == 0: number /= 2 else: number -= 1 steps += 1 return steps assert f(0) == 0
benchmark_functions_edited/f11295.py
def f(i: int, j: int, n: int) -> int: return min(n - j, 8 - (j % 8), 8 - (i % 8)) assert f(1, 4, 8) == 4
benchmark_functions_edited/f4872.py
def f(index, l): if index >= len(l): return len(l) - 1 elif index < 0: return 0 else: return index assert f(-100, [1,2,3]) == 0
benchmark_functions_edited/f1341.py
def f(list): for x in reversed(list): return x assert f([2]) == 2
benchmark_functions_edited/f8129.py
def f(s, defval=0): n = str(s).strip() if s else None if not n: return defval try: return int(n) except: print("Could not int(%s)" % (n,)) return defval assert f("\t") == 0
benchmark_functions_edited/f2167.py
def f(transform, y_value): return int(round(y_value * transform[1][1])) assert f( ((1, 0, 0), (0, 1, 0)), 0 ) == 0
benchmark_functions_edited/f10698.py
def f(x, y): # find largest shift less than x i = 0 s = y while s < x: s <<= 1 i += 1 s >>= 1 i -= 1 d = 0 rem = x while i >= 0: if s < rem: rem -= s d += 1<<i i -= 1 s >>= 1 return d assert f(2, 3) == 0
benchmark_functions_edited/f1825.py
def f(data): sum = 0 for c in data: sum ^= c return sum assert f(bytes([0, 0, 1, 0])) == 1
benchmark_functions_edited/f10591.py
def f(score1, score2, score3, score4, score5): min_score = min(score1, score2, score3, score4, score5) max_score = max(score1, score2, score3, score4, score5) sum_score = score1 + score2 + score3 + score4 + score5 return sum_score - min_score - max_score assert f(0, 0, 0, 0, 0) == 0
benchmark_functions_edited/f386.py
def f(x, y): print("INSIDE ADDER!") return x + y assert f(1, 0) == 1
benchmark_functions_edited/f170.py
def f(x, y): ret = 3 * x * x * x * y * y * y return ret assert f(0, 0) == 0
benchmark_functions_edited/f3238.py
def f(success): if success: print('Success.') return 0 print('Failed.') return 1 assert f(True) == 0
benchmark_functions_edited/f10000.py
def f(str1, str2): a = set(str1.split()) b = set(str2.split()) c = a.intersection(b) return float(len(c)) / (len(a) + len(b) - len(c)) assert f("hello", "world") == 0
benchmark_functions_edited/f14500.py
def f(Z1, Z2): produkt = 0 if Z1 < Z2: zahl_klein = Z1 zahl_gross = Z2 else: zahl_klein = Z2 zahl_gross = Z1 while zahl_klein >= 1: if zahl_klein % 2 != 0: produkt = produkt + zahl_gross zahl_klein = zahl_klein // 2 zahl_gross = zahl_gross * 2 return produkt assert f(2, 2) == 4
benchmark_functions_edited/f10035.py
def f(n: int) -> int: total = 0 fizzvisits = set() for i in range(0, n, 3): total += i fizzvisits.add(i) for j in range(0, n, 5): if j not in fizzvisits: total += j return total assert f(2) == 0
benchmark_functions_edited/f3120.py
def f(value: int): return int((value / 100.0) * 255) assert f(1) == 2
benchmark_functions_edited/f4493.py
def f(variable, items): return min(items, key=lambda x: abs(x - variable)) assert f(3, [1, 2, 3, 4, 5]) == 3
benchmark_functions_edited/f14238.py
def f(d): if isinstance(d, dict): return 1 + (max(map(get_dictionary_depth, d.values())) if d else 0) return 0 assert f( { "a": 1, "b": 2, "c": { "a": 3, "b": 4, "c": { "a": 5, "b": 6, }, }, } ) == 3
benchmark_functions_edited/f1756.py
def f(poemString): return len(poemString.split()) assert f("A multiple line\nstring.") == 4
benchmark_functions_edited/f70.py
def f(i, j): return int(i == j) assert f(4, 0) == 0
benchmark_functions_edited/f3564.py
def f(n): i = 0 j = 1 n = n - 1 while n >= 0: i, j = j, i + j n = n - 1 return i assert f(0) == 0
benchmark_functions_edited/f3054.py
def f(L): return sum(map(lambda x: len(x), L)) assert f( ['a', 'bc', 'd', '', 'efg'] ) == 7
benchmark_functions_edited/f1514.py
def f(a, min_value, max_value): return max(min(a, max_value), min_value) assert f(3, 3, 5) == 3
benchmark_functions_edited/f13189.py
def f(matrix, col: int) -> int: col_terms = (matrix[line][col] for line in range(col, len(matrix))) col_terms_abs = list(map(abs, col_terms)) max_abs = max(col_terms_abs) return col_terms_abs.index(max_abs) + col assert f( [ [-1, 2, 3], [3, 5, 7], [-1, 2, 3], [3, 5, 7], ], 2, ) == 3
benchmark_functions_edited/f2785.py
def f(a: int, b: int, n: int): count = 0 while b <= n: a, b = max(a, b), b+a count += 1 return count assert f(3, 12, 20) == 2
benchmark_functions_edited/f3573.py
def f(num): if num==1: return 1 else: return(num*f(num-1)) assert f(2) == 2
benchmark_functions_edited/f9602.py
def f(tree): if tree is None: return 1 if tree.is_empty(): return 4 number = 0 number += f(tree.left) number += f(tree.middle) number += f(tree.right) return number assert f(None) == 1
benchmark_functions_edited/f13266.py
def f(haystack, needle): if needle == "" or haystack == needle: return 0 size = len(needle) for i in range(len(haystack)-size+1): if haystack[i:i+size] == needle: return i return -1 assert f("mississippi", "issip") == 4
benchmark_functions_edited/f9281.py
def f(x, y): step, remainder = divmod(x, y) if remainder: step = (x + remainder) // y if step == 0: step = 1 return step assert f(5, 3) == 2
benchmark_functions_edited/f3153.py
def f(s): count=0 for i in range(len(s)): if s[i] != " " and (i==0 or s[i-1]==" "): count+=1 return count assert f( "Loooooove live!" ) == 2
benchmark_functions_edited/f11981.py
def f(day): if day == "Sunday": return 0 elif day == "Monday": return 1 elif day == "Tuesday": return 2 elif day == "Wednesday": return 3 elif day == "Thursday": return 4 elif day == "Friday": return 5 elif day == "Saturday": return 6 else: return None assert f("Thursday") == 4
benchmark_functions_edited/f6148.py
def f(service): instance_counts = service["instance-counts"] return instance_counts["healthy-instances"] + instance_counts["unhealthy-instances"] assert f( { "instance-counts": { "total-instances": 5, "healthy-instances": 3, "unhealthy-instances": 2 } } ) == 5
benchmark_functions_edited/f12260.py
def f(exp1, exp2): words1, _ = exp1 words2, _ = exp2 l1 = len(words1) l2 = len(words2) l_intersect = len(set(words1).intersection(set(words2))) return 0 if l_intersect / float(l1) >= l_intersect / float(l2) else 1 assert f( ('word1','word2'), ('word1','word3') ) == 0
benchmark_functions_edited/f1119.py
def f(a, b, u): return a**(1-u) * b**u assert f(1, 1, 0.75) == 1
benchmark_functions_edited/f101.py
def f(x): return 1 if x >= 0 else -1 assert f(0) == 1
benchmark_functions_edited/f6758.py
def f(x,y): if x > y: return x return y assert f(-4,3) == 3
benchmark_functions_edited/f2702.py
def f(relSeas_peak, relSeas_edge, period): return (relSeas_peak - relSeas_edge) / period assert f(20, 10, 10) == 1
benchmark_functions_edited/f1078.py
def f(dpid): dpid = int(dpid.replace(":", ""), 16) return dpid assert f("00:00:00:00:00:00:00:01") == 1
benchmark_functions_edited/f14006.py
def f(x, a, b, A=0, B=1): if a == b: res = B else: res = (x - a) / (1.0 * (b - a)) * (B - A) + A if res < A: res = A if res > B: res = B return res assert f(-0.1, 0, 1, 0, 10) == 0
benchmark_functions_edited/f2803.py
def f(x1: float, y1: float, x2: float, y2: float) -> float: return ((x2 - x1) ** 2 + (y2 - y1) ** 2) ** 0.5 assert f(0, 0, 3, 4) == 5
benchmark_functions_edited/f9740.py
def f(sequence): maxsofar, maxendinghere = 0, 0 for x in sequence: # invariant: ``maxendinghere`` and ``maxsofar`` are accurate for ``x[0..i-1]`` maxendinghere = max(maxendinghere + x, 0) maxsofar = max(maxsofar, maxendinghere) return maxsofar assert f([1, 2, 3, -1]) == 6
benchmark_functions_edited/f14176.py
def f(config, n_iter): ranges = [i for i in range(len(config) - 1) if config[i][0] <= n_iter < config[i + 1][0]] if len(ranges) == 0: assert n_iter >= config[-1][0] return config[-1][1] assert len(ranges) == 1 i = ranges[0] x_a, y_a = config[i] x_b, y_b = config[i + 1] return y_a + (n_iter - x_a) * float(y_b - y_a) / float(x_b - x_a) assert f( [(0, 1), (2, 3), (5, 4), (10, 5)], 0) == 1
benchmark_functions_edited/f7755.py
def f(x): if x == 'yes': return 1 else: return 0 assert f(0) == 0
benchmark_functions_edited/f5090.py
def f(typ): try: return len(typ.__args__) except AttributeError: # For Any type, which takes no arguments. return 0 assert f(object) == 0
benchmark_functions_edited/f13961.py
def f(data_augm_factor): if data_augm_factor >= 8: data_augm_factor = 8 elif data_augm_factor >= 4: data_augm_factor = 4 elif data_augm_factor >= 2: data_augm_factor = 2 else: data_augm_factor = 1 return data_augm_factor assert f(5) == 4