file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f1404.py
def f(row): return max(row) - min(row) assert f( [7, 5, 3]) == 4
benchmark_functions_edited/f12934.py
def f(s): return max(len(s) for s in s.split("\n")) assert f("") == 0
benchmark_functions_edited/f7874.py
def f(a, b): d = b - a if (d < 0): d = d + 2**32 if (d <= 0): d = d + 2**64 - 2**32 return d assert f(2**32+1, 2**32+1) == 0
benchmark_functions_edited/f13744.py
def f(n): length = 1 while n != 1: print(n) if n % 2 == 0: n = n // 2 # Integer division prevents "1.0" output else: n = 3 * n + 1 length = length + 1 print(n) # n is now 1 return length assert f(10) == 7
benchmark_functions_edited/f8484.py
def f(position: int, roll: int) -> int: return position + (roll * 2) assert f(1, 2) == 5
benchmark_functions_edited/f5358.py
def f(s): if s is not None: return len(s) return 0 assert f("") == 0
benchmark_functions_edited/f8538.py
def f(name, value, conditions): msg = fassert value in conditions.keys(), msg return conditions[value] assert f( 'a', '1', { '1': 1, '2': 2, } ) == 1
benchmark_functions_edited/f8010.py
def f(depth, block_size): block = block_size * block_size if depth % block != 0: depth = block * (1 + (depth // block)) return depth assert f(3, 2) == 4
benchmark_functions_edited/f1964.py
def f(a_dictionary): return(len(a_dictionary)) assert f( {} ) == 0
benchmark_functions_edited/f7693.py
def f(number): if number <= 0: return 1 bit_len = int.bit_length(number) power2 = 2 ** (bit_len - 1) if power2 == number: return number else: return power2 * 2 assert f(0) == 1
benchmark_functions_edited/f13690.py
def f(time, start, duration, repeat_time, end): t = time() if start <= t < end: return 1 if (t - start) % repeat_time < duration else 0 else: return 0 assert f(lambda: 1, 0, 1, 2, 2) == 0
benchmark_functions_edited/f180.py
def f(alpha, t): return 1./(t+1J)**(alpha+1) assert f(-1, 0) == 1
benchmark_functions_edited/f2386.py
def bin2dec (s): s = str(s) return int(s,2) assert f(111) == 7
benchmark_functions_edited/f9976.py
def f(a, b): # Surprisingly enough there doesn't seem to be a more elegant way. # Check http://stackoverflow.com/questions/6192825/ a %= 360 b %= 360 if a < b: return f(b, a) else: return min(a-b, b-a+360) assert f(5.5, 10.5) == 5
benchmark_functions_edited/f9766.py
def f(number1, number2): if not isinstance(number1, int) or not isinstance(number2, int): raise TypeError("Numerator and denominator must be integers") while number1 % number2: number1, number2 = number2, number1 % number2 return number2 assert f(100, 101) == 1
benchmark_functions_edited/f1318.py
def f(a,b): while b != 0: a, b = b, a%b return a assert f(20, 35) == 5
benchmark_functions_edited/f11973.py
def f(keep_dims, x_dim, x_ndim, batch_axis): if keep_dims: out_dim = x_dim else: out_dim = 0 for i in range(x_ndim): if i == x_dim: break if i in batch_axis: continue else: out_dim += 1 return out_dim assert f(False, 3, 4, (1,)) == 2
benchmark_functions_edited/f3473.py
def f(first, last): return first + (last - first) >> 1 assert f(0, 2) == 1
benchmark_functions_edited/f4890.py
def f(spans, limit): for idx, _ in enumerate(spans): if spans[idx][1] >= limit: return idx return len(spans) assert f( [ (0, 2), (3, 6), (6, 9), ], 2, ) == 0
benchmark_functions_edited/f11416.py
def f(c, a, c50, n): return (a*(c**n)/((c50**n)+(c**n))) assert f(0, 0, 0, 0) == 0
benchmark_functions_edited/f9844.py
def f(freqs): samples = 0 for (number, freq) in freqs: samples += freq samples_median = samples / 2.0 current_samples = 0 for (number, freq) in freqs: current_samples += freq if current_samples >= samples_median: return number return 0 assert f( [ (1, 2), (2, 1), (3, 2) ] ) == 2
benchmark_functions_edited/f2527.py
def f(needle, haystack): return len(haystack.split(needle)) - 1 assert f('b', 'abc') == 1
benchmark_functions_edited/f5914.py
def f(x): num = 0 n = len(x) for i in range(n): num = num + 2 ** i * int(x[n - i - 1]) return num assert f( '000000000000000000000000000000000000000000000000000000000000001') == 1
benchmark_functions_edited/f9409.py
def f(level: int): return (level ** 3) // 2 assert f(1) == 0
benchmark_functions_edited/f12284.py
def f(i, j, n): if i <= j: return (n * (n + 1) // 2) - ((n - i) * (n - i + 1) // 2) + (j - i) else: return f(j, i, n) assert f(0, 2, 4) == 2
benchmark_functions_edited/f708.py
def f(lst): return sum([float(x) for x in lst])/len(lst) assert f([1, 2, 3, 4, 5]) == 3
benchmark_functions_edited/f3911.py
def f(char_ind: int, sent: str) -> int: return sent[:char_ind].count(" ") assert f(5, "A B C") == 2
benchmark_functions_edited/f12895.py
def f(freq): z_less_200 = freq / 102.9 z_greater_200 = 26.81 * freq / (1960 + freq) - 0.53 return (freq > 200) * z_greater_200 + (freq <= 200) * z_less_200 assert f(0) == 0
benchmark_functions_edited/f2541.py
def f(mft_reference): return (mft_reference >> 48) & 0xFFFF assert f(0x0000000100000000) == 0
benchmark_functions_edited/f14124.py
def f(ps1, ps2, external_p): x3, y3 = external_p x1, y1 = ps1 x2, y2 = ps2 px = x2-x1 py = y2-y1 norm = px*px + py*py u = ((x3 - x1) * px + (y3 - y1) * py) / float(norm) if u > 1: u = 1 elif u < 0: u = 0 x = x1 + u * px y = y1 + u * py dx = x - x3 dy = y - y3 dist = (dx*dx + dy*dy)**.5 return dist assert f( (-1, 0), (1, 0), (0, 0) ) == 0
benchmark_functions_edited/f3197.py
def f(node): return 2 * node + 1 assert f(4) == 9
benchmark_functions_edited/f13396.py
def f(tosses): consecutive_tosses = 1 max_consecutive_tosses = 1 for i in range(0, len(tosses) - 1): if tosses[i] == tosses[i + 1]: consecutive_tosses += 1 max_consecutive_tosses = max(max_consecutive_tosses, consecutive_tosses) else: consecutive_tosses = 1 return max_consecutive_tosses assert f( [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]) == 1
benchmark_functions_edited/f10887.py
def f(lag=1): win_size = 2 * lag + 1 neighbours = win_size**2 - (2 * (lag - 1) + 1)**2 return neighbours assert f(1) == 8
benchmark_functions_edited/f5880.py
def f(num_frames, frame_length, frame_step): if num_frames == 0: return 0 return (num_frames - 1) * frame_step + frame_length assert f(0, 0.020, 0.010) == 0
benchmark_functions_edited/f4055.py
def f(x, min_x, max_x): return x * (max_x - min_x) + min_x assert f(0, 0, 0) == 0
benchmark_functions_edited/f13348.py
def f(index, key): if index + key > 25: return index + key - 26 return index + key assert f(5, 2) == 7
benchmark_functions_edited/f2658.py
def f(*args): tot = 0 for num in args: tot += num return tot assert f(0, 0, 0) == 0
benchmark_functions_edited/f5972.py
def f(option): if option == 'DRAG': return 3 if option == 'None': return 0 return int(option) assert f(0) == 0
benchmark_functions_edited/f4843.py
def f(museum_ix, mvsas_ix, day_ix, p_len, d_len): return day_ix + (d_len)*(mvsas_ix + (p_len)*(museum_ix)) assert f(0, 0, 0, 2, 4) == 0
benchmark_functions_edited/f12526.py
def f(invalid_run_point, all_builds): return (invalid_run_point - 1 if invalid_run_point + 1 in all_builds else invalid_run_point + 1) assert f(4, [2, 3, 4, 5]) == 3
benchmark_functions_edited/f6881.py
def f(axis: int, ndim: int) -> int: if not -ndim <= axis < ndim: raise ValueError(f'invalid axis {axis} for ndim {ndim}') if axis < 0: axis += ndim return axis assert f(1, 5) == 1
benchmark_functions_edited/f6282.py
def f(counts): h = 0 for c in counts: if c >= h + 1: h += 1 else: break return h assert f([1,1,1,1,1]) == 1
benchmark_functions_edited/f11183.py
def f(n: int, k: int) -> int: c = [[0] * (k+1) for _ in range(n+1)] for i in range(n+1): c[i][0] = 1 for j in range(1, 1 + min(i, k)): c[i][j] = c[i-1][j-1] + c[i-1][j] return c[n][k] assert f(3, 0) == 1
benchmark_functions_edited/f6264.py
def f(obj): return {} if obj is None else obj assert f(0) == 0
benchmark_functions_edited/f6658.py
def f(kernel, x, min_x, max_x, int_k): if x < min_x or x > max_x: return 0 else: return kernel(x) / int_k assert f(lambda x: 4, 2, 3, 2, 1) == 0
benchmark_functions_edited/f2266.py
def std_var_mean (Spectrum): mean = sum(Spectrum)/len(Spectrum) return mean assert f([1,2,3,4,5,6,7,8,9]) == 5
benchmark_functions_edited/f14457.py
def f(number, fib_list): # If the number has already been computed if fib_list[number] != -1: return fib_list[number] if number <= 1: fib_list[number] = number else: fib_list[number] = f(number - 1, fib_list) + f(number - 2, fib_list) return fib_list[number] assert f(1, [-1] * 10) == 1
benchmark_functions_edited/f10334.py
def f(tup): size = len(tup) result = 0 for i in range(size): result = tup[i] << (i * 8) | result return result assert f(tuple()) == 0
benchmark_functions_edited/f10762.py
def f(dist, r_max, diameter): if dist < r_max - diameter / 2: return 1 if dist > r_max + diameter / 2: return 0 else: return -dist / diameter + r_max / diameter + 0.5 assert f(6, 2, 1) == 0
benchmark_functions_edited/f2078.py
def f(s, t): return len(s.intersection(t)) / len(s.union(t)) assert f(set([1, 2, 3, 4, 5]), set([6, 7, 8, 9])) == 0
benchmark_functions_edited/f4835.py
def f(payload): user_id = payload.get("user_id") return user_id assert f({"user_id": 1}) == 1
benchmark_functions_edited/f2426.py
def f(log_spec): return 10 ** (log_spec / 10) assert f(0) == 1
benchmark_functions_edited/f169.py
def f(value, arg): return (value) - (arg) assert f(3, 2) == 1
benchmark_functions_edited/f426.py
def f(val, offs): return val | (1 << offs) assert f(0, 0) == 1
benchmark_functions_edited/f7111.py
def f(term): if isinstance(term, dict): [(k, v)] = term.items() return v else: return term assert f(1) == 1
benchmark_functions_edited/f4942.py
def f(value): value = int(value) if value < 1: raise ValueError('Light IDS are greater or equal to 1') return value assert f(3) == 3
benchmark_functions_edited/f10842.py
def f(x, a, b, c): return 2 * a * (x - b) assert f(1, 1, 0, 1) == 2
benchmark_functions_edited/f12773.py
def f(amount, gst_rate): return amount - (amount / (1 + gst_rate)) assert f(0, 0.1) == 0
benchmark_functions_edited/f9909.py
def f(individual, complete_solution): for i in range(len(complete_solution)): if type(complete_solution[i]) == type(individual): return i # else: # return None assert f(1, [1,2,3]) == 0
benchmark_functions_edited/f10932.py
def f(list1: list) -> object: if len(list1) == 0: return None else: return list1[0] assert f([1, 2, 3, 4]) == 1
benchmark_functions_edited/f1305.py
def f(k, N): arr = [str(k*n) for n in range(1, N+1)] s = "".join(arr) return int(s) assert f(5, 1) == 5
benchmark_functions_edited/f5709.py
def f(lst1, lst2): if len(lst1) == 0: return 0 num_rep = len([x for x in lst1 if x in lst2]) return num_rep / len(lst1) assert f( [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] ) == 1
benchmark_functions_edited/f2272.py
def f(n): return sum(i for i in range(1, n + 1)) ** 2 assert f(1) == 1
benchmark_functions_edited/f4626.py
def f(x, y): return sum(bin(xi^yi).count('1') for xi,yi in zip(bytearray(x),bytearray(y))) assert f(b"cat", b"cat") == 0
benchmark_functions_edited/f7426.py
def f(list_of_numbers): answer = 1 for number in list_of_numbers: answer *= number return answer assert f([]) == 1
benchmark_functions_edited/f3112.py
def f(number): return int(number * 1000) / 10. assert f(0) == 0
benchmark_functions_edited/f12277.py
def f(word, M): # Calculate fhash formular G = 37 result = 0 word = list(word) for i in range(len(word)): if i == 0: result += ord(word[i]) else: result += ord(word[i]) * (G ** i) return result % M assert f("big", 4) == 2
benchmark_functions_edited/f4068.py
def f(bits): r = 0 s = 1 for b in bits: if b & 1: r += s s <<= 1 return r assert f(b'0') == 0
benchmark_functions_edited/f7818.py
def f(cls, val): try: return cls._enum_value_map_[val] except (KeyError, TypeError, AttributeError): return val assert f(int, 0) == 0
benchmark_functions_edited/f9277.py
def f(class_probabilities): return sum(class_probabilities[c] for c in class_probabilities) assert f({'ham': 0.5,'spam': 0.5}) == 1
benchmark_functions_edited/f6116.py
def f(lumin, lambdaValue): # lambdaValue normally select 0.6 w = lumin**lambdaValue #w = (255*np.clip(w,0,1)).astype('uint8') return(w) assert f(1, 1) == 1
benchmark_functions_edited/f9980.py
def f(x1,y1, x2,y2): return int(abs(x2-x1) + abs(y2-y1)+.5) assert f(0, 0, 1, -1) == 2
benchmark_functions_edited/f7395.py
def f(ppm): return 1 + ppm * 1E-6 assert f(0) == 1
benchmark_functions_edited/f853.py
def f(val): return val[31] ^ val[30] assert f(32 * [1]) == 0
benchmark_functions_edited/f2363.py
def f(length): return ((length + 7) & ~7) - length assert f(6) == 2
benchmark_functions_edited/f3009.py
def f(grid): try: return len(grid[0]) except IndexError: return 0 assert f( [[1], [1], [1], [1], [1], [1], [1]]) == 1
benchmark_functions_edited/f1339.py
def f(size: float) -> float: return round(size / 2 ** 20, 2) assert f(0) == 0
benchmark_functions_edited/f2814.py
def f(n): pred, curr = 0, 1 k = 1 while k < n: pred, curr = curr, curr + pred k += 1 return curr assert f(5) == 5
benchmark_functions_edited/f12755.py
def f(n, k): if 0 <= k <= n: ntok = 1 ktok = 1 for t in range(1, min(k, n - k) + 1): ntok *= n ktok *= t n -= 1 return ntok // ktok else: return 0 assert f(5, 4) == 5
benchmark_functions_edited/f7179.py
def f(row): sorted_row = sorted(row)[0] smallest, largest = sorted_row, sorted(row)[-1] return largest - smallest assert f(list(range(1, 10))) == 8
benchmark_functions_edited/f10373.py
def _grae_xmax_ ( graph ) : xmx = None np = len(graph) for ip in range( np ) : x , exl , exh , y , eyl , eyh = graph[ip] x = x + abs( exh ) if None == xmx or x >= xmx : xmx = x return xmx assert f( [(-1,2,2, 2,2,2), (3,2,2, 4,2,2) ] ) == 5
benchmark_functions_edited/f11731.py
def f(a, b): # assert find_gcd(a, b) != 1, "a and b do not have a mod inverse and are " \ # "not relatively prime" u1, u2, u3 = 1, 0, a v1, v2, v3 = 0, 1, b while v3 != 0: q = u3 // v3 v1, v2, v3, u1, u2, u3 = u1-q*v1, u2-q*v2, u3-q*v3, v1, v2, v3 return u1 % b assert f(17, 33) == 2
benchmark_functions_edited/f12675.py
def f(risk): _index = 0 if risk == 0.9: _index = 1 elif risk == 1.0: _index = 2 elif risk == 1.1: _index = 3 return _index assert f(0.9) == 1
benchmark_functions_edited/f12655.py
def f(accounts: int, deploy_idx: int) -> int: return deploy_idx if accounts == 0 else \ deploy_idx % accounts or accounts assert f(1, 2) == 1
benchmark_functions_edited/f4296.py
def f(name, string): return int(name.lower() in string) assert f( "the", "the") == 1
benchmark_functions_edited/f12326.py
def f(string): non_blank_counter = 0 for line in string.splitlines(): if line.strip(): non_blank_counter += 1 return non_blank_counter assert f( "\n\n " ) == 0
benchmark_functions_edited/f13929.py
def f(hms): h, m, s = hms return 3000 * h + 60 * m + s assert f( (0, 0, 0) ) == 0
benchmark_functions_edited/f10662.py
def f(pattern: str) -> int: return int(pattern[::-1], 3) assert f(str(bin(0)[2:].zfill(4))) == 0
benchmark_functions_edited/f13427.py
def count_marquage (marquage): marquage_ligne = marquage['ligne'] marquage_colonne = marquage['colonne'] nb = 0 for elt in marquage_ligne: nb_occur = marquage_ligne.count(elt) if nb < nb_occur: nb = nb_occur for elt in marquage_colonne: nb_occur = marquage_colonne.count(elt) if nb < nb_occur: nb = nb_occur return nb assert f( {'ligne': ['X', 'X', 'X', 'O'], 'colonne': ['O', 'O', 'X', 'X'], 'diagonale_gauche': ['O', 'X', 'X', 'O'], 'diagonale_droite': ['X', 'O', 'O', 'X']}) == 3
benchmark_functions_edited/f2444.py
def f(vals): return sum(vals)/float(len(vals)) if vals else 0 assert f( [] ) == 0
benchmark_functions_edited/f13178.py
def f(term): if not "args" in dir(term): return 0 if term.args == (): return 0 elif term.args[1].args == (): return 1 else: return int(term.args[1].args[1]) assert f(3) == 0
benchmark_functions_edited/f1673.py
def f(F): n = len(F) mu = F[int(n/2)] return mu assert f([1, 2, 3]) == 2
benchmark_functions_edited/f8476.py
def f(sequence_of_values): mean = float(sum(sequence_of_values))/float(len(sequence_of_values)) SSD = sum([(float(x)-mean)**2 for x in sequence_of_values]) return SSD/(len(sequence_of_values)-1) assert f([1, 3, 5]) == 4
benchmark_functions_edited/f11730.py
def f(number: float) -> int: if abs(round(number) - number) == 0.5: return int(2.0 * round(0.5 * number)) else: return int(round(number)) assert f(2) == 2
benchmark_functions_edited/f2146.py
def f(side): # You have to code here # REMEMBER: Tests first!!! return side ** 2 assert f(2) == 4
benchmark_functions_edited/f95.py
def f(n): return bin(n)[2:].count('1') assert f(0b10011010) == 4
benchmark_functions_edited/f1995.py
def f(x) -> int: try: return int(x) except: return 0 assert f("1") == 1
benchmark_functions_edited/f7446.py
def f(S): n = len(S) total = 0 for j in range(n): # loop from 0 to n-1 for k in range(1+j): # loop from 0 to j # note the increment of 2 total += int(S[k]) return total assert f(list('00000')) == 0
benchmark_functions_edited/f8614.py
def f(x): #All the valid values appear to be <= 6 if float(x) <= 6: return x #replace those with 1 bedroom since that is 90% of all properties else: return 1 assert f(5) == 5
benchmark_functions_edited/f10449.py
def f(discrete_action, mouse_speed): if discrete_action == 1: return -mouse_speed elif discrete_action == 2: return mouse_speed else: return 0 assert f(2, 3) == 3