file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f12162.py
def f(og, fg, method="simple"): if method == "advanced": return (76.08 * (og - fg) / (1.775 - og)) * (fg / 0.794) return 131.25 * (og - fg) assert f(1.000, 1.000) == 0
benchmark_functions_edited/f11722.py
def f(y_min): return y_min * (y_min + 1) // 2 assert f(0) == 0
benchmark_functions_edited/f13483.py
def f(forward_value, strike_value, is_call_bool): if is_call_bool: # call return max(forward_value - strike_value, 0) else: # put return max(strike_value - forward_value, 0) assert f(2, 2, True) == 0
benchmark_functions_edited/f11245.py
def f(k1, k2): res = 0 for km in set(k1.keys()).f(set(k2.keys())): res += 2 * min(k1[km], k2[km]) return res / (sum(k1.values()) + sum(k2.values())) assert f( {1: 1, 2: 1}, {1: 1, 2: 1} ) == 1
benchmark_functions_edited/f4880.py
def f(arg1, arg2): return abs(arg1-arg2) assert f(2, 0) == 2
benchmark_functions_edited/f11456.py
def f(some_dict): if isinstance(some_dict, dict): try: return {int(k): v for k, v in some_dict.items()} except ValueError: pass return some_dict assert f(0) == 0
benchmark_functions_edited/f2466.py
def f(n): m = n & (n - 1) return m ^ n assert f(15) == 1
benchmark_functions_edited/f11400.py
def f(wordlist, word): start = 0 end = len(wordlist) - 1 while start <= end: mid = int((start + end)/ 2) word_mid = wordlist[mid] if word_mid > word: end = mid - 1 elif word_mid < word: start = mid + 1 else: return mid return -1 assert f(list("abc"), "a") == 0
benchmark_functions_edited/f2458.py
def f(x,y): while(y): x, y = y, x % y return x assert f(3,5) == 1
benchmark_functions_edited/f9343.py
def f(num: int) -> int: if num == 1: return 1 if num % 2 == 0: return f(num // 2) + 1 else: return f(3 * num + 1) + 1 assert f(4) == 3
benchmark_functions_edited/f3926.py
def f(seq_list): lmax=0 for seq in seq_list: lmax=max( lmax, len(seq) ) return lmax assert f( ['ATC', 'GTA', 'GTAA', 'G'] ) == 4
benchmark_functions_edited/f6196.py
def f(obs, freq): return (1-freq)**(1-obs) * freq**obs assert f(0, 0) == 1
benchmark_functions_edited/f11383.py
def f(x, y, f=None): if y: if f: return f(y) else: return y else: return x assert f(1, None, None) == 1
benchmark_functions_edited/f1938.py
def f(x): if isinstance(x, tuple): return map(deep_list, x) return x assert f(1) == 1
benchmark_functions_edited/f6247.py
def f( winning_deck ): score = 0 for point, card in enumerate( winning_deck[::-1] ): score += (point+1) * card return score assert f( [1, 1] ) == 3
benchmark_functions_edited/f1144.py
def f(data: bytearray) -> int: return int(chr(data[1])) assert f(bytearray(b'0123456789123')) == 1
benchmark_functions_edited/f8948.py
def f(sequence, fn=None): if fn is None: return min(sequence)[1] else: return min((fn(e), e) for e in sequence)[1] assert f(range(10), lambda x: x**2) == 0
benchmark_functions_edited/f4663.py
def f(seguidores, seguindo): try: return (seguidores / (seguidores + seguindo)) except ZeroDivisionError: return 0.0 assert f(10, 0) == 1
benchmark_functions_edited/f14540.py
def f(value): value = value & 0xffffffff if value & 0x80000000: v = value - 0x100000000 else: v = value return v assert f(1) == 1
benchmark_functions_edited/f10256.py
def f(array): low = 0 high = len(array) - 1 while low < high: mid = (low + high) // 2 if array[mid] > array[high]: low = mid + 1 else: high = mid return array[low] assert f([3, 4, 5, 1, 2]) == 1
benchmark_functions_edited/f3977.py
def f(n: int) -> int: if n <= 0: return 0 nfft = 2 while (nfft < n): nfft = (nfft << 1) return nfft assert f(2) == 2
benchmark_functions_edited/f416.py
def f(a, b): print(a * b) return a * b assert f(1, 2) == 2
benchmark_functions_edited/f13912.py
def f(array, low, high, pindex): # Place pivot in front array[low], array[pindex] = array[pindex], array[low] i = low + 1 for j in range(low + 1, high): if array[j] < array[low]: array[i], array[j] = array[j], array[i] i += 1 # Place pivot in right place pindex = i - 1 array[low], array[pindex] = array[pindex], array[low] return pindex assert f(list('abcde'), 0, 4, 2) == 2
benchmark_functions_edited/f10416.py
def f(Ifault, length=1): Resistance = round(28710 * length / Ifault**1.4, 2) return Resistance assert f(0.3, 0) == 0
benchmark_functions_edited/f2128.py
def f(base_minor, base_major, height): return height*((base_minor + base_major)/2) assert f(1, 5, 3) == 9
benchmark_functions_edited/f11022.py
def f(pipe_friction_const, L): hpipe = pipe_friction_const*L print('hpipe (Piping friction loss) = {} ft'.format(hpipe)) return hpipe assert f(2.25/100.0, 0.0) == 0
benchmark_functions_edited/f1920.py
def f(N_avg,N2_avg,**kwargs): return N2_avg - N_avg**2 assert f(2,4) == 0
benchmark_functions_edited/f4594.py
def f(x: int, y: int, modulo: int = 32) -> int: return (x + y) & ((1 << modulo) - 1) assert f(1, 2, 32) == 3
benchmark_functions_edited/f10977.py
def f(string, list_to_exclude): try: assert string not in list_to_exclude except AssertionError: raise RuntimeError(f"Input may not be one of {list_to_exclude}.") return string assert f(1, [2,3]) == 1
benchmark_functions_edited/f4383.py
def f(tile1, tile2): return abs(tile1[0]-tile2[0]) + abs(tile1[1]-tile2[1]) assert f( (0,0), (2,2) ) == 4
benchmark_functions_edited/f11083.py
def f(x, y, z, i): if i == 0: return x ^ y ^ z elif i == 1: return (x & y) | (~x & z) elif i == 2: return (x | ~y) ^ z elif i == 3: return (x & z) | (y & ~z) elif i == 4: return x ^ (y | ~z) else: assert False assert f(1, 0, 1, 0) == 0
benchmark_functions_edited/f4664.py
def f(n1, n2): if n1 < n2: n1, n2 = n2, n1 while n1 % n2: n1, n2 = n2, n1 % n2 return n2 assert f(2, 4) == 2
benchmark_functions_edited/f8235.py
def f(play): return [2 ** i for i in range(49)].index(play) // 7 assert f(32) == 0
benchmark_functions_edited/f9330.py
def f(v, low, high): return max(int(low), min(int(v), int(high))) assert f(3, 2.6, 2.6) == 2
benchmark_functions_edited/f258.py
def f(aa, bb, cc): return cc - aa * bb assert f(1, 1, 2) == 1
benchmark_functions_edited/f2470.py
def f(lst,obj): count = 0 for x in lst: if x == obj: count += 1 return count assert f( [3], 3) == 1
benchmark_functions_edited/f4479.py
def f(x): try: return x['endtime'] except (KeyError, ValueError, IndexError): return x['time'] + x['length'] * x['dt'] assert f({'time': 1, 'length': 1, 'dt': 1}) == 2
benchmark_functions_edited/f4352.py
def f(text, char): count = 0 for c in text: if c == char: count += 1 return count assert f('xyz', 'x') == 1
benchmark_functions_edited/f13166.py
def f(alpha, cli, cdi): den = cli(alpha)**2 + cdi(alpha)**2 return 1 / den**(.25) assert f(0, lambda alpha: 0, lambda alpha: 1) == 1
benchmark_functions_edited/f2294.py
def f(n=100_000_000): i = 0 s = 0 while i < n: s += i i += 1 return s assert f(3) == 3
benchmark_functions_edited/f4544.py
def f(n, i): a = 1 for k in range(n, n-i, -1): a = a * k for k in range(i, 0, -1): a = a / k return a assert f(6, 5) == 6
benchmark_functions_edited/f6992.py
def f(out): for line in out: if '12d1:1446' in line: return 0 if '12d1:1001' in line: return 1 return -1 assert f([ '12d1:1001 12d1:1001', '12d1:1001 12d1:1001', '12d1:1001 12d1:1001', '12d1:1001 12d1:1001', ]) == 1
benchmark_functions_edited/f5697.py
def f(n): result = 0 while n: result += n % 10 n = n // 10 return result assert f(100) == 1
benchmark_functions_edited/f6220.py
def f(host): return host.count('.') assert f( 'x.y.com') == 2
benchmark_functions_edited/f7647.py
def f(t): # use on python scalars/pytorch scalars if isinstance(t, (float, int)): return t if hasattr(t, 'item'): return t.item() else: return t[0] assert f(1) == 1
benchmark_functions_edited/f8327.py
def f( a, x ): hi = len( a ) lo = 0 while lo < hi: mid = ( lo + hi ) // 2 if x < a[ mid ][ 0 ]: hi = mid else: lo = mid + 1 return lo assert f( [(0,1),(1,1),(2,1)], 1.5 ) == 2
benchmark_functions_edited/f12689.py
def f(x, weight): if x >= 5: return weight else: return -weight assert f(7, 7) == 7
benchmark_functions_edited/f5913.py
def f(nb, batch_size): basic = nb//batch_size total = basic + (0 if nb%batch_size==0 else 1) return total assert f(10, 20) == 1
benchmark_functions_edited/f2428.py
def gainceiling (val=None): global _gainceiling if val is not None: _gainceiling = val return _gainceiling assert f(5) == 5
benchmark_functions_edited/f9253.py
def f(mass, velocity): return 0.5 * mass * velocity ** 2 def test_f(): mass = 10 # [kg] velocity = 4 # [m/s] assert f(mass, velocity) == 80 assert f(1000, 0) == 0
benchmark_functions_edited/f14274.py
def f(r_error_comp, r_error_ref): return (1-((r_error_ref-r_error_comp)/r_error_comp)) assert f(0.1, 0.2) == 0
benchmark_functions_edited/f6702.py
def f(a: int, p: int): symbol = pow(a, (p - 1) // 2, p) if symbol == 1: return pow(a, (p + 1) // 4, p) assert f(1, 11) == 1
benchmark_functions_edited/f987.py
def f(value): return max(0, min(100, round((value * 100.0) / 255.0))) assert f(0) == 0
benchmark_functions_edited/f6665.py
def f(day): converter = { 'mon' : 0, 'tue' : 1, 'wed' : 2, 'thu' : 3, 'fri' : 4, 'sat' : 5, 'sun' : 6 } return converter[day] assert f('wed') == 2
benchmark_functions_edited/f11502.py
def f(expr1, expr2, expr3): if expr1: return expr2 else: return expr3 assert f(True, 2, 3) == 2
benchmark_functions_edited/f11578.py
def f(din): if len(din) == 1: dout = din[0] else: dout = din[0] & f(din[1:]) return dout assert f([0, 1, 2, 3, 4]) == 0
benchmark_functions_edited/f8686.py
def f(iterator, default=None): return next(iterator, default) assert f(iter([1, 2, 3]), None) == 1
benchmark_functions_edited/f961.py
def f(b): return 0 if b==0 else 1+f(b>>1) assert f(0b00000111) == 3
benchmark_functions_edited/f281.py
def f(x, a, b): return a*x + b assert f(1, 1, 1) == 2
benchmark_functions_edited/f5512.py
def f(a, b): return (a > b) - (a < b) assert f((1, 2), (1, 2)) == 0
benchmark_functions_edited/f13613.py
def f(n, a): if n <= 0 or a <= 0: raise ValueError("Both arguments to _sqrt_nearest should be positive.") b=0 while a != b: b, a = a, a--n//a>>1 return a assert f(4, 1) == 2
benchmark_functions_edited/f10341.py
def f(objects, key1, key2): count = 0 for ranker in range(len(objects[key1])): x1 = objects[key1][ranker] x2 = objects[key2][ranker] if x1 != None and x2 != None and x1 > x2: count += 1 return count assert f( {'A': [100, 200, 300], 'B': [200, 500, 600]}, 'A', 'B') == 0
benchmark_functions_edited/f11704.py
def f(low, high): if high < low: raise ValueError("Expected arg \"low\" to be less than arg \"high\"") return low + (high - low) / 2 assert f(-20000, 20000) == 0
benchmark_functions_edited/f13339.py
def f(new_state): heuristic_cost = 0 for row in new_state: if -1 in row: first_item = row[0] for item in row: if(item != first_item and item != -1): heuristic_cost += 1 return heuristic_cost assert f([[1, 1, 1], [1, 1, 1]]) == 0
benchmark_functions_edited/f155.py
def f(num,pow): return 1.0*num**(1.0/pow) assert f(16,4) == 2
benchmark_functions_edited/f1226.py
def f(c): fc = 0 for fr in c: fc += 1 return fc assert f( [["a", "b", "c"], ["d", "e", "f"]] ) == 2
benchmark_functions_edited/f2994.py
def f(deck): score = 0 for i, card in enumerate(deck): score += card * (len(deck) - i) return score assert f([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0
benchmark_functions_edited/f1886.py
def f(b): if b is None: return None else: return bool(b) assert f(1) == 1
benchmark_functions_edited/f7790.py
def f(x: float) -> float: c = 1.70158 * 1.525 if x < 0.5: return (pow(2 * x, 2) * ((c + 1) * 2 * x - c)) / 2 else: return (pow(2 * x - 2, 2) * ((c + 1) * (x * 2 - 2) + c) + 2) / 2 assert f(1) == 1
benchmark_functions_edited/f4027.py
def f(g): return len(g[0]) assert f( [[" ", "a", " "], ["b", "b", "b"], [" ", "c", " "]]) == 3
benchmark_functions_edited/f3963.py
def f(matrix): # SYFPEITHI NORMALIZATION return sum([ max(value.values()) for _, value in matrix.items() ]) assert f( { 'A' : { 'A' : 1 } } ) == 1
benchmark_functions_edited/f7523.py
def f(n, k) -> int: if n == k: return 1 elif n <= 0 or k <= 0: return 0 else: return f(n - k, k) + f(n - 1, k - 1) assert f(4, 1) == 1
benchmark_functions_edited/f5106.py
def f(array, operation = None): if len(array) == 0: return None return array[-1] assert f([1, 2]) == 2
benchmark_functions_edited/f10028.py
def f(number, exponent): if exponent == 0: return 1 elif exponent % 2 == 0: return f(number**2, exponent//2) else: return number * f(number**2, exponent//2) assert f(5, 1) == 5
benchmark_functions_edited/f8743.py
def f(n: int) -> int: a = 0 b = 1 for i in range(n): a, b = b, a + b return a assert f(3) == 2
benchmark_functions_edited/f4893.py
def f(*, require_id=False, register_id=False): opts = 0 opts |= require_id opts |= (register_id << 1) return opts assert f(**{'require_id': True,'register_id': True}) == 3
benchmark_functions_edited/f11146.py
def f(x, input_min=-1, input_max=1, output_min=0, output_max=255): assert input_max > input_min assert output_max > output_min return (x - input_min) * (output_max - output_min) / (input_max - input_min) + output_min assert f(-1.0, -1, 1, 0, 10000) == 0
benchmark_functions_edited/f12174.py
def f(memory): if memory < 1.792: mem_bin = 0 elif memory < 7.168: mem_bin = 1 elif memory < 14.336: mem_bin = 2 elif memory >= 14.336: mem_bin = 3 else: mem_bin = "nan" return mem_bin assert f(14.335) == 2
benchmark_functions_edited/f14163.py
def f(antecedents_support, combination_support): try: return combination_support / antecedents_support except ZeroDivisionError: return 0 assert f(50, 100) == 2
benchmark_functions_edited/f37.py
def f(l): return list(l)[0] assert f((i for i in range(2))) == 0
benchmark_functions_edited/f9625.py
def f(string_value): return int(string_value.strip()) assert f('1') == 1
benchmark_functions_edited/f13999.py
def f(alist): mymax = alist[0] * alist[0] for each in range(0,len(alist)-1): for other in range(0, len(alist) - 1): if alist[each] == alist[other]: continue elif (alist[each] *alist[other]) > mymax: mymax = alist[each] * alist[other] # CHANGE OR REMOVE THE LINE BELOW return mymax assert f(list(range(1,2))) == 1
benchmark_functions_edited/f2368.py
def f(l, n): try: return l[n] except (TypeError, IndexError): return 'None' assert f(list(range(10)), 3) == 3
benchmark_functions_edited/f4541.py
def f(X): return (X + abs(X)) / 2 assert f(0) == 0
benchmark_functions_edited/f5331.py
def f(V, E0, B0, B1, V0): eta = (V/V0)**(1./3.) E = E0 + 9.*B0*V0/16.*(eta**2-1)**2*(6 + B1*(eta**2-1.) - 4.*eta**2) return E assert f(4, 4, 4, 4, 4) == 4
benchmark_functions_edited/f7517.py
def f(num): if num == 0: return 0 if num > 0: return 1 return -1 assert f(-0.0) == 0
benchmark_functions_edited/f6486.py
def f(i, dileft, diright, dim): if i <= dileft: ans = dileft elif dim-i <= diright: ans = dim-diright else: ans = i return ans assert f(5, 5, 5, 100) == 5
benchmark_functions_edited/f241.py
def f(x, y): return -int(-x // y) assert f(8, 4) == 2
benchmark_functions_edited/f7912.py
def f(predicate, seq): idx = 0 for elem in seq: if predicate(elem): return idx idx += 1 return -1 assert f(lambda x: x == 2, [0, 1, 2]) == 2
benchmark_functions_edited/f7285.py
def f(arr): cnt = 0 for i in range(0, len(arr) - 1): for j in range(i + 1, len(arr)): if arr[i] > arr[j]: cnt += 1 return cnt assert f([1, 2, 4, 3]) == 1
benchmark_functions_edited/f5527.py
def f(inventory, addedItems): numberAdded = 0 for i in addedItems: inventory.setdefault(i, 0) inventory[i] += 1 return 1 assert f( {'gold coin': 42, 'rope': 1}, ['gold coin', 'gold coin', 'gold coin']) == 1
benchmark_functions_edited/f12375.py
def f(*exprs): # You've already done them; just return the right value. if len(exprs) > 0: return exprs[-1] else: return None assert f(2, 3, 4) == 4
benchmark_functions_edited/f8616.py
def f(x, y): assert isinstance(x, (int, float)), "The x value must be an int or float" assert isinstance(y, (int, float)), "The y value must be an int or float" return x ** y assert f(3, 0) == 1
benchmark_functions_edited/f5585.py
def f(Pin_ast, Pout, Pper): return (1/2.)*(Pin_ast + Pout) - Pper assert f(10, 10, 10) == 0
benchmark_functions_edited/f7717.py
def f(msr_value): offset = (msr_value & 0xFFE00000) >> 21 offset = offset if offset <= 0x400 else -(0x800 - offset) return int(round(offset / 1.024)) assert f(0x100000000) == 0
benchmark_functions_edited/f11477.py
def f(linea: str, palabra: str) -> int: return linea.count(palabra) assert f( "la casa de papelera es de papel", "de" ) == 2
benchmark_functions_edited/f858.py
def f(x, xmin, xrng, xres): return int((x-xmin)/xrng * (xres-1)) assert f(-2, -2, 4, 5) == 0
benchmark_functions_edited/f8085.py
def f(inds, nrow, ncol): row_major = inds row, col = row_major//ncol, row_major%ncol return col*nrow + row assert f(0, 2, 2) == 0
benchmark_functions_edited/f14223.py
def f(g1, l1_g): if g1.isalpha(): if l1_g == 1: pass else: print("illegal format.") g = str(input("Your guess: ")) g1 = g.upper() l1_g = len(g1) return l1_g else: print("illegal format.") g = str(input("Your guess: ")) g1 = g.upper() l1_g = len(g1) return l1_g assert f("E", 1) == 1
benchmark_functions_edited/f8434.py
def f(data): assert len(data) >= 4 num = data[3] num += ((data[2] << 8) & 0xff00) num += ((data[1] << 16) & 0xff0000) num += ((data[0] << 24) & 0xff000000) return num assert f(b'\x00\x00\x00\x02') == 2