file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f3068.py
def f(s: bytes) -> int: assert len(s) == 32 return int.from_bytes(s, 'little') assert f(bytes.fromhex('0000000000000000000000000000000000000000000000000000000000000000')) == 0
benchmark_functions_edited/f1671.py
def f(list1): length = len(list1) mid = length//2 return mid assert f(list(range(0))) == 0
benchmark_functions_edited/f3628.py
def f(prefix): return { 'foo' : 8, 'foobar' : 8, 'bar' : 3, }.get(prefix, 2) assert f('bar') == 3
benchmark_functions_edited/f13421.py
def f(n): "*** YOUR CODE HERE ***" if n == 1: print(1) return 1 elif n % 2 == 0: print(n) return f(n // 2) + 1 else: print(n) return f(3 * n + 1) + 1 assert f(4) == 3
benchmark_functions_edited/f13016.py
def f(exon_list, position): exon_length = [int(i[1]) - int(i[0])+1 for i in exon_list] sum_of_exons = 0 for exon in range(len(exon_length)): if position < sum_of_exons + exon_length[exon]: return position + int(exon_list[exon][0]) - sum_of_exons sum_of_exons += exon_length[exon] return -1 assert f( [(0,5),(5,10),(15,20)], 5 ) == 5
benchmark_functions_edited/f10296.py
def f(r: int, g: int, b: int ) -> int: return b + (g << 8) + (r << 16) assert f(0, 0, 0) == 0
benchmark_functions_edited/f9379.py
def f(a: str, b: str) -> int: for common, (ca, cb) in enumerate(zip(a, b)): if ca != cb: return common return min(len(a), len(b)) assert f(b'abc', b'') == 0
benchmark_functions_edited/f6416.py
def f(string): result = 0 for n, c in enumerate(string): if isinstance(c, str): c = ord(c) result |= c << (8 * n) return result assert f(b'\x00\x00\x00\x00') == 0
benchmark_functions_edited/f12654.py
def f(value): value, modifier = str(value).split(".")[0], "" if value[:1] == "-": value, modifier = value[1:], "-" integer_part, float_part = value[:2], value[3:] return float(modifier + integer_part + "." + float_part) assert f("4.4.3") == 4
benchmark_functions_edited/f5702.py
def f(args): offset = args.get('offset', '0') if offset.isdigit(): return int(offset) else: return 0 assert f({'offset': 'a'}) == 0
benchmark_functions_edited/f930.py
def f(position, roll): new_position = position + (roll * 2) return new_position assert f(1, 2) == 5
benchmark_functions_edited/f1456.py
def f(v1,v2): return v1[0]*v2[0] + v1[1]*v2[1] assert f( [1, 1], [1, -1] ) == 0
benchmark_functions_edited/f2457.py
def f(data): return data.real ** 2 + data.imag ** 2 assert f((1 + 2j)) == 5
benchmark_functions_edited/f4057.py
def f(array: list) -> int: index, value = max(enumerate(array), key=lambda x: x[1]) return index assert f( [1, 2, 3, 4, 5, 5, 5] ) == 4
benchmark_functions_edited/f3890.py
def decodeBits (len, val): return val if (val & (1 << len - 1)) else val - ((1 << len) - 1) assert f(6, 65) == 2
benchmark_functions_edited/f3223.py
def f(n, width): (mask, shift) = ((3, 2), (7, 3))[width == 64] return ((n + mask) & ~mask) >> shift assert f(48, 64) == 6
benchmark_functions_edited/f889.py
def f(read_name): return int(read_name[8]) assert f(r'ERR175914.5682134_4') == 4
benchmark_functions_edited/f6840.py
def f(set1, set2): size_intersection = float(len(set1.intersection(set2))) size_union = float(len(set1.union(set2))) return size_intersection / size_union assert f(set(), set(["b", "c"])) == 0
benchmark_functions_edited/f1325.py
def f(n): L = [] for s in str(n): L.append(int(s)) return sum(L) assert f(123) == 6
benchmark_functions_edited/f10598.py
def f(value, power): return (((value - 1) >> power) + 1) << power assert f(8, 3) == 8
benchmark_functions_edited/f10190.py
def f(str: str) -> int: if str == 'L': return 1 if str == 'R': return -1 return 0 assert f(10) == 0
benchmark_functions_edited/f13183.py
def f(numbers, window_length=3): increases = 0 for index, _ in enumerate(numbers[:-window_length]): prev_window = sum(numbers[index:index + window_length]) cur_window = sum(numbers[index + 1:index + window_length + 1]) if cur_window > prev_window: increases += 1 return increases assert f( [200, 208, 200, 207, 240, 269, 260, 263, 199, 210] ) == 5
benchmark_functions_edited/f6405.py
def f(words, letter): count = 0 for word in words: count += word.count(letter) return count assert f(['hello', 'world', 'hello', 'hi', 'bye'], 'x') == 0
benchmark_functions_edited/f2993.py
def f(a, b, amount): return ((1.0 - amount) * a) + (amount * b) assert f(0, 100, 0) == 0
benchmark_functions_edited/f11570.py
def f(arg,no_raise=True): if arg in {0,1,2}: return arg elif arg in '012': return int(arg) try: return { "low":0, "medium":1, "high":2 }[arg.lower()] except KeyError: return arg assert f(False) == 0
benchmark_functions_edited/f1959.py
def f(n: int) -> int: sum = 0 for i in range(1, n + 1): sum += i return sum assert f(2) == 3
benchmark_functions_edited/f2136.py
def f(a,b): while b: a, b = b, a % b return a assert f(5,12) == 1
benchmark_functions_edited/f13623.py
def f(R,i,n): factor = (1+i)**n anu = (factor-1)/i total = R*anu return total assert f(1000, 0.05/12, 0) == 0
benchmark_functions_edited/f10543.py
def f(current_salary, level_salary): assert current_salary >= level_salary return -(current_salary - level_salary) assert f(1500, 1500) == 0
benchmark_functions_edited/f4196.py
def f(weight): weight_stone = weight / 14 return weight_stone assert f(0) == 0
benchmark_functions_edited/f1275.py
def f(i, j): return i * 30 - i * (i + 1) // 2 + j - 1 assert f(0, 1) == 0
benchmark_functions_edited/f7881.py
def f(menu_items, parent_id): counter = 0 for menu in menu_items: if menu['parent_id'] == parent_id: counter += 1 return counter assert f( [{'id': 1, 'name': 'Pasta', 'parent_id': 3}, {'id': 2, 'name': 'Meat', 'parent_id': 3}, {'id': 3, 'name': 'Pasta and Meat', 'parent_id': None}], 10) == 0
benchmark_functions_edited/f58.py
def f(data): return max(data) - min(data) assert f(range(1, 10)) == 8
benchmark_functions_edited/f10775.py
def f(l, idx, default=None): try: return l[idx] except IndexError: return default assert f(range(5), 1) == 1
benchmark_functions_edited/f9960.py
def f(n): res = 1 while n!=1: if n % 2 == 0: n = n//2 else: n = 3 * n + 1 res += 1 return res assert f(2) == 2
benchmark_functions_edited/f5150.py
def f(pos, wiggle, stds): partial = stds[pos-wiggle:pos+wiggle] smallest = min(partial, key=lambda x: x[0]) return smallest[2] assert f(0, 2, [[0, 1, 0], [0, 0, 1]]) == 0
benchmark_functions_edited/f13686.py
def f(seq1, seq2): dist = sum([char1 != char2 for char1, char2 in zip(seq1, seq2)]) return dist assert f('GGGCCGTTGGT', 'GGACCGTTGAC') == 3
benchmark_functions_edited/f1212.py
def f(i): n = 1 while n < i: n *= 2 return n assert f(8) == 8
benchmark_functions_edited/f6565.py
def f(a, b): if a is None and b is None: return 0 elif a is None: return -1 elif b is None: return 1 else: return (a > b) - (a < b) assert f(1, 1) == 0
benchmark_functions_edited/f3519.py
def f(region, metric, ms): if metric in region: value = region[metric] return round((value / ms) * 100) else: return 0 assert f({"name": "Region"}, "total_time", 1000) == 0
benchmark_functions_edited/f11462.py
def f(area_deg: float): scale_m_per_deg = 30 / 0.00025 return area_deg * (scale_m_per_deg ** 2) / 10000 assert f(0) == 0
benchmark_functions_edited/f11515.py
def f(score): if score >= 0 and score < 0.2: return 0 elif score >= 0.2 and score < 0.4: return 1 elif score >= 0.4 and score < 0.6: return 2 elif score >= 0.6 and score < 0.8: return 3 else: return 4 assert f(0.4) == 2
benchmark_functions_edited/f5219.py
def f(n): if n == 0: return 0 if n == 1: return 1 return f(n - 1) + f(n - 2) assert f(3) == 2
benchmark_functions_edited/f11303.py
def f(artifacted_blocks): annoyance = 0 if len(artifacted_blocks) != 0: for block in artifacted_blocks: annoyance += block.annoyance return annoyance / len(artifacted_blocks) else: return 0 assert f([]) == 0
benchmark_functions_edited/f12286.py
def f(ordered, target): low = 0 high = len(ordered)-1 while low <= high: mid = (low + high) // 2 if target < ordered[mid]: high = mid-1 elif target > ordered[mid]: low = mid+1 else: return mid return -(low + 1) assert f(range(10), 6) == 6
benchmark_functions_edited/f6834.py
def f(number1, number2): if number1 > number2: return number1 elif number2 > number1: return number2 else: return number1 assert f(3, 5) == 5
benchmark_functions_edited/f4190.py
def f(arg): if arg is None or str(arg).lower() == 'none': return None return int(arg) assert f('1') == 1
benchmark_functions_edited/f387.py
def f(seconds): return seconds / (60.0**2 * 24.0) assert f(86400) == 1
benchmark_functions_edited/f10196.py
def f( location ): if ( ".." in location ): return 1 elif ( "/" in location ): return 1 elif ( len( set( location ) ) == 1 and location[0] == ' ' ): return 0 elif ( len( set( location ) ) == 0 ): return 0 assert f( "" ) == 0
benchmark_functions_edited/f4066.py
def f(lis, index): try: return lis[index] except IndexError: return None assert f(list((1, 2, 3, 4, 5)), 2) == 3
benchmark_functions_edited/f5802.py
def f(person, one_gene, two_genes): return (2 if person in two_genes else 1 if person in one_gene else 0) assert f(0, [], []) == 0
benchmark_functions_edited/f10515.py
def f(flags, objects): if sum(flags) == 1: return objects[0] elif sum(flags) > 1: return tuple([object for flag, object in zip(flags, objects) if flag]) else: return () assert f((1, 0), (1, 2)) == 1
benchmark_functions_edited/f7442.py
def f(length, fsize, fshift): pad = (fsize - fshift) if length % fshift == 0: M = (length + pad * 2 - fsize) // fshift + 1 else: M = (length + pad * 2 - fsize) // fshift + 2 return M assert f(6, 5, 2) == 4
benchmark_functions_edited/f13287.py
def f(time: int, job_process_time: int, due_date_job: int) -> int: time_after_job = time + job_process_time return time_after_job - due_date_job assert f(15, 10, 20) == 5
benchmark_functions_edited/f13767.py
def f(n): memory = {} x, i = 1, 0 while x not in memory: memory[x] = i x = (x * 10) % n i += 1 return i - memory[x] assert f(4) == 1
benchmark_functions_edited/f7808.py
def f(cc, look_at): count = 0 for p in cc: if not look_at[p]: continue if p==0 or cc[p]==0: continue count += 1 return count assert f( {0:0, 1:1, 2:0}, {0:False, 1:True, 2:False} ) == 1
benchmark_functions_edited/f13469.py
def f(generator, enforce=True): result = None for item in generator: result = item break if enforce: for item in generator: raise RuntimeError('Generator "%s" had more than one item.' % generator.__name__) return result assert f(range(10), False) == 0
benchmark_functions_edited/f2175.py
def f(a, b): return pow(a, b) assert f(-1, 2) == 1
benchmark_functions_edited/f10844.py
def f(predicted_class_list, true_class_list): wrong_classification = 0 for pred, act in zip(predicted_class_list, true_class_list): if pred != act: wrong_classification += 1 return round(wrong_classification / len(predicted_class_list), 4) assert f( ["a", "a", "a"], ["a", "a", "a", "a", "a", "a", "a", "a", "a", "a"]) == 0
benchmark_functions_edited/f9477.py
def f(number: float) -> int: return abs(round(number)) assert f(3.0) == 3
benchmark_functions_edited/f14263.py
def f(a, b): assert a>0 and b>0 if a<=b: return a for k in range(0, a-b+1): bh = b + k if bh>1 and a % bh == 0: return bh bh = b - k if bh>1 and a % bh == 0: return bh raise assert f(5, 3) == 5
benchmark_functions_edited/f9043.py
def f( rnet, vegetation_fraction): result = vegetation_fraction * rnet return result assert f( 1, 0) == 0
benchmark_functions_edited/f13045.py
def f(n): pv = {v: v**n for v in range(10)} match = [] for num in range(2**n, 10**(n+1)): digits = (int(dg) for dg in str(num)) sum_ = sum(pv[d] for d in digits) if num == sum_: match.append(num) return sum(match) assert f(0) == 1
benchmark_functions_edited/f9932.py
def f(estimators, estimators_features, X): return sum(estimator.decision_function(X[:, features]) for estimator, features in zip(estimators, estimators_features)) assert f(list(), list(), list([1,2,3])) == 0
benchmark_functions_edited/f14035.py
def f(model_trace): sites = [site for site in model_trace.values() if site["type"] == "sample"] dims = [ frame.dim for site in sites for frame in site["cond_indep_stack"] if frame.dim is not None ] max_plate_nesting = -min(dims) if dims else 0 return max_plate_nesting assert f( { "x": {"type": "sample", "fn": lambda: 1, "cond_indep_stack": []}, "y": {"type": "sample", "fn": lambda: 2, "cond_indep_stack": []}, } ) == 0
benchmark_functions_edited/f10152.py
def f(event, attributes): score = 0 for attribute in attributes: if attribute["category"] == "Network activity": ty = attribute["type"] if ty == "domain": score += 5 return score assert f(None, [{"category":"Network activity", "type":"domain"}]) == 5
benchmark_functions_edited/f2418.py
def f(v): i = 0 while i in v: i += 1 return i assert f(range(5)) == 5
benchmark_functions_edited/f6904.py
def f(cond,if_true_value,else_value): if(cond): return if_true_value else: return else_value assert f(False,"4",5) == 5
benchmark_functions_edited/f851.py
def f(i, j): return 1 if i == j else 0 assert f(4, 1) == 0
benchmark_functions_edited/f10472.py
def f(gL,gS,J,S,L): return gL * (J * (J + 1) - S * (S + 1) + L * (L + 1)) / (2 * J * (J + 1)) + \ gS * (J * (J + 1) + S * (S + 1) - L * (L + 1)) / (2 * J * (J + 1)) assert f(1,1,2,1,1) == 1
benchmark_functions_edited/f10902.py
def f(a,b): last_digit_a = int(str(a)[-1]) if b % 4 == 0: exp = 4 else: exp = b % 4 return (last_digit_a ** exp) % 10 assert f(2,7) == 8
benchmark_functions_edited/f6165.py
def f(seat_map): occupied = 0 for seat, state in seat_map.items(): if state == "#": occupied += 1 return occupied assert f( { (0, 0): "L", (1, 0): "#", (1, 1): "#", (0, 1): "L", (1, 2): "L", (2, 2): "L", } ) == 2
benchmark_functions_edited/f5339.py
def f(aDict): return sum(len(value) for value in aDict.values()) assert f({}) == 0
benchmark_functions_edited/f13960.py
def f(node_tuple_list): max_coordinate = 0 for node_tuple in node_tuple_list: if len(node_tuple) == 3 and node_tuple[2] > max_coordinate: max_coordinate = node_tuple[2] return max_coordinate assert f([(1, 1, 1), (2, 2, 2), (3, 3, 3), (4, 4, 4), (5, 5, 5), (6, 6, 6)]) == 6
benchmark_functions_edited/f13151.py
def f(num_R_vertices: int, num_E_vertices: int): return 1 - abs(num_R_vertices - num_E_vertices) / (num_R_vertices + num_E_vertices) assert f(1, 1) == 1
benchmark_functions_edited/f1800.py
def f(nu,Alf,betalf,nuref=30e9): return Alf*(nu/nuref)**(betalf) assert f(30e9, 1, -2) == 1
benchmark_functions_edited/f7122.py
def f(month): months = ['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'] return months.index(month) + 1 assert f("MAR") == 3
benchmark_functions_edited/f6347.py
def f(x, bits=32): tot = 0 while x: tot += 1 x &= x - 1 return tot assert f(0x10001) == 2
benchmark_functions_edited/f4090.py
def f(t): if t is None or not t.left and not t.right: return 0 else: return 1 + max(f(t.left), f(t.right)) assert f(None) == 0
benchmark_functions_edited/f6612.py
def f(row, minimum, maximum): count = 0 for n in row: if minimum <= n <= maximum: count = count + 1 return count assert f([0, 100], 1, 100) == 1
benchmark_functions_edited/f1887.py
def f(t, p, n=6): p += 1 print (t, p, n) pepe = t * p * n print (pepe) return pepe assert f(0, 5) == 0
benchmark_functions_edited/f12815.py
def f(subset): representation = 0 for i in subset: representation += (1 << i) return representation assert f(set()) == 0
benchmark_functions_edited/f13316.py
def f(decimal_num: str): decimal_string = str(decimal_num) if len(decimal_string) > 0: first = decimal_string[0] current = 2**(len(decimal_string) - 1) if first == '1' else 0 decimal_string = decimal_string[1:] return current + f(decimal_string) return 0 assert f(100) == 4
benchmark_functions_edited/f10547.py
def f(minimum, maximum, x): if x <= minimum: return minimum elif x >= maximum: return maximum else: return x assert f(0, 5, 5) == 5
benchmark_functions_edited/f12849.py
def f(n): if n < 10: return n else: n -= 10 num = 90 digits = 2 nums = num * digits while n > nums: n -= nums num *= 10 digits += 1 nums = num * digits else: res_digit = str(10 ** (digits - 1) + (n // digits))[n % digits] return int(res_digit) assert f(2) == 2
benchmark_functions_edited/f7350.py
def f(x): res = {"Sunday":0, "Monday":1, "Tuesday":2, "Wednesday":3, "Thursday":4, "Friday":5, "Saturday":6} ans = res.get(x, None) return ans assert f("Friday") == 5
benchmark_functions_edited/f10511.py
def f(codon, seq): seq = seq.upper() codon = codon.upper() i = 0 # Scan sequence until we hit the start codon or the end of the sequence while seq[i:i+3] != codon and i < len(seq): i += 1 if i == len(seq): return -1 return i assert f( 'GCG', 'GCGTACGCGTACGCGTATAGCGTACGCGCGCGCGTACGCGTACGCGT') == 0
benchmark_functions_edited/f14471.py
def f(timeseries, tidx=0, vidx=1): try: t = (timeseries[-1][vidx] + timeseries[-2] [vidx] + timeseries[-3][vidx]) / 3 return t except IndexError: return timeseries[-1][vidx] assert f( [(0, 0), (1, 0), (2, 1), (3, 0), (4, 0), (5, 0), (6, 0)]) == 0
benchmark_functions_edited/f1134.py
def f(a,b): if(a != 0 or b != 0): return 1 else: return 0 assert f(1,1) == 1
benchmark_functions_edited/f13267.py
def f(filename, data): print('Checking page count', filename) return len(data['analyzeResult']['readResults']) assert f( '000003.json', { 'analyzeResult': { 'readResults': [{ 'page': 1 }, { 'page': 2 }, { 'page': 3 }, { 'page': 4 }] } } ) == 4
benchmark_functions_edited/f5695.py
def f(data: bytes, bitlen: int): val = '0b' + ''.join([f'{b:08b}' for b in data]) return int(val[0:2 + bitlen], 2) assert f(b'\x00\x00\x00\x00', 24) == 0
benchmark_functions_edited/f1317.py
def f(line): return len(line) - len(line.lstrip()) assert f( 'if foo:') == 0
benchmark_functions_edited/f13700.py
def f(row, rarefy=0, count=False): if count: return sum(row > 0) row_sum, R = sum(row), 0 if row_sum == 0: return 0 for val in row: prob_success = val / row_sum prob_fail = 1 - prob_success prob_detect = 1 - (prob_fail ** rarefy) if val and rarefy <= 0: R += 1 else: R += prob_detect return int(R + 0.5) assert f([0, 0]) == 0
benchmark_functions_edited/f1996.py
def f(arg): if arg > 0: a = 1 else: a = 0 return a assert f(0) == 0
benchmark_functions_edited/f8659.py
def f(v, bound): for b in bound: if v >= b[0] and v <= b[1]: return v return min([(abs(x - v), x) for x in bound.flatten()])[1] assert f(0, ((0, 100), (0, 100))) == 0
benchmark_functions_edited/f13087.py
def f(n, k): # pragma: no cover if k < 0 or k > n: return 0 if k in (0, n): return 1 binom = 1 for i in range(min(k, n - k)): binom *= n - i binom //= i + 1 return binom assert f(1, 0) == 1
benchmark_functions_edited/f12030.py
def f(conc): per_cubic_angstrom = conc / 1e+24 per_unit_cell = per_cubic_angstrom * (13.003 * 13.003 * 12.498) return per_unit_cell assert f(0.0) == 0
benchmark_functions_edited/f2049.py
def f(record): return record['exit_idx'] - record['entry_idx'] assert f( {'entry_idx': 0, 'exit_idx': 0}) == 0
benchmark_functions_edited/f1126.py
def f(s): if s == "+": return 11 if s == "*": return 12 return int(s) + 1 assert f(4) == 5
benchmark_functions_edited/f5785.py
def f(n, target): ct = 0 if n is None: return 0 if n.value == target: ct = 1 return ct + f(n.next, target) assert f(None, 5) == 0