file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f355.py
def f(x): return max(x) - min(x) assert f(list(range(0, 10))) == 9
benchmark_functions_edited/f3403.py
def f(num): if (num<=1): return num return num+f(num-1) assert f(0) == 0
benchmark_functions_edited/f1493.py
def f(c, H, D): if c == 0: return 0 return min(2 * H / D, 10) assert f(0, 3, 0) == 0
benchmark_functions_edited/f12744.py
def f(iterable, default=False, pred=None): # f([a,b,c], x) --> a or b or c or x # f([a,b], x, f) --> a if f(a) else b if f(b) else x return next(filter(pred, iterable), default) assert f(range(1, 10)) == 1
benchmark_functions_edited/f8876.py
def f(nucleotide): if nucleotide == 'C': return 2 if nucleotide == 'G': return 3 if nucleotide == 'A': return 1 if nucleotide == 'T': return 4 return 0 assert f('C') == 2
benchmark_functions_edited/f6138.py
def f(left: int, right: int) -> int: res = left + right return res if -2 < res < 2 else (res < 0) - (res > 0) assert f(1, -1) == 0
benchmark_functions_edited/f3056.py
def f(values): return sum(values) / float(len(values)) assert f([2.5, 3.5, 2.75, 3.25]) == 3
benchmark_functions_edited/f13503.py
def f(parents, num_values): num_pa_instantiations = 1 for pa in parents: num_pa_values = num_values[pa] num_pa_instantiations *= num_pa_values return num_pa_instantiations assert f([], [1, 2, 3, 3]) == 1
benchmark_functions_edited/f10402.py
def f(d: int) -> int: if d == 1: return 0 i = 2 while i * i <= d: if d % i == 0: return 0 i = i + 1 return 1 assert f(29) == 1
benchmark_functions_edited/f2350.py
def f(v): try: return int(float(v)) except: return None assert f(1.01) == 1
benchmark_functions_edited/f5136.py
def f(value, typ): if typ == "b": return bool(value) if typ == "i": return int(value) return value assert f(2, "i") == 2
benchmark_functions_edited/f8012.py
def f(n): assert n and (n & (n - 1)) == 0 i = -1 while n: i += 1 n >>= 1 return i assert f(0b00000000000000000000000000000100) == 2
benchmark_functions_edited/f4475.py
def f(string_var): try: return int(string_var) except ValueError: return 0 assert f('1.5a') == 0
benchmark_functions_edited/f3382.py
def f(num:int) -> int: return ((num & 0xffff) ^ 0x8000) - 0x8000 assert f(0x0000) == 0
benchmark_functions_edited/f4388.py
def f(month): if month == "Wayeb'": return 5 else: return 20 assert f("Wayeb'") == 5
benchmark_functions_edited/f4695.py
def f(y, m, d): return (y - (m < 3) + (y - (m < 3)) // 4 - (y - (m < 3)) // 100 + (y - (m < 3)) // 400 + ord('-bed=pen+mad.'[m]) + d) % 7 assert f(2022, 6, 3) == 5
benchmark_functions_edited/f5336.py
def f(node): return pow(7, node[0]) * pow(5, node[1]) assert f( (0, 1) ) == 5
benchmark_functions_edited/f4113.py
def f(rec, tru): return len(rec & tru)/len(tru) if len(tru) != 0 else 0 assert f({1, 2, 3}, set()) == 0
benchmark_functions_edited/f12254.py
def f(i, sampleRate, nFFT): return (i * (sampleRate / (nFFT*2))) assert f(0, 1000, 1001) == 0
benchmark_functions_edited/f12272.py
def f(players_to_check_in_order, hands, passed_list): for player in players_to_check_in_order: if hands[player] and player not in passed_list: return player return None assert f( [1, 2, 3, 4], {1: [], 2: [1], 3: [], 4: []}, []) == 2
benchmark_functions_edited/f4064.py
def f(rating_list): if not rating_list: return 0 return round(sum(rating_list) / len(rating_list)) assert f( [1, 1, 1]) == 1
benchmark_functions_edited/f9440.py
def f(seq): #count = 0 #for s in seq: # if s not in ['A','T','C','G','N']: # pdb.set_trace() # print(s) return sum(s.upper() not in ['A','T','C','G','N'] for s in seq) assert f("ACGT") == 0
benchmark_functions_edited/f11588.py
def f(cell1, cell2): return abs(cell1[0]-cell2[0]) + abs(cell1[1]-cell2[1]); assert f( (3, 5), (2, 5) ) == 1
benchmark_functions_edited/f4129.py
def f(f, x, h=1e-6): return (f(x - h) - 2 * f(x) + f(x + h)) / float(h**2) assert f(lambda x: 1, 3) == 0
benchmark_functions_edited/f7482.py
def f(a, b, c): # *** YOUR CODE HERE *** return a assert f(1, 1, 1) == 1
benchmark_functions_edited/f1092.py
def f(label: str) -> int: return label.count("\n") + 1 assert f( "one" ) == 1
benchmark_functions_edited/f3533.py
def f(x): import random import time time.sleep(random.random()) return x**2 assert f(-1) == 1
benchmark_functions_edited/f12634.py
def f(n, ratings): result = [1] * n for i in range(1, n): if ratings[i] > ratings[i - 1]: result[i] = result[i - 1] + 1 else: result[i] = 1 for i in range(n - 2, -1, -1): if ratings[i] > ratings[i + 1]: result[i] = max(result[i], result[i + 1] + 1) return sum(result) assert f(8, [1, 1, 1, 1, 1, 1, 1, 1]) == 8
benchmark_functions_edited/f3245.py
def f(n: int) -> int: if n < 2: return n return f(n - 1) + f(n - 2) assert f(4) == 3
benchmark_functions_edited/f9754.py
def f(n: int): n = abs(n) i = 0 while i**2 <= n: i += 1 if n - (i-1)**2 < i**2 - n: return i - 1 else: return i assert f(10) == 3
benchmark_functions_edited/f2161.py
def f(location): if location is None: return None return location[0] assert f((1, 0)) == 1
benchmark_functions_edited/f10177.py
def f(intersection, union): return len(intersection) / len(union) assert f(set(), set([1])) == 0
benchmark_functions_edited/f1189.py
def f(x, y): return 5*max(abs(x[0]-y[0]),abs(x[1]-y[1]),abs(x[2]-y[2])) assert f([0, 0, 0], [-1, -1, -1]) == 5
benchmark_functions_edited/f14404.py
def f(R): # For "small" R (5.3.7); R < 0.53 if R < 0.53: return 2*R + R**3 + (5/6)*(R**5) # For "large" R (5.3.8); R >= 0.85 if R >= 0.85: return (1 / (2 * (1 - R) - ((1-R)**2) - ((1-R)**3))) # return (1 / (2*(1-R))) # (5.3.9) - this isn't a good approximation # For "medium" R (5.3.10); 0.53 <= R < 0.85 return -0.4 + 1.39*R + (0.43/(1-R)) assert f(0) == 0
benchmark_functions_edited/f13097.py
def f(seq, dim_list): i = 0 for s, d in zip(seq, dim_list): i *= d i += s return i assert f([0, 2, 1], [3, 3, 3]) == 7
benchmark_functions_edited/f5178.py
def f(combo, speed=1000000000): return (combo // speed) // (24 * 3600) assert f(100000000) == 0
benchmark_functions_edited/f9858.py
def f(num1, num2): v = num1 % num2 if v < 0 and num1 > 0 or v > 0 and num1 < 0: v = v + num1 return v assert f(1234567890, 1) == 0
benchmark_functions_edited/f12972.py
def f(abscissa, gradient, intercept): return gradient * abscissa + intercept assert f(1, 3, 2) == 5
benchmark_functions_edited/f10727.py
def f(input_size: int, sizes: list, strides: list): t = input_size for size, stride in zip(sizes, strides): t = int((t - size) / stride + 1) return t assert f(12, [3, 4], [1, 2]) == 4
benchmark_functions_edited/f5182.py
def f(ngram: str) -> int: number = 0 for char in ngram: number = number * 26 + ord(char) - ord('A') return number assert f( "AAA") == 0
benchmark_functions_edited/f9925.py
def f(true_pos, false_pos): try: prec = true_pos / float(true_pos + false_pos) return round(prec, 3) except BaseException: return None assert f(0, 1) == 0
benchmark_functions_edited/f4319.py
def f(progress, period, x_range): x = int((progress / period) * x_range) return x assert f(1, 3, 1) == 0
benchmark_functions_edited/f1206.py
def f(num): return len(f"{num}") assert f(0) == 1
benchmark_functions_edited/f847.py
def f(r): return int(r.get("rangNr", 0)) assert f(dict()) == 0
benchmark_functions_edited/f12318.py
def f(nums, k): if not nums: return 0 tally = {0:1} n = len(nums) count = 0 s = 0 for num in nums: s += num if s - k in tally: count += tally[s-k] if s in tally: tally[s] += 1 else: tally[s] = 1 return count assert f([1], 1) == 1
benchmark_functions_edited/f49.py
def f(a, b): a >>= b return a assert f(1, 3) == 0
benchmark_functions_edited/f11850.py
def sucrose (inverted_sugar_pre_hidrolisys, inverted_sugar_post_hidrolisys): inverted_sugar_from_sucrose = inverted_sugar_post_hidrolisys - inverted_sugar_pre_hidrolisys sucrose = inverted_sugar_from_sucrose * 0.95 ## 0.95 is the convertion factor for inverted sugar to sucrose return sucrose assert f(10, 10) == 0
benchmark_functions_edited/f4894.py
def f( l, e ) : if( l == e ) : return 0 t = type( l[0] ) for i in l : if ( t != type( i ) ) : return 1 return 0 assert f( ['a', 'b', 'c', 'd', 'e'], ['a', 'b', 'c', 'd', 'e'] ) == 0
benchmark_functions_edited/f2789.py
def f(array, index): if index == 0: return len(array) - 1 return index - 1 assert f( ['a', 'b', 'c', 'd', 'e'], 4 ) == 3
benchmark_functions_edited/f1695.py
def f(h): return int.from_bytes(h,"big") assert f(b'\x00\x00\x00\x00\x00\x00\x00\x01') == 1
benchmark_functions_edited/f12912.py
def f(pairs, match_score=1, mismatch_score=-1, gap_score=-1): total = 0 for c,i in pairs: if c in ["="]: total += i*match_score elif c in ["X"]: total += i * mismatch_score elif c in ["I", "D", "N", "S", "H", "P"]: total += i * gap_score return total assert f(zip('IIIIIIIIIIIIIIIIIIIII', [0]), 100) == 0
benchmark_functions_edited/f14206.py
def f(limit): max_length = 0 div = 0 for number in range(limit-1, 2, -1): # pylint: disable=misplaced-comparison-constant length = next((x for x in range(1, number) if 1 == (10**x%number)), None) if length is not None and length > max_length: max_length, div = length, number return div assert f(10) == 7
benchmark_functions_edited/f3348.py
def f(letter: str) -> int: return ord(letter) - ord('A') + 1 assert f('A') == 1
benchmark_functions_edited/f7734.py
def f(w_stable): consumption = 0 prev_w = None for w in w_stable: if prev_w is not None and w < prev_w: consumption += prev_w - w prev_w = w return consumption assert f(sorted([1, 2, 3, 4, 5])) == 0
benchmark_functions_edited/f8202.py
def f(m): ans = 0 ans += m // 10 ans += (m % 10) // 5 ans += (m % 10) - (((m % 10) // 5 ) * 5) return ans assert f(0) == 0
benchmark_functions_edited/f14160.py
def f(res): tot_length = 120 n_fields = 5 fmt = ''.join(['{:^', str(tot_length // n_fields), '}']) * n_fields print(fmt.format( 'Parameter', 'Result', 'Value', 'Derivative', 'Condition N' )) for k, v in res.items(): print( fmt.format(*(k + tuple(v))) ) continue return 0 assert f(dict()) == 0
benchmark_functions_edited/f227.py
def f(n): return n * (n + 1) / 2 assert f(3) == 6
benchmark_functions_edited/f4496.py
def f(ep, eb, gamma, e): eps = 1 - (ep ** 2 - eb * e * 1j) / (e ** 2 + 2 * e * gamma * 1j) # Mod drude term return eps assert f(1, 1, 1, -1j) == 1
benchmark_functions_edited/f4661.py
def f(cluster): x, y = list(zip(*cluster))[:2] return min(len(set(x)), len(set(y))) assert f(set([('A', 1), ('B', 2), ('C', 3)])) == 3
benchmark_functions_edited/f3846.py
def f(num_row, a, b, m): return (a * num_row + b) % m assert f(3, 1, 3, 4) == 2
benchmark_functions_edited/f8895.py
def f(haystack, needle): length_h = len(haystack) length_n = len(needle) for i in range(length_h - length_n + 1): if haystack[i:i + length_n] == needle: return i return -1 assert f("abcd", "abc") == 0
benchmark_functions_edited/f13896.py
def f(ref_dataset: int) -> int: if ref_dataset is None: raise ValueError("Reference to a dataset must not be empty.") if ref_dataset <= 0: raise ValueError("Reference to a dataset must be positive.") return ref_dataset assert f(1) == 1
benchmark_functions_edited/f7951.py
def f(xs, ys): max_i = min(len(xs), len(ys)) - 1 for i, (x, y) in enumerate(zip(xs, ys)): if x == y and (i == max_i or xs[i+1] != ys[i+1]): return i return -1 assert f( ['a', 'b', 'c'], ['x', 'b', 'y'], ) == 1
benchmark_functions_edited/f10500.py
def f(value: float) -> int: value_str: str = str(value) if "e-" in value_str: _, buf = value_str.split("e-") return int(buf) elif "." in value_str: _, buf = value_str.split(".") return len(buf) else: return 0 assert f(0) == 0
benchmark_functions_edited/f10497.py
def f(n): putere = 1 while 2**putere < n+2: putere += 1 return putere assert f(27) == 5
benchmark_functions_edited/f12271.py
def f(start, length, bits): newStart = start % bits newEnd = newStart + length totalWords = (newEnd-1) / bits return totalWords + 1 assert f(0, 2, 1) == 2
benchmark_functions_edited/f2347.py
def f(n): if n==1: return 1 return n * f(n-1) assert f(1.0) == 1
benchmark_functions_edited/f4828.py
def f(alpha, beta, x): one_minus_x = 1 - x return (one_minus_x ** alpha) * (one_minus_x ** beta) assert f(0, 0, 0.25) == 1
benchmark_functions_edited/f3007.py
def f(y, m, d): return (y-(m<3)+(y-(m<3))//4-(y-(m<3))//100+(y-(m<3))//400+ord('-bed=pen+mad.'[m])+d)%7 assert f(2019, 3, 20) == 3
benchmark_functions_edited/f13879.py
def f(p, n): # return (p[0] > p[1] and n[0] < n[1]) or (p[0] < p[1] and n[0] > n[1]) if (p[0] > p[1] and n[0] < n[1]): return -1 elif (p[0] < p[1] and n[0] > n[1]): return 1 return 0 assert f( (2, 3), (2, 2) ) == 0
benchmark_functions_edited/f13835.py
def f(l, stop): if (stop <= -l) or (stop > l): raise IndexError('stop index out of range') elif stop <= 0: # let stop == 0 be shorthand for stop == l, # i.e. including all profiles to the end stop = (stop - 1) % l + 1 return stop assert f(4, 3) == 3
benchmark_functions_edited/f10063.py
def f(x, a, b, c): return a*x**b + c assert f(0, 1, 1, 1) == 1
benchmark_functions_edited/f14119.py
def f(_b, _x): # Initialize counter _head = 0 # Iterate through values in vector for i in _x: if i == _b: _head += 1 else: break return _head assert f(0, [0, 0, 0, 0, 0, 0]) == 6
benchmark_functions_edited/f9614.py
def f(cand_d, ref_ds): count = 0 for m in cand_d.keys(): m_w = cand_d[m] m_max = 0 for ref in ref_ds: if m in ref: m_max = max(m_max, ref[m]) m_w = min(m_w, m_max) count += m_w return count assert f({}, [{'a': 1, 'b': 3}, {'b': 2, 'c': 2}]) == 0
benchmark_functions_edited/f4842.py
def f(pos, shape): res = 0 acc = 1 for pi, si in zip(reversed(pos), reversed(shape)): res += pi * acc acc *= si return res assert f((0, 0, 0), (1, 2, 3)) == 0
benchmark_functions_edited/f1910.py
def f(vec1, vec2): return vec1[0]*vec2[0] + vec1[1]*vec2[1] + vec1[2]*vec2[2] assert f( (1, 0, 1), (0, 1, 0) ) == 0
benchmark_functions_edited/f11328.py
def f(word: str) -> int: if len(word) == 4: return 1 return len(word) + 7 * (len(set(word)) == 7) assert f( 'aa' ) == 2
benchmark_functions_edited/f1127.py
def f(edge): if edge[2] >= len(edge[4]): return 1 return 0 assert f( ('a', 'b', 1, 3, (5,6,6)) ) == 0
benchmark_functions_edited/f1474.py
def f(x): if x == None: return 0 else: return 1 assert f(10) == 1
benchmark_functions_edited/f5598.py
def f(n: int) -> int: a = 0 b = 1 for i in range(n): a, b = b, a + b return a assert f(4) == 3
benchmark_functions_edited/f9212.py
def f(input: float, low: float, high: float) -> float: return max(min(input, high), low) assert f(3, 2, 3) == 3
benchmark_functions_edited/f1988.py
def f(vector_1, vector_2): return sum([abs((vector_1[i] - vector_2[i])) for i in range(len(vector_1))]) assert f( [1, 2, 3], [1, 2, 3] ) == 0
benchmark_functions_edited/f9749.py
def f(profit, infos_boursiere): if not 'PER' in infos_boursiere: return 0 if profit is None: return None per = float(infos_boursiere['PER'].split()[0]) if profit <= 0: return 0 return round(per/profit, 1) assert f(0, {'PER': '1000000000 100'}) == 0
benchmark_functions_edited/f2514.py
def f(data): main_switch = int(data["main_switch"]) return main_switch assert f( {"main_switch": 1} ) == 1
benchmark_functions_edited/f6265.py
def f(h0, hks, cf_t): h_of_t = h0 ii = 0 while ii < len(hks): h_of_t += cf_t[ii] * hks[ii] ii += 1 return h_of_t assert f(1, [2, 3], [0.0, 0.0]) == 1
benchmark_functions_edited/f4048.py
def f(board, index): board = board if board >= 0 else -board return (board % 10 ** (index + 1)) // 10 ** index assert f(0, 0) == 0
benchmark_functions_edited/f2709.py
def f(header, item): for i, elem in enumerate(header): if elem.lower() == item.lower(): return i return None assert f( ["column1", "column2", "column3"], "column3" ) == 2
benchmark_functions_edited/f14373.py
def f(lst): highest_nums = [float('-inf'), float('-inf')] for i in lst: if i > highest_nums[1]: if i > highest_nums[0]: highest_nums[1] = highest_nums[0] highest_nums[0] = i elif i < highest_nums[0]: highest_nums[1] = i return highest_nums[1] assert f( [10, 3, 4, 1, 2, 3] ) == 4
benchmark_functions_edited/f10249.py
def f(last_row): m = 0 column_index = -1 for i, entry in enumerate(last_row): if entry < 0: if entry < m: m = entry column_index = i return column_index assert f( [1, -1, 0, -1, 1, 0, 0, -1, 0, 0, 0, -1, 0, 0, 0, 0, 0, -1, 1, 1]) == 1
benchmark_functions_edited/f663.py
def f(t, base, t1, slope): return base + ((t-t1)*slope if t>=t1 else 0) assert f(0, 0, 0, 0) == 0
benchmark_functions_edited/f4635.py
def f(e, indexes): if len(e) == 1: return e[0] else: R = [e[i] for i in indexes] if len(R) == 1: return R[0] return R assert f( (1,), (0,) ) == 1
benchmark_functions_edited/f3069.py
def f(s): s=s.replace("\t"," "*2) indent=0 while len(s) and s[0]==" ": indent+=1 s=s[1:] return indent assert f("\t") == 2
benchmark_functions_edited/f6418.py
def f(phenome): ret = 0.0 for i in range(len(phenome) - 1): x = phenome[i] ret += 100.0 * (x ** 2 - phenome[i+1]) ** 2 + (x - 1.0) ** 2 return ret assert f( [1.0, 1.0] ) == 0
benchmark_functions_edited/f6495.py
def f(buzz): out = 1 if(buzz > 0.55): out = 5 elif(buzz > 0.35): out = 4 elif(buzz > 0.15): out = 3 elif(buzz > 0.01): out = 2 return out assert f(0.54) == 4
benchmark_functions_edited/f6256.py
def f(name): values = [None, 'A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K'] return values.index(name) assert f('4') == 4
benchmark_functions_edited/f207.py
def f(n: int) -> int: return 4 * n + 3 assert f(0) == 3
benchmark_functions_edited/f11659.py
def f(n, count): if n < 10: return count else: n /= 10 count += 1 count = f(n, count) return count assert f(1234567, 1) == 7
benchmark_functions_edited/f10291.py
def f(n, m, l): if n == 0: return 1 elif l == 0: return 0 elif m == 0: return 0 return sum(f(n - i, m - 1, i) for i in range(1, min(n, l) + 1)) assert f(1, 0, 2) == 0
benchmark_functions_edited/f5387.py
def f(n): assert n > 0 a, b = 1, 1 for i in range(n - 1): a, b = b, a + b return a assert f(4) == 3
benchmark_functions_edited/f2159.py
def f(s, a, i): return s[:i].count(a) assert f( 'paraparaparadise', 'p', 0) == 0