file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f2398.py
def f(f, seq): for item in seq: if f(item): return item assert f(lambda x: x == 4, [1, 2, 3, 4, 5]) == 4
benchmark_functions_edited/f13454.py
def f(x, threshold=0.5): prediction = None if x >= threshold: prediction = 1 else: prediction = 0 return prediction assert f(0.6) == 1
benchmark_functions_edited/f7424.py
def f(count): highest_bit = -1 for i in range(0,32): if (count & (1<<i)) != 0: highest_bit = i return highest_bit assert f(0b00000000000000000000000010000000) == 7
benchmark_functions_edited/f9737.py
def f(s, m): return max(abs(s), abs(m)) assert f(0, -1) == 1
benchmark_functions_edited/f6403.py
def f(i, j): return 1 if i == j else 0 assert f(3, 4) == 0
benchmark_functions_edited/f10549.py
def f(queue, person_name): return queue.count(person_name) assert f( ['Adela', 'Emma', 'Olivia', 'Olivia', 'Sophia', 'Olivia'], 'Olivia' ) == 3
benchmark_functions_edited/f8490.py
def f(value): value = int(value) if value < 0 or value > 254: raise ValueError('Minimum saturation is 0, to the maximum 254') return value assert f(1) == 1
benchmark_functions_edited/f9462.py
def f(rated_stars): numerator = 0 denominator = 0 for key, value in rated_stars.items(): numerator += int(key) * value denominator += value return numerator/denominator assert f({'1': 2}) == 1
benchmark_functions_edited/f4403.py
def f(x,N,sign_ptr,args): out = 0 sps = args[0] for i in range(N): j = (N-1) - i out += ( x%sps ) * (sps**j) x //= sps # return out assert f(0,3,None,[3]) == 0
benchmark_functions_edited/f8407.py
def _gr_xmax_ ( graph ) : xmx = None np = len(graph) for ip in range( np ) : x , y = graph[ip] if None == xmx or x >= xmx : xmx = x return xmx assert f( [(1, 2)] ) == 1
benchmark_functions_edited/f13701.py
def f(arr: list) -> int: length: int = len(arr) if length == 0 or arr[0] == 0: return -1 if length == 1: return 0 jumps: list = [length + 1] * length jumps[0] = 0 for index, element in enumerate(arr[:-1]): for j in range(index + 1, min(element + index + 1, length)): jumps[j] = min(jumps[index] + 1, jumps[j]) return jumps[length - 1] assert f([1]) == 0
benchmark_functions_edited/f8954.py
def f(a, b, c): return (b ** 2) - (4 * a * c) assert f(2, 1, 0) == 1
benchmark_functions_edited/f10866.py
def f(number, min_value=0.0, max_value=1.0): return max(min(number, max_value), min_value) assert f(-5, 0, 10) == 0
benchmark_functions_edited/f8719.py
def f(iterable): i = 0 for x in iterable: i += 1 return i assert f(list()) == 0
benchmark_functions_edited/f7727.py
def f(n_neut, exp_rel_neut, alpha, theta): tml = (n_neut + alpha - 1) / (exp_rel_neut + (1/theta)) if alpha <= 1: tml = max(alpha * theta, tml) return tml assert f(1, 2, 1, 1) == 1
benchmark_functions_edited/f4446.py
def f(i, k, T, B): return (pow(2, k) * pow(2, T - k * (i + 1), B)) // B assert f(0, 1, 4, 2) == 0
benchmark_functions_edited/f12736.py
def f(seq, val): try: return seq.index(val) except ValueError: return -1 assert f(list("abcdef"), "e") == 4
benchmark_functions_edited/f9086.py
def f(n): "*** YOUR CODE HERE ***" if n <= 0: return 0 else: return n + f(n - 2) assert f(0) == 0
benchmark_functions_edited/f1730.py
def f(pixel): return(max((pixel[0], pixel[1], pixel[2])) / 255 * 100) assert f( ( 0, 0, 0) ) == 0
benchmark_functions_edited/f12301.py
def f(n): "*** YOUR CODE HERE ***" i,length = n,1 while i>1: print(i) if i%2==0: i = i//2 else: i = i*3+1 length +=1 print(i) return length assert f(10) == 7
benchmark_functions_edited/f6531.py
def f(x, y): res = 0 for _ in range(8): if y & 0x1: res ^= x y = y >> 1 x = x << 1 if x & 0x100: x ^= 0x11B return res assert f(3, 0) == 0
benchmark_functions_edited/f9146.py
def f(total_correct: int, total_found: int) -> float: return total_correct / total_found if total_found != 0 else 0 assert f(5, 5) == 1
benchmark_functions_edited/f7927.py
def f(n): ## Your code starts here sum = 1 for div in range(2, n): if n%div == 0: sum += div return sum ## Your code ends here assert f(2) == 1
benchmark_functions_edited/f909.py
def f(x, x0, x1): return max(min(x, x1), x0) assert f(3, 3, 3) == 3
benchmark_functions_edited/f5526.py
def f(i): # nicked from http://wiki.python.org/moin/BitManipulation count = 0 while i: i &= i - 1 count += 1 return count assert f(15) == 4
benchmark_functions_edited/f9900.py
def f(seed_set_cascades): combined = set() for i in seed_set_cascades.keys(): for j in seed_set_cascades[i]: combined = combined.union(j) return len(combined) assert f({}) == 0
benchmark_functions_edited/f8383.py
def _gr_xmin_ ( graph ) : xmn = None np = len(graph) for ip in range( np ) : x , y = graph[ip] if None == xmn or x <= xmn : xmn = x return xmn assert f( [(1,2)] ) == 1
benchmark_functions_edited/f9739.py
def f(x): if x < 3: x = 1 if 3 <= x< 5: x = 2 if 5 <= x< 7: x = 3 if 7 <= x< 9: x = 4 if 9 <= x< 11: x = 5 elif 11 <= x< 13: x = 5 return x assert f(11) == 5
benchmark_functions_edited/f4884.py
def f(n: int) -> int: return n * (n + 1) // 2 assert f(3) == 6
benchmark_functions_edited/f9750.py
def f(*args): L = len(args) if L == 0: return 0 if L == 1: return args[0] if L == 2: a, b = args while b: a, b = b, a % b return a return f(f(args[0], args[1]), *args[2:]) assert f(2, 1, 0) == 1
benchmark_functions_edited/f8339.py
def f(position: int, target_position: int) -> int: return abs(position - target_position) assert f(1, 5) == 4
benchmark_functions_edited/f11745.py
def f(stop, dim_size): if stop is None: return dim_size if stop < 0: return 0 if stop < -dim_size else stop % dim_size return stop if stop < dim_size else dim_size assert f(-10, 10) == 0
benchmark_functions_edited/f5311.py
def f(items, condition_fn): for index, item in enumerate(items): if condition_fn(item): return index return None assert f( ['a', 'b', 'c'], lambda s: s == 'c') == 2
benchmark_functions_edited/f13312.py
def f(string, row, col): n = 0 for _ in range(row-1): n = string.find('\n', n) + 1 return n+col-1 assert f(r1, 2) == 1
benchmark_functions_edited/f4536.py
def f(data, base): res = 0 for power, factor in data: res = res + factor * (base**power) return res assert f( [], 10) == 0
benchmark_functions_edited/f12453.py
def f(verdict): if verdict == 'Malicious': return 3 elif verdict == 'Suspicious': return 2 elif verdict == 'Benign' or verdict == 'Redirector': return 1 else: return 0 assert f(24) == 0
benchmark_functions_edited/f8032.py
def f(x, y0, y1): return 0.5 * x * (y1 - y0) assert f(10, 15, 15) == 0
benchmark_functions_edited/f12611.py
def f(str1, str2): n = len(str1) m = len(str2) if n < m: return 0 i = 0 for j in range(m): if i >= n: return 0 while str1[i] != str2[j]: #print(str1[i], i, str2[j], j) i += 1 if i >= n: return 0 i += 1 return 1 assert f( "a", "a") == 1
benchmark_functions_edited/f8648.py
def f(subcategory_id: int) -> int: return 5 if subcategory_id == 4 else 1 assert f(5) == 1
benchmark_functions_edited/f13621.py
def f(root, path): sub_data = root for key in path: sub_data = sub_data[key] return sub_data assert f( {'foo': {'bar': [1, 2, 3]}}, ['foo', 'bar', 1] ) == 2
benchmark_functions_edited/f1068.py
def f(n, m): return 2**n % 10**m assert f(3, 1) == 8
benchmark_functions_edited/f1914.py
def f(f, seq): for item in seq: if f(item): return item assert f(lambda x: x == 4, [2, 3, 5, 4, 1]) == 4
benchmark_functions_edited/f13449.py
def f(arr): largest = arr[0] # stores the largest value largest_index = 0 # stores the position of the largest value for i in range(1, len(arr)): if arr[i] > largest: largest = arr[i] largest_index = i return largest_index assert f( [1, 2, 3] ) == 2
benchmark_functions_edited/f5832.py
def f(seq, func): return min(seq, key=func) assert f(range(10), lambda x:x*x) == 0
benchmark_functions_edited/f2374.py
def f(time_month): ans = time_month * 30 * 24 * 60 * 60 return ans assert f(0) == 0
benchmark_functions_edited/f10270.py
def f(cigar_tuple): if cigar_tuple[0] == 0 or cigar_tuple[1] <= 10: return 1 else: return 0 assert f( (1,1) ) == 1
benchmark_functions_edited/f3352.py
def f(value, arg): try: return float(value) + float(arg) except (ValueError, TypeError): return '' assert f(3, 1) == 4
benchmark_functions_edited/f1823.py
def f(m, neff=2.4, wavelength=1.55): return m * wavelength / neff assert f(0) == 0
benchmark_functions_edited/f9033.py
def f(fname, data): if isinstance(data, str): data = data.encode("ascii") with open(fname, "wb") as stream: return stream.write(data) assert f(b"test.txt", b"ab") == 2
benchmark_functions_edited/f8944.py
def f(str1, str2): # From http://code.activestate.com/recipes/499304-hamming-distance/ diffs = 0 for ch1, ch2 in zip(str1, str2): if ch1 != ch2: diffs += 1 return diffs assert f( 'GAGCCTACTAACGGGAT', 'CATCGTAATGACGGCCT' ) == 7
benchmark_functions_edited/f7832.py
def f(s1, s2): assert len(s1) == len(s2) return sum(ch1 != ch2 for ch1, ch2 in zip(s1, s2)) assert f("abc", "abd") == 1
benchmark_functions_edited/f575.py
def f(ne, nj, j, x, y): return j * ne**2 + x * ne + y + 1 assert f(2, 2, 0, 0, 0) == 1
benchmark_functions_edited/f3344.py
def f(x, model_hparams, vocab_size): del model_hparams, vocab_size # unused arg return x assert f(1, 1, 1) == 1
benchmark_functions_edited/f5491.py
def f(xi, zi, xj, zj): return 0 if zj <= zi else (zj - zi) / (xj - float(xi)) assert f(1, 5, 2, 6) == 1
benchmark_functions_edited/f5039.py
def f(phenome): ret = 0 i = len(phenome) - 1 while i >= 0 and phenome[i] == 0: ret += 1 i -= 1 return ret assert f([1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0]) == 2
benchmark_functions_edited/f13044.py
def f(num: int) -> int: if num < 0: raise ValueError("Number should not be negative.") return 1 if num in (0, 1) else num * f(num - 1) assert f(0) == 1
benchmark_functions_edited/f9246.py
def f(occ): count = 0 while isinstance(occ, tuple) and len(occ) == 2: count = count + 1 occ = occ[1] return count assert f((1, (2, None))) == 2
benchmark_functions_edited/f9008.py
def f(x): num_bits = 0 while x: num_bits += x & 1 x >>= 1 print(x) return num_bits assert f(380) == 6
benchmark_functions_edited/f9258.py
def f(array): jumps = 0 i = 0 n = len(array) while i < n - 1: jumps += 1 if i < n - 2 and array[i + 2] == 0: i = i + 2 else: i += 1 return jumps assert f( [0, 0, 0, 1, 0, 0] ) == 3
benchmark_functions_edited/f10265.py
def f(cpus, memory, disk): return max(float(cpus),float(memory)/2000) assert f(2,3000,1000) == 2
benchmark_functions_edited/f14396.py
def f(a, b): distance = ((a[1] - b[1])**2 + (a[0] - b[0])**2)**0.5 ##print("distance =", str(distance)) return distance assert f( (0, 0), (1, 0) ) == 1
benchmark_functions_edited/f820.py
def f(x, n): return (x&(0x01 << n)) >> n assert f(0b0000, 5) == 0
benchmark_functions_edited/f182.py
def f(x): from math import sqrt return sqrt(x) assert f(25) == 5
benchmark_functions_edited/f1785.py
def f(m, x): return (x * 0.0) + m assert f(1, 1) == 1
benchmark_functions_edited/f899.py
def f(x, y, slope): return y[0] - slope*x[0] assert f( [1, 2, 3], [1, 2, 3], 1, ) == 0
benchmark_functions_edited/f4579.py
def f(fns, x): for fn in fns: result = fn(x) if result != x: return result return x assert f([lambda x: x + 1, lambda x: x + 2], 3) == 4
benchmark_functions_edited/f977.py
def f(point1, point2): return sum(abs(point1[i]-point2[i]) for i in range(len(point1))) assert f( (1,1), (2,2)) == 2
benchmark_functions_edited/f9558.py
def f(value): return sum(c.isspace() for c in str(value)) assert f('\n\n') == 2
benchmark_functions_edited/f4360.py
def f(eve, objs): an = next(nu for nu, obj in enumerate(objs) if eve == obj) return an assert f(1, (1,2,3)) == 0
benchmark_functions_edited/f2091.py
def f(b,m): b2=(b*b)%m b4=(b2*b2)%m b5=(b*b4)%m assert(b5==pow(b,5,m)) return b5 assert f(0, 5) == 0
benchmark_functions_edited/f149.py
def f(x): return 4*x**2 + x**3 assert f(0) == 0
benchmark_functions_edited/f11845.py
def f(Cu, Cth, Ck, c1=0.26, c2=0.07, c3=0.10): return c1 * Cu + c2 * Cth + c3 * Ck assert f(0, 0, 0) == 0
benchmark_functions_edited/f2497.py
def f(arg): total = 0 for val in arg: total += val return total assert f([]) == 0
benchmark_functions_edited/f871.py
def f(f, n): return f(f * n, n - 1) if n > 1 else f assert f(5, 1) == 5
benchmark_functions_edited/f12088.py
def f(what, otherwise): try: return what() except AttributeError: return otherwise assert f(lambda: 1 + 1, 0) == 2
benchmark_functions_edited/f11447.py
def f(bitmask): ones = 0 while bitmask != 0: # Check if least significant bit is 1 if bitmask & 1 == 1: ones += 1 # Shift over 1 bitmask >>= 1 return ones assert f(0b00000000000000000000000000000000000000000000000000000000000000001) == 1
benchmark_functions_edited/f10461.py
def f(x1,y1,x2,y2): return int(abs(x2-x1) + abs(y2-y1)+.5) assert f(1,2,1,3) == 1
benchmark_functions_edited/f2413.py
def f(str1, str2): return sum(a!=b and not( a=='N' or b=='N' ) for a,b in zip(str1, str2)) assert f( 'A', 'A' ) == 0
benchmark_functions_edited/f11901.py
def f(ranks, n=3): num = len([rank for rank in ranks if rank <= n]) return num / len(ranks) assert f([1, 2, 3, 4, 5], 0) == 0
benchmark_functions_edited/f3606.py
def f(x): try: return len(str(x)) except Exception as e: print(f"Exception raised:\n{e}") return 0 assert f("hello") == 5
benchmark_functions_edited/f9492.py
def f(word): wl = len(word) if wl < 3: return 0 if ((wl == 3) or (wl == 4)): return 1 if wl == 5: return 2 if wl == 6: return 3 if wl == 7: return 5 if wl >= 8: return 11 assert f("Aaaaa") == 2
benchmark_functions_edited/f14122.py
def f(s, s0=0.08333, theta=0.242): c0 = 1.0 / s0 / (1 - 1.0 / -theta) # normalization constant if s >= 0: if s <= s0: return c0 else: return c0 * (s / s0)**(-(1. + theta)) else: return 0 assert f(-1.5) == 0
benchmark_functions_edited/f196.py
def f(a, b, c): return a * b + c assert f(1, 2, 3) == 5
benchmark_functions_edited/f11680.py
def f(line: str) -> int: spaces: int = 0 if (len(line) > 0): if (line[0] == ' '): for letter_idx in range(len(line)): if (line[letter_idx + 1] != ' '): spaces = letter_idx + 1 break return spaces assert f('\n\n\n') == 0
benchmark_functions_edited/f655.py
def f(v, w): return sum(v_i * w_i for v_i, w_i in zip(v, w)) assert f((), ()) == 0
benchmark_functions_edited/f5248.py
def f(seq): norm = 0 for i in range(len(seq)): norm += abs(seq[i]) return norm assert f(tuple()) == 0
benchmark_functions_edited/f10864.py
def f(checker, sample): counter = 0 for thing in sample: if thing == checker: counter += 1 return counter assert f(4, [1, 0, 1, 0, 1]) == 0
benchmark_functions_edited/f11495.py
def f(sig_info, errors): if 'meeting_url' not in sig_info.keys(): print('ERROR! meeting_url is a required field') errors += 1 else: print('Check meeting_url: PASS') return errors assert f( {'meeting_url': 'zoom.us/j/123456789'}, 1) == 1
benchmark_functions_edited/f7571.py
def f(movie1, movie2): squared_difference = 0 for i in range(len(movie1)): squared_difference += (movie1[i] - movie2[i]) ** 2 final_distance = squared_difference ** 0.5 return final_distance assert f(list(range(5)), list(range(5))) == 0
benchmark_functions_edited/f5576.py
def f(strt, end, step): num = (end - strt) // step if (end - strt) % step != 0: num += 1 return num assert f(0, 100, 20) == 5
benchmark_functions_edited/f13218.py
def f(text): if not text: return 0 count = 0 inside_word = False for char in text: if char.isspace(): inside_word = False elif not inside_word: count += 1 inside_word = True return count assert f('a b c d e ') == 5
benchmark_functions_edited/f8037.py
def f(talj, kvot, product): summation = 0 talj *= product qfactor = 1 while talj: talj //= kvot summation += (talj // qfactor) qfactor += 2 return summation assert f(0, 1, 1) == 0
benchmark_functions_edited/f1546.py
def f(bounds): mi, ma = bounds return mi assert f( (1, 1) ) == 1
benchmark_functions_edited/f8907.py
def f(offset, limit): pref_offset = offset - limit if pref_offset >= 0: return pref_offset assert f(11, 5) == 6
benchmark_functions_edited/f6947.py
def f(season, day, period): return 1 + (168 * (season - 1)) + (24 * (day - 1)) + (period - 1) assert f(1, 1, 1) == 1
benchmark_functions_edited/f12053.py
def f(kwargs, param): try: return kwargs.pop(param) except KeyError: raise TypeError('Missing keyword argument {param}'.format(param=param)) assert f( {'param': 0}, 'param' ) == 0
benchmark_functions_edited/f2090.py
def f(obj): return next(iter(obj)) assert f(range(2, 10, 3)) == 2
benchmark_functions_edited/f11782.py
def f(item, tablesize): ordinal_list = [ord(i) for i in item] return sum(ordinal_list) % tablesize assert f("", 5) == 0
benchmark_functions_edited/f11997.py
def f(a: float, b: float) -> float: c = a - b return c assert f(1, 1) == 0
benchmark_functions_edited/f12577.py
def f(id,cycle_length): if id==0: return cycle_length-1 else: return id-1 assert f(0,3) == 2