file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f10895.py
def f(b, I, mu0, mu1): # recovery rate, depends on mu0, mu1, b mu = mu0 + (mu1 - mu0) * (b / (I + b)) return mu assert f(50, 0, 1, 1) == 1
benchmark_functions_edited/f4505.py
def f(k, Nj): z = 1 + (-1+k+Nj/2)%Nj return int(z) assert f(3, 2) == 2
benchmark_functions_edited/f9370.py
def f(populate: str) -> int: return populate.count('.') assert f("100") == 0
benchmark_functions_edited/f7582.py
def f(actual, actual_min, actual_max, wanted_min, wanted_max): return (wanted_max - wanted_min) * ( (actual - actual_min) / (actual_max - actual_min) ) + wanted_min assert f(0, 0, 100, 0, 100) == 0
benchmark_functions_edited/f9154.py
def f(include_am, include_lm): added_feature_count = 0 if include_am: added_feature_count += 1 if include_lm: added_feature_count += 1 return added_feature_count assert f(False, False) == 0
benchmark_functions_edited/f13899.py
def f(aps, ap): for i, v in enumerate(aps): if v["serNum"] == ap["serNum"]: return i return -1 assert f( [ { "serNum": "1234567890", "ip": "10.10.10.10", "location": "somewhere", }, { "serNum": "1234567890", "ip": "10.10.10.11", "location": "somewhere else", }, ], { "serNum": "1234567890", "ip": "10.10.10.10", "location": "somewhere", }, ) == 0
benchmark_functions_edited/f4604.py
def f(n): x = n y = (x + 1) // 2 while y < x: x = y y = (x + n // x) // 2 return x assert f(16) == 4
benchmark_functions_edited/f1940.py
def f(value, scale, offset): return (value * scale) - offset assert f(0, 0.5, 0) == 0
benchmark_functions_edited/f8905.py
def f(microsec): if type(microsec) is not int: raise ValueError("microsec must be integer") return float(microsec) / 1000000 assert f(1000000) == 1
benchmark_functions_edited/f9636.py
def f(num, epsilon=1e-6, maxiter=1e6): x0, x1 = 0, 1 cnt = 0 while abs(x1 - x0) > epsilon: x0, x1 = x1, 0.5*(x1 + num/x1) cnt += 1 if cnt == maxiter: raise Exception("Max iteration reached") return x1 assert f(1, 1e-10) == 1
benchmark_functions_edited/f12860.py
def f(not_to_exceed): answer = 0 term_one = 1 term_two = 2 while term_two < not_to_exceed: if not term_two % 2: answer += term_two next_term = term_one + term_two term_one = term_two term_two = next_term return answer assert f(0) == 0
benchmark_functions_edited/f9085.py
def f(n: int) -> int: # Find the pentagonal number to nth degree. pentagonal_number = (n * ((3 * n) - 1) // 2) # Find the total number of dots. dots = ((n-1) ** 2) dots += pentagonal_number return dots assert f(1) == 1
benchmark_functions_edited/f10710.py
def f(lst): result = 0 # Accumulator for x in lst: if type(x) == int: result = result+1 return result assert f( [1, 2, 3, 4, 5, 6, 7.0] ) == 6
benchmark_functions_edited/f5131.py
def f(words, lexion): return sum([1 if word in lexion else 0 for word in words]) assert f( ["happy", "sad", "joyful"], ["joyful", "excited", "pleased", "happy"] ) == 2
benchmark_functions_edited/f69.py
def f(x,a,b): return a + b*x assert f(3, 1, 1) == 4
benchmark_functions_edited/f12829.py
def f(irr, area): pwr = irr * area return pwr assert f(2, 2) == 4
benchmark_functions_edited/f4693.py
def f(string): return int(round(float(string)*10000000)) assert f(0.000000000000001) == 0
benchmark_functions_edited/f5672.py
def f(nm, dm): if dm == 0: return 0. else: return nm / float(dm) assert f(10, 10) == 1
benchmark_functions_edited/f209.py
def f(x,a): return 2 * (x-a) assert f(2, 1) == 2
benchmark_functions_edited/f369.py
def f(mag,zp=25): f = 10**(2/5*(zp-mag)) return f assert f(25) == 1
benchmark_functions_edited/f13211.py
def f(sides: int, n: int) -> int: return (sides - 2)*n*(n-1)//2 + n assert f(5, 1) == 1
benchmark_functions_edited/f4160.py
def f(x: int) -> int: shiftamount = 1 while x >> shiftamount: x ^= x >> shiftamount shiftamount <<= 1 return x & 1 assert f(0) == 0
benchmark_functions_edited/f6257.py
def f(db) -> float: if db <= 44: return 0.0 db_cost = (db-40) / (75-40) return round(db_cost, 3) assert f(44) == 0
benchmark_functions_edited/f6814.py
def f(a, b): return max(-1, min(a[1], b[1]) - max(a[0], b[0]) + 1) assert f( [0, 2], [1, 3]) == 2
benchmark_functions_edited/f3093.py
def f(x1, x2, theta_0, theta_1, theta_2): return theta_0 + theta_1 * x1 + theta_2 * x2 assert f(5, 1, 0, 1, 1) == 6
benchmark_functions_edited/f12840.py
def f(dscp): dscp_to_queue = { 8 : 0, 5 : 2, 3 : 3, 4 : 4, 46 : 5, 48 : 6} return dscp_to_queue.get(dscp, 1) assert f(6) == 1
benchmark_functions_edited/f4307.py
def f(va,vb,vc,Zload): return (1/2)*(va*(-(va/Zload)).conjugate() + vb*(-(vb/Zload)).conjugate() + vc*(-(vc/Zload)).conjugate()) assert f(0,0,0,1) == 0
benchmark_functions_edited/f4461.py
def f(x, logomega0, b, height): return height / ((1 - b) + (b / (1 + b)) * (b * (10**logomega0 / x) + (x / 10**logomega0)**b)) assert f(10, 1, 1.00001, 1) == 1
benchmark_functions_edited/f13081.py
def f(tw_vectors): return max( list( max(offset + len(s) for (offset, s) in data) for (sharenum, (test, data, new_length)) in tw_vectors.items() if data ), ) assert f( { # Test and write vectors for a share. 0: ([0, 1, 2], [(0, b'123'), (3, b'123')], 6), }, ) == 6
benchmark_functions_edited/f6984.py
def f(x,y,floor=0): d = abs(x-y) if floor and d < floor: d = 0 return d assert f(1,-1) == 2
benchmark_functions_edited/f13676.py
def f(d, path, delimiter="/"): def item_by_tag(d, tags): # print(">>>>>>>>>>>>>> running nested", d, tags) t = tags[-1] child = d[t] if len(tags) == 1: return child return item_by_tag(child, tags[:-1]) tags = path.split(delimiter) tags.reverse() # print(">>>>>>>>>>>>>> splitted", tags) return item_by_tag(d, tags) assert f( {'a': {'b': 3}}, 'a/b', ) == 3
benchmark_functions_edited/f7117.py
def f(card_list): num_remaining = 0 for c in card_list: if c.is_unsolved(): num_remaining += 1 return num_remaining assert f([]) == 0
benchmark_functions_edited/f12746.py
def f(reg): if reg is not None: if reg == 'Tikhonov': N = 1 elif reg == 'GP': N = 3 elif reg == 'GP2': N = 2 else: print("%s is not a valid regularization method. Using no regularization." %reg) N = 0 else: N = 0 return N assert f('Tikhonov') == 1
benchmark_functions_edited/f3192.py
def f(disks: int) -> int: return 2 ** disks - 1 assert f(1) == 1
benchmark_functions_edited/f13482.py
def f(timestamp): try: timestamp_list = timestamp.split() h_m_s_list = timestamp_list[0].split(":") h = int(h_m_s_list[0]) m = int(h_m_s_list[1]) s = int(h_m_s_list[2]) ms = int(timestamp_list[-1]) except: h = 0 m = 0 s = 0 ms = 0 pass return (h*3600+m*60+s)*1000+ms assert f( "00:00:00 000") == 0
benchmark_functions_edited/f10074.py
def f(m, n, k=1): return m * 2 ** n - k * 2 ** (n - 1) assert f(3, 1) == 5
benchmark_functions_edited/f6337.py
def f(_, returns, raise_exception=None): if raise_exception: raise raise_exception return returns assert f(2, 3) == 3
benchmark_functions_edited/f11485.py
def f(ar: list) -> int: res = [] couples = {} for i in ar: count = ar.count(i) couples["{}".format(i)] = count for i in couples: x = couples[i] // 2 if x >= 1: res.append(x) else: pass return sum(res) assert f([10, 20, 20, 10, 10, 30, 50, 10, 20, 10]) == 3
benchmark_functions_edited/f10771.py
def f(val): try: return int(val) except (ValueError, TypeError): try: return float(val) except (ValueError, TypeError): if val.lower() == 'n/a': return None return val assert f('1') == 1
benchmark_functions_edited/f7844.py
def f(data): unique_events = {} for event in data["traceEvents"]: if "name" in event: unique_events[event["name"]] = 1 return len(unique_events) assert f({"traceEvents": []}) == 0
benchmark_functions_edited/f1106.py
def f(val, n): return (val % 0x100000000) >> n assert f(0, 6) == 0
benchmark_functions_edited/f1343.py
def f(n): return n + int(str(n)[::-1]) assert f(0) == 0
benchmark_functions_edited/f7794.py
def f(n, factor, max_size): if max_size is None or n * factor <= max_size: return factor return max_size // n assert f(6, 2, 24) == 2
benchmark_functions_edited/f1656.py
def f(kev): lamda = 12.3984 / kev #keV to Angstrom return lamda assert f(12.3984) == 1
benchmark_functions_edited/f14154.py
def f(page, max_number=None): if page == None or page < 1: page = 1 if max_number != None: if page > max_number: page = max_number return page assert f(0, 200) == 1
benchmark_functions_edited/f13837.py
def f(list): list_sum = 0 try: for i in list: list_sum += int(i) return list_sum / len(list) except (TypeError, ValueError, ZeroDivisionError): print() assert f([1]) == 1
benchmark_functions_edited/f4133.py
def f(dict_): try: return next(iter(dict_.values())) except StopIteration: raise ValueError("dict has no values") assert f({"a": 1}) == 1
benchmark_functions_edited/f8832.py
def f(x): if(x>=0): s=1 else: s = -1 return(s) assert f(0.0) == 1
benchmark_functions_edited/f13418.py
def f(e_hungry, e_dirt, e_mood): total = sum([e_hungry, e_dirt, e_mood]) if e_hungry > 12: return 6 elif total < 6: return 1 elif total < 10: return 2 elif total < 14: return 3 elif total < 18: return 4 else: return 5 assert f(0, 0, 0) == 1
benchmark_functions_edited/f1090.py
def f(i, j, ncol): return i * ncol + j assert f(1, 1, 2) == 3
benchmark_functions_edited/f10041.py
def f(nir, red, green): return (nir/green) - (red + green) assert f(1, 0, 1) == 0
benchmark_functions_edited/f7622.py
def f(n): assert n >= 0 and int(n) == n, 'The number has to be positive integers only' if n == 0: return 0 else: return int(n%10) + f(int(n/10)) assert f(4) == 4
benchmark_functions_edited/f8839.py
def f(iterable): return sum(iterable)/len(iterable) assert f([1, 2, 3, 4, 5]) == 3
benchmark_functions_edited/f11801.py
def f(val, default): return default if not val else val assert f('', 0) == 0
benchmark_functions_edited/f8293.py
def f(x,setval): if x < 0 : x=setval return x assert f(-1,1)==1
benchmark_functions_edited/f5138.py
def f(dictionary): if isinstance(dictionary, dict): return 1 + (max(map(dict_depth, dictionary.values())) if dictionary else 0) return 0 assert f({ 'a': 1, 'b': { 'c': { 'd': { 'e': 2, }, }, }, }) == 4
benchmark_functions_edited/f10494.py
def f(x): if x == 0: return 0 # invariant: l^2 <= x and x < r^2 l = 1 r = x while r-l > 1: m = l + (r-l)//2 s = m*m if s <= x: l = m else: r = m return l assert f(7) == 2
benchmark_functions_edited/f10924.py
def f(loss_rate): nines = 0 power_of_ten = 0.1 while True: if power_of_ten < loss_rate: return nines power_of_ten /= 10.0 nines += 1 if power_of_ten == 0.0: return 0 assert f(0.03) == 1
benchmark_functions_edited/f13420.py
def f(board): if not board: return 0 row = len(board) col = len(board[0]) cache = [0] * col for i in range(row): for j in range(col): if j == 0: cache[j] = cache[j] + board[i][j] else: cache[j] = max(cache[j], cache[j-1]) + board[i][j] return cache[-1] assert f([]) == 0
benchmark_functions_edited/f6199.py
def f(i): i += 1 return i assert f(5) == 6
benchmark_functions_edited/f411.py
def f(p1): return p1[1] % 2 if p1 else 0 assert f((None, 11)) == 1
benchmark_functions_edited/f8342.py
def f(a, l, r): pivot, i = a[l], l+1 for j in range(l+1, r+1): if a[j] <= pivot: a[i], a[j] = a[j], a[i] i += 1 a[i-1], a[l] = a[l], a[i-1] return i-1 assert f([1, 3, 1, 2, 0], 0, 4) == 2
benchmark_functions_edited/f7797.py
def f(roi_5day, n_rebase_per_day): reward_rate = roi_5day**(1 / (n_rebase_per_day * 5)) - 1 return reward_rate assert f(1, 1) == 0
benchmark_functions_edited/f7167.py
def f(*args): if any(x is not None for x in args): return min(x for x in args if x is not None) return None assert f(2, 1, 3) == 1
benchmark_functions_edited/f7287.py
def f(iterator): if hasattr(iterator, "__len__"): return len(iterator) nelements = 0 for _ in iterator: nelements += 1 return nelements assert f(["foo", "bar", "baz"]) == 3
benchmark_functions_edited/f5246.py
def f(series): if not hasattr(series, 'shape'): return 1 if len(series.shape) == 1: return 1 else: return series.shape[1] assert f([[1,2,3], [4,5,6]]) == 1
benchmark_functions_edited/f2439.py
def f(row): return max(row) - min(row) assert f([1]) == 0
benchmark_functions_edited/f10788.py
def f(maybe_dict, key: str): if isinstance(maybe_dict, dict): return maybe_dict.get(key, None) return maybe_dict assert f(1, "key") == 1
benchmark_functions_edited/f2904.py
def f(m): count = 0 while (m): count += m & 1 m >>= 1 return count assert f(128) == 1
benchmark_functions_edited/f13074.py
def f(event, attributes): score = 0 for attribute in attributes: if (attribute["category"] == "Payload installation") or (attribute["category"] == "Payload delivery"): ty = attribute["type"] if ty == "filename" or ty == "md5" or ty == "sha256" or ty == "sha1": score += 10 return score assert f(None, []) == 0
benchmark_functions_edited/f13683.py
def f(stairs: int, X): #we've reached the top if stairs == 0: return 1 elif stairs < 0: return 0 else: validSteps = [] for num in X: if stairs >= num: validSteps.append(num) sum = 0 for steps in validSteps: sum += f(stairs - steps, X) return sum assert f(1, [1, 2, 3]) == 1
benchmark_functions_edited/f695.py
def f(number): return (number * 2654435761) % 2**32 assert f(0) == 0
benchmark_functions_edited/f7041.py
def f(x, y): # In Python, this function is identical to the remainder operator. # However, many other languages define remainders differently assert y > 0 return x % y assert f(4, 10) == 4
benchmark_functions_edited/f5247.py
def f(x, y): c = 0 for i in range(31, 0, -1): c = (c << 1) | ((x >> i) & 1) c = (c << 1) | ((y >> i) & 1) return c assert f(0, 0) == 0
benchmark_functions_edited/f860.py
def f(a, p): tmp = pow(a, (p-1)//2, p) return -1 if tmp == p-1 else tmp assert f(1, 7) == 1
benchmark_functions_edited/f6219.py
def f(ints): denom = min(ints) while True: resid = [i % denom == 0 for i in ints] if all(resid): return denom else: denom -= 1 assert f((2, 6, 9, 12, 17)) == 1
benchmark_functions_edited/f5739.py
def f( job ): if hasattr( job, 'parse_script_date' ): return job.parse_script_date return 0 assert f( 1 ) == 0
benchmark_functions_edited/f1405.py
def f(v, d): if not v: v = d return v assert f(1, 2) == 1
benchmark_functions_edited/f9696.py
def f(buf, start, length): # note: purposefully does /not/ use struct.unpack, because that is used by the code we validate val = 0 for i in range(start, start+length): val <<= 8 val += ord(buf[i]) return val assert f(b'\x00\x00\x00\x00\x00', 0, 0) == 0
benchmark_functions_edited/f1473.py
def f(n): from math import ceil return int(ceil(n)) assert f(1) == 1
benchmark_functions_edited/f12347.py
def f(f, *args, **kwds): return f(*args, **kwds) assert f(lambda a=None: a, 1) == 1
benchmark_functions_edited/f13748.py
def f(faces, edges, verticies): # Return the calculated value return verticies + edges - faces assert f(1, 0, 2) == 1
benchmark_functions_edited/f1501.py
def f(func, *args): return func(*args) assert f(lambda x: x * 2, 4) == 8
benchmark_functions_edited/f4756.py
def f(integer, default=None): try: return int(integer) except (TypeError, ValueError): return default assert f(3.14) == 3
benchmark_functions_edited/f2992.py
def f(img): img = 255 - img return img assert f(255) == 0
benchmark_functions_edited/f7240.py
def f(obj, *keys, default=None): for key in keys: if key in obj: obj = obj[key] else: return default return obj assert f({1:2}, 1) == 2
benchmark_functions_edited/f4537.py
def f(x, y): return (1 - x) ** 2 + 100 * (y - x ** 2) ** 2 assert f(1, 1) == 0
benchmark_functions_edited/f9073.py
def f(text = None): try: choice = int(input(text if text else "Choose something...\n")) return choice except Exception as error: print("Please don't be a douche, input a valid number.") return 0 assert f("9") == 0
benchmark_functions_edited/f7209.py
def f(rate, freq): if freq == 0: return 0 return rate / freq assert f(48000, 48000) == 1
benchmark_functions_edited/f4713.py
def f(val, min=0.0, max=1.0): if val < min: return min elif val > max: return max else: return val assert f(0) == 0
benchmark_functions_edited/f5711.py
def f(dom): return dom[1] if isinstance(dom, tuple) else dom assert f(1) == 1
benchmark_functions_edited/f10630.py
def f(m): m1 = m % 10 m2 = m1 % 5 return m//10 + m1//5 + m2 assert f(0) == 0
benchmark_functions_edited/f3990.py
def f(n): if n in [13, 14, 17, 18, 19]: return 0 return n assert f(2) == 2
benchmark_functions_edited/f8371.py
def f(n): if n == 1: return 0 # r[i] will contain the ith Fibonacci number r = [-1] * (n + 1) r[0] = 0 r[1] = 1 for i in range(2, n + 1): r[i] = r[i - 1] + r[i - 2] return r[n - 1] assert f(4) == 2
benchmark_functions_edited/f10664.py
def f(ascii_code: int) -> int: if ascii_code < 48 or 87 < ascii_code < 96 or ascii_code > 119: raise ValueError(f'Invalid ASCII {ascii_code}.') decimal = ascii_code - 48 if decimal > 40: decimal -= 8 return decimal assert f(50) == 2
benchmark_functions_edited/f2178.py
def f(bits): return 2**(bits) - 1 assert f(0) == 0
benchmark_functions_edited/f14214.py
def f(h1, h2): a1, b1 = h1 a2, b2 = h2 c1 = -a1-b1 c2 = -a2-b2 return (abs(a1 - a2) + abs(b1 - b2) + abs(c1 - c2)) / 2 assert f( (-1, -1), (0, 0) ) == 2
benchmark_functions_edited/f8306.py
def f(pixel): return (0.5 * pixel[0] + pixel[1] + 1.5 * pixel[2])/3 assert f( (0, 0, 0) ) == 0
benchmark_functions_edited/f8175.py
def f(hex_num): AES_IRREDUCIBLE = 0x11A if hex_num > 0xFF: hex_num = hex_num % AES_IRREDUCIBLE return hex_num assert f(0x11F) == 5
benchmark_functions_edited/f6574.py
def f(x): if int(x) == x: return 0 return len(str(x)) - len(str(int(x))) - 1 assert f(123456789.0) == 0