file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f13342.py
def f(final_transcript, j, partial_transcripts): prefix = final_transcript[:j] partial_time = 0 for partial_time, partial_transcript in reversed(partial_transcripts): if partial_transcript[:j] != prefix: return partial_time return partial_time assert f( "the quick brown fox jumps over the lazy dog", 0, [] ) == 0
benchmark_functions_edited/f5886.py
def f(base_lr, epoch, step_epoch, multiplier=0.1): lr = base_lr * (multiplier ** (epoch // step_epoch)) return lr assert f(1, 10, 25) == 1
benchmark_functions_edited/f772.py
def f(x, y): return abs(0-x) + abs(0-y) assert f(0,1) == 1
benchmark_functions_edited/f2097.py
def f(record): return record[1]['f:resource_id'] assert f( ("my_table", {"f:resource_id": 1}) ) == 1
benchmark_functions_edited/f7813.py
def f(n: int, r : int): product = 1 for i in range(n - r + 1, n + 1): product *= i for x in range(2, r+1): product /= x return product assert f(5, 1) == 5
benchmark_functions_edited/f10799.py
def f(idata, input): ret = 0 if idata == input: ret = 1 return int(ret) assert f(chr(3), chr(3)) == 1
benchmark_functions_edited/f4939.py
def f(gen,edges): size = 1 for x in range(1,gen+1): size += (edges * (edges - 1)**(x - 1)) return size assert f(0, 3) == 1
benchmark_functions_edited/f4442.py
def f(d: dict, x: float): keys = list(d.keys()) index = int(x * (len(keys) - 1)) return d[keys[index]] assert f( {0: 1}, 0.9 ) == 1
benchmark_functions_edited/f7014.py
def f(current_step, warmup_steps, base_lr, init_lr): lr_inc = (float(base_lr) - float(init_lr)) / float(warmup_steps) lr1 = float(init_lr) + lr_inc * current_step return lr1 assert f(5, 2, 2, 2) == 2
benchmark_functions_edited/f5040.py
def f(values): values = [int(value) for value in values] return values if len(values) > 1 else values[0] assert f('1') == 1
benchmark_functions_edited/f4621.py
def f(encoding): n_bits = 0 for e in encoding: n_bits += e if e >= 0 else abs(e) + 1 return n_bits assert f([1,1,2,3]) == 7
benchmark_functions_edited/f1326.py
def f(x, a, b): #To-Do set the objective equation return a*x+b assert f(4, 1, 2) == 6
benchmark_functions_edited/f785.py
def f(a): return any(i == x for i, x in enumerate(a)) assert f([1,0,2,3,4,5,6,7,8,9,10]) == 1
benchmark_functions_edited/f1504.py
def f(d:dict): return max(d.values()) + 1 assert f({1: 1, 2: 2, 3: 3, 4: 4}) == 5
benchmark_functions_edited/f8572.py
def f(m, n): counter = 0 upper_limit = m // 2 + 1 for idx in range(1, upper_limit): jdx = m - idx if idx ^ jdx == n: counter += 1 return counter assert f(3, 3) == 1
benchmark_functions_edited/f13884.py
def f(value_of_the_whole_items: dict, amount_of_the_items: dict) -> float: value = 0 for v1, v2 in zip(value_of_the_whole_items.values(), amount_of_the_items.values()): value += v1*v2 return value assert f( {'x': 1, 'y': 2, 'z': 3}, {'x': 0.5, 'y': 0.5, 'z': 0.5}) == 3
benchmark_functions_edited/f1394.py
def f(x, n): if n == 0: return 1 else: return x * f(x, n-1) assert f(5, 1) == 5
benchmark_functions_edited/f4806.py
def f(value): try: return int(value) except (ValueError, TypeError): return '' assert f(1) == 1
benchmark_functions_edited/f6501.py
def f(x): return bin(x).count("1") assert f(0b00001001) == 2
benchmark_functions_edited/f9426.py
def f(x, lower, upper, delta): if x < lower or x >= upper: return None return int((x-lower)//delta) assert f(0, 0, 20, 50) == 0
benchmark_functions_edited/f12893.py
def f(a, b): count = 0 assert len(a) == len(b) for i in range(len(a)): if a[i] != b[i]: count += 1 if a[i] == 'G1/G2' and (b[i] in ['G1', 'G2', 'G1*', 'G2*']): count -= 1 return count assert f(list('1111111111111111111111111111111'), list('1011111111111111111111111111111')) == 1
benchmark_functions_edited/f4242.py
def f(*args): count = 0 for arg in args: if (arg): count += 1 return(count) assert f(True) == 1
benchmark_functions_edited/f6436.py
def f(x1: int, x2: int) -> int: if x1 == x2: return 0 dx = x1 - x2 return int(dx / abs(dx)) assert f(20, 20) == 0
benchmark_functions_edited/f791.py
def f(y, t=0, r=1, k=1): dydt = r*y*(1 - y/k) return dydt assert f(1, 1, 1, 1) == 0
benchmark_functions_edited/f11076.py
def f(pressure: float, p0: float) -> float: return (1 - ((pressure / p0) ** 0.190284)) * 145366.45 * 0.3048 assert f(1000.0, 1000) == 0
benchmark_functions_edited/f9225.py
def f(args): return len(args[0]) assert f(list('ab')) == 1
benchmark_functions_edited/f5632.py
def f(num, floor=2): assert num >= floor trial = floor while num % trial != 0: trial += 1 return trial assert f(3, 2) == 3
benchmark_functions_edited/f11529.py
def f(Q, cp, cn): Qn = 1 - Q Wh = cp * Q + cn * Qn return Wh assert f(0, 1, 0) == 0
benchmark_functions_edited/f10804.py
def f(bot_hand): score = 0 for card in bot_hand: if ("Ace" in card) or ("King" in card): score += 3 if "Spades" in card: score += 0.25 if ("Queen" in card) or ("Jack" in card): score += 2 return int(score / 3) + 1 assert f( ['Two of Hearts', 'Four of Hearts', 'Six of Hearts', 'Seven of Hearts', 'Eight of Hearts']) == 1
benchmark_functions_edited/f11430.py
def f(arr): current_sum = 0 expected_sum = 0 for num in arr: current_sum += num for i in range(len(arr) - 1): expected_sum += i return current_sum - expected_sum assert f([0, 0]) == 0
benchmark_functions_edited/f11511.py
def f(list_results_row:list) -> float: volume = float(0) for i in range(len(list_results_row)): volume += float(list_results_row[i][3]) return volume assert f([[1, 2, 3, 4]]) == 4
benchmark_functions_edited/f11616.py
def f(tp: int, fn: int) -> float: if tp + fn != 0: recall = float(tp / (tp + fn)) else: # prevent zero division error. recall = 0 return recall assert f(0, 10) == 0
benchmark_functions_edited/f3856.py
def f(v1, v2): return bin(v1 ^ v2).count("1") assert f(1, 4) == 2
benchmark_functions_edited/f6185.py
def f(x, low, high): return 2 * (x - low) / (high - low) - 1 assert f(2, 1, 2) == 1
benchmark_functions_edited/f11272.py
def f(n1: float, n2: float) -> float: r = abs((n1 - n2) / (n1 + n2)) ** 2 return r assert f(1.0, 1.0) == 0
benchmark_functions_edited/f5328.py
def f(j, key): return j[key] if key in j else 0; assert f({'a': 1, 'b': 2}, 'c') == 0
benchmark_functions_edited/f8706.py
def f(start, end, amount): level = start + (amount * (end - start)) return level assert f(1, 10, 0) == 1
benchmark_functions_edited/f7954.py
def f(number): size = 1 found = False while not found: if (size * size) < number: size += 1 else: found = True return size assert f(4) == 2
benchmark_functions_edited/f9493.py
def std_var_norm (Spectrum , mean): norm=0 for i in range(len(Spectrum)): norm = norm + pow((Spectrum[i]-mean),2); norm = pow(norm, 0.5)/(len(Spectrum)-1) if norm == 0: norm = 1; return norm assert f( [1, 1, 1], 1) == 1
benchmark_functions_edited/f4615.py
def f(log_a, log_b): return log_a * (log_a - log_b) assert f(1, 1) == 0
benchmark_functions_edited/f12631.py
def f(x, m, M=None): if M is None: M = m[1] m = m[0] # bound x between min (m) and Max (M) return min(max(x, m), M) assert f(-1, 0, 2) == 0
benchmark_functions_edited/f11780.py
def f(event_dict): num_events = 0 for _, event_times in event_dict.items(): num_events += len(event_times) return num_events assert f({}) == 0
benchmark_functions_edited/f166.py
def f(value): return int(value[0]) assert f("4") == 4
benchmark_functions_edited/f5551.py
def f(x, y, n): return sum(xi == yi for xi, yi, ni in zip(x, y, n) if ni != "#") assert f(u"ab", u"bc", u"####") == 0
benchmark_functions_edited/f14523.py
def f(json_dict, sensor_type, group, tool): if group not in json_dict: return None if sensor_type in json_dict[group]: if sensor_type == "target" and json_dict[sensor_type] is None: return 0 return json_dict[group][sensor_type] elif tool is not None: if sensor_type in json_dict[group][tool]: return json_dict[group][tool][sensor_type] return None assert f( {"a": {"b": {"c": 0}}}, "c", "a", "b") == 0
benchmark_functions_edited/f10332.py
def f(iterable): if iterable is None or len(iterable) == 0: return None return iterable[0] assert f(range(1, 6)) == 1
benchmark_functions_edited/f9930.py
def f(r, g, b, a): if (r, g, b) == (0, 0, 0): return a return (0.299 * r + 0.587 * g + 0.114 * b) * a / 255 assert f(0, 128, 0, 0) == 0
benchmark_functions_edited/f5044.py
def f(deck: dict) -> int: total = 0 for card, card_item in deck.items(): total += card_item['count'] return total assert f(dict()) == 0
benchmark_functions_edited/f8412.py
def f(X, k): return X[k] - X[k - 1] assert f(range(0, 10, 1), 1) == 1
benchmark_functions_edited/f7177.py
def f(x) -> int: if isinstance(x, str): # in this kata a string is NOT an ARRAY of chars. return -1 try: return len(x) except TypeError: return -1 assert f([1,[1,2]]) == 2
benchmark_functions_edited/f512.py
def f(value): return round(value + 273.15, 1) assert f(-273.15) == 0
benchmark_functions_edited/f4089.py
def f(word): i = 0 for letter in word: if letter != 0: i += 1 return i assert f(b'11001010') == 8
benchmark_functions_edited/f7809.py
def f(target=200): coins = [1, 2, 5, 10, 20, 50, 100, 200] ways = [1] + [0] * target for coin in coins: for i in range(coin, target + 1): ways[i] += ways[i - coin] return ways[target] assert f(1) == 1
benchmark_functions_edited/f12161.py
def f(z_score, cutoff): if z_score <= cutoff: return 1 else: return 0 assert f(0.6, 0.5) == 0
benchmark_functions_edited/f5130.py
def f(x): return max(0, x) assert f(-2) == 0
benchmark_functions_edited/f9986.py
def f(responses): reward = 0.0 for r in responses: reward += r.clicked return reward assert f([]) == 0
benchmark_functions_edited/f9668.py
def f(kappa, a): if a > kappa: return a - kappa elif a < -kappa: return a + kappa else: return 0. assert f(2, 3) == 1
benchmark_functions_edited/f2621.py
def f(a, p): if a <= p // 2: return a else: return a - p assert f(1, 36) == 1
benchmark_functions_edited/f12532.py
def f(n): "*** YOUR CODE HERE ***" print(n) if n == 1: return 1 elif n % 2 == 0: return 1 + f(n // 2) else: return 1 + f(n * 3 + 1) assert f(10) == 7
benchmark_functions_edited/f3213.py
def f(base, height): # You have to code here # REMEMBER: Tests first!!! return (base * height) / 2 assert f(2, 2) == 2
benchmark_functions_edited/f5374.py
def f(node, new_node=None): if new_node is not None: node[1] = new_node return node[1] assert f((1, 2)) == 2
benchmark_functions_edited/f12594.py
def f(top, ranking, j): position = -1 for i in range(top): if ranking[i] == j: position = i break if position == -1: weight = 0 else: weight = top - position return weight assert f(3, ['a', 'b', 'c', 'd'], 'b') == 2
benchmark_functions_edited/f5444.py
def f(len, val): if (val & (1 << len - 1)): pass else: val -= (1 << len) - 1 return val assert f(3, 5) == 5
benchmark_functions_edited/f12003.py
def f(nu, nu_ref_s, beta_s): x = nu / nu_ref_s sed = x ** beta_s return sed assert f(1, 1, 1) == 1
benchmark_functions_edited/f5997.py
def f(position, other_position): if position == other_position: return 0 elif position > other_position: return -1 return 1 assert f(0, 1) == 1
benchmark_functions_edited/f12215.py
def f(num: int) -> int: num_digits = 0 # so far as the number is greater than zero while num > 0: num_digits += 1 num = num // 10 # integer divide to get rid of the last digit return num_digits assert f(123) == 3
benchmark_functions_edited/f9315.py
def f(n): log=-1 while n>0: log+=1 n=n>>1 return log assert f(32) == 5
benchmark_functions_edited/f3796.py
def f(num1, num2, num3): return num1 + num2 + num3 - min(num1, num2, num3) - max(num1, num2, num3) assert f(3, 3, 2) == 3
benchmark_functions_edited/f12459.py
def f(f1, f2, f): # Dane's logbook #1, page 92 return f1 + f2 - f1*f2/f assert f(10, 2, 5) == 8
benchmark_functions_edited/f5300.py
def f(base_minor, base_major, height): # You have to code here # REMEMBER: Tests first!!! return (1/2) * (base_minor + base_major) * height assert f(0, 0, 0) == 0
benchmark_functions_edited/f1221.py
def f(n, s, t): if s == t: return 0 else: return 1 assert f(3, 1, 0) == 1
benchmark_functions_edited/f5072.py
def f(number: int) -> int: return len(str(number)) assert f(1000) == 4
benchmark_functions_edited/f14412.py
def BezierTransistion (search, handles): h1x, h1y, h2x, h2y = handles cx = 3 * h1x bx = 3 * (h2x - h1x) - cx ax = 1 - cx - bx t = search for i in range (100): x = (ax*t**3 + bx*t**2 + cx*t) - search if round(x,4) == 0: break dx = 3.0 * ax*t**2 + 2.0 * bx * t + cx t -= (x/dx) return 3*t*(1-t)**2 *h1y + 3*t**2 *(1-t) *h2y + t**3 assert f(1, [0, 0, 1, 1]) == 1
benchmark_functions_edited/f12265.py
def f(a_byte): val = 0 # loop until there are no more 1s while a_byte > 0: # if a_byte is odd then there is a 1 in the 1st bit if a_byte % 2 > 0: val += 1 # shift the byte one to the right a_byte = a_byte >> 1 return val assert f(0b00000000) == 0
benchmark_functions_edited/f13583.py
def f(text, pattern): n = 0 for i in range(len(text)-len(pattern)+1): if text[i:i+len(pattern)] == pattern: n += 1 return n assert f( "CGGCGGCGGCG", "CGG") == 3
benchmark_functions_edited/f7748.py
def f(ll1, ll2): assert type(ll1) == list assert type(ll2) == list counts = 0 for list_i in ll1: if list_i in ll2: counts += 1 return counts assert f( [1, 2, 3, 4, 5, 6], [2, 4, 6, 8, 10, 12] ) == 3
benchmark_functions_edited/f10749.py
def f(array, item, index=0): if len(array) <= index: return index if array[index] == item: return index else: return f(array, item, index + 1) assert f(list(range(100)), 0) == 0
benchmark_functions_edited/f2973.py
def f(x): x = int(x) n = 1 while n < x: n = n << 1 return n assert f(3.0) == 4
benchmark_functions_edited/f5345.py
def f(s1, s2): return sum(i != j for (i,j) in zip(s1, s2) if i != 'N' and j != 'N') assert f( 'ACCTAGTA', 'ACCTATAA') == 2
benchmark_functions_edited/f14552.py
def f(condition, locals): import ast condition_variables = set() st = ast.parse(condition) for node in ast.walk(st): if type(node) is ast.Name: condition_variables.add(node.id) for v in condition_variables: if v not in locals: locals[v] = None result = eval(condition, {}, locals) return result assert f( "not (a == 1 or b == 2)", locals(), ) == 1
benchmark_functions_edited/f13350.py
def f(events): events_count = {} if len(events) == 0: return 0 for event in events: if not events_count.get(event.date_time_start.date()): events_count[event.date_time_start.date()] = 1 else: events_count[event.date_time_start.date()] += 1 return max(events_count.values()) assert f([]) == 0
benchmark_functions_edited/f12152.py
def f(hcount_str): if not hcount_str: return 0 if hcount_str == 'H': return 1 return int(hcount_str[1:]) assert f('H2') == 2
benchmark_functions_edited/f10883.py
def f(real_mbit, warn_mbit, crit_mbit): if real_mbit < warn_mbit: if real_mbit > crit_mbit: exit_code = 1 return exit_code else: exit_code = 2 return exit_code else: exit_code = 0 return exit_code assert f(2, 2, 2) == 0
benchmark_functions_edited/f4240.py
def f(row, column_name): return 1 if row[column_name] == "yes" else 0 assert f( {"is_hillary_clinton": "nO"}, "is_hillary_clinton" ) == 0
benchmark_functions_edited/f1889.py
def f(vp, alpha=310, beta=0.25): return alpha * vp**beta assert f(0) == 0
benchmark_functions_edited/f2732.py
def f(value): return round((float(value) / 18.018), 1) assert f(0) == 0
benchmark_functions_edited/f713.py
def f(nonfitbit_id): # for n in nonfitbit_id: return nonfitbit_id assert f(2) == 2
benchmark_functions_edited/f10831.py
def f(p): for z in range(2, p): if pow(z, (p - 1) // 2, p) == p - 1: return z return -1 assert f(547) == 2
benchmark_functions_edited/f14445.py
def f(e): if hasattr(e, 'errno'): return e.errno elif e.args: return e.args[0] else: return None assert f(OSError(1, "Operation not permitted")) == 1
benchmark_functions_edited/f5037.py
def f(index, size): if index is None or index >= 0: return index elif index < 0: return size + index assert f(1, 2) == 1
benchmark_functions_edited/f9611.py
def f(num): if not isinstance(num, int): raise TypeError("provide only integer input") num_str = str(num) lenght = len(num_str) if num_str[0] == "-": lenght -= 1 return lenght assert f(1234) == 4
benchmark_functions_edited/f11337.py
def f(particle_name): return { 'gamma': 0, 'proton': 1, 'electron': 2, 'muon': 3, }[particle_name] assert f('gamma') == 0
benchmark_functions_edited/f12439.py
def f(x_nt, y_nt, alphabet=None): if not alphabet: alphabet = {"AT": 1.0, "TA": 1.0, "GC": 1.0, "CG": 1.0} pair = x_nt + y_nt return alphabet.get(pair, 0) assert f(1, 0) == 0
benchmark_functions_edited/f6605.py
def f(element, true=object(), false=object()): if element is True: return true elif element is False: return false return element assert f(1, False) == 1
benchmark_functions_edited/f14007.py
def f(a, b): m = 0 assert 0 <= a < 0x100 assert 0 <= b < 0x100 while b: if b & 1 == 1: m ^= a a <<= 1 if a & 0x100: a ^= 0x101 b >>= 1 assert 0 <= m < 0x100 return m assert f(1, 0) == 0
benchmark_functions_edited/f7879.py
def f(time): t = str(time).split(':') seconds = int(t[0]) * 3600 + int(t[1]) * 60 + int(t[2]) return seconds assert f('00:00:00') == 0
benchmark_functions_edited/f6237.py
def f(action, completed_members): for member in completed_members: if member['action'] == action.id: return member['count'] return 0 assert f({'id': 1, 'name': 'Test', 'count': 3}, []) == 0
benchmark_functions_edited/f699.py
def f(cube): prior.called = True return -1 + 2 * cube assert f(1/2) == 0
benchmark_functions_edited/f13457.py
def f(delta_microseconds: float) -> float: return (delta_microseconds / 2) / 29.1 assert f(0) == 0
benchmark_functions_edited/f13123.py
def f(dhash1, dhash2): difference = (int(dhash1, 16)) ^ (int(dhash2, 16)) return bin(difference).count("1") assert f( "1234567890abcdef1234567890abcdef", "1234567890abcdef1234567890abcdef" ) == 0