file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f3429.py
def f(val, default=0): try: return int(val) except (ValueError, TypeError): return default assert f(True, 2) == 1
benchmark_functions_edited/f11078.py
def f(array): out_temp = 1 len_t=len(array) for i in range(len_t - 1): for j in range(i+1,len_t): if array[i] < array[j]: break else: pass else : out_temp += 1 return out_temp assert f(range(1,10)) == 1
benchmark_functions_edited/f12624.py
def f(num_h_layers, epoch_factor, penalty_every, **_): max_episode = (num_h_layers * epoch_factor) // penalty_every if max_episode == 0: raise ValueError('Penalty_every has to be smaller than the total number of epochs.') return max_episode assert f(1, 2, 1) == 2
benchmark_functions_edited/f11620.py
def f(yi, yi1, dqml): return dqml[yi1][yi] / sum(dqml[yi1].values()) assert f(1, 1, {1: {1: 1}}) == 1
benchmark_functions_edited/f13480.py
def f(path, search_space, include_key=False): if not isinstance(path, (tuple, list)): path = [path] current_value = search_space[path[0]] if len(path) == 1: return (path[0], current_value) if include_key else current_value return f(path[1:], current_value, include_key) assert f("a", {"a...
benchmark_functions_edited/f6033.py
def f(a_string): try: an_int = int(a_string) except (ValueError, TypeError): an_int = 0 return an_int assert f("abc") == 0
benchmark_functions_edited/f6973.py
def f(str1: str, str2: str) -> int: diffs = 0 for ch1, ch2 in zip(str1, str2): if ch1 != ch2: diffs += 1 return diffs assert f('a', 'A') == 1
benchmark_functions_edited/f5105.py
def f(w1: str, w2: str)->int: sim = 0 for ch in w1: if ch in w2: sim += 1 return sim assert f('abc', 'def') == 0
benchmark_functions_edited/f3209.py
def f(x: float, y: float=2, z: float=3) -> float: return x + y + z assert f(1, 2, 3) == 6
benchmark_functions_edited/f4963.py
def f(nod1, nod2, tsys_nod2): return (nod1-nod2)/nod2*tsys_nod2 assert f(1, 1, 1) == 0
benchmark_functions_edited/f6611.py
def f(n): if n<0: return -1 else: return 1 assert f(0)==1
benchmark_functions_edited/f11145.py
def f(y): return 1 - y**2 assert f(0) == 1
benchmark_functions_edited/f2130.py
def f(e): assert e >= -1650 assert e <= 1650 return (int(e) * 78913) // 2**18 assert f( 1) == 0
benchmark_functions_edited/f11250.py
def f(bitVec: list): bitStr = ''.join(str(b) for b in bitVec) return int(bitStr, 2) assert f( [0, 0, 0, 0] ) == 0
benchmark_functions_edited/f6953.py
def f(ugraph): total_edges = 0 for edges in ugraph.values(): total_edges += len(edges) return total_edges / 2 assert f(dict()) == 0
benchmark_functions_edited/f7617.py
def f(uuid_val): msb_s = ''.join(str(uuid_val).split('-')[:3]) msb = int(msb_s, 16) if int(msb_s[0], 16) > 7: msb = msb - 0x10000000000000000 return msb assert f(0x0000000000000000) == 0
benchmark_functions_edited/f9673.py
def f(num: int, bit: int) -> int: return (num >> bit) & 1 assert f(1234, 6) == 1
benchmark_functions_edited/f5169.py
def f(puzzle: str) -> int: return puzzle.index('\n') assert f( 'abcd\nefgh\nijkl\n' ) == 4
benchmark_functions_edited/f2582.py
def f(input_num, start, x_dist): return (input_num - start) % ((x_dist - 1) * 2) assert f(6, 0, 3) == 2
benchmark_functions_edited/f478.py
def f(x): return 0 if x > 0 else 1 assert f(1) == 0
benchmark_functions_edited/f10658.py
def f(n): a = 1 for m in range(1, 6, 1): a *= n % 10 n //= 10 return a assert f(123456000) == 0
benchmark_functions_edited/f4182.py
def f(original_gravity: float, final_gravity: float): return (original_gravity - final_gravity) * 131.25 assert f(7.0, 7.0) == 0
benchmark_functions_edited/f5715.py
def f(list, default): try: return list.pop(0) except IndexError: return default assert f([1, 2], None) == 1
benchmark_functions_edited/f4683.py
def f(success: bool) -> int: if success: print('Success.') return 0 print('Failed.') return 1 assert f(False) == 1
benchmark_functions_edited/f2376.py
def f(sum, base): return (sum % base) assert f(8, 2) == 0
benchmark_functions_edited/f1231.py
def f(tuple1, tuple2): return abs(tuple1[0] - tuple2[0]) + abs(tuple1[1] - tuple2[1]) assert f( (1,3), (0,0) ) == 4
benchmark_functions_edited/f11070.py
def f(p1, p2): return p2[0]-p1[0] assert f( (10, 20), (10, 20) ) == 0
benchmark_functions_edited/f1014.py
def f(x): return int("".join(str(i) for i in x), 2) assert f(list(bin(7)[2:].rjust(7, "0"))) == 7
benchmark_functions_edited/f12316.py
def f(graph, ft_type, method, sorted_features, ft_dict): num_of_feature_type = 0 if ft_type in ft_dict else None if ft_type in sorted_features and ft_type in ft_dict: num_of_feature_type = len(sorted_features[ft_type]) for f in sorted_features[ft_type]: method(graph, f) return nu...
benchmark_functions_edited/f5673.py
def f(x=[]): len_x = len(x) x.append(None) return len_x assert f([1, 2, 3, 4]) == 4
benchmark_functions_edited/f14031.py
def f(total_recs, max_rec): cnt = total_recs / max_rec if total_recs % max_rec > 0: cnt += 1 return cnt assert f(30, 5) == 6
benchmark_functions_edited/f4023.py
def f(diagonal_1, diagonal_2): # You have to code here # REMEMBER: Tests first!!! return (diagonal_1 * diagonal_2)/2 assert f(-1, 0) == 0
benchmark_functions_edited/f1764.py
def f(m_state, rule): return int(rule[-1 - m_state]) assert f(1, "100") == 0
benchmark_functions_edited/f14100.py
def f(pixel_index, block_size, rows_cols): return block_size if (pixel_index + block_size) < rows_cols else rows_cols - pixel_index assert f(2, 3, 3) == 1
benchmark_functions_edited/f6103.py
def f(r): return 3 * r**3/3 - 9 / 4 * r**4/4 + 3 / 16 * r**6/6 assert f(2) == 1
benchmark_functions_edited/f10976.py
def f(part, whole): if 0 in [part, whole]: return float(0) return 100 * ((float(part) / float(whole))) assert f(0.1, 0) == 0
benchmark_functions_edited/f4559.py
def f(a, b): return max(abs(x - y) for x, y in zip(a, b)) assert f( [1, 2, 3], [1, 2, 4] ) == 1
benchmark_functions_edited/f5537.py
def f(idx, cc_size, fs=None): if idx > cc_size / 2: idx = idx - cc_size if fs is None: return idx else: return 1.0 * idx / fs assert f(11, 8) == 3
benchmark_functions_edited/f2888.py
def f(y_true, y_pred): edit_distance = 0 return edit_distance assert f( "I love apples", "I love apples" ) == 0
benchmark_functions_edited/f10342.py
def f(array): sum = 0 for element in array: sum += abs(element) return sum / len(array) assert f([0]) == 0
benchmark_functions_edited/f1136.py
def f(x): out = 1 for a in x: out *= a return out assert f([1.0, 2.0]) == 2
benchmark_functions_edited/f1527.py
def f(resp, noise): return 100*abs((noise-resp)/resp) assert f(-1, -1) == 0
benchmark_functions_edited/f1139.py
def f(y, linear): a,b,offset = linear x = ((y*offset) -b)//a return x assert f(1, (1, 0, 0)) == 0
benchmark_functions_edited/f3740.py
def f(code: str) -> int: if isinstance(code, str): return len(code.split('\n')) return 0 assert f('a') == 1
benchmark_functions_edited/f14466.py
def f(preds, targets, k=10): hits = 0. acc = 0. for i in range(k): if preds[i] in targets: hits += 1.0 acc += hits / (i + 1) return acc / min(k, len(targets)) assert f([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) == 1
benchmark_functions_edited/f7370.py
def f(args, key, fallback): return int(args[key]) if args.__contains__(key) else fallback assert f(dict(), "a", 1) == 1
benchmark_functions_edited/f8995.py
def f(y, x): return (y % 3) * 3 + (x % 3) assert f(2, 4) == 7
benchmark_functions_edited/f338.py
def f(array): *_, x = array return x assert f(set([1, 2, 3])) == 3
benchmark_functions_edited/f2663.py
def f(year_length, degrees): return degrees * (year_length/360.0) assert f(365, 0) == 0
benchmark_functions_edited/f8816.py
def f(time, eph_start, eph_stop): for i in range(len(eph_start)): if (time >= eph_start[i]) & (time <= eph_stop[i]): return i else: continue return -1 assert f(10, [0, 5], [10, 15]) == 0
benchmark_functions_edited/f11207.py
def f(string1,string2): i = 0 suffString1 = string1 prefString2 = string2 while prefString2 != suffString1: i += 1 suffString1 = string1[i:] prefString2 = string2[0:len(suffString1)] return len(prefString2)-1 assert f( "abc", "bc") == 1
benchmark_functions_edited/f1334.py
def f(codon, productions): return codon%len(productions) assert f(20, [1,2,3]) == 2
benchmark_functions_edited/f3851.py
def f(seq_length): half_offset = int((seq_length - 1) / 2) return seq_length - 1 - half_offset assert f(1) == 0
benchmark_functions_edited/f2912.py
def f(setA, setB): setA, setB = set(setA), set(setB) return len(setA.intersection(setB)) / len(setA.union(setB)) assert f(set([1, 2, 3, 4]), set([4, 3, 2, 1])) == 1
benchmark_functions_edited/f530.py
def f(a, b): return a[0]*b[0] + a[1]*b[1] + a[2]*b[2] assert f( (1,2,3), (0,1,0) ) == 2
benchmark_functions_edited/f8792.py
def f(x, m, c): return m * x + c assert f(2, 1, 0) == 2
benchmark_functions_edited/f2787.py
def f(string): return len(string.split()) assert f("one two three") == 3
benchmark_functions_edited/f12576.py
def f(f, *args, **kwargs): if callable(f): return f(*args, **kwargs) elif len(args) and hasattr(f, '__get__'): # support staticmethod/classmethod return f.__get__(None, args[0])(*args, **kwargs) else: assert False, "expected a function or staticmethod/classmethod" assert f(l...
benchmark_functions_edited/f6242.py
def f(la, lb): if len(la) != len(lb): return 1 for i in range(0, len(la)): sa = la[i] sb = lb[i] if sa != sb: return 1 return 0 assert f( [1, 2, 3], [] ) == 1
benchmark_functions_edited/f9207.py
def f(numbers): if not numbers: return 0 if len(numbers) % 2 == 1: return sorted(numbers)[len(numbers)//2] else: a, b = sorted(numbers)[len(numbers)//2], numbers[len(numbers)//2-1] return round((a+b)/2, 2) assert f(0) == 0
benchmark_functions_edited/f676.py
def f(y_eval, mean_y, std_y): return (y_eval - mean_y) / std_y assert f(1, 1, 1) == 0
benchmark_functions_edited/f1833.py
def f(string): try: int(string) except ValueError: return 0 else: return 1 assert f("22") == 1
benchmark_functions_edited/f12714.py
def f(alignmentValue, bitPosition): if bitPosition <= 0 or alignmentValue == 0: return bitPosition return (((bitPosition - 1) // alignmentValue) + 1) * alignmentValue assert f(8, 2) == 8
benchmark_functions_edited/f14174.py
def f(function, *args, **kwargs): if getattr(args[0], '_use_oauth', False): kwargs['_use_oauth'] = True return function(*args, **kwargs) assert f(lambda x: x, 1) == 1
benchmark_functions_edited/f10304.py
def f( n ): if n < 2: return 1 else: f = f(n-1) + f(n-2) return f assert f(5) == 8
benchmark_functions_edited/f9865.py
def f(a, b): n = len(a) assert(n == len(b)) sum = 0.0 for i in range(n): sum += a[i] * b[i] return sum assert f( (0,0,0), (0,0,0) ) == 0
benchmark_functions_edited/f2170.py
def f(gap): newGap = (gap * 10) // 13 return 1 if newGap < 1 else newGap assert f(0) == 1
benchmark_functions_edited/f698.py
def f(a, b): return (a + b - 1) // b assert f(4, 2) == 2
benchmark_functions_edited/f12110.py
def f(total: int, block_size: int, current_offset: int) -> int: if current_offset + block_size > total: step_size = total - current_offset else: step_size = current_offset return step_size assert f(2, 2, 0) == 0
benchmark_functions_edited/f8472.py
def f(numbers): if not numbers: return None total = 0 count = 0 for number in numbers: total += number count += 1 return total / count assert f([2, 4, 6]) == 4
benchmark_functions_edited/f991.py
def f(row): return len(row['text'].split(' ')) assert f( {'text': 'a b c'} ) == 3
benchmark_functions_edited/f7773.py
def f(val, bitNo, bit): mask = 1 << bitNo val &= ~mask if bit: val |= mask return val assert f(0, 6, 0) == 0
benchmark_functions_edited/f1934.py
def f(line: str) -> int: return len(line.split("#")[0]) assert f( " # This is a comment # with a second comment" ) == 2
benchmark_functions_edited/f13842.py
def f(x, threshold=0.5): prediction = None if x >= threshold: prediction = 1 else: prediction = 0 return prediction assert f(0.4, 0.4) == 1
benchmark_functions_edited/f4419.py
def f(dy1, dy2, dx): return (0.5*dx)**2 * (dy1**2 + dy2**2) assert f(0, 0, 0) == 0
benchmark_functions_edited/f1630.py
def f(a,b,c): return (a[0]-c[0])*(b[1]-c[1]) - (a[1]-c[1])*(b[0]-c[0]) assert f( (0, 0), (1, 1), (1, 1) ) == 0
benchmark_functions_edited/f8062.py
def f(a , b): com_div =[1] i =2 while i<= min(a,b): if a % i == 0 and b % i ==0: com_div.append(i) i = i+1 return com_div[-1] assert f(3, 4) == 1
benchmark_functions_edited/f4134.py
def f(grid, char): res = 0 for line in grid: res += sum(1 for c in line if c == char) return res assert f( 'y') == 0
benchmark_functions_edited/f6334.py
def f(cells): idx = len(cells) for cell in cells[::-1]: if cell.source: return idx idx -= 1 return idx assert f([]) == 0
benchmark_functions_edited/f5464.py
def f(x, *p): A, x0, C = p xc = x - x0 return A * xc**2 + C assert f(1, 1, 0, 0) == 1
benchmark_functions_edited/f7618.py
def f(line): column_num = int(line.split()[1].replace("#","")) return column_num assert f( '_rlnCtfFigureOfMerit #2') == 2
benchmark_functions_edited/f13437.py
def f(nums, target): low = 0 high = len(nums)-1 while high>=low: middle = (low+high) // 2 if nums[middle] == target: return middle elif nums[middle] < target: low=middle+1 else: high=middle-1 ...
benchmark_functions_edited/f6533.py
def f(x, q): k = len(x) x.sort() return x[int(q * k)] assert f([1, 1, 1, 2, 2, 2, 3, 3, 3, 4], 0.5) == 2
benchmark_functions_edited/f7671.py
def f(y, board): try: y = int(y) except ValueError: return -1 height = len(board) y -= 1 if y >= 0 and y < height: return y else: return -1 assert f(1, [ ["a", "b", "c"], ["a", "b", "c"], ["a", "b", "c"] ]) == 0
benchmark_functions_edited/f6662.py
def f(*args): incr = 1.0/len(args) r = 0.0 x = args[0] for y in args: if y == x: r += incr return r assert f(5, 5, 5, 5) == 1
benchmark_functions_edited/f1428.py
def f(tup): _x, y = tup return y assert f((0,1)) == 1
benchmark_functions_edited/f5046.py
def f(func, value, default=None): try: return func(value) except (ValueError, TypeError): return default assert f(int, "1") == 1
benchmark_functions_edited/f5784.py
def f(number): return int(number, 16) assert f("0x02") == 2
benchmark_functions_edited/f3913.py
def f(character): # a -> 0, ..., z -> 25 return int(ord(character.lower()) - 97) assert f( "d") == 3
benchmark_functions_edited/f1778.py
def f(distance): if distance > 0: return 1 else: return 0 assert f(-1) == 0
benchmark_functions_edited/f7979.py
def f(s): if len(s) != 4: return 0 a = ord(s[0]) << 24 b = ord(s[1]) << 16 c = ord(s[2]) << 8 l = s[3] d = ord(l) if l.isdigit(): d = d - ord('0') return a+b+c+d assert f(u'b') == 0
benchmark_functions_edited/f13640.py
def f(structure): if isinstance(structure, (list, tuple)): return 1 + sum(map(measure_approximate_cost, structure)) elif isinstance(structure, dict): return len(structure) + sum(map(measure_approximate_cost, structure.values())) elif isinstance(structure, int) or structure is None: return 1 else: assert False, type...
benchmark_functions_edited/f4459.py
def f(list, index): if 0 <= index < len(list): return list[index] else: return None assert f(list((1, 2, 3)), 1) == 2
benchmark_functions_edited/f5516.py
def f(p, p_other_lag, p_own_lag, rounder_number): return 1 if p == 1 else 0 assert f(1, None, None, 0) == 1
benchmark_functions_edited/f5338.py
def f(d, path): for k in path.split('.'): if k.isdigit(): k = int(k) d = d[k] return d assert f( {'a': 1, 'b': 2}, 'b', ) == 2
benchmark_functions_edited/f11310.py
def f(sig_info, error): if 'meeting_url' not in sig_info.keys(): print('ERROR! meeting_url is a required field') error += 1 else: print('Check meeting_url: PASS') return error assert f({'meeting_url': 'https://zoom.com'}, 0) == 0
benchmark_functions_edited/f10422.py
def f(n, k): result = 1 while k > 0: k = k - 1 result *= n n = n - 1 return result assert f(4, 0) == 1
benchmark_functions_edited/f11661.py
def f(partition:list, num_of_sums:int=1)->float: sorted_sums = sorted([sum(part) for part in partition]) return sum(sorted_sums[:num_of_sums]) assert f([[1, 2], [3, 4], [5, 6]]) == 3
benchmark_functions_edited/f11734.py
def f(layer_keys_pressed, layer_count): tmp = 0 if len(layer_keys_pressed) > 0: for layer_id in layer_keys_pressed: if layer_id > tmp: # use highest layer number tmp = layer_id if tmp >= layer_count: tmp = layer_count - 1 return tmp assert f({0, 1, 2}, 3) ==...
benchmark_functions_edited/f8450.py
def f(c, maxc, minc=0): if c > maxc: c = maxc if c < minc: c = minc return c assert f(-3, 2, 1) == 1