file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f2698.py
def f(x, p): return pow(x, (p+1)//4, p) assert f(5, 2) == 1
benchmark_functions_edited/f14037.py
def f(z): z_rem = z n_min = 0 n = 0 while True: n_min += n * min((n+1)*(n+2), z_rem) z_rem -= (n+1)*(n+2) if z_rem <= 0: break n += 1 return n_min assert f(7) == 5
benchmark_functions_edited/f6202.py
def f(detection): ret_val = 0.0 for occ in detection.get("occs",[]): ret_val += occ["se"]-occ["ss"] return ret_val assert f( {"occs": [{"ss": 0, "se": 1}]} ) == 1
benchmark_functions_edited/f11824.py
def f(z, theta): return (z ** (1 + theta))/(1 + theta) assert f(0, 2) == 0
benchmark_functions_edited/f9501.py
def f(key): if len(key) > 0: char = ord(key[0]) if char <= 0x7F: return 1 elif char >= 0xC2 and char <= 0xDF: return 2 elif char >= 0xE0 and char <= 0xEF: return 3 elif char >= 0xF0 and char <= 0xF4: return 4 return 1 else: return 0 assert f(b"") == 0
benchmark_functions_edited/f3705.py
def f(A): return min((a, i) for i, a in enumerate(A))[1] assert f([3, 1, 2]) == 1
benchmark_functions_edited/f9235.py
def f(counts_dict): result = 0 for key in counts_dict.keys(): result += int(key, 2) * counts_dict[key] return result assert f( { '111': 1 } ) == 7
benchmark_functions_edited/f6322.py
def f(item: list): if type(item) == list: return sum(f(subitem) for subitem in item) else: return 1 assert f([10, 20, 30]) == 3
benchmark_functions_edited/f4212.py
def f(name): return len(name.split()) assert f("The quick brown fox jumps over the lazy dog") == 9
benchmark_functions_edited/f894.py
def f(x): "*** YOUR CODE HERE ***" return x[-1] assert f([5, 2, 6]) == 6
benchmark_functions_edited/f14360.py
def f(first: set, second: set) -> int: return int(bool(first & second)) assert f(set("abcdefghijklmnopqrstuvwxyz"), set("ijkl")) == 1
benchmark_functions_edited/f13015.py
def f(nw, src, dst): try: return len(set(nw.neighbors(src)).intersection(set(nw.neighbors(dst)))) / len(set(nw.neighbors(src)).union(set(nw.neighbors(dst)))) except: return 0 assert f(None, 1, 2) == 0
benchmark_functions_edited/f9317.py
def f(x, y, fn): return sum([(i - j) ** 2 for i, j in zip(map(fn, x), y)]) assert f(range(1, 10), range(1, 10), lambda x: x) == 0
benchmark_functions_edited/f12909.py
def f(clustering): levels = [] for el in clustering: if isinstance(el, dict): levels.append(f(el['references'])) if not levels: return 1 else: return max(levels) + 1 assert f([]) == 1
benchmark_functions_edited/f367.py
def f(p, x): return p[0]*x + p[1] assert f( (0,1), 1 ) == 1
benchmark_functions_edited/f8931.py
def f(dictionary, key, value): if not key in dictionary.keys(): return value else: return dictionary[key] assert f(dict({0: 0, 1: 1}), 1, 2) == 1
benchmark_functions_edited/f7471.py
def f(t1, t2): if t1 > t2: return t1 else: return t2 assert f(3, 5) == 5
benchmark_functions_edited/f8515.py
def f(x): new_str = str(x) i = 1 rev_str = new_str[::-1] if rev_str[-1] == "-": rev_str = rev_str.strip("-") i = -1 if (int(rev_str)>=2**31): return 0 return (int(rev_str)) * i assert f(2**31-1) == 0
benchmark_functions_edited/f1360.py
def f(s): if len(s) == 1: return int(s) else: return int(s[-1]) + 10*int(s[:-1]) assert f('000000') == 0
benchmark_functions_edited/f8142.py
def f(char): dictionary = {"+": 1, "-": 1, "*": 2, "/": 2, "^": 3} return dictionary.get(char, -1) assert f("/") == 2
benchmark_functions_edited/f12571.py
def f(predicted_value: float, real_label: float) -> float: return max(0, 1 - real_label * predicted_value) assert f(-1, -1) == 0
benchmark_functions_edited/f7787.py
def f(grid, x, y, m, n): if x == 0 and y == n - 1: return 1 if x < 0 or y > n-1: return 0 if grid[x][y]: return 0 return (f(grid, x-1, y, m, n) + f(grid, x, y+1, m, n))%1000003 assert f( [[1, 0, 0], [0, 1, 0], [0, 0, 1]], 2, 1, 3, 3 ) == 0
benchmark_functions_edited/f4800.py
def f(machine, laborCost, laborU): return machine + (laborCost * laborU) assert f(3, 2, 1) == 5
benchmark_functions_edited/f775.py
def f(s: str) -> int: return ord(s) - ord('0') assert f('8') == 8
benchmark_functions_edited/f8278.py
def f(num, count): if num == 0: return count-1 return f(num//10, count+1) assert f(1, 0) == 0
benchmark_functions_edited/f11958.py
def f(num1,num2): if(num1>num2): num = num1 den = num2 else: num = num2 den = num1 rem = num % den while(rem != 0): num = den den = rem rem = num % den gcd = den lcm = int(int(num1 * num2)/int(gcd)) return lcm assert f(1, 1) == 1
benchmark_functions_edited/f5111.py
def f(r, g, b): return ((r & 0xF0) << 8) | ((g & 0xFC) << 3) | (b >> 3) assert f(0, 0, 0) == 0
benchmark_functions_edited/f4591.py
def f(perimeter, apothem): # You have to code here # REMEMBER: Tests first!!! return (1/2) * perimeter * apothem assert f(2, 1) == 1
benchmark_functions_edited/f696.py
def f(base, height): return float(base * height) assert f(2, 4) == 8
benchmark_functions_edited/f6388.py
def f(n): try: n = int(n) except: print('Error validating number. Please only use positive integers.') return 0 else: return n assert f(True) == 1
benchmark_functions_edited/f14512.py
def f(nums): for num in nums: if int(str(nums).count(str(num))) > 1: return num return None assert f([1, 2, 1, 4, 3, 12]) == 1
benchmark_functions_edited/f39.py
def f(x, p): return pow(x, p - 2, p) assert f(3, 7) == 5
benchmark_functions_edited/f38.py
def f(x): return int(x >= 0) assert f(-3) == 0
benchmark_functions_edited/f849.py
def f(x, A, x0, C): return A*(x - x0)**2 + C assert f(0, 1, 0, 1) == 1
benchmark_functions_edited/f2646.py
def f(data): n = len(data) if n < 1: return 0 return sum(data)/float(n) assert f([1, 2, 3]) == 2
benchmark_functions_edited/f8541.py
def f(s): if s.rfind('\n') == -1: return len(s) return len(s) - s.rfind('\n') - len('\n') assert f('a\n') == 0
benchmark_functions_edited/f12027.py
def f(score, opponent_score, margin=8, num_rolls=5): def beacon(x): return 1+abs(x//10 - x%10) bacon_opponent = beacon(opponent_score) if bacon_opponent >= margin: result = 0 else: result = num_rolls return result assert f(0, 0) == 5
benchmark_functions_edited/f5496.py
def f(value, fallback=0): if value is None: return fallback try: return int(value) except ValueError: return fallback assert f(True) == 1
benchmark_functions_edited/f3721.py
def f(n, acc=1): if n < 2: return 1 * acc return f(n - 1, acc * n) assert f(1) == 1
benchmark_functions_edited/f14135.py
def f(v0, t, g=9.81): height = v0*t - 0.5*g*t**2 return height assert f(10, 0) == 0
benchmark_functions_edited/f5064.py
def f(n, k): result = 1 for i in range(1, k+1): result = result * (n-i+1) // i return result assert f(6, 5) == 6
benchmark_functions_edited/f9117.py
def f(password_list): count = 0 for password in password_list: if (password["min"] <= password["password"].count(password["char"]) <= password["max"]): count += 1 return count assert f([{"char": "a", "min": 2, "max": 9, "password": "<PASSWORD>"}, {"char": "b", "min": 2, "max": 9, "password": "<PASSWORD>"}]) == 0
benchmark_functions_edited/f9689.py
def f(benchmark_list): longest_name = 1 for bc in benchmark_list: if len(bc['name']) > longest_name: longest_name = len(bc['name']) return longest_name assert f( [{'name': 'foo', 'id': 'abcde', 'date': '2018-04-15T12:04:00Z'}] ) == 3
benchmark_functions_edited/f12138.py
def f(linear): linear = float(linear) if linear <= 0.0031308: srgb = linear * 12.92 else: srgb = 1.055 * pow(linear, 1. / 2.4) - 0.055 return srgb assert f(0) == 0
benchmark_functions_edited/f2314.py
def f(l): return (l << 2) / 3 + 2 assert f(3) == 6
benchmark_functions_edited/f3636.py
def f(state) -> int: return min(state, 100 - state) assert f(1) == 1
benchmark_functions_edited/f1916.py
def f(x): from math import sqrt return sqrt(x) assert f(49) == 7
benchmark_functions_edited/f10133.py
def f(x, pars): result = x*0 # do x*0 to keep shape of x (scalar or array) if len(pars) == 0: return result result += pars[-1] for i in range(1, len(pars)): result += pars[-i-1]*x x = x*x return result assert f(1, [1,1]) == 2
benchmark_functions_edited/f12218.py
def f(time, value, tstep): return value if time() >= tstep else 0 assert f(lambda: 2, 1, 2) == 1
benchmark_functions_edited/f13237.py
def f(lph): kgps = (0.875/3600) * lph return kgps assert f(0) == 0
benchmark_functions_edited/f12226.py
def f(data1, data2): set_difference = None if data1 is None or data2 is None: set_difference = None else: set_difference = len(set(data1).difference(data2)) return set_difference assert f(range(10), range(10)) == 0
benchmark_functions_edited/f10567.py
def f(x): return x * (x > 0) assert f(3) == 3
benchmark_functions_edited/f14000.py
def f(var1, var2, long_var_name='hi'): print(long_var_name) return var1 + var2 assert f(1, 3) == 4
benchmark_functions_edited/f5087.py
def f(n, minimum, maximum): return max(minimum, min(n, maximum)) assert f(3, 3, 1) == 3
benchmark_functions_edited/f7332.py
def f(n: int) -> int: square_of_sum = (n*(n+1) // 2)**2 sum_of_squares = n*(n+1)*(2*n+1) // 6 return square_of_sum - sum_of_squares assert f(1) == 0
benchmark_functions_edited/f2957.py
def f(x: int, y: int): if y == 0: return x return f(y, x%y) assert f(1024, 1234) == 2
benchmark_functions_edited/f13832.py
def f(s: str, t: str) -> int: s = ' ' + s t = ' ' + t d = {} S = len(s) T = len(t) for i in range(S): d[i, 0] = i for j in range (T): d[0, j] = j for j in range(1, T): for i in range(1, S): if s[i] == t[j]: d[i, j] = d[i-1, j-1] else: d[i, j] = min(d[i-1, j] + 1, d[i, j-1] + 1, d[i-1, j-1] + 1) return d[S-1, T-1] assert f("101", "100") == 1
benchmark_functions_edited/f4636.py
def f(data, base=None): if base is None or base == 0: return data return data + -data % base assert f(2, 5) == 5
benchmark_functions_edited/f3327.py
def f(value, maxvalue, minvalue): value = (value - minvalue) / (maxvalue - minvalue) return value assert f(100, 100, 1000) == 1
benchmark_functions_edited/f2011.py
def f(result): # pragma: no cover return result.get('entities', []) assert f({"entities": 1}) == 1
benchmark_functions_edited/f1071.py
def f(time, D_alpha, alpha): return 2.0*D_alpha*time**alpha assert f(1, 1, 0) == 2
benchmark_functions_edited/f9959.py
def f(*x): if len(x) == 1 and isinstance(x[0], list): x = x[0] p = 1 for i in x: if hasattr(i, "__mul__"): p *= i return p assert f([1, 2, 3]) == 6
benchmark_functions_edited/f1389.py
def f(some_list): return some_list[-1] assert f(range(5)) == 4
benchmark_functions_edited/f6601.py
def f(x, y, d): positive = (x - y) % d negative = (y - x) % d if positive > negative: return -negative return positive assert f(2, 2, 5) == 0
benchmark_functions_edited/f3788.py
def f(lst, e): try: return lst.index(e) except: return len(lst) assert f(range(3), 3) == 3
benchmark_functions_edited/f4243.py
def f(x, c): x &= 0xFFFFFFFFFFFFFFFF return ((x >> c) | (x << (64 - c))) & 0xFFFFFFFFFFFFFFFF assert f(0, 22) == 0
benchmark_functions_edited/f8939.py
def f(from_bytes: bytes) -> int: return int.from_bytes(from_bytes, byteorder='little', signed=False) assert f(b'\x00\x00\x00\x00\x00\x00\x00\x00') == 0
benchmark_functions_edited/f4073.py
def f(number): if number > 0: return 1 elif number < 0: return -1 else: return 0 assert f(1.0001) == 1
benchmark_functions_edited/f13952.py
def f(a: int, b: int) -> int: return a + b if a != 0 and b != 0 else 42 assert f(2, 2) == 4
benchmark_functions_edited/f7715.py
def f(substring, string): counter = 0 index = string.find(substring) while index >= 0: counter += 1 index = string.find(substring, index + 1) return counter assert f('bar', 'foo') == 0
benchmark_functions_edited/f12477.py
def f(type, previous): one = ["transmission"] two = ["memory"] three = ["processing"] if type in one: return 0 if type in two: return previous if type in three: return 0 print("type not found. Exiting.") exit() assert f( "transmission", 0 ) == 0
benchmark_functions_edited/f2920.py
def f(word, letter): return word.lower().count(letter.lower()) assert f( 'sAnita', 't') == 1
benchmark_functions_edited/f13268.py
def f(p0,p1,p2): p0x = p0[0] p0y = p0[1] p1x = p1[0] p1y = p1[1] p2x = p2[0] p2y = p2[1] return ((p1x-p0x)*(p2y-p0y)-(p2x-p0x)*(p1y-p0y)) assert f( (0,0), (1,1), (0,0) ) == 0
benchmark_functions_edited/f5244.py
def f(dummy: int, key: int, biggest) -> int: if dummy < 0: return -(dummy + (biggest + 1) * (key - 1) + 1) return dummy assert f(5, 2, 1) == 5
benchmark_functions_edited/f13927.py
def f(K,L): if(len(K) == len(L)): try: return(sum([x*y for x,y in zip(K,L)]) ) except ValueError: print('elements of K and L are not all numeric') exit() else: print("K and L are not of the same length") assert f([0,1,2],[0,1,2]) == 5
benchmark_functions_edited/f2015.py
def f(timestamp: int, rate: int) -> int: return int(int(timestamp << 16) / rate) << 16 assert f(0, 1) == 0
benchmark_functions_edited/f13871.py
def f(binstr): # this will cast to long as needed num = 0 for charac in binstr: # the most significant byte is a the start of the string so we multiply # that value by 256 (e.g. <<8) and add the value of the current byte, # then move to next byte in the string and repeat num = (num << 8) + ord(charac) return num assert f(b'') == 0
benchmark_functions_edited/f14184.py
def f(ratings_1, ratings_2, r): distance = 0 commonRatings = False for key in ratings_1: if key in ratings_2: distance += pow(abs(ratings_1[key] - ratings_2[key]), r) commonRatings = True if commonRatings: return pow(distance, 1/r) else: return 0 assert f( {'The Strokes: 3.0', 'Slightlyt Stoopid: 2.5'}, {'Slightlyt Stoopid: 3.5', 'The Strokes: 4.0'}, 1) == 0
benchmark_functions_edited/f3604.py
def f(n,d): if n<1 or d<2: return -1 count=0 while n%d==0: n//=d count+=1 return count assert f(10, 9) == 0
benchmark_functions_edited/f7842.py
def f(torr): return(torr/0.0075062) assert f(0) == 0
benchmark_functions_edited/f12960.py
def f(iterable, pred=None, default=None): # f([a,b,c], default=x) --> a or b or c or x # f([a,b], fn, x) --> a if fn(a) else b if fn(b) else x return next(filter(pred, iterable), default) assert f(range(1, 10), lambda x: x % 5 == 0) == 5
benchmark_functions_edited/f9998.py
def f(a,b): return sorted([a,b])[0] assert f(6, 10) == 6
benchmark_functions_edited/f6916.py
def f(perm, index): order = 1 curr = index while index != perm[curr]: order += 1 curr = perm[curr] return order assert f(range(10), 5) == 1
benchmark_functions_edited/f2333.py
def f(inpt): return int(float(inpt)) assert f(0) == 0
benchmark_functions_edited/f308.py
def f(t, a): return a*t**(0.5) assert f(1, 1) == 1
benchmark_functions_edited/f12585.py
def f(abData, off): cbData = len(abData); if off >= cbData: return -1; offCur = off; while abData[offCur] != 0: offCur = offCur + 1; if offCur >= cbData: return -1; return offCur - off; assert f(b'\x00', 0) == 0
benchmark_functions_edited/f10943.py
def f(s): crc = 0 for b in s: b = ord(b) crc = crc ^ (b << 8) for i in range(0, 8): if crc & 0x8000 == 0x8000: crc = (crc << 1) ^ 0x1021 else: crc = crc << 1 crc = crc & 0xffff return crc assert f(b'') == 0
benchmark_functions_edited/f9366.py
def f(number, *args, **kwargs): if len(kwargs) > 0 and kwargs['signed'] and number[0] == '1': return -(-(int(number, *args))+(2**len(number))) return int(number, *args) assert f('100', 2) == 4
benchmark_functions_edited/f8533.py
def f(s): for i, c in enumerate(s): if c.isalpha(): return i + 1 raise Exception("No alpha characters in string: {}".format(s)) assert f("a") == 1
benchmark_functions_edited/f12827.py
def f(tasks): U = 0 for task in tasks: U += (task.c/task.t) return round(U, 3) assert f([]) == 0
benchmark_functions_edited/f13093.py
def f(digits): weights_for_check_digit = [2, 4, 8, 5, 0, 9, 7, 3, 6, 1, 2, 4, 8] check_digit = 0 for i in range(0, 13): check_digit += weights_for_check_digit[i] * digits[i] check_digit %= 11 if check_digit == 10: check_digit = 0 return check_digit assert f([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0
benchmark_functions_edited/f8559.py
def ror (endv, iv): return (endv - iv)/iv assert f(1000, 1000) == 0
benchmark_functions_edited/f919.py
def f(elt): try: return elt['n'] except KeyError: return 0 assert f({'n': 3}) == 3
benchmark_functions_edited/f11812.py
def f(lmbda, A0, A1, A2, A3, A4, A5): n_squ = A0 + A1*lmbda**2 + A2*lmbda**-2 + A3*lmbda**-4 + A4*lmbda**-6 + A5*lmbda**-8 return(n_squ**0.5) assert f(1, 0, 0, 0, 0, 0, 0) == 0
benchmark_functions_edited/f13028.py
def f(referencedIDs, identifiedElements): keepTags = ['font'] num = 0 for id in identifiedElements: node = identifiedElements[id] if id not in referencedIDs and node.nodeName not in keepTags: node.removeAttribute('id') num += 1 return num assert f(set(['id1']), {'id1': 1}) == 0
benchmark_functions_edited/f3916.py
def f(opt_params, key): return opt_params.get(key, None) assert f({'a': 1, 'b': 2}, 'a') == 1
benchmark_functions_edited/f9534.py
def f(i): import time return int(time.mktime(time.strptime(i, "%d/%m/%Y %H:%M:%S"))) assert f("01/01/1970 00:00:00") == 0
benchmark_functions_edited/f7564.py
def f(version): key = None if version == 2.5: key = 2 else: key = int(version - 1) assert(0 <= key <= 2) return key assert f(1.0) == 0
benchmark_functions_edited/f14478.py
def f(word): word_dict = { "one": 1, "two": 2, "three": 3, "four": 4, "five": 5, "six": 6, "seven": 7, "eight": 8, "nine": 9, "ten": 10, "eleven": 11, "twelve": 12, "zero": 0, 0: 0, } return word_dict[word] assert f(0) == 0
benchmark_functions_edited/f9327.py
def f(n): if n ==0: return 0 if n ==1: return 1 else: return n + f(n-2) assert f(1) == 1