file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f6014.py
def f(i, n, number): product = 1 for i in range (i, i+n): product *= int(number[i]) return product assert f(0, 1, '123456') == 1
benchmark_functions_edited/f9604.py
def f(ell, m): return ell**2 + m + ell assert f(0, 2) == 2
benchmark_functions_edited/f4533.py
def f(a): b = dict(map(lambda item: (item[1],item[0]),a.items())) max_key = b[max(b.keys())] return max_key assert f( {1: 10, 2: 20, 3: 30, 4: 40} ) == 4
benchmark_functions_edited/f7274.py
def f(position): x, y = position # x = 10**x # y = 10**y return (1.5 - x + x * y) ** 2 + (2.25 - x + x * y ** 2) ** 2 + (2.625 - x + x * y ** 3) ** 2 assert f([3.0, 0.5]) == 0
benchmark_functions_edited/f12121.py
def f(n, a): for i in range(2 * n ** 2)[1:]: if pow(a, i, n) == 1: return i assert f(10, 3) == 4
benchmark_functions_edited/f14365.py
def f(input_list, number): for index, element in enumerate(input_list): if element == number: return index return -1 assert f([5], 5) == 0
benchmark_functions_edited/f14501.py
def f(item, prefixes): for index, prefix in enumerate(prefixes): if item.startswith(prefix): return index return len(prefixes) assert f( "apple", ["orange", "apple"]) == 1
benchmark_functions_edited/f4648.py
def f(X_i, M, X_nk_n): return 1*(M <= X_nk_n < X_i) assert f(1, 1, 1) == 0
benchmark_functions_edited/f10011.py
def f(r1, r2): return (r1 + r2) / r1 assert f(1, 2) == 3
benchmark_functions_edited/f9329.py
def f(nums): count = 0 most = nums[0] for n in nums: if n == most: count += 1 else: count -= 1 if count < 0: most = n count = 1 return most assert f( [3, 3, 3, 3, 3]) == 3
benchmark_functions_edited/f6076.py
def f(value): return int("{}".format(value), 8) assert f('0') == 0
benchmark_functions_edited/f7008.py
def f(value: str): if isinstance(value, str) and len(value) == 0: raise ValueError("String must contain at least one character.") return value assert f(1) == 1
benchmark_functions_edited/f13031.py
def f(data, flatten=False): try: return data.to_dict(flatten=flatten) except AttributeError: return data assert f(1) == 1
benchmark_functions_edited/f609.py
def f(n): if n < 0: return 0 else: return 1 assert f(-5) == 0
benchmark_functions_edited/f7351.py
def f(condor_submit_out): return float(condor_submit_out.split()[-1]) assert f( "Submitting job(s).\n1 job(s) submitted to cluster 8.") == 8
benchmark_functions_edited/f3388.py
def f(audio): (left, right) = audio assert len(left) == len(right) return len(left) assert f( ([1, 2, 3], [4, 5, 6]) ) == 3
benchmark_functions_edited/f12554.py
def f(content, weights, alphabet): ordinal = 0 for i, c in enumerate(content): ordinal += weights[i] * alphabet.index(c) + 1 return ordinal assert f('a', [0, 1], ['a', 'b']) == 1
benchmark_functions_edited/f6876.py
def f(obj, ops, op): res = obj for o in reversed(ops): res = o.apply(res, op) return res assert f(1, [], lambda a: a) == 1
benchmark_functions_edited/f12313.py
def f(metric_fn, prediction, ground_truths): scores_for_ground_truths = [] for ground_truth in ground_truths: score = metric_fn(prediction, ground_truth) scores_for_ground_truths.append(score) return max(scores_for_ground_truths) assert f( lambda x, y: len(x) + len(y), ["a", "b", "c"], ["c"], ) == 4
benchmark_functions_edited/f7716.py
def f(x: float, lower_cap: float = -1, higher_cap: float = 1): if x < lower_cap: return lower_cap elif x > higher_cap: return higher_cap else: return x assert f(1, 1, 1) == 1
benchmark_functions_edited/f1386.py
def f(a, b): return a[0] * b[1] - a[1] * b[0] assert f( (1, 1), (1, 1)) == 0
benchmark_functions_edited/f11190.py
def f(first_term: int, common_difference: int, requested_term: int) -> int: return first_term + (requested_term - 1) * common_difference assert f(1, 3, 1) == 1
benchmark_functions_edited/f12697.py
def f(x, gamma): return 1.0/(1.0-gamma*x) assert f(0, -1) == 1
benchmark_functions_edited/f12729.py
def f(inpt, output, i = 0, k = 1): if k <= len(inpt): i = f(inpt, output, i, 2 * k) output[k - 1] = inpt[i] i += 1 i = f(inpt, output,i, 2 * k + 1) return i assert f([9, 8, 7, 6, 5, 4, 3, 2, 1], [0] * 10) == 9
benchmark_functions_edited/f6434.py
def f(ratio): try: return float(ratio) except ValueError: num, denom = ratio.split('/') return float(num) / float(denom) assert f(4) == 4
benchmark_functions_edited/f1985.py
def f(n): pos = n.find(".") return len(n) if pos < 0 else pos assert f("1.23") == 1
benchmark_functions_edited/f3370.py
def f(exon_frame): mapping = {0: 0, 1: 2, 2: 1, -1: '.'} return mapping[exon_frame] assert f(1) == 2
benchmark_functions_edited/f5292.py
def f(timestamp, last_data=[], data=[]): if len(data): return data[-1]["trade_id"] assert f(1234, [], [{'trade_id': 1}, {'trade_id': 2}, {'trade_id': 3}]) == 3
benchmark_functions_edited/f6320.py
def f(nu, f, p, pv0, e, B, R, eta): return (B*(1 - e*nu)*p - p/pv0)/(1 + B*(1 - e*nu)*p - p/pv0) assert f(0, 0, 0, 1, 0, 0, 0, 0) == 0
benchmark_functions_edited/f5016.py
def f(Gender): if Gender == 'Male': return 1 else: return 0 assert f(1) == 0
benchmark_functions_edited/f8557.py
def f(value): try: value = int(value) except: try: value = float(value) except: pass return value assert f('0') == 0
benchmark_functions_edited/f6172.py
def f(true, predicted): return abs((true - predicted) / true) * 100 assert f(1, 1) == 0
benchmark_functions_edited/f11842.py
def f(text, prime, x): ans = 0 for c in reversed(text): ans = (ans * x + ord(c)) % prime return ans assert f( "", 53, 31, ) == 0
benchmark_functions_edited/f12580.py
def f(expmips): MIP0_mz = [x[0] for x in expmips if x[-1] == 0][0] # get mz-val of x15N == 0 rest_mz = [x[0] for x in expmips if x[-1] != 0] sum_rest_mz = sum(rest_mz) if sum_rest_mz == 0: return MIP0_mz else: return MIP0_mz / sum_rest_mz assert f([(1, 1, 1, 0), (2, 1, 1, 0)]) == 1
benchmark_functions_edited/f9999.py
def f(string_with_number): try: return int(''.join(ele for ele in string_with_number if ele.isdigit())) # get digits except ValueError: # if no digits in the string, just assign -1 return -1 assert f('1') == 1
benchmark_functions_edited/f1270.py
def f(val: int, bitNo: int) -> int: return val ^ (1 << bitNo) assert f(3, 1) == 1
benchmark_functions_edited/f5333.py
def f(function, iterable): for x in iterable: if function(x) == True: return x assert f(lambda x: x == 2, [0, 1, 2]) == 2
benchmark_functions_edited/f8796.py
def f(y_test): if y_test == []: return 0 else: return sum(y_test) assert f([]) == 0
benchmark_functions_edited/f2393.py
def f(n: int) -> int: return sum(i for i in range(1, n + 1)) assert f(3) == 6
benchmark_functions_edited/f8790.py
def f(X, Xf, r): if abs(Xf-X) <= r/2: deltae = 1-2*(X-Xf)**2/r**2 elif Xf < X-r/2: deltae = 2*(Xf-X+r)**2/r**2 else: deltae = 2*(Xf-X-r)**2/r**2 return deltae assert f(0, 0, 2) == 1
benchmark_functions_edited/f7067.py
def f(align, base): rmdr = int(base) % align if rmdr == 0: return 0 else: return align - rmdr assert f(4, 4) == 0
benchmark_functions_edited/f7545.py
def f(feet: float) -> float: if not isinstance(feet, (float, int)): return 0 return feet / 3.28084 assert f(0.0) == 0
benchmark_functions_edited/f8670.py
def f(key:str) -> int: if len(key) == 0: return -1 else: return len(key.split('.'))-1 assert f(getKeyLevel.__name__) == 0
benchmark_functions_edited/f12641.py
def f(x): x = (((x >> 16) ^ x) * 0x045d9f3b) & 0xFFFFFFFF x = (((x >> 16) ^ x) * 0x045d9f3b) & 0xFFFFFFFF x = ((x >> 16) ^ x) & 0xFFFFFFFF return x assert f(18446744073709551616) == 0
benchmark_functions_edited/f10923.py
def f(x: int) -> int: str_num = str(x) is_negative = False if str_num[0] == '-': is_negative = True str_num = str_num[1:] sign = '-' if is_negative else '+' num = int(sign + "".join(list(reversed(str_num)))) return num assert f(-0) == 0
benchmark_functions_edited/f12533.py
def f(n): # Initialize the sum total = 0 # Initialize the number of factors count = 0 for i in range(1, n+1): # Check if i is a divisor of n if n % i == 0: total += i count += 1 average = total/count return average assert f(1) == 1
benchmark_functions_edited/f13337.py
def f(one, two): total = 0 for pair in set(one).intersection(two): total += min(one.count(pair), two.count(pair)) return total assert f(set(), {'a'}) == 0
benchmark_functions_edited/f319.py
def f(sigma0, sigma1, d): return sigma0+sigma1*d assert f(0, 1, 1) == 1
benchmark_functions_edited/f6981.py
def f(value, arg): try: return int(value) - int(arg) except (ValueError, TypeError): try: return value - arg except Exception: return '' assert f(1, 1) == 0
benchmark_functions_edited/f3247.py
def f(string): if string: return int(string) else: return None assert f(1) == 1
benchmark_functions_edited/f14041.py
def f(value): # Check value is >= 0 if value < 0: msg = "Value to convert ({value}) is not >= 0".format(value=value) raise ValueError(msg) return len(bin(value)) - 2 assert f(41) == 6
benchmark_functions_edited/f9304.py
def sumequal (x , y , z): intnum = list([x,y,z]) if len(set(intnum)) == len(intnum): #if lengths are equal and we have no duplicate return sum(intnum) else: return 0 assert f(3, 5, 1) == 9
benchmark_functions_edited/f1892.py
def f(vote_id): return 1 if vote_id in [2, 5] else 0 assert f(2) == 1
benchmark_functions_edited/f6573.py
def euclid_alg (a, b): a, b = abs(a), abs(b) while b != 0: r = a % b a, b = b, r return a assert f(0, 1) == 1
benchmark_functions_edited/f2607.py
def f(n): return 1 + f(n & n - 1) if n else 0 assert f(0b00000000) == 0
benchmark_functions_edited/f7171.py
def f(n): assert n >= 0 and int(n) == n, 'fibonacci number can not be negative or non integers' if n in [0,1]: return n else: return f(n-1) + f(n-2) assert f(2) == 1
benchmark_functions_edited/f1175.py
def f(pp): print(pp) return sum(pp) / len(pp) assert f(list(range(1))) == 0
benchmark_functions_edited/f343.py
def f(L): if len(L) > 0: return L[0] assert f([1,2,3]) == 1
benchmark_functions_edited/f4295.py
def f(v_1_i, v_2_i): v_1_1, v_1_2, v_1_3 = v_1_i v_2_1, v_2_2, v_2_3 = v_2_i return v_1_1*v_2_1 + v_1_2*v_2_2 + v_1_3*v_2_3 assert f( (1, 0, 0), (0, 1, 0) ) == 0
benchmark_functions_edited/f7076.py
def f(data): vn = data[5] & int('00111110', 2) vn = vn >> 1 return vn assert f( [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00] ) == 0
benchmark_functions_edited/f825.py
def f(n): return 2**n - 1 assert f(2) == 3
benchmark_functions_edited/f875.py
def f(m,w,l): return m * (w**2 + l**2) / 12 assert f(0, 1, 1) == 0
benchmark_functions_edited/f9255.py
def f(dbz): if dbz >= 55: granizo = ((10**(dbz/10))/200)**(5/8) if granizo <= 1: return 0 else: return granizo else: return 0 assert f(0) == 0
benchmark_functions_edited/f2618.py
def f(s): n = 0 for k in s: if k == ',': n+=1 return n assert f( "1234" ) == 0
benchmark_functions_edited/f6591.py
def f(goal_reached): if goal_reached: return 1 else: return -0.04 assert f(True) == 1
benchmark_functions_edited/f14534.py
def f(l, amp=0.1, alpha=2.0, beta=-2.0, l0=2): l0 = int(l0) if hasattr(l, "__len__"): p = amp * ((l + 1.0) / (l0 + 1.0)) ** alpha p[l >= l0] = amp * ((l[l >= l0] + 1.0) / (l0 + 1.0)) ** beta p[0] = 1.0 return p else: if l == 0: return 1.0 elif l < l0: return amp * ((l + 1.0) / (l0 + 1)) ** alpha else: return amp * ((l + 1.0) / (l0 + 1)) ** beta assert f(0, 1, 1, 1) == 1
benchmark_functions_edited/f11413.py
def f(ord, type='lowpass') -> int: if type in ['lowpass', 'highpass', 'allpass']: ncount = (ord-1)/2 + 1 if (ord % 2) else ord/2 # 6 coeffs/stage. elif type in ['bandpass', 'bandstop']: ncount = ord else: raise ValueError('filter type %s is not valid.' % type) return int(ncount) assert f(4, 'highpass') == 2
benchmark_functions_edited/f14357.py
def f(number, length): number = ~number result = 0x00 for i in range(length): result = (result << 2) | (number & 0x03) number >>= 2 return result assert f(2, 1) == 1
benchmark_functions_edited/f12093.py
def f(a, b): b = abs(b) if a < 0: a = b - (-a % b) x, nx = 0, 1 r, nr = b, a % b while nr: x, nx = nx, x - (r // nr) * nx r, nr = nr, r - (r // nr) * nr if r == 1: return x + b if x < 0 else x assert f(17, 5) == 3
benchmark_functions_edited/f3722.py
def f(x): if isinstance(x['base_count'], list): return int(x['base_count'][0] or 0) else: return 0 assert f( {'base_count': None}) == 0
benchmark_functions_edited/f432.py
def f(num): try:v=int(num) except:v=0 return v assert f(set()) == 0
benchmark_functions_edited/f10240.py
def f(src, pt, tform): # The dest[pt] = src[tform(pt)] tformed = tform(pt) ret = src(tformed[1], tformed[0]) return ret assert f(lambda x, y: x + y, (1, 0), lambda pt: (pt[0], pt[1])) == 1
benchmark_functions_edited/f10502.py
def f(number): assert number >= 0 offset = 1 while offset ** 2 <= number: offset *= 2 count = 0 while offset > 0: if (count + offset) ** 2 <= number: count += offset offset //= 2 return count assert f(14) == 3
benchmark_functions_edited/f9990.py
def f(func): h = 0 for c in func: h = ((h << 7) & 0xFFFFFFFE) | (h >> (32 - 7)) h = h ^ c return h assert f(b'') == 0
benchmark_functions_edited/f7271.py
def f(betas, t): total = 0 for beta in betas: total = total * t + beta return total assert f((1, 2), 1) == 3
benchmark_functions_edited/f5730.py
def f(nums, target): try: return nums.index(target) except ValueError: nums.append(target) nums.sort() return nums.index(target) assert f([1, 3, 5, 6], 5) == 2
benchmark_functions_edited/f4932.py
def f(direction): directioMap = { "X": 1, "Y": 2, "Z": 3 } return directioMap[direction] assert f("X") == 1
benchmark_functions_edited/f10008.py
def f(dictionary, certname, state): try: return dictionary[certname][state] except: return 0 assert f( { "cert1": {"changed": 0, "failed": 0, "skipped": 0, "unchanged": 1}, "cert2": {"changed": 0, "failed": 0, "skipped": 1, "unchanged": 0}, "cert3": {"changed": 1, "failed": 1, "skipped": 0, "unchanged": 0}, }, "cert1", "changed", ) == 0
benchmark_functions_edited/f7269.py
def f(obj: str) -> int: if not isinstance(obj, str): raise ValueError() return int(obj) assert f("2") == 2
benchmark_functions_edited/f5369.py
def f(function, list): for item in list: if function(item) is True: return item assert f(lambda x: x % 5 == 0, [1, 2, 3, 4, 5, 6]) == 5
benchmark_functions_edited/f5859.py
def f(full_dict, path_string): key_value = full_dict for i in path_string.split('/')[1:] : key_value = key_value[i] return key_value assert f( { 'a': { 'b': { 'c': { 'd': 4 } } } }, '/a/b/c/d' ) == 4
benchmark_functions_edited/f11343.py
def f(n_instances): thresholds = [(i, i * 2000) for i in range(1, 31)] for divisor, threshold in thresholds: if n_instances <= threshold: return int(n_instances / divisor) assert f(0) == 0
benchmark_functions_edited/f10498.py
def f(set1, set2): if len(set1) == 0 or len(set2) == 0: return 0 inter = len(set1.intersection(set2)) return inter / (len(set1) + len(set2) - inter) assert f(set(), {1}) == 0
benchmark_functions_edited/f13275.py
def f(op1, op2, operator): if operator == '*': return op1 * op2 elif operator == "/": return op1 / op2 elif operator == "+": return op1 + op2 elif operator == "-": return op1 - op2 elif operator == "%": return op1 % op2 assert f(2, 0, '*') == 0
benchmark_functions_edited/f7098.py
def f(im_name, parse_type='id'): assert parse_type in ('id', 'cam') if parse_type == 'id': parsed = int(im_name[:8]) else: parsed = int(im_name[9:13]) return parsed assert f( '00000001_cam000002') == 1
benchmark_functions_edited/f8901.py
def f(edgeLen, width, minDistance): if edgeLen < width: return 0 c = 1 + (edgeLen - minDistance) // (minDistance + width) return max(0, int(c)) assert f(4, 1, 2) == 1
benchmark_functions_edited/f11028.py
def f(num): if not isinstance(num, int) or num < 0: raise ValueError('Sequence Fibonacci can be determined only for positive integer') if num in [0, 1]: return num elif num == 2: return 1 return f(num - 1) + f(num - 2) assert f(2) == 1
benchmark_functions_edited/f952.py
def f(x): return 3 * x ** 2 + 5 assert f(0) == 5
benchmark_functions_edited/f10068.py
def f(needle, p): length = 0; j = len(needle) - 1 for i in reversed(range(p + 1)): if needle[i] == needle[j]: length += 1 else: break j -= 1 return length assert f(b"abracadabra", 8) == 0
benchmark_functions_edited/f5938.py
def f(x, bias=0): indicator = 1 if x >= bias else 0 return indicator assert f(20, 10) == 1
benchmark_functions_edited/f10857.py
def f(x): # Taken from http://stackoverflow.com/a/4912729. Many thanks! x -= (x >> 1) & 0x55555555 x = ((x >> 2) & 0x33333333) + (x & 0x33333333) x = ((x >> 4) + x) & 0x0f0f0f0f x += x >> 8 x += x >> 16 return x & 0x0000003f assert f(0b00000100) == 1
benchmark_functions_edited/f10339.py
def f(tzd): if tzd == "Z": return 0 assert len(tzd) == 6 # only accept forms like +08:00 for now assert (tzd[0] == "-" or tzd[0] == "+") and \ tzd[3] == globals.time_separator return -60 * (60 * int(tzd[:3]) + int(tzd[4:])) assert f(u"Z") == 0
benchmark_functions_edited/f5590.py
def f(value, min_value, max_value): if value > max_value: return max_value if value < min_value: return min_value return value assert f(-1, 0, 5) == 0
benchmark_functions_edited/f669.py
def f(x:int): return int(x) if x else 0 assert f(0) == 0
benchmark_functions_edited/f5517.py
def f(seq,method=bool): if not seq: return False s = None for s in seq: if method(s): return s return s if not s else None assert f([0, None, False]) == 0
benchmark_functions_edited/f5206.py
def f(mystr): count = 0 for mychar in mystr: if mychar.isspace(): count += 1 return count assert f(" ") == 3
benchmark_functions_edited/f4452.py
def f(string): if string == "-": return None if string == "": return None return int(string) assert f(1.0) == 1
benchmark_functions_edited/f10741.py
def f(ls): def helper(ls, acc): if len(ls) == 0: return acc # this is a tail recursion because the final instruction is a recursive call. return helper(ls[1:], ls[0] + acc) return helper(ls, 0) assert f([1, 2, 3]) == 6
benchmark_functions_edited/f10239.py
def f(d_rev): min = 1e10 for x in d_rev: len_bit = len(x) if(len_bit < min): min = len_bit return min assert f( { '10010':'a', '1010':'b', '1011':'c', '0001':'d', '1110':'e' } ) == 4
benchmark_functions_edited/f2874.py
def f(a : int,b : int, c : int, x : int) -> int: return (((a*x*x + b) * x*x) + c) assert f(0, 0, 0, 0) == 0