file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f323.py
def f(alpha0, alpha1, d): return alpha0+alpha1/d assert f(1, 2, 1) == 3
benchmark_functions_edited/f12101.py
def f(number: int, multiple: int) -> int: assert multiple != 0 return int((number + multiple - 1) / multiple) * multiple assert f(0, 10) == 0
benchmark_functions_edited/f13516.py
def f(lst): if not lst: raise ValueError("input must be non-empty list") return max(set(lst), key=lst.count) assert f([3, 1, 1, 1, 4, 4, 4, 1]) == 1
benchmark_functions_edited/f2864.py
def f(I_par, I_per): return I_par + 2 * I_per assert f(1, 0) == 1
benchmark_functions_edited/f9431.py
def f(n): if n & 1: return 0 if not n: return 0 if n < 0: n = -n t = 0 while not n & 0xffffffffffffffff: n >>= 64; t += 64 while not n & 0xff: n >>= 8; t += 8 while not n & 1: n >>= 1; t += 1 return t assert f(0x7fffffffffffffffffffffffffffffff) == 0
benchmark_functions_edited/f2786.py
def f(x, label=None): if label: print('%s: %s' % (label, x)) else: print(x) return x assert f(4, 'test') == 4
benchmark_functions_edited/f13741.py
def f(num_atoms, m0=None, m1=None, m2=None): #| - scf_poly_model # X_min_ = poly.fit_transform(num_atoms) # scf_per_min_i = lg.predict(X_min_)[0] # print("m0:", m0, "m1:", m1, "m2:", m2) # ##################################################### scf_per_min_i = 0 + \ (m0) * (num_atoms ** 0) + \ (m1) * (num_atoms ** 1) + \ (m2) * (num_atoms ** 2) return(scf_per_min_i) #__| assert f(3, 0, 0, 0) == 0
benchmark_functions_edited/f11543.py
def f(tree, index): res = tree[index] end = index - (index & -index) index -= 1 while index != end: res -= tree[index] index -= (index & -index) return res assert f( [0, 2, 4, 2, 4, 2, 2, 4, 4, 4, 2, 4, 4, 4], 2) == 2
benchmark_functions_edited/f3038.py
def f(ls): return max(set(ls), key=ls.count) assert f([1, 1, 3, 3, 3, 3]) == 3
benchmark_functions_edited/f5207.py
def f(r, g, b): maxi = max(r, g, b) ave = (r + g + b) / 3 return 2 if ave >= 80 else 0 if maxi == b else 1 assert f(254, 255, 255) == 2
benchmark_functions_edited/f12428.py
def f(input_dict, query, default=None): for element in query: is_list_index = isinstance(element, int) and isinstance(input_dict, (list, tuple)) if is_list_index or element in input_dict: input_dict = input_dict[element] else: return default return input_dict assert f([0, 1], [1]) == 1
benchmark_functions_edited/f12019.py
def f(values, target): left, right = 0, len(values) - 1 while left <= right: mid = int((left + right) / 2) if target < values[mid]: right = mid - 1 elif target > values[mid]: left = mid + 1 else: return mid return False assert f(range(10), 0) == 0
benchmark_functions_edited/f7568.py
def f(x, shift_amount, length): shift_amount = shift_amount % length return ((x >> (length - shift_amount)) + (x << shift_amount)) % (1 << length) assert f(8, 8, 8) == 8
benchmark_functions_edited/f89.py
def f(a): return a/2+0.5 assert f(-1) == 0
benchmark_functions_edited/f1301.py
def f(x): return int(x, base=0) assert f("00000") == 0
benchmark_functions_edited/f1427.py
def f(n): if n == 1: return n return n*f(n-1) assert f(3) == 6
benchmark_functions_edited/f17.py
def f(x, y): return (x + y) * y assert f(100, -100) == 0
benchmark_functions_edited/f1923.py
def f(n): #probably is already the name return n assert f(1) == 1
benchmark_functions_edited/f5.py
def f(x,a,b): return a + b*x assert f(1,2,3) == 5
benchmark_functions_edited/f7705.py
def f(xs): p = 1 for x in xs: p *= x return p assert f([1]) == 1
benchmark_functions_edited/f342.py
def f(val): return float('0' + str(val)) assert f(1) == 1
benchmark_functions_edited/f11315.py
def f(values, precision=1e-16): for i in range(1, len(values)): if abs(values[i] - values[0]) > precision: return values[i] print("NOTHING FOUND; PROBLEM IN SPECTRUM?") assert f([1, 2, 3]) == 2
benchmark_functions_edited/f4529.py
def f(N): ct = 0 for _ in range(100): for _ in range(N): for _ in range(10000): ct += 1 return ct assert f(0) == 0
benchmark_functions_edited/f12331.py
def f(number, bits): if number == 0: return bits return min(bits, (~number & (number-1)).bit_length()) assert f(15, 4) == 0
benchmark_functions_edited/f3871.py
def f(iterable, selector): for x in iterable: if selector(x): return x assert f(range(5), lambda x: x > 2) == 3
benchmark_functions_edited/f11821.py
def f(atom, lagrange=None): if lagrange is None: lagrange = atom.lagrange if lagrange is None: raise ValueError('either atom must be in Lagrange ' + 'mode or a keyword "lagrange" ' + 'argument must be supplied') return lagrange assert f(None, 2) == 2
benchmark_functions_edited/f2880.py
def f(val): return val / (12 * 100) assert f(0) == 0
benchmark_functions_edited/f4488.py
def f(proba): if hasattr(proba, "simplify"): return proba.f().factor() else: return proba assert f(1) == 1
benchmark_functions_edited/f13802.py
def f(ses_hash, usr_hash): total = 0 kmax = 0 for k in usr_hash.keys(): if k in ses_hash: kmax += 1 total += (abs(int(ses_hash[k]) - int(usr_hash[k])) - 24) score = 4.8 - (total/kmax) #4 ms minus average deviation off normal if score > 4.8: score = 1 elif score < 0: score = 0 else: score = abs(score)/4.8 return(score) assert f( { "0815": "1530", "0930": "1730" }, { "0815": "1530", "0930": "1730" } ) == 1
benchmark_functions_edited/f12914.py
def f(letter, offset, ascii): # Offset the string offset_string = ascii[offset - 33:] # Find the characters score score = 0 while score < len(offset_string): if letter == offset_string[score]: return score score += 1 # If no score is found then there must be an error raise ValueError assert f('A', 33, 'ACGT') == 0
benchmark_functions_edited/f10618.py
def f(value, in_start, in_stop, out_start, out_stop): return out_start + (out_stop - out_start) * ((value - in_start) / (in_stop - in_start)) assert f(0, 0, 10, 0, 100) == 0
benchmark_functions_edited/f11555.py
def f(n): if n: if n <= 9: return n / 10.0 + 0.3 # otherwise you don't see it elif n >= 10: return 1 else: print( "ERROR: tags tot count needs to be a number (did you run python manage.py tags_totcount ?" ) assert f(7) == 1
benchmark_functions_edited/f11602.py
def f(alignment, current_size, next_element_size): if alignment == 1: return 0 # Always aligned elem_size = min(alignment, next_element_size) remainder = current_size % elem_size if remainder == 0: return 0 return elem_size - remainder assert f(1, 2, 1) == 0
benchmark_functions_edited/f3111.py
def f(s): try: return len(s.encode("gb2312")) except ValueError: return len(s) assert f('') == 0
benchmark_functions_edited/f12628.py
def f( number: int, accumulator: int = 1, ) -> int: if number == 0: return accumulator return f( number=number - 1, accumulator=accumulator * number, ) assert f(0) == 1
benchmark_functions_edited/f1565.py
def f(syn, obs, nt, dt): wadj = syn - obs return wadj assert f(1, -1, 1, 1) == 2
benchmark_functions_edited/f5726.py
def f(inList): sum = 0 for num in inList: sum += num return sum assert f([]) == 0
benchmark_functions_edited/f5677.py
def f(year): flag = 0 if (year % 4 == 0): flag = 1 elif (year % 100 == 0) and (year % 400 != 0): flag = 0 return flag assert f(1993) == 0
benchmark_functions_edited/f237.py
def f(one, two): return(one - two) assert f(10, 4) == 6
benchmark_functions_edited/f14430.py
def f(history, depth): if depth == 0: return 0 else: for i in range(len(history)): if history[i][1] == depth: return i assert f([["a", 0, 0], ["b", 1, 1], ["c", 1, 2]], 1) == 1
benchmark_functions_edited/f5141.py
def f(model_file_name): # Unchanged from original work return int(model_file_name.split("_")[2].split(".")[0]) assert f( "model_epoch_0.pt" ) == 0
benchmark_functions_edited/f11627.py
def f(list): longest = "" for item in list: item = str(item) # Can't use len() on int if len(longest) < len(item): longest = item return len(longest) assert f(list("abcdefgh")) == 1
benchmark_functions_edited/f2296.py
def f(base, power): return sum([int(x) for x in list(str(base**power))]) assert f(2, 3) == 8
benchmark_functions_edited/f13520.py
def f(output, key, mimetype=None): md = output.get("metadata") or {} if mimetype and mimetype in md: value = md[mimetype].get(key) if value is not None: return value return md.get(key) assert f( {"metadata": {"image/png": {"width": 5, "height": 10}}}, "width", "image/png") == 5
benchmark_functions_edited/f5881.py
def f(a, b, n): res = 1 q = a while b > 0: if b % 2 == 1: res = q*res % n q = q*q % n b //= 2 return res assert f(2, 2, 3) == 1
benchmark_functions_edited/f5445.py
def f(x): return x*(x>1e-13); assert f(-1) == 0
benchmark_functions_edited/f12168.py
def f(x, a, b, c): return (x - b) ** 2 assert f(2, 1, 2, 3) == 0
benchmark_functions_edited/f2010.py
def f(sigmoid_output): return sigmoid_output*(1 - sigmoid_output) assert f(0) == 0
benchmark_functions_edited/f11179.py
def f(function, args, kwargs): return function(*args, **kwargs) assert f(lambda *args: sum(args), (1, 2, 3), {}) == 6
benchmark_functions_edited/f12001.py
def f(outlist_hits): total_num_hits = 0 for accession in outlist_hits.keys(): total_num_hits += len(outlist_hits[accession]) return total_num_hits assert f({"RF00001": [(10, 15)]}) == 1
benchmark_functions_edited/f8641.py
def f(x, y, eps): sm = 0 for k in range(len(x)): sm += (x[k]-y[k])**2 if sm > eps: return 0 return 1 assert f([2, 2, 2], [1, 1, 1], 1) == 0
benchmark_functions_edited/f5413.py
def f(number): if number < 0: return -1 elif number > 0: return 1 else: return 0 assert f(1) == 1
benchmark_functions_edited/f8548.py
def f(v1, v2, alpha): return v1 + alpha * (v2 - v1) assert f(3, 4, 1) == 4
benchmark_functions_edited/f10689.py
def f(distance): magic_num = 1078.599717114 # km return distance / magic_num assert f(0) == 0
benchmark_functions_edited/f5952.py
def f(number: str) -> int: try: result = int(number) return -1 if result < 0 else result except ValueError: return -1 assert f(4) == 4
benchmark_functions_edited/f5577.py
def f(nums): if len(nums) == 1: return 0 number=max(nums) index=nums.index(number) nums.remove(number) return index if number>=max(nums)*2 else -1 assert f( [3, 6, 1, 0] ) == 1
benchmark_functions_edited/f5352.py
def f(arbre): if arbre is None: return 0 tg = f(arbre.get_ag()) td = f(arbre.get_ad()) return tg + td + 1 assert f(None) == 0
benchmark_functions_edited/f10929.py
def f(lista_palavras): freq = dict() for palavra in lista_palavras: p = palavra.lower() if p in freq: freq[p] += 1 else: freq[p] = 1 return len(freq) assert f(['Python', 'Python', 'Python']) == 1
benchmark_functions_edited/f12048.py
def f(a: int, b: int) -> int: # Return the GCD of a and b using Euclid's algorithm: while a != 0: a, b = b % a, a return b assert f(2, 1) == 1
benchmark_functions_edited/f6996.py
def f(var, parameters): if hasattr(parameters, 'viewer_descr') and var in parameters.viewer_descr: return parameters.viewer_descr[var] return var assert f(5, 5) == 5
benchmark_functions_edited/f5971.py
def f(x: int, y: int, Ngrid: int): return x + y*Ngrid assert f(1, 0, 1) == 1
benchmark_functions_edited/f3844.py
def f(arbre): if arbre is None: return 0 return 1 + max(f(arbre.get_gauche()), f(arbre.get_droite())) assert f(None) == 0
benchmark_functions_edited/f11608.py
def f(format:str) -> int: if format == 'S19': return 4 elif format == 'S28': return 6 elif format == 'S37': return 8 else: raise ValueError("Invalid parameter in method formatToAddressLength: %s" % format) assert f('S28') == 6
benchmark_functions_edited/f2812.py
def f(x, y): if x < -499999 or y < -499999: return 1 return 0 assert f(400, 300) == 0
benchmark_functions_edited/f10544.py
def f(arr): i = 0 m = 0 for x in arr: if i == 0: m = x i = 1 elif m == x: i += 1 else: i -= 1 if arr.count(m) > len(arr) / 2: return m return None assert f([1,1,1,1,1]) == 1
benchmark_functions_edited/f11698.py
def f(x, a): # This implementation is also known as Horner's Rule. n = len(a) - 1 p = a[n] for i in range(1, n+1): p = p * x + a[n-i] return p assert f(1, [1, 2]) == 3
benchmark_functions_edited/f9202.py
def f(N, k): if k > N or N < 0 or k < 0: return 0 M = N + 1 nterms = min(k, N - k) numerator = 1 denominator = 1 for j in range(1, nterms + 1): numerator *= M - j denominator *= j return numerator // denominator assert f(-2, 7) == 0
benchmark_functions_edited/f9913.py
def f(x, y): result = x // y if (x % y): result += 1 return result assert f(6, 5) == 2
benchmark_functions_edited/f830.py
def f(s): if not len(s): return 0 return int(s.encode("hex"), 16) assert f(b'') == 0
benchmark_functions_edited/f3781.py
def f(unique_wc, total_wc): ld = unique_wc / total_wc return ld assert f(100, 50) == 2
benchmark_functions_edited/f5999.py
def f(data, max_points=200): num_points = len(data) markevery = max(num_points // max_points, 1) return markevery assert f(list(range(10))) == 1
benchmark_functions_edited/f6590.py
def f(f, x, dt): a = f(x) b = f(x + dt / 2.0 * a) c = f(x + dt / 2.0 * b) d = f(x + dt * c) return x + dt * (a + 2.0 * b + 2.0 * c + d) / 6.0 assert f(lambda x: x, 0, 1) == 0
benchmark_functions_edited/f10537.py
def f(lines, start_line: int): end_line = start_line while lines[end_line].endswith('\\\n'): end_line += 1 if end_line >= len(lines): break return end_line assert f( ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I'], 3) == 3
benchmark_functions_edited/f4982.py
def f(puzzle: str) -> int: return puzzle.count('\n') assert f('a\nb\nc\n') == 3
benchmark_functions_edited/f13574.py
def f(value, min_value, max_value): return max(min_value, min(value, max_value)) assert f(5, 0, 3) == 3
benchmark_functions_edited/f11211.py
def f(periodType, timeToElapse): if periodType == "days": return timeToElapse elif periodType == "weeks": return timeToElapse * 7 elif periodType == "months": return timeToElapse * 30 else: return 0 assert f(None, 18) == 0
benchmark_functions_edited/f12079.py
def f(n): a = 3 result = 0 while a < n: if a % 3 == 0 or a % 5 == 0: result += a elif a % 15 == 0: result -= a a += 1 return result assert f(4) == 3
benchmark_functions_edited/f5803.py
def f(a,b): return max(0,min(a[1],b[1]) - max(a[0],b[0])) assert f( [1,2], [2,3] ) == 0
benchmark_functions_edited/f12803.py
def f(param, rand_function): if isinstance(param, list) and len(param) == 2: param_gen = rand_function(param[0], param[1]) else: param_gen = param return param_gen assert f([1,2], lambda x,y: x+y) == 3
benchmark_functions_edited/f10757.py
def f(input_array): return input_array.index(sorted(input_array)[1]) assert f([1, 3, 1]) == 0
benchmark_functions_edited/f13727.py
def f(x, coefficients): point = 0 # Loop through reversed list, so that indices from enumerate match the # actual coefficient indices for coefficient_index, coefficient_value in enumerate(coefficients[::-1]): point += x ** coefficient_index * coefficient_value return point assert f(2, [2, 1]) == 5
benchmark_functions_edited/f11600.py
def f(n): p = 2 num = 0 if type(n) != int or n <= 1: return 0 while n != 1: if n % p == 0: n = n / p num = num + p else: p = p + 1 return int(num) assert f(1) == 0
benchmark_functions_edited/f4810.py
def f(object): try: object[0] except (TypeError, KeyError): return 0 except IndexError: pass return 1 assert f({"a": 1}) == 0
benchmark_functions_edited/f11074.py
def f(n): try: if type(n) in [int, float]: return sum([True for d in str(n) if d.isdigit() and int(d) % 2 != 0]) else: raise TypeError("Given input is not a supported type") except TypeError as e: print("Error:", str(e)) assert f(4) == 0
benchmark_functions_edited/f11277.py
def f(a, p): s, t, sn, tn, r = 1, 0, 0, 1, 1 while r != 0: q = p // a r = p - q * a st, tt = sn * (-q) + s, tn * (-q) + t s, t = sn, tn sn, tn = st, tt p = a a = r return t assert f(7, 10) == 3
benchmark_functions_edited/f10216.py
def f(item, args): return item[args[0]] assert f( {"col1": 1, "col2": 2, "col3": 3}, ["col2"] ) == 2
benchmark_functions_edited/f4369.py
def f(a, b): if a < b: a, b = b, a while b > 0: r = a % b a = b b = r return a assert f(12, 15) == 3
benchmark_functions_edited/f7281.py
def f(criterion, xs, y): loss = 0. for x in xs: loss += criterion(x, y) # loss /= len(xs) return loss assert f(lambda x, y: (x - y)**2, (0, 0), 0) == 0
benchmark_functions_edited/f7139.py
def f(episode_list, max_val): return len([x for x in episode_list if x > max_val]) assert f(range(30), 30) == 0
benchmark_functions_edited/f7751.py
def f(altitude): if 0 <= altitude and altitude <= 20000: return 150 - 0.0075*altitude # m/s else: raise Exception("Invalid at given altitude: {0}".format(altitude)) assert f(20000) == 0
benchmark_functions_edited/f10105.py
def f(A): # Define a variable to store the previous element in an iteration previous_int = 1 while True: if previous_int+1 in A: previous_int += 1 continue else: return previous_int+1 assert f( [1, 2, 3, 5]) == 4
benchmark_functions_edited/f5260.py
def f(deg_sep, ALPHA=1.0): return (deg_sep + 1) ** (- ALPHA) assert f(0) == 1
benchmark_functions_edited/f5566.py
def f(somelist): total = 0 for num in somelist: total = total + num return total assert f(range(1)) == 0
benchmark_functions_edited/f4477.py
def f(L): if len(L) < 2: return None return L[1] assert f(list(range(10))) == 1
benchmark_functions_edited/f12500.py
def f(N): count=0 original=['0','1','2','5','6','8','9'] after=['0','1','5','2','9','8','6'] dic=dict(zip(original,after)) for i in range(1,N+1): number=str(i) temp="" if "3" in number or "4" in number or "7" in number: continue for x in number: test=dic[x] if test: temp+=test if temp != number: count+=1 return count assert f(0) == 0
benchmark_functions_edited/f13807.py
def f(n: int, m: int = 2) -> int: if n < 0: raise ValueError('Only non-negative integers are supported for n.') elif n == 0: return -1 q, r = divmod(n, m) count = 0 while not r: count += 1 q, r = divmod(q, m) return count assert f(12) == 2
benchmark_functions_edited/f1522.py
def f(cond, fn, value, name): return fn(value, name) if cond else value assert f(True, lambda x, name: x + 1, 0, 'add 1') == 1
benchmark_functions_edited/f8936.py
def f(string, default): # If the string is not numeric if not string.isnumeric(): return default # Otherwise, return the string as int else: return int(string) assert f("2", print) == 2
benchmark_functions_edited/f11095.py
def f(func, args, kwargs): return func(*args, **kwargs) assert f(lambda a, b: a * b, (), {'a': 2, 'b': 3}) == 6
benchmark_functions_edited/f9065.py
def f(nums): counter = 0 for i in nums: counter += i return counter / len(nums) assert f((1, 2, 3)) == 2