file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f11452.py
def f(numbers): total = 1 for i in range(2, len(numbers) + 2): total += i total -= numbers[i - 2] return total assert f([1, 3, 4]) == 2
benchmark_functions_edited/f7479.py
def f(value): if value < 1: return 0 else: return value assert f(1.0) == 1
benchmark_functions_edited/f14456.py
def f(y_true, y_pred): # intialize error at 0 error_ = 0 # loop over all samples in the true and predicted list for yt, yp in zip(y_true, y_pred): # calculate the absolute error and add to the error value error_ += (yt - yp) ** 2 # return MAE return error_ / len(y_true) assert f( [2, 3, 5], [1, 1, 1]) == 7
benchmark_functions_edited/f6254.py
def f(number, divisor): tmp = number%divisor if tmp == 0: return 0 return divisor - tmp assert f(9, 3) == 0
benchmark_functions_edited/f4671.py
def f(s): count = 0 for c in s: if 'a' <= c <= 'f': count += 1 return count assert f( "" ) == 0
benchmark_functions_edited/f8838.py
def f(instruction, blank): bias = instruction[0]-blank[0] + instruction[1]-blank[1] return (instruction[0] - blank[0])**2 + (instruction[1] - blank[1])**2 + bias assert f( (0, 0), (-1, 1) ) == 2
benchmark_functions_edited/f6253.py
def f(codec: str) -> int: if codec.startswith("utf-32"): return 4 if codec.startswith("utf-16"): return 2 return 1 assert f("utf-32-le") == 4
benchmark_functions_edited/f3058.py
def f(val, bits): if (val & (1 << (bits - 1))) != 0: val -= (1 << bits) return val assert f(1, 4) == 1
benchmark_functions_edited/f10953.py
def f(number): if number <= 1: return number return f(number - 1) + f(number - 2) assert f(0) == 0
benchmark_functions_edited/f6586.py
def f(x, w, b): return w * x + b assert f(5, 1, 1) == 6
benchmark_functions_edited/f1907.py
def f(v1, v2): x1, y1, z1 = v1 x2, y2, z2 = v2 return x1*x2 + y1*y2 + z1*z2 assert f( (0,1,0), (0,0,-1) ) == 0
benchmark_functions_edited/f1403.py
def f(before, rhs, dt): return before + rhs * dt assert f(1, 0, 0.25) == 1
benchmark_functions_edited/f12244.py
def f(brake): brakevalue = { 'off': 0, 'on': 1 } brake = brake.lower() if type(brake) is not str: raise NameError('Invalid brake value.') if brake not in list(brakevalue.keys()): raise NameError('Invalid brake value.') return brakevalue[brake] assert f('off') == 0
benchmark_functions_edited/f2571.py
def f(statement, value): print() print(statement) print(value) return value assert f(1, 2) == 2
benchmark_functions_edited/f3055.py
def f(listy): return (len(listy)) assert f(['hello']) == 1
benchmark_functions_edited/f14454.py
def f(f, u=None, v=None): if v is not None: return (v - f)/f else: return f/(u - f) assert f(1, 0, 1) == 0
benchmark_functions_edited/f3780.py
def f(data, batch_size, num_epochs): return int((len(data)-1)/batch_size) + 1 assert f(range(10), 4, 4) == 3
benchmark_functions_edited/f12365.py
def f(block_count): return pow(block_count * 5.5, 0.87) * 0.75 assert f(0) == 0
benchmark_functions_edited/f8410.py
def f(x: float, epsilon: float = 1e-6) -> float: a = 0 b = x r = x xp = r*r while abs(x-xp) > epsilon: r = (a+b)/2 xp = r*r if xp < x: a = r else: b = r return r assert f(0) == 0
benchmark_functions_edited/f9954.py
def f(ebit, interest): return ebit / (ebit - interest) assert f(100, 50) == 2
benchmark_functions_edited/f10389.py
def f(aligned_seq1, aligned_seq2): cnt = 0 ending = len(aligned_seq1) - 3 for i in range(ending): cnt += int(aligned_seq1[i] != aligned_seq2[i] and aligned_seq1[i] != "-" and aligned_seq2[i] != "-") return cnt assert f("ATGC", "TATG") == 1
benchmark_functions_edited/f12469.py
def f(responses, derived): try: under = float(responses.get('child_support_amount_under_high_income', 0)) except ValueError: under = 0 try: over = float(responses.get('amount_income_over_high_income_limit', 0)) except ValueError: over = 0 return under + over assert f( {'child_support_amount_under_high_income': 'a', 'amount_income_over_high_income_limit': 0}, {}) == 0
benchmark_functions_edited/f4543.py
def f(pressure, sealevel_pa=101325.0): altitude = 44330.0 * (1.0 - pow(pressure / sealevel_pa, (1.0/5.255))) return altitude assert f(101325) == 0
benchmark_functions_edited/f4363.py
def f(f: float) -> int: return int(round(f, 0)) assert f(0.0000000001) == 0
benchmark_functions_edited/f8693.py
def f(epoch, iteration, dataset_len, epochs, warmup_epochs): factor = epoch // 30 lr = 0.1 ** factor return lr assert f(1, 1, 1, 1, 1) == 1
benchmark_functions_edited/f7294.py
def f(x): n = len(x) if n < 2: raise ValueError('dimension must be greater than one') return -sum(100 * (x[i+1] - x[i]**2)**2 + (1 - x[i])**2 for i in range(n-1)) assert f([1, 1]) == 0
benchmark_functions_edited/f3420.py
def f(issues): return sum([int(i["story points"]) for i in issues if i["story points"] is not None]) assert f( [ {"story points": "1", "priority": "must"}, {"story points": "2", "priority": "should"}, {"story points": None, "priority": "must"}, {"story points": "3", "priority": "must"} ] ) == 6
benchmark_functions_edited/f12388.py
def f(root, partial_sum): if root is None: return 0 partial_sum = partial_sum * 2 + root.val if not root.right and not root.left: return partial_sum return f(root.right, partial_sum) + \ f(root.left, partial_sum) assert f(None, 0) == 0
benchmark_functions_edited/f8000.py
def f(a, b, fx = lambda x: x): return (fx(b) - fx(a))/(b - a) assert f(1, 3, lambda x: 2*x) == 2
benchmark_functions_edited/f11572.py
def f(s1, s2): if len(s1) != len(s2): raise ValueError("Undefined for sequences of unequal length") mm=0 sup=0 for el1, el2 in zip(s1, s2): if el1=='-' and el2=='-': continue sup +=1 if el1 != el2: mm +=1 return mm*1.0/sup assert f(list("ACGT"), list("ACGT")) == 0
benchmark_functions_edited/f8582.py
def f(p,size): return min(max(0,p),size); assert f(5,7) == 5
benchmark_functions_edited/f921.py
def f(li): return sum(li)/len(li) assert f([2, 4, 6, 8]) == 5
benchmark_functions_edited/f11625.py
def f(numbers: list) -> int: largest_num = 0 # Edit this function so that it return the largest number within the list return largest_num assert f(0) == 0
benchmark_functions_edited/f228.py
def f(x): return (x + 1) * 127.5 assert f(-1) == 0
benchmark_functions_edited/f2453.py
def f(size): s = 1 for i in size: s *= i return s assert f([1]) == 1
benchmark_functions_edited/f9627.py
def f(iterable): max_i = -1 max_v = float('-inf') for i, iter in enumerate(iterable): temp = max_v max_v = max(iter,max_v) if max_v != temp: max_i = i return max_i assert f([10, 10, 10]) == 0
benchmark_functions_edited/f7913.py
def f(dataset: list) -> int: return sum(i != j for i, j in zip(*dataset)) assert f( [ "abcd\nefgh\nijkl\n", "abcd\nefgh\nijkl\n", ] ) == 0
benchmark_functions_edited/f9917.py
def f(d): max_cnt = -1e90 max_vid = None for vid in d: if d[vid]>max_cnt: max_cnt = d[vid] max_vid = vid return max_vid assert f({1: 10}) == 1
benchmark_functions_edited/f8431.py
def f(mag_star, mag_ref=0): return 10**(0.4*((mag_ref)-(mag_star))) assert f(0) == 1
benchmark_functions_edited/f3767.py
def f(label): if label == 'female': return 0 else: return 1 # end if assert f('male') == 1
benchmark_functions_edited/f10583.py
def f(words): max_size = 0 for word in words: if len(word) > max_size: max_size = len(word) return max_size assert f( ['I', 'am', 'the', 'dog', 'that', 'barks']) == 5
benchmark_functions_edited/f13581.py
def f(value: str): try: f = float(value) if f.is_integer(): return int(f) return f except ValueError: return value assert f("0") == 0
benchmark_functions_edited/f4534.py
def f(count, chars): if chars and count: import math return int(count * math.log(len(chars), 2)) else: return 0 assert f(2, '') == 0
benchmark_functions_edited/f13383.py
def f(l): steps = 1 for i in range(1, len(l)): if l[i] == l[0]: if l[:i] == l[i:i+i]: return steps steps += 1 return None assert f([1, 1, 1, 1, 1]) == 1
benchmark_functions_edited/f7738.py
def f(position): return "abcdefgh".find(position[0]) + (int(position[1]) - 1) * 8 assert f("a1") == 0
benchmark_functions_edited/f14033.py
def f(w1, w2): this_row = range(len(w1)+1) for row_num in range(1, len(w2)+1): prev_row = this_row this_row = [row_num] for j in range(1, len(prev_row)): this_row.append(min( this_row[-1]+1, prev_row[j]+1, prev_row[j-1] + (w1[row_num-1:row_num] != w2[j-1:j]), )) return this_row[-1] assert f('ab', 'ac') == 1
benchmark_functions_edited/f13797.py
def f(current_step: int, max_step: int) -> int: if current_step < 1: current_step = 1 elif current_step > max_step: current_step = max_step return current_step assert f(4, 1) == 1
benchmark_functions_edited/f397.py
def f(x, a, b): return a * x ** (-b) assert f(2, 2, 0) == 2
benchmark_functions_edited/f13467.py
def f(num): if int(num) < num: # num is positive float # e.g. int(2.5) = 2 return int(num) + 1 else: # num is integer, or num is negative float # e.g. int(2.0) = 2 # e.g. int(-2.5) = -2 return int(num) assert f(0.99) == 1
benchmark_functions_edited/f8755.py
def f(stepsDict): n = 0 for s in stepsDict: if not stepsDict[s].complete: if stepsDict[s].startTime != -1: n += 1 return n assert f(dict()) == 0
benchmark_functions_edited/f4083.py
def f(msg, lst): if msg == lst[0]: return lst[1] return lst[0] assert f(2, [0, 1]) == 0
benchmark_functions_edited/f14240.py
def f(knot, knot_vector, **kwargs): # Get tolerance value tol = kwargs.get('tol', 0.001) mult = 0 # initial multiplicity for kv in knot_vector: if abs(knot - kv) <= tol: mult += 1 return mult assert f(5.0, [0.0, 1.0, 2.0, 3.0, 4.0]) == 0
benchmark_functions_edited/f4750.py
def f(sample): for i in range(len(sample)): if sample[i] != sample[-i - 1]: return 0 return 1 assert f( "ab" ) == 0
benchmark_functions_edited/f5816.py
def f(self, key, default=None): try: return self[key] except KeyError: return default assert f(dict(), 1, 2) == 2
benchmark_functions_edited/f12504.py
def f(target, pairs): accum = 0 for length, count in reversed(sorted(pairs)): accum += length*count if accum >= target: break else: raise Exception('Total=%d < target=%d' %(accum, target)) return length assert f(15, [(1, 5), (1, 5), (1, 5), (1, 5)]) == 1
benchmark_functions_edited/f8976.py
def f(value, intervals): for index, interval in enumerate(intervals): if interval[0] <= value <= interval[1]: return index return -1 assert f(2, [(1, 5), (6, 10)]) == 0
benchmark_functions_edited/f7843.py
def f(fixed_point_val: int, precision: int) -> int: if (precision >= 0): return fixed_point_val >> precision return fixed_point_val << precision assert f(2, 0) == 2
benchmark_functions_edited/f6126.py
def f(a, b, c): M = [[a[0] - c[0], a[1] - c[1]], [b[0] - c[0], b[1] - c[1]]] # Return det(M) return M[0][0] * M[1][1] - M[0][1] * M[1][0] assert f( (1, 1), (5, 1), (1, 1) ) == 0
benchmark_functions_edited/f11571.py
def f(close, low, open, high): if high == close: return 1 elif high == open: return -1 else: return 0 assert f(5, 2, 1, 6) == 0
benchmark_functions_edited/f10458.py
def f(p_beta: float, opinion): opinion_rate = 1 if opinion == 1: opinion_rate /= 2 return p_beta * opinion_rate assert f(0, 10) == 0
benchmark_functions_edited/f6987.py
def f(number, porc): return number + (number * (porc / 100)) assert f(0, 10) == 0
benchmark_functions_edited/f11888.py
def f(iterable): i = iter(iterable) try: item = next(i) except StopIteration: raise ValueError("Too few items. Expected exactly one.") try: next(i) except StopIteration: return item raise ValueError("Too many items. Expected exactly one.") assert f(range(1)) == 0
benchmark_functions_edited/f9387.py
def f(parent_index, heap): # Remember, this is a 1-based index. if parent_index * 2 >= len(heap): # There is no left child return 0 return parent_index * 2 assert f(5, [5, 4, 3, 2, 1]) == 0
benchmark_functions_edited/f8329.py
def f(the_list, substring): for i, s in enumerate(the_list): if s.startswith(substring): return i return -1 assert f( ['abc', 'def', 'xyz'], 'ab') == 0
benchmark_functions_edited/f1950.py
def f(st1, yt1, t): return st1 - st1 / t + yt1 assert f(0, 0, 1) == 0
benchmark_functions_edited/f8600.py
def f(r, aa): # return r * r - 2 * r + aa * aa return r * (r - 2) + aa * aa assert f(2, 0) == 0
benchmark_functions_edited/f8425.py
def f(root): if root is None: return 0 left = f(root.left) right = f(root.right) if left < 0 or right < 0 or abs(left - right) > 1: return -1 return max((left, right)) + 1 assert f(None) == 0
benchmark_functions_edited/f4873.py
def f(lst): return len([ y for (x,y) in zip(lst, lst[1:]) if y > x]) assert f([1, 2, 3, 4]) == 3
benchmark_functions_edited/f1075.py
def f(l, item): l.append(item) return len(l)-1 assert f(list(), 'a') == 0
benchmark_functions_edited/f10442.py
def f(a, b): while b != 0: a, b = b, a % b return a assert f(2,0) == 2
benchmark_functions_edited/f8308.py
def f(x): return (((x - 1) >> 2) + 1) << 2 assert f(0) == 0
benchmark_functions_edited/f5741.py
def f(TP, atrank): # FP = min((atrank + 1) - TP, nGroundTruth) nRetreived = atrank + 1 FP = nRetreived - TP return FP assert f(3, 5) == 3
benchmark_functions_edited/f8492.py
def f(d, key): for k in key.split('.'): if k in d: d = d[k] else: return None if isinstance(d, list): return ', '.join([str(i) for i in d]) else: return d assert f({'a': 1}, 'a') == 1
benchmark_functions_edited/f6010.py
def f(rec=0, yds=0, tds=0, ppr=1): return yds*0.1 + rec*ppr + tds*6 assert f(1, 0, 0) == 1
benchmark_functions_edited/f12140.py
def f(headers): if 'x-goog-stored-content-length' in headers: length = headers['x-goog-stored-content-length'] elif 'Content-Length' in headers: length = headers['Content-Length'] else: length = 0 return int(length) assert f({'Content-Length': '1'}) == 1
benchmark_functions_edited/f1616.py
def f(x, a, b, c, d): return (x - a) / (b - a) * (d - c) + c assert f(5, 0, 10, 0, 10) == 5
benchmark_functions_edited/f3333.py
def f(xa, ya, xb, yb, xc, yc): return (xb - xa) * (yc - ya) - \ (xc - xa) * (yb - ya) assert f(0, 0, 1, 1, 2, 2) == 0
benchmark_functions_edited/f14225.py
def f(n, order, current_max): # +-(0~9) if order == 0: return int(current_max) # +-(10~99999) else: # Get digit division = 10**(order-1) num = (n - (n % division))/division if num > current_max: current_max = num return f(n % division, order-1, current_max) assert f(10, 2, 0) == 1
benchmark_functions_edited/f14246.py
def f(grid): z = 0 for col in grid: for row in col: if row != 0: z += 1 x = 0 for col in grid: maxx = 0 for row in col: maxx = max(row, maxx) x += maxx y = 0 for i in range(len(grid)): maxy = 0 for j in range(len(grid)): maxy = max(grid[j][i], maxy) y += maxy return z + x + y assert f( [[1, 0], [0, 2]] ) == 8
benchmark_functions_edited/f879.py
def f(x): from math import sqrt return sqrt(abs(x)) assert f(9) == 3
benchmark_functions_edited/f3644.py
def f(prev, cur, m): if m not in prev or m not in cur: return 0 return cur[m] - prev[m] assert f( {'m1': 1,'m2': 2}, {'m1': 2,'m2': 3}, 'm1') == 1
benchmark_functions_edited/f4967.py
def f(strn): return len(strn.encode("utf-8")) assert f(u"abc") == 3
benchmark_functions_edited/f6790.py
def f(cigar): if cigar[-1] == 'N': return -int(cigar[:-1]) return int(cigar[:-1]) assert f(**{'cigar': '3M'}) == 3
benchmark_functions_edited/f5455.py
def f(n, k): if n == 0 or n != 0 and n == k: return 1 if k == 0 or n < k: return 0 return k * f(n-1, k) + f(n-1, k-1) assert f(4, 4) == 1
benchmark_functions_edited/f6856.py
def f(x): if x > 0: return +1 elif x < 0: return -1 elif x == 0: return 0 assert f(-0.0) == 0
benchmark_functions_edited/f4553.py
def f(n, r): u, s = n, n+1 while u < s: s = u t = (r-1) * s + n // pow(s, r-1) u = t // r return s assert f(4, 5) == 1
benchmark_functions_edited/f7010.py
def f(m_mel): return 700*(10**(m_mel/2595) - 1.0) assert f(0) == 0
benchmark_functions_edited/f1535.py
def f(num): if num >= 0: return 1 else: return -1 assert f(10) == 1
benchmark_functions_edited/f14209.py
def f(obj): if not obj['AutoScalingGroups']: return 0 instances = obj['AutoScalingGroups'][0]['Instances'] in_service = 0 for instance in instances: if instance['LifecycleState'] == 'InService': in_service += 1 return in_service assert f( { 'AutoScalingGroups': [ { 'Instances': [ { 'LifecycleState': 'InService' } ] } ] }) == 1
benchmark_functions_edited/f7899.py
def f(d: dict) -> int: largest = 0 for i in d.values(): temp = len(i) if temp > largest: largest = temp return largest assert f( {"key1": [], "key2": ["c", "d", "e"]} ) == 3
benchmark_functions_edited/f896.py
def f(A, B, u, m): return A + B * u ** m assert f(0, 1, 1, 2) == 1
benchmark_functions_edited/f12633.py
def f(*chores): chore_hours = 0 total_hours = 17 for arg in chores: chore_hours += arg[1] total_hours -= chore_hours if total_hours <= 0: return 0 return total_hours assert f( ('B', 20) ) == 0
benchmark_functions_edited/f7567.py
def f(key_one, key_two): val_key_one = int(key_one, 16) val_key_two = int(key_two, 16) return val_key_one ^ val_key_two assert f( "1c0111001f010100061a024b53535009181c", "1c0111001f010100061a024b53535009181c" ) == 0
benchmark_functions_edited/f12678.py
def f(given_name): parts = given_name.split('_') for part in parts: if part.isnumeric(): return int(part) return None assert f('my_cool_name_1') == 1
benchmark_functions_edited/f2319.py
def f(xs): return xs[-1] assert f(range(2)) == 1
benchmark_functions_edited/f6458.py
def f(a, b): # like divmod_min, just skipping a single add r = (a % b) diff = b - r if abs(r) > abs(diff): r = -diff return r assert f(21, 5) == 1
benchmark_functions_edited/f1442.py
def f(f, x, dx=1e-5): return (0.5/dx) * (f(x+dx) - f(x-dx)) assert f(lambda x: x**2, 0) == 0
benchmark_functions_edited/f1682.py
def f(s: str) -> int: return len(s) - len(s.lstrip(" ")) assert f("\t\thello") == 0
benchmark_functions_edited/f12338.py
def f(i, alpha, num_symbols): return i * (num_symbols - 1) + alpha assert f(0, 0, 3) == 0
benchmark_functions_edited/f13675.py
def f(arr): smallest = arr[0] # stores the smallest value smallest_index = 0 # stores the position of the smallest value for i in range(1, len(arr)): if arr[i] < smallest: smallest = arr[i] smallest_index = i return smallest_index assert f( [1, 2, 3, 0, 4, 5] ) == 3