file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f1679.py
def f(Do, WT): return Do - 2 * WT assert f(6, 0) == 6
benchmark_functions_edited/f4791.py
def f(orientation): return (orientation + 2) % 4 assert f(0) == 2
benchmark_functions_edited/f8656.py
def f(n: int, p: int) -> int: fact = [1]*p for i in range(1, p): fact[i] = fact[i-1] * i % p ans = 1 while n > 1: if n//p & 1: ans = p - ans ans = ans * fact[n % p] % p n //= p return ans assert f(1, 5) == 1
benchmark_functions_edited/f5276.py
def f(time, computed_values): return computed_values["traced_flow_rate"] assert f(0, {"traced_flow_rate": 3}) == 3
benchmark_functions_edited/f11590.py
def f(filename): import os if os.path.isfile(filename): return os.path.getmtime(filename) else: return 0 assert f('not_a_file') == 0
benchmark_functions_edited/f1098.py
def f(cp): return cp if isinstance(cp, int) else cp[0] assert f(2) == 2
benchmark_functions_edited/f12512.py
def f(x, y, max_iters): c = complex(x, y) z = 0.0j for i in range(max_iters): z = z * z + c if (z.real * z.real + z.imag * z.imag) >= 4: return i return max_iters assert f(0, 0, 1) == 1
benchmark_functions_edited/f4931.py
def f(l,w): if l <=0 or w <=0: raise ValueError return l*w assert f(1,2) == 2
benchmark_functions_edited/f9767.py
def f(struct, keys, default=None): if not keys: return struct try: return f(struct[keys[0]], keys[1:]) except (KeyError, IndexError): return default assert f( {'a': {'b': 2}}, ['a', 'b'], ) == 2
benchmark_functions_edited/f6505.py
def f(label: str) -> int: return 1 if label=="POSITIVE" else 0 assert f("POSITIVE") == 1
benchmark_functions_edited/f5227.py
def f(chars): if chars: return ((len(chars) - 1) * 2 + 1) ** 2 else: return -1 assert f("a") == 1
benchmark_functions_edited/f6131.py
def f(m, n): if m == 0: return n+1 if n == 0: return f(m-1, 1) return f(m-1, f(m, n-1)) assert f(1, 3) == 5
benchmark_functions_edited/f14399.py
def f(elements): dictionary = {} elements.sort() for element in elements: if element in dictionary: dictionary[element] += 1 else: dictionary[element] = 1 # Get the max value max_value = max(dictionary.values()) highest_elements = [key for key, value in dictionary.items() if value == max_value] modes = sorted(highest_elements) return modes[0] assert f([1, 2, 3, 4, 4, 4, 5]) == 4
benchmark_functions_edited/f11036.py
def f(max_bits, num): return int(bin(num)[2:].zfill(max_bits)[-max_bits:][::-1], 2) assert f(4, 0) == 0
benchmark_functions_edited/f6011.py
def f(vecA, vecB): x1, y1 = vecA[0], vecA[1] x2, y2 = vecB[0], vecB[1] return x1 * x2 + y1 * y2 assert f( [0, 0], [1, 0] ) == 0
benchmark_functions_edited/f14210.py
def f(lista, elemento): contador = 0 try: while contador <= len(lista): if contador == elemento: break contador += 1 print('SEQUENCIAL INDEX DEU CERTO') return contador except IndexError: print('Elemento nao achado') assert f(list(range(10)), 2) == 2
benchmark_functions_edited/f10135.py
def f(string): if not string: return 0 elif string == "": return 0 else: try: return int(string) except ValueError: return float(string) assert f(2) == 2
benchmark_functions_edited/f7150.py
def getBits (num, gen): out = 0 for i in range (num): out <<= 1 val = gen.next () if val != []: out += val & 0x01 else: return [] return out assert f(0, [1,0]) == 0
benchmark_functions_edited/f4571.py
def f(m): if (m == 'all') or (m is None): return(m) else: return(int(m)) assert f(1.0) == 1
benchmark_functions_edited/f5084.py
def f(lst: list) -> int: cnt = 0 for i in range(len(lst)): for j in range(len(lst[0])): if lst[i][j] == 1: cnt += 1 return cnt assert f( [[0, 1, 0], [0, 0, 0], [0, 0, 0]]) == 1
benchmark_functions_edited/f4849.py
def f(cm): return 2 * cm[1][1] / float(2 * cm[1][1] + cm[0][1] + cm[1][0]) assert f( [[1, 1], [0, 0]] ) == 0
benchmark_functions_edited/f11418.py
def f(list_, i): v = list_[i] while i > 0 and list_[i - 1] > v: i -= 1 return i assert f([1, 1, 1], 1) == 1
benchmark_functions_edited/f4330.py
def f(coord, L): # XXX: 3D hardcoded, can do N-D return coord[0] * L[1] * L[2] + coord[1] * L[2] + coord[2] assert f((0, 0, 0), (1, 1, 2)) == 0
benchmark_functions_edited/f8157.py
def f(column): if isinstance(column, tuple): column = '_'.join(str(x) for x in column) return column assert f(1) == 1
benchmark_functions_edited/f10768.py
def f(listvalue): return sum(listvalue) / len(listvalue) assert f([1, 2, 3, 4, 5]) == 3
benchmark_functions_edited/f8723.py
def f(n, k, base_case): if k == 0 or k == n: print('base case!') base_case[0] += 1 return 2 else: return f(n-1, k-1, base_case) + f(n-1, k, base_case) assert f(3, 0, [0]) == 2
benchmark_functions_edited/f9055.py
def f(kargs): func = kargs['func'] del kargs['func'] out = func(**kargs) return out assert f( {'func': lambda a, b: a * b, 'a': 1, 'b': 2}) == 2
benchmark_functions_edited/f2801.py
def f(x, y): diag = x + y bottom = diag * (diag + 1) / 2 return bottom + y assert f(3, 0) == 6
benchmark_functions_edited/f10679.py
def f(stop_after): if stop_after <= 0: return 0 if stop_after <= 2: return 1 prev = 1 curr = 1 count = 2 while count <= stop_after: curr = curr + prev prev = curr - prev count = count + 1 return prev assert f(2) == 1
benchmark_functions_edited/f10992.py
def f(data, bit_index): if bit_index < 8 * len(data): cur_byte = data[bit_index // 8] return (cur_byte >> (7 - bit_index % 8)) & 0x1 raise RuntimeError("Out of bound index %s" % bit_index) assert f(b"\x00", 2) == 0
benchmark_functions_edited/f3398.py
def f(x, y): if not isinstance(x, (int, float)) or not isinstance(y, (int, float)): return 0 return x - y assert f(0, -1) == 1
benchmark_functions_edited/f966.py
def f(l0, l1): return sum(x * y for x, y in zip(l0, l1)) assert f((), ()) == 0
benchmark_functions_edited/f14507.py
def f(em: str, k: int, m: list): if k == 0: return 1 s = len(em) - k if em[s] == '0': return 0 if m[k] is not None: return m[k] result = f(em, k - 1, m) if k >= 2 and int(em[s:s + 2]) <= 26: result += f(em, k - 2, m) m[k] = result return result assert f( '1211', 2, [None] * 20 ) == 2
benchmark_functions_edited/f8243.py
def f(string): vowel_count = 0 #iterate over given string for char in string: #check if char is a vowel if char in 'aeiou': vowel_count += 1 return vowel_count assert f('xyz') == 0
benchmark_functions_edited/f13564.py
def f(number, typen=float): if typen is float: try: return float(number) except: return number elif typen is int: try: return int(number) except: return number assert f("1.0") == 1
benchmark_functions_edited/f8803.py
def f(x,y): num_x = int(x.split('_')[1]) num_y = int(y.split('_')[1]) if num_x > num_y: value = 1 elif num_y > num_x: value = -1 else: value = 0 return value assert f( "trial_0900001", "trial_09") == 1
benchmark_functions_edited/f12762.py
def f(func, *args, **kwargs): return func(*args, **kwargs) assert f(lambda x, y=1: x, 1) == 1
benchmark_functions_edited/f1396.py
def f(val, ll, ul): return (val - ll) / (ul - ll) assert f(0, 4, 0) == 1
benchmark_functions_edited/f29.py
def f(a, b): a ^= b return a assert f(3, 3) == 0
benchmark_functions_edited/f13569.py
def f(a, b, f): NEWTON_COTES_POINTS = 7 NEWTON_COTES_COEFFICIENTS = [0.29285714, 1.54285714, 0.19285714, 1.94285714, 0.19285714, 1.54285714, 0.29285714] h = (b - a) / (NEWTON_COTES_POINTS - 1) sum_fs = 0.0 for i in range(0, NEWTON_COTES_POINTS): sum_fs += NEWTON_COTES_COEFFICIENTS[i] * f(a + (i * h)) return h * sum_fs assert f(0, 0, lambda x: x) == 0
benchmark_functions_edited/f13751.py
def fitness (password, test_word): if len(test_word) != len(password): print('words must be equal length!') return else: score = 0 i = 0 while i < len(password): if password[i] == test_word[i]: score += 1 i += 1 return score * 100 / len(password) assert f(b'abc', b'bcd') == 0
benchmark_functions_edited/f4052.py
def f(num): return 0 if num == '' else int(num) assert f(3) == 3
benchmark_functions_edited/f5434.py
def f(Na, Nb): Nab = len(set(Na).intersection((set(Nb)))) return float(Nab) / (len(Na) + len(Nb) - Nab) assert f(set([1, 2, 3]), set([1, 2, 3])) == 1
benchmark_functions_edited/f2735.py
def f(int_no): c = 0 while int_no: int_no &= int_no - 1 c += 1 return c assert f(22) == 3
benchmark_functions_edited/f7615.py
def f(direction: int) -> int: if direction == 0: return 1 elif direction == 1: return 0 elif direction == 2: return 3 else: return 2 assert f(0) == 1
benchmark_functions_edited/f764.py
def f(host): return host["NID"] assert f({ "name": "jane", "NID": 5 }) == 5
benchmark_functions_edited/f5574.py
def f(a, n, m): ans = 1 while n > 0: if (n & 1) == 1: ans = (ans * a) % m n = n >> 1 a = (a * a) % m return ans assert f(11, 10000000, 100000) == 1
benchmark_functions_edited/f11405.py
def f(number: int, base: int) -> int: if number < 1 or base < 2: raise ValueError("math domain error") result = 1 accum = base while accum < number: result += 1 accum *= base return result assert f(2, 3) == 1
benchmark_functions_edited/f12778.py
def f(a, x): mn = 0 mx = len(a) - 1 i = 0 while mx - mn > 1: i = (mn + mx) // 2 if a[i] == x: return i elif x > a[i]: mn = i else: mx = i if a[mn] == x: return mn elif a[mx] == x: return mx else: return None assert f( [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 5 ) == 4
benchmark_functions_edited/f4056.py
def f(flags): return (flags & 0x7800) >> 11 assert f(0x0000) == 0
benchmark_functions_edited/f5706.py
def f(C, k, clk): return -1 * k * C * (C - clk) assert f(0, 1, 0) == 0
benchmark_functions_edited/f5548.py
def f(x): x = int(x) return 1 if x == 0 else 2 ** (x - 1).bit_length() assert f(0) == 1
benchmark_functions_edited/f10282.py
def f(a, b): if a >= 0 or b <= 0: return (max(abs(a), abs(b)) + 1) // 2 else: t = min(abs(a), abs(b)) return t + f(a + t, b - t) assert f(5, 10) == 5
benchmark_functions_edited/f7583.py
def f(temp): return (temp * 9) / 5 assert f(0) == 0
benchmark_functions_edited/f9215.py
def f(tree): if tree: n_nodes = f(tree.left) n_nodes += f(tree.right) n_nodes += 1 return n_nodes return 0 assert f(None) == 0
benchmark_functions_edited/f2362.py
def f(molecules): return sum(map(len, molecules)) assert f(((),)) == 0
benchmark_functions_edited/f3972.py
def f(s): try: ret = int(s) except ValueError: #Try float. ret = float(s) return ret assert f(5.0) == 5
benchmark_functions_edited/f11181.py
def f(p1x, p1y, p2x, p2y): min_d = 9e4 p1x, p1y = p1x[:8], p1y[:8] p2x, p2y = p2x[:8], p2y[:8] for i in range(len(p1x)): for j in range(len(p1x)): if ((p2x[i]-p1x[j])**2 + (p2y[i]-p1y[j])**2)**0.5 < min_d: min_d = ((p2x[i]-p1x[j])**2 + (p2y[i]-p1y[j])**2)**0.5 return min_d assert f([1, 2, 2], [1, 2, 2], [1, 2, 2], [1, 2, 2]) == 0
benchmark_functions_edited/f13841.py
def f(g1, s, guesses_number): if g1 in s: print("You have " + str(guesses_number) + " guesses left.") else: guesses_number = guesses_number - 1 if guesses_number == 0: pass else: # print("There is no " + str(g1) + "'s in the word.") print("You have " + str(guesses_number) + " guesses left.") return guesses_number assert f(1, [1, 2], 0) == 0
benchmark_functions_edited/f10655.py
def f(objects): s = set() for t in objects: for i in t: s.add(i) nvars = len(s) b = list(sorted(s)) b.sort() if b != list(range(nvars)): raise ValueError('elements should be labelled in 0,...,nvars-1') return nvars assert f({}) == 0
benchmark_functions_edited/f7181.py
def f(x, y, name="rosenbrock"): if name == "rosenbrock": return (1 - x) ** 2 + 100 * (y - x ** 2) ** 2 else: raise NotImplementedError assert f(1, 1) == 0
benchmark_functions_edited/f12073.py
def f(current: int, min: int, max: int) -> int: return round(float(current - min) / (max - min) * 100) assert f(0, 0, 200) == 0
benchmark_functions_edited/f2657.py
def f(i): #return int(log(3*y+1)/log(2))>>1 return int((3*i+1).bit_length()-1)>>1 assert f(19) == 2
benchmark_functions_edited/f5479.py
def f(int_type: int) -> int: count = 0 while int_type: int_type &= int_type - 1 count += 1 return count assert f(0b1) == 1
benchmark_functions_edited/f6494.py
def f(n): if n % 2 == 0: n += 1 return n assert f(7) == 7
benchmark_functions_edited/f2752.py
def f(string,i,j): l=0; n = len(string) while (l+max(i,j)<n) and (string[i+l]==string[j+l]): l+=1 return l assert f("abcdefgh",0,6) == 0
benchmark_functions_edited/f4382.py
def f(points, points2sec=126/(5**3 * 6)): return points * points2sec * 3600**-1 assert f(0) == 0
benchmark_functions_edited/f1533.py
def f(x, in_min, in_max): return (x - in_min) * 2 / (in_max - in_min) + -1 assert f(0, -1, 1) == 0
benchmark_functions_edited/f4502.py
def f(binary): return int(binary, 2) assert f( "010") == 2
benchmark_functions_edited/f13954.py
def f(binary: str) -> int: is_negative = binary[0] == "-" binary = binary[1:] if is_negative else binary decimal = 0 for i in range(0, len(binary)): decimal += int(binary[i]) * (2 ** (len(binary) - i - 1)) return -decimal if is_negative else decimal assert f("1") == 1
benchmark_functions_edited/f13761.py
def f(codon, exon_num): # get left size cut_at = codon["split_"] left_side_ref = codon["ref_codon"][:cut_at] left_side_que = codon["que_codon"][:cut_at] ls_ref_gaps = left_side_ref.count("-") ls_que_gaps = left_side_que.count("-") fs_left = abs(ls_ref_gaps - ls_que_gaps) % 3 != 0 if fs_left: return exon_num - 1 else: return exon_num assert f( { "ref_codon": "ATG-TTA", "que_codon": "ATA-TTA", "split_": 2, }, 1 ) == 1
benchmark_functions_edited/f13730.py
def f(i, j, vertices): vi = vertices[i] vj = vertices[j] # use the height of money box as threshold threshold = abs(vi[1][1] - vi[2][1]) flag = 1 for a, b in zip(vi, vj): # check threshold for 4 corners if abs(a[1] - b[1]) > threshold: flag = 0 break return flag assert f(2, 1, [((10, 1), (0, 2), (1, 2)), ((1, 0), (1, 1), (1, 2)), ((0, 1), (1, 1), (2, 1))]) == 0
benchmark_functions_edited/f1181.py
def f(a, b, c=10): total = a+b+c return total assert f(2, 4, 3) == 9
benchmark_functions_edited/f8083.py
def f(i, j, n): return n * (n - 1) // 2 - (n - i) * (n - i - 1) // 2 + j - i - 1 assert f(2, 2, 2) == 0
benchmark_functions_edited/f3747.py
def f(lis): num = "" i = 0 while i < len(lis): num += str(lis[i]) i += 1 return int(num) assert f( [0, 0, 0, 0]) == 0000
benchmark_functions_edited/f4733.py
def f(bits): value = 0 for p, c in enumerate( reversed(bits) ): value += c * 2 ** p return value assert f( [0, 1, 0] ) == 2
benchmark_functions_edited/f6108.py
def f(token_index, sentence, duration): sentence_len = max(len(sentence), 1) return token_index / sentence_len * duration assert f(0, ['a', 'b', 'c'], 100) == 0
benchmark_functions_edited/f13410.py
def f(s, l, m): return l*(l+1) - s*(s+1) assert f(1, 1, 1) == 0
benchmark_functions_edited/f5787.py
def f(s: int) -> int: if s == 1: return 1 elif (s & (s - 1) == 0) and s != 0: return int(s / 2) else: return 0 assert f(*[4]) == 2
benchmark_functions_edited/f8890.py
def f(a, b=True): if a == -1: print("negative") result = 5 return result assert f(0, False) == 5
benchmark_functions_edited/f14177.py
def f(features_employed_by_explainer, features_employed_black_box): score = 0 for feature_employe in features_employed_by_explainer: if feature_employe in features_employed_black_box: score += 1 return score/len(features_employed_by_explainer) assert f( [1, 2, 3], [1, 2, 3]) == 1
benchmark_functions_edited/f972.py
def f(p1, p2): (x1, y1), (x2, y2) = p1, p2 return abs(x1 - x2) + abs(y1 - y2) assert f( (-1,0), (0,0) ) == 1
benchmark_functions_edited/f5765.py
def f(left, right): try: return left / right except ZeroDivisionError: return 0.0 * left assert f(0, 2) == 0
benchmark_functions_edited/f129.py
def f(f): return(round(int(f))) assert f(7.0) == 7
benchmark_functions_edited/f880.py
def f(m, n): return m * ((n+m-1) // m) assert f(1, 3) == 3
benchmark_functions_edited/f11517.py
def f(nums): # [1, 2, 3, 1] dp = [] for i in range(len(nums)): dp.append(nums[i]) for j in range(i): if i - j != 1: dp[j] = max(dp[j], dp[j - 1] + nums[j]) print(dp, i) return max(dp) assert f([1, 2, 3]) == 4
benchmark_functions_edited/f10290.py
def f(term): count = 0 for char in term: if char != "_": count+=1 return count assert f( "___x__y_z_t" ) == 4
benchmark_functions_edited/f3240.py
def f(D, t, d): return 2 * d * D * t assert f(1, 1, 1) == 2
benchmark_functions_edited/f760.py
def f(char, text): return text.count(char) assert f( "c", "abcabc" ) == 2
benchmark_functions_edited/f9448.py
def f(problem, population, point, dom_func): return len([1 for another in population if dom_func(problem, point, another)]) assert f( {'a': 1, 'b': 2, 'c': 3}, [{'a': 1, 'b': 3, 'c': 2}, {'a': 2, 'b': 1, 'c': 3}], {'a': 1, 'b': 3, 'c': 2}, lambda prob, a, b: all(a[key] <= b[key] for key in a if key in b) ) == 1
benchmark_functions_edited/f2823.py
def f(inlist): if isinstance(inlist, (list, tuple)): return inlist[0] return inlist assert f((5, 6, 7)) == 5
benchmark_functions_edited/f14309.py
def f(number): if number in (0, 1) or number < 0: return 1 return number * f(number - 1) assert f(3) == 6
benchmark_functions_edited/f10062.py
def f(n, vmin, vmax): return max(min(n, vmax), vmin) assert f(2, 0, 10) == 2
benchmark_functions_edited/f4717.py
def f(k, r): if r < 2**(k-1): return 0 return ((k + r)%2 + k+1 - ((2*r) % (2**(2**k - r).bit_length())).bit_length()) // 2 assert f(3, 3) == 0
benchmark_functions_edited/f12811.py
def f(log_level): if log_level.lower() == "debug": return 4 elif log_level.lower() == "info": return 3 elif log_level.lower() == "warning": return 2 elif log_level.lower() == "error": return 1 elif log_level.lower() == "critical": return 0 else: return 2 assert f(**{"log_level": "ERROR"}) == 1
benchmark_functions_edited/f3989.py
def f(n): for i in range(30, 0, -1): p = 1 << i if p <= n: return p return -1 assert f(7) == 4
benchmark_functions_edited/f7075.py
def f(string, base=0): try: return int(string, base=base) except ValueError: return float(string) assert f("7") == 7
benchmark_functions_edited/f10905.py
def f(values, value, pred): first, last = 0, len(values) count = last - first while count > 0: i = first step = count // 2 i += step if pred(values[i], value): i += 1 first = i count -= step + 1 else: count = step return first assert f((1,), 1, lambda a, b: a < b) == 0
benchmark_functions_edited/f6404.py
def f(radian): radian = float(radian) pi = 22/7 degree = float(radian * (180 / pi)) return degree assert f(0) == 0
benchmark_functions_edited/f13575.py
def f(a, m): if a < 0 or m <= a: a = a % m # From Ferguson and Schneier, roughly: c, d = a, m uc, vc, ud, vd = 1, 0, 0, 1 while c != 0: q, c, d = divmod(d, c) + (c,) uc, vc, ud, vd = ud - q * uc, vd - q * vc, uc, vc # At this point, d is the GCD, and ud*a+vd*m = d. # If d == 1, this means that ud is a inverse. assert d == 1 if ud > 0: return ud else: return ud + m assert f(3, 10) == 7