file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f5983.py
def f(x, y, z): return x * y + z assert f(1, 2, 3) == 5
benchmark_functions_edited/f716.py
def f(p, q): return max([abs(p[i] - q[i]) for i in range(len(p))]) assert f((1, 2, 3), (1, 2, 3)) == 0
benchmark_functions_edited/f2001.py
def f(upper: int) -> int: n = upper - 1 return n * (n + 1) // 2 assert f(3) == 3
benchmark_functions_edited/f6039.py
def f(data, true_char): encode = lambda x: "1" if x == true_char else "0" binary = "".join(encode(x) for x in data) return int(binary, 2) assert f(b"00000000", b"1") == 0
benchmark_functions_edited/f13397.py
def f(n, m, i, j): x = ((2**(len(bin(n))-j)-1) << (j+1)) + (2**i - 1) return n & x | m << i assert f(0, 1, 1, 2) == 2
benchmark_functions_edited/f3462.py
def f(x): if x % 2 is 0: # x is even return int(x/2) return int(3*x+1) assert f(12) == 6
benchmark_functions_edited/f3246.py
def f(func, seq): return next((item for item in seq if func(item))) assert f(lambda x: x > 5, range(10)) == 6
benchmark_functions_edited/f4719.py
def f(num1, num2): # Separated into a function because >> has surprising precedence return (num1*num2) >> 20 assert f(1, 0) == 0
benchmark_functions_edited/f9760.py
def f(proposalId, distributionList): count = 0 for d in distributionList: if d.ProjectID == proposalId: count += 1 return count assert f(42, []) == 0
benchmark_functions_edited/f5478.py
def f(axis, stripped_axes): return axis - sum(1 if stripped_axis < axis else 0 for stripped_axis in stripped_axes) assert f(3, [0, 2]) == 1
benchmark_functions_edited/f5882.py
def f(s): d = 0 o = 0 for c in s: if c == '<': o += 1 elif (c == '>') and (o > 0): d += 1 o -= 1 return d assert f( '<abc' ) == 0
benchmark_functions_edited/f12465.py
def f(slots, events, X, **kwargs): overflow = 0 for row, event in enumerate(events): for col, slot in enumerate(slots): overflow += (event.demand - slot.capacity) * X[row, col] return overflow assert f( [], [], [], ) == 0
benchmark_functions_edited/f13062.py
def f(scores): total = 0 for i in range(len(scores)): total += scores[i] return total / len(scores) assert f([-10, 10]) == 0
benchmark_functions_edited/f4972.py
def f(from_cell, to_cell): return abs(from_cell[0] - to_cell[0]) + abs(from_cell[1] - to_cell[1]) assert f( (1, 1), (2, 2) ) == 2
benchmark_functions_edited/f13318.py
def f(text_label): prev_label = int(text_label) if prev_label not in [1, 2]: raise ValueError("Expecting label to 1 (non-speech) or 2 (speech); " "got {0}".format(prev_label)) return prev_label assert f(2) == 2
benchmark_functions_edited/f13282.py
def f(level, maxval): return float(level) * maxval / 10. assert f(0, 10) == 0
benchmark_functions_edited/f6311.py
def f(id): product_id_to_name = {} if id in product_id_to_name: return product_id_to_name[id] else: return id assert f(5) == 5
benchmark_functions_edited/f9545.py
def f(card, deck_size, shuffles, shuffler): position = card for shuffle, parameter in shuffles: shuffling = shuffler(shuffle) position = shuffling(deck_size, position, parameter) return position assert f(0, 20, [("shuffle", 5)], lambda s: lambda d, x, p: (x + p) % d) == 5
benchmark_functions_edited/f2759.py
def f(lst): if len(lst) == 0: return 0 x = lst[0] for v in lst[1:]: x *= v return x assert f([1, 2, 3]) == 6
benchmark_functions_edited/f8898.py
def f(iterable): try: return max(iterable) except ValueError: return None assert f(range(5)) == 4
benchmark_functions_edited/f8919.py
def f(*values): ret = tuple([v for v in values if v is not None]) if len(ret) == 1: return ret[0] return ret assert f(None, 1) == 1
benchmark_functions_edited/f3742.py
def f(offset_ms, samplerate): return int((- offset_ms) / 1000.0 * samplerate) assert f(0, 100000) == 0
benchmark_functions_edited/f2221.py
def f(t, n): d = (2*t) / ((n-1) ** 0.5) return d assert f(0, -1) == 0
benchmark_functions_edited/f12574.py
def f(timeSeries, duration): #complexity: O(n) +O(n) = O(n) poisoned = [] for t in timeSeries: #loop over all elements in timeSeries = O(n) poisoned += list(range(t, t+duration)) #O(1) b/c duration = constant poisoned_secs = set(poisoned) # O(n) return len(poisoned_secs) assert f( [1,2,3,4]...
benchmark_functions_edited/f2216.py
def f(a, b): if id(a) > id(b): return 1 if id(a) < id(b): return -1 return 0 assert f(1, None) == 1
benchmark_functions_edited/f7184.py
def f(x: int) -> int: if x == 0: return 1 s = 0 if x < 0: s = 1 while x != 0: x = x // 10 s += 1 return s assert f(1000) == 4
benchmark_functions_edited/f3077.py
def f(sign, exp): if sign == 1: return 1 assert sign == -1 return -1 if exp % 2 else 1 assert f(1, 2) == 1
benchmark_functions_edited/f14358.py
def f(confusion_table, actual_class, pred_class): if actual_class not in confusion_table: return 0 predictions = confusion_table[actual_class] if pred_class in predictions: return predictions[pred_class] else: return 0 assert f({}, 'C', 'C') == 0
benchmark_functions_edited/f605.py
def f(val): if val is None: return None return int(val) assert f("1") == 1
benchmark_functions_edited/f6901.py
def f(filename="", text=""): with open(filename, "w", encoding="utf-8") as f: f.write(text) return len(text) assert f("test.txt", "a\nb\nc") == 5
benchmark_functions_edited/f10823.py
def f(uuidtxt): score = 0 if uuidtxt != None: if len(uuidtxt) < 10: score = 0 elif uuidtxt.find("{") > -1 or uuidtxt.find("}") > -1 or uuidtxt.lower() != uuidtxt: score = 1 else: score = 2 return score assert f("99000000-0000-0000-0000-00000000000...
benchmark_functions_edited/f12178.py
def byte_alignment (bytes) : return (bytes ^ (bytes - 1)) & bytes assert f(511) == 1
benchmark_functions_edited/f2925.py
def f(banks): return banks.index(max(banks)) assert f([0, 1, 0, 0]) == 1
benchmark_functions_edited/f4854.py
def f(text): try: retval = float(text) except ValueError: retval = text return retval assert f("1") == 1
benchmark_functions_edited/f13945.py
def f(n: int = 4000000) -> int: even_fibs = [] a, b = 0, 1 while b <= n: if b % 2 == 0: even_fibs.append(b) a, b = b, a + b return sum(even_fibs) assert f(2) == 2
benchmark_functions_edited/f5988.py
def f(a, b): return a.real*b.real + a.imag*b.imag assert f(complex(2, 0), complex(1, 0)) == 2
benchmark_functions_edited/f8042.py
def f(op): if op == "vertex": return 0 elif op == "geometry": return 1 elif op == "fragment": return 2 raise RuntimeError("unknown GLSL file type: %s" % (op)) assert f("geometry") == 1
benchmark_functions_edited/f5571.py
def f(state: dict, i: int, fee: float = 0) -> float: if state['R'][i] == 0: return 0 else: return (state['Q'][i] / state['R'][i]) * (1 - fee) assert f( { 'R': [10000, 10000, 10000, 10000, 10000], 'Q': [10000, 20000, 10000, 20000, 10000], }, 2, ) == 1
benchmark_functions_edited/f8608.py
def f(_line): check = 0 for char in _line[:-1]: if char.isdigit(): check += int(char) if char == "-": check += 1 _check_val = check % 10 return(_check_val) assert f( "1 28283U 02054A 13331.51510638 .00001106 00000-0 28063-4 0 9997") == 5
benchmark_functions_edited/f1201.py
def f(height1, height2): return (height1 - height2) * 0.0065 assert f(100, 100) == 0
benchmark_functions_edited/f4399.py
def f( f, ll, if_empty): if len(ll) == 0: return if_empty else: return f(ll) assert f(len, [0, 1], 0) == 2
benchmark_functions_edited/f5117.py
def f(val): try: return int(val) except: return 0 assert f('') == 0
benchmark_functions_edited/f5461.py
def f(x, y): dist = 0 for i in range(0, len(x)): if x[i] != y[i]: dist += 1 return dist assert f(list("1111"), list("0000")) == 4
benchmark_functions_edited/f8696.py
def f(x, binary=True): if binary: _min, _theta = 0, .5 else: _min, _theta = -1, 0 if x > _theta: return 1 if x == _theta: return _theta return _min assert f(1000) == 1
benchmark_functions_edited/f11610.py
def f(list_of_nums): largest_diff = 0 for i in range(len(list_of_nums)-1): # The issue was here and -1 was added to fit it diff = abs(list_of_nums[i] - list_of_nums[i+1]) if diff > largest_diff: largest_diff = diff return largest_diff assert f([9, 8, 7]) == 1
benchmark_functions_edited/f7513.py
def f(string): try: scalar = float(string) return scalar except ValueError: return string assert f(1) == 1
benchmark_functions_edited/f6688.py
def f(n, alpha, beta, x): term1 = 2 * (n + alpha - 1) term2 = (n + beta - 1) term3 = (2 * n + alpha + beta) return term1 * term2 * term3 assert f(1, 1, 1, 1) == 8
benchmark_functions_edited/f671.py
def f(x, a, b, c): return a*x**2 + b*x + c assert f(0, 2, 3, 4) == 4
benchmark_functions_edited/f5075.py
def f(x, x1, x2, y1, y2): return (((y2 - y1) / (x2 - x1)) * (x - x1)) + y1 assert f(1, 1, 3, 1, 2) == 1
benchmark_functions_edited/f4975.py
def f(n, generator): for x in range(n): next(generator) return next(generator) assert f(0, iter([1, 2, 3])) == 1
benchmark_functions_edited/f1495.py
def f(text): return len(text.strip().splitlines()) assert f( "First line.\n" "Second line.\n" "\n" "Fourth line." ) == 4
benchmark_functions_edited/f5955.py
def f(verbose_level=1): global O_VERBOSE_LEVEL O_VERBOSE_LEVEL = verbose_level return O_VERBOSE_LEVEL assert f(5) == 5
benchmark_functions_edited/f547.py
def f(speed): tmp = speed / 10 return tmp * tmp assert f(0) == 0
benchmark_functions_edited/f5186.py
def f(word1, word2): return sum([1 for c in word1 if c in word2]) / max(len(word1), len(word2)) assert f('hello', 'hello') == 1
benchmark_functions_edited/f13651.py
def f(obj): assert isinstance(obj, (dict, list, set)), obj if not obj: return 0 if isinstance(obj, dict): obj = obj.values() elem = next(iter(obj)) if isinstance(elem, (dict, list, set)): return sum(f(v) for v in obj) else: return len(obj) assert f({1}) == 1
benchmark_functions_edited/f4708.py
def f(n): if n == 0: return 1 else: return n * f(n - 1) assert f(1) == 1
benchmark_functions_edited/f13531.py
def f(url): if "groups" in url: if "posts" in url: return 3 elif "members" in url: return 4 else: return 2 elif "posts" in url: return 1 else: return 0 assert f( "http://www.pinterest.com/groups/somegroup") == 2
benchmark_functions_edited/f11849.py
def f(*args): return args[0] if args else None assert f(1, 2, 3) == 1
benchmark_functions_edited/f7959.py
def f(built_prims, prim_type): retval = 0 for _, p in built_prims: if p.prim_type == prim_type: retval = max(retval, p.digest_len) return retval assert f((), 'unknown') == 0
benchmark_functions_edited/f11253.py
def f(string): if string == "": return 0 x = ord(string[0]) << 7 for c in string[1:]: x = ((1000003 * x) ^ ord(c)) & (1 << 32) x = (x ^ len(string)) return x assert f("") == 0
benchmark_functions_edited/f2134.py
def f(n): if n < 0: return 0 elif n > 1: return 1 else: return n assert f(0) == 0
benchmark_functions_edited/f11325.py
def f(person, geneSetDictionary): if person in geneSetDictionary["no_genes"]: gene_count = 0 elif person in geneSetDictionary["one_gene"]: gene_count = 1 else: gene_count = 2 return gene_count assert f(1, {"one_gene": {1}, "no_genes": {2}}) == 1
benchmark_functions_edited/f7120.py
def f(str): if not isinstance(str, list): str = str.splitlines(True) for line in str: if line.strip(): return len(line) - len(line.lstrip()) return 0 assert f( ) == 0
benchmark_functions_edited/f2330.py
def f(x: int, divisor: int) -> int: return int(x / divisor) * divisor assert f(3, 10) == 0
benchmark_functions_edited/f6240.py
def f(data, funcs): for func in funcs: data = func(data) return data assert f(3, [lambda n: n + 1]) == 4
benchmark_functions_edited/f10678.py
def f(n: int) -> int: count = 0 while n: n &= n-1 count += 1 return count assert f(15) == 4
benchmark_functions_edited/f11412.py
def f(lst1, lst2): # loop over each character while keeping a total of the squared differences # between lst1[i] and lst2[i]. This will return the square of the distance # between two 26 dimensional vectors. total = 0 for i in range(26): total += (lst1[i] - lst2[i]) * (lst1[i] - lst2[i]) return total assert ...
benchmark_functions_edited/f10214.py
def f(num, base=1): return num.__class__(base * round(float(num) / base)) assert f(6) == 6
benchmark_functions_edited/f5166.py
def f(ab: float, bc: float) -> int: from math import atan2, degrees return round(degrees(atan2(ab, bc))) assert f(1, 10) == 6
benchmark_functions_edited/f1259.py
def f(diagonal_1, diagonal_2): return (diagonal_1 * diagonal_2) / 2 assert f(0, 0) == 0
benchmark_functions_edited/f4195.py
def f(number): if number > 0: return 1 elif number < 0: return -1 else: return 0 assert f(1) == 1
benchmark_functions_edited/f6187.py
def f(A): len_ar = len(A) + 1 sum_length = int(len_ar * (len_ar + 1) / 2) return sum_length - sum(A) assert f([1]) == 2
benchmark_functions_edited/f11614.py
def f(a, key): ng = -1 ok = len(a) def is_ok(a, key, idx): if key <= a[idx]: return True else: return False while (abs(ok - ng) > 1): mid = (ok + ng) // 2 if is_ok(a, key, mid): ok = mid else: ng = mid return ...
benchmark_functions_edited/f8272.py
def f(s1,s2): if len(s1) != len(s2): raise ValueError("Undefined for sequences of unequal length") return sum(ch1 != ch2 for ch1, ch2 in zip(s1, s2)) assert f("ACTG", "AACC") == 3
benchmark_functions_edited/f159.py
def f(X, Y): return X[0]*Y[0] + X[1]*Y[1] assert f( (1, 1), (1, 1) ) == 2
benchmark_functions_edited/f12395.py
def f(x, y, max_iters): c = complex(x, y) z = 0.0j for i in range(max_iters): z = z * z + c if (z.real * z.real + z.imag * z.imag) >= 4: return i return max_iters assert f(0, 0, 1) == 1
benchmark_functions_edited/f361.py
def f(cond, b): return cond or b() assert f(True, lambda: 1 & 0) == 1
benchmark_functions_edited/f1378.py
def f(bra, ket): return 0 if bra == 0 or ket == 0 else bra == ket assert f(2, 2) == 1
benchmark_functions_edited/f2149.py
def f(elements): return max(elements) - min(elements) assert f([1] * 10) == 0
benchmark_functions_edited/f7888.py
def f(i,dx): total = 0 for e in range(len(i)): total = total + 2*i[e] total = total- (i[0]+i[-1]) return (dx*total/2) assert f( [1,2,3],1) == 4
benchmark_functions_edited/f9149.py
def f(angle1: float, angle2: float) -> float: return (abs(angle1 - angle2) + 180) % 360 - 180 assert f(0, 0) == 0
benchmark_functions_edited/f13639.py
def f(x): # check if x is positive if x < 0: print("Error: negative value supplied") return -1 else: print("Here we Go") # Intial guess for the square root z = x / 2.0; #continuously improve the guess #Adapted from https://tour.golang.org/flowcontrol/8 while abs...
benchmark_functions_edited/f7712.py
def f(eps): return 2*eps/(1 + abs(eps)**2) assert f(0.0) == 0
benchmark_functions_edited/f674.py
def f(U): return 0.5 * U * U assert f(0) == 0
benchmark_functions_edited/f6626.py
def f(hand): return len(hand) #returns the length of Hand assert f({}) == 0
benchmark_functions_edited/f9486.py
def f(item): if isinstance(item, tuple): return item[0] return item assert f(1) == 1
benchmark_functions_edited/f7688.py
def f(a, r, n=7): total = 0 for i in range (0, n): total = total + a *r ** i return total assert f(8, 1, 1) == 8
benchmark_functions_edited/f14014.py
def f(item, mapper, unknown="@@@UNKNOWN@@@"): if item in mapper.keys(): return mapper[item] return mapper["@@@UNKNOWN@@@"] if unknown is None: unknown = len(mapper) return mapper.get(item, unknown) assert f(1, {1: 1}) == 1
benchmark_functions_edited/f761.py
def f(x, a, b): return a + b * x assert f(2, 1, 2) == 5
benchmark_functions_edited/f4396.py
def f(array): maximum = 0 for v in array: maximum = max(v, maximum) return maximum assert f( [1, 2, 3, 4] ) == 4
benchmark_functions_edited/f6313.py
def f(ori_offset, offset_mapping): for index, span in enumerate(offset_mapping): if span[0] <= ori_offset < span[1]: return index return -1 assert f(2, [(0, 2), (2, 4), (4, 6)]) == 1
benchmark_functions_edited/f2742.py
def f(x: int, n:int) -> int: if n >= 0: return x & ((1 << n) - 1) else: return x & (-1 << -n) assert f(1, 1) == 1
benchmark_functions_edited/f3659.py
def f(v1, v2): result = v1 ^ v2 return float(bin(result).count('1')) assert f(10, 90) == 2
benchmark_functions_edited/f8730.py
def f(line): sum = 0 cnt = 0 for i in range(0, len(line[:-1]), 3): if not '--' in line[i]: cnt += 1 sum += int(line[i]) return sum / cnt assert f(list('1--1')) == 1
benchmark_functions_edited/f7191.py
def f(n): if n % 1 >= 0.5: r = int(n) + 1 else: r = int(n) return r assert f(1) == 1
benchmark_functions_edited/f10813.py
def f(date_str: str) -> int: y, m, d = map(int, date_str.split(".")) return (y - 2200) * 360 + (m - 1) * 30 + d - 1 assert f("2200.01.01") == 0
benchmark_functions_edited/f12502.py
def f(str1, str2): # ensure length of str1 >= str2 if len(str2) > len(str1): str1, str2 = str2, str1 # distance is difference in length + differing chars distance = len(str1) - len(str2) for index, value in enumerate(str2): if value != str1[index]: distance += 1 retu...
benchmark_functions_edited/f3261.py
def f(square_size): return int(sum(range(1, square_size ** 2 + 1)) / square_size) assert f(1) == 1
benchmark_functions_edited/f6849.py
def f(link_counters): for processor in link_counters.values(): if 'to_write' in processor: return processor['to_write'] assert f( { 0: {'to_write': 1} } ) == 1
benchmark_functions_edited/f3400.py
def f(node) -> int: if node is None: return 0 else: return node.color assert f(None) == 0