file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f10821.py
def f(m, n): if m == 0: return 2 else: sum_ = 3*f(m-1, n) i = 2 while m-i >= 0: sum_ += (-1)**(i+1) * f(m-i, n) i += 1 sum_ += ((-1)**(n % 2))*(m % 2) return sum_ assert f(0, 5) == 2
benchmark_functions_edited/f9488.py
def f(ht): return (ht / 100) ** 2 assert f(100) == 1
benchmark_functions_edited/f13692.py
def f(grad, grad_old, grad_new): return grad - grad_old + grad_new assert f(0, 0, 1) == 1
benchmark_functions_edited/f7861.py
def f(r): try: return len(r) except TypeError: return 0 assert f({'a': 0}) == 1
benchmark_functions_edited/f10513.py
def f(l): if len(l) == 0: return None if len(l) == 1: return l[0] lsum = l[0] for d in l[1:]: lsum += d return lsum / len(l) assert f( [3, 4, 5] ) == 4
benchmark_functions_edited/f8061.py
def f(frame): return sum( [ abs(x)**2 for x in frame ] ) / len(frame) assert f( [0, 0, 0, 0] ) == 0
benchmark_functions_edited/f12075.py
def f(letter: str) -> int: return [ord(char) - 96 for char in letter.lower()][0] - 1 assert f("C") == 2
benchmark_functions_edited/f10072.py
def f(fl): if fl > 1.0: return 0 else: fl_splitted = str(fl).split(".")[-1] N_unstripped = len(fl_splitted) N_left_stripped = len(fl_splitted.lstrip("0")) return N_unstripped - N_left_stripped assert f(12345.0) == 0
benchmark_functions_edited/f3784.py
def f(value): try: value = int(value) except: value = None return value assert f(False) == 0
benchmark_functions_edited/f1148.py
def f(f): if not f: return 0 else: return f[0] assert f({}) == 0
benchmark_functions_edited/f9455.py
def f(p): A = 0 for i in range(len(p)): A += p[i - 1][0] * p[i][1] - p[i][0] * p[i - 1][1] return A / 2. assert f( [[0, 0], [2, 0], [0, 2], [0, 0]] ) == 2
benchmark_functions_edited/f10688.py
def f(alist): csum = 0 factor = 0 for item in alist: csum += item*factor factor += 1 return csum assert f( [0, 0, 0, 0, 0, 0, 0, 0, 0]) == 0
benchmark_functions_edited/f7414.py
def f(di, t, qoi, b): return qoi / ((1 + b * di * t) ** (1 / b)) assert f(0, 1, 1, 1) == 1
benchmark_functions_edited/f11193.py
def f(ks, s, hw): if hw % s == 0: pad = max(ks - s, 0) else: pad = max(ks - (hw % s), 0) if pad % 2 == 0: return pad // 2 else: return pad // 2 + 1 assert f(3, 1, 16) == 1
benchmark_functions_edited/f1213.py
def f(nsec: int) -> int: return (nsec + 500) // 10 ** 3 assert f(1500) == 2
benchmark_functions_edited/f681.py
def f(letter): return ord(str.lower(letter))-96 assert f( "E" ) == 5
benchmark_functions_edited/f4081.py
def f(x, y): return -2 * x * y / (x ** 2 + y ** 2) ** 2 assert f(1, 0) == 0
benchmark_functions_edited/f12419.py
def f(expr): return expr.count("(") - expr.count(")") assert f( "1+2" ) == 0
benchmark_functions_edited/f7377.py
def f(base): base = base.upper() if base == 'A': return 0 if base == 'C': return 1 if base == 'G': return 2 if base == 'T': return 3 return 4 assert f( 'X' ) == 4
benchmark_functions_edited/f3232.py
def f(x, x_0, x_1, y_0, y_1): return y_0+(x-x_0)*(y_1-y_0)/(x_1 - x_0) assert f(2, 0, 2, 0, 1) == 1
benchmark_functions_edited/f2547.py
def f(s): return int(s, 2) assert f(str(1)) == 1
benchmark_functions_edited/f13703.py
def f(mol_condition_before, mol_condition_after, num_divided_mols): if num_divided_mols == 1: return 0. return (mol_condition_after.count(1) - mol_condition_before.count(1)) / num_divided_mols assert f( [1, 1, 0, 0, 0], [0, 0, 1, 1, 0], 2) == 0
benchmark_functions_edited/f8459.py
def f(tms): year, month, day = tms[:3] if day > 31: return 0 if month in [4, 6, 9, 11] and day > 30: return 0 if month == 2 and (year%4 == 0 and day > 29 or day > 28): return 0 return 1 assert f( (2005, 7, 1) ) == 1
benchmark_functions_edited/f3368.py
def f(actualResult, forecastResult): return (actualResult - forecastResult)**2 assert f(1, 2) == 1
benchmark_functions_edited/f8921.py
def f(index, dim): if index is not None and index < 0: index %= dim return index assert f(-1, 10) == 9
benchmark_functions_edited/f10284.py
def f(shape_values): result = 1 for val in shape_values: result *= val return result assert f([1, 2, 3]) == 6
benchmark_functions_edited/f51.py
def f(x,y): return x*y/(x+y) assert f(0,2) == 0
benchmark_functions_edited/f8442.py
def f(strings, s): for n, t in enumerate(strings): if t == s: return n strings.append(s) return len(strings) - 1 assert f(("Goodbye world!",), "Goodbye world!") == 0
benchmark_functions_edited/f11350.py
def f(codelist): max_length = 0 for term in codelist.split(", "): if len(term) > max_length: max_length = len(term) return max_length assert f("1, 2, 3, 4, 5, 6, 7, 8, 9, 10") == 2
benchmark_functions_edited/f3715.py
def f(n): a, b = 0, 1 for i in range(n-1): a, b = b, a + b return a assert f(0) == 0
benchmark_functions_edited/f7126.py
def f(register, cur_instruction, target, other_register): try: register[target] = other_register['sound'].pop(0) except IndexError: return cur_instruction - 1 return cur_instruction assert f( {'register': 0,'sound': [1, 2, 3]}, 0, 'target', {'sound': [4, 5]} ) == 0
benchmark_functions_edited/f4153.py
def f(text, default): try: return int(text) except (ValueError, TypeError): return default assert f("", 3) == 3
benchmark_functions_edited/f4315.py
def f(fpath): if "EN_" in fpath: return 0 else: return 1 assert f(r"EN_uk.txt") == 0
benchmark_functions_edited/f8802.py
def f(selectpicker_id: str) -> int: min_values = { "0": 0, "1": 19, "2": 26, "3": 36, "4": 46, "5": 56 } return min_values.get(selectpicker_id, 0) assert f(0) == 0
benchmark_functions_edited/f11299.py
def f(a: int) -> int: pierwsza = a druga = int(str(a)*2) trzecia = int(str(a) * 3) czwarta = int(str(a) * 4) wynik = pierwsza + druga + trzecia + czwarta return wynik assert f(0) == 0
benchmark_functions_edited/f6685.py
def f(response): if response["result"]["workerType"] == 1: err_cd = 0 else: err_cd = 1 return err_cd assert f({"result": {"workerType": 2}}) == 1
benchmark_functions_edited/f14066.py
def f(y): y = sorted(y) n = len(y) if n%2 == 1: return y[n//2] else: i = n//2 return (y[i - 1] + y[i])/2 assert f([1, 3, 5, 7, 9]) == 5
benchmark_functions_edited/f5216.py
def f(n: int) -> int: f0: int = 0 f1: int = 0 f2: int = 1 for _ in range(n): f0, f1, f2 = f1, f2, f0 + f1 + f2 return f0 assert f(2) == 1
benchmark_functions_edited/f9658.py
def f(syllableCounter, phonemeCounter, seq): total = 0 n = 0 while n < (syllableCounter - 1): total += len(seq[n]) n += 1 total += phonemeCounter return (total - 1) assert f(1, 3, ["a"]) == 2
benchmark_functions_edited/f3390.py
def f(GPE,mass,height): result=GPE/mass*height return result assert f(0, 10, 1) == 0
benchmark_functions_edited/f14208.py
def f(x, s0=0.08333, theta=0.242): c0 = 1.0 / s0 / (1 - 1.0 / -theta) if x < 0: return 0 elif x <= s0: return c0 * x else: return c0 * (s0 + (s0 * (1 - (x / s0) ** -theta)) / theta) assert f(-1, 2) == 0
benchmark_functions_edited/f14251.py
def f(terms): sum = 0 total = 0 for i in terms.keys(): sum = sum + terms[i] total = total + terms[i]/float(i) assert(abs(sum-1.0) < .0001) return total assert f( { 1:1 } ) == 1
benchmark_functions_edited/f13718.py
def f(profileDict): assert isinstance(profileDict, dict) # Assume that the number of OpenMP threads is the same on all processes, so # getting the min, max or mean will give the same value return profileDict["info"]["metrics"]["num_omp_threads_per_process"]["max"] assert f({"info": {"metrics": {"num_omp_threads_per_process": {"min": 3, "max": 3}}}}) == 3
benchmark_functions_edited/f5568.py
def f(parameter, default_val, base=10): try: return int(str(parameter), base) except ValueError: return default_val assert f('1', 0) == 1
benchmark_functions_edited/f9751.py
def f(chr_name): chr_id = chr_name[3:] if chr_id == 'X': return 23 elif chr_id == 'Y': return 24 elif chr_id == 'M': return 25 return int(chr_id) assert f('chr1') == 1
benchmark_functions_edited/f12213.py
def f(length: int, reversed_idx: int) -> int: return length - 1 - reversed_idx assert f(5, 0) == 4
benchmark_functions_edited/f2737.py
def f(colour): r, g, b = colour return (r + g + b) / 3 assert f((0, 0, 0)) == 0
benchmark_functions_edited/f5083.py
def f(array, word_size): result = 0 for val in array: result *= 2 ** word_size result += val return result assert f(bytearray([0b00000001]), 1) == 1
benchmark_functions_edited/f2310.py
def f(integer): c = 1 while ((2*c - 1)*(2*c - 1)) <= integer: c += 1 return c assert f(0) == 1
benchmark_functions_edited/f6998.py
def f(arr, index): if index >= len(arr): return 0 if arr[index] == 11: return 1 + f(arr, index+1) else: return f(arr, index+1) assert f([1, 11, 11], 4) == 0
benchmark_functions_edited/f9979.py
def f(row): prim_key = row['das']['primary_key'] key, att = prim_key.split('.') if isinstance(row[key], list): for item in row[key]: if item.has_key(att): return item[att] else: return row[key][att] assert f( {'das': {'primary_key':'record.ID'},'record': {'ID': 0}}) == 0
benchmark_functions_edited/f1900.py
def f(n): if n == 1 or n == 2: return 1 return f(n - 1) + f(n - 2) assert f(3) == 2
benchmark_functions_edited/f6832.py
def f(limit, ubound=100): limit = int(limit) assert limit > 0, "limit must be positive" assert limit <= ubound, "limit exceeds max" return limit assert f(2) == 2
benchmark_functions_edited/f693.py
def f(a): if a < 0: return 0 else: return 1 assert f(-42) == 0
benchmark_functions_edited/f1628.py
def f(r): return int(r.get("wedAant", 0)) assert f( {"random": "hello"} ) == 0
benchmark_functions_edited/f9185.py
def f(m: list, x, y) -> int: if x == -1 or y == -1 or y == len(m): return 0 if x == len(m[y]): return 0 if m[y][x] == '#': return 1 return 0 assert f( ["#.#..#..###", "##......#...", "##......#...", "#.#..#..###", ".#...#....#.", "..##....#...", "#...##...#..", ".#..#...#.#."], 3, 5) == 1
benchmark_functions_edited/f563.py
def f(kA, kB, NA, NB): return kA / NA - kB / NB assert f(1, 2, 1, 2) == 0
benchmark_functions_edited/f1182.py
def f(number): return (number * (number + 1)) / 2 assert f(0) == 0
benchmark_functions_edited/f10797.py
def f(path): import re version_matcher = re.compile("([\w\d/]+_v)([0-9]+)([\w\d._]+)") m = re.match(version_matcher, path) if m: return int(m.group(2)) assert f( "A/B/C/C_v000/abc.png") == 0
benchmark_functions_edited/f11275.py
def f(x: float, y: float) -> float: return (x - y) ** 2 assert f(0, 1) == 1
benchmark_functions_edited/f4411.py
def f(x0: float, y0: float, x1: float, y1: float) -> float: return abs(x0 - x1) + abs(y0 - y1) assert f(-2, 1, 1, 1) == 3
benchmark_functions_edited/f9163.py
def f(z: complex , n_max: int = 200, r_max: float = 2): zn = z for n in range(n_max): if abs(zn) > r_max: return n zn = zn*zn + z return 0 assert f(-1.0+1.0j) == 2
benchmark_functions_edited/f9369.py
def f(char, other): return int(char) + int(other) assert f(1, 3) == 4
benchmark_functions_edited/f8906.py
def f(k): # BN databases should always go first if k.endswith('.bndb'): return 0 # Definition files matter more than raw files if any(k.endswith(e) for e in ('.def', '.idt')): return 5 return 10 assert f(r'C:\Program Files\IDA\my_file.idb.bndb') == 0
benchmark_functions_edited/f6096.py
def f(data, freq): return sum([freq[chr(ch)] for ch in data]) assert f(b"abc", {"a": 1, "b": 1, "c": 2}) == 4
benchmark_functions_edited/f4096.py
def f(a, b): # Using `-1 * a` means everything works even when I've forgotten to # override __sub__ in classes. return a*b + (-1)*b*a assert f(1, 1) == 0
benchmark_functions_edited/f8514.py
def f(num1,num2): count = 0 for x, y in zip(str(num1), str(num2)): if x == y: count = count + 1 total = max(len(str(num1)), len(str(num1))) return count/float(total) assert f(123, 456) == 0
benchmark_functions_edited/f6303.py
def f(a, b): return ((a[0] - b[0])**2 + (a[1] - b[1])**2)**0.5 assert f( (1, 0), (0, 0) ) == 1
benchmark_functions_edited/f260.py
def f(num): return bin(num).count("1") assert f(0b00000000000000000000000000000001) == 1
benchmark_functions_edited/f12619.py
def f(x, y): if y != 0: return int(x) / int(y) else: print("Error! Divisor can't be 0") raise ZeroDivisionError assert f(0, 42) == 0
benchmark_functions_edited/f13494.py
def f(a: int, b: int) -> int: while a: a, b = b % a, a return b assert f(77, 300) == 1
benchmark_functions_edited/f1641.py
def f(letter): QScore = ord(letter) - 33 return QScore assert f('!') == 0
benchmark_functions_edited/f12882.py
def f(arr: list, length: int, index: int, prev_max: int) -> int: if index >= length: return 0 cur_max = 0 if arr[index] > prev_max: cur_max = arr[index] + f(arr, length, index + 1, arr[index]) return max(cur_max, f(arr, length, index + 1, prev_max)) assert f([0], 1, 0, 0) == 0
benchmark_functions_edited/f4191.py
def f(A, B, C): res = 1 % C while B > 0: if B & 1: # Odd res = (res * A) % C A = A**2 % C B >>= 1 return res assert f(3, 4, 5) == 1
benchmark_functions_edited/f5918.py
def f(x): return 1/2 * x ** 2 + 3 assert f(0) == 3
benchmark_functions_edited/f7540.py
def f(n): if n < 0: raise TypeError("Nonzero positive integers only") elif n == 0: return 1 else: return 1 << (n-1).bit_length() assert f(5) == 8
benchmark_functions_edited/f850.py
def f(x): return x * (x > 0) assert f(1) == 1
benchmark_functions_edited/f10162.py
def f(arr: list, start: int, end: int) -> int: i, j = start - 1, start while j < end: if arr[j] < arr[end]: i += 1 arr[i], arr[j] = arr[j], arr[i] j += 1 i += 1 arr[i], arr[end] = arr[end], arr[i] return i assert f( [5, 3, 7, 11, 1, 2, 6], 0, 1) == 0
benchmark_functions_edited/f4265.py
def f(a, b, c) : #print "Modulo of %0d^%0d mod %0d is %0d" % (a, b, c, (int(a)**int(b)) % int(c)) #print a,b,c; return ((int(a)**int(b)) % int(c)) assert f(1, 2, 3) == 1
benchmark_functions_edited/f12298.py
def f(x, a, b, c): return a * (x - b) ** 2 + c assert f(0, 1, 0, 2) == 2
benchmark_functions_edited/f12070.py
def f(n, data): import heapq data=list(data) n=float(n) return heapq.nlargest(int(len(data)*(n/100.0)), data)[-1] assert f(100, [1]) == 1
benchmark_functions_edited/f8164.py
def f(L1, L2): return sum(n for n in map(lambda x, y: x ** y, L1, L2)) assert f([0, 0, 0], [1, 2, 3]) == 0
benchmark_functions_edited/f12288.py
def f(input: str) -> int: if input == "DIAMANTE": return 1 elif input == "OURO": return 2 elif input == "PRATA": return 3 elif input == "BRONZE": return 4 raise ValueError(f"Club ({input}) desconhecido, verifique") assert f("DIAMANTE") == 1
benchmark_functions_edited/f10184.py
def f(ripe_object, name, value): # print(ripe_object) try: error = ripe_object["errormessages"]["errormessage"][0]["text"] if error.find("101"): return 1 else: return 2 except: return 0 assert f(None, "test", "test") == 0
benchmark_functions_edited/f8132.py
def f(n: int) -> int: from math import factorial return factorial(n) assert f(0) == 1
benchmark_functions_edited/f786.py
def f(rho, rhou, p): return rhou**2 / rho + p assert f(1, 1, 1) == 2
benchmark_functions_edited/f9805.py
def f(func, func_like, *args, **kwargs): try: return func_like(*args, **kwargs) except TypeError: return func(*args, **kwargs) assert f(lambda a: a, lambda b: b, 3) == 3
benchmark_functions_edited/f13985.py
def f(ord1, ord2): changes = 0 for i in range(10): for j in range(i + 1, 10): o1go2 = (ord1.index(i) > ord1.index(j) and ord2.index(i) > ord2.index(j)) o1lo2 = (ord1.index(i) < ord1.index(j) and ord2.index(i) < ord2.index(j)) if not (o1go2 or o1lo2): changes += 1 return changes assert f(list(range(10)), list(range(10))) == 0
benchmark_functions_edited/f1944.py
def f(entity): return sum(entity["score"]) / len(entity["score"]) assert f( { "score": [0, 0, 0], } ) == 0
benchmark_functions_edited/f11021.py
def f(a: float) -> float: if a < 0: raise ValueError("math domain error") return a ** (1 / 2) assert f(1) == 1
benchmark_functions_edited/f8393.py
def f(array, target, index=0): if index == len(array): return -1 elif array[index] == target: return index else: # move on the next index return f(array, target, index + 1) assert f( [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], 2) == 2
benchmark_functions_edited/f11300.py
def f(src: str, lineno: int) -> int: assert lineno >= 1 pos = -1 for _ in range(lineno): pos = src.find('\n', pos + 1) if pos == -1: return len(src) return pos assert f(r"a", 1) == 1
benchmark_functions_edited/f6444.py
def f(el1, el2, cdict, ldict): return min(len(cdict[el1] & cdict[el2]), len(ldict[el1] & ldict[el2])) \ / float(len(cdict[el1] & cdict[el2])) assert f(1, 2, {1: {2, 3}, 2: {1, 3}, 3: {1, 2}}, {1: {2, 3}, 2: {1, 3}, 3: {1, 2}}) == 1
benchmark_functions_edited/f1530.py
def f(d, key): return d.pop(key) assert f( {'a': 1, 'b': 2, 'c': 3}, 'b') == 2
benchmark_functions_edited/f425.py
def f(a: int): return sum(map(int, str(a))) assert f(1) == 1
benchmark_functions_edited/f1037.py
def f(value: float) -> int: return round(value / 0.0079) assert f(0.0000001) == 0
benchmark_functions_edited/f13823.py
def f(index, text, expansion_length=0): start = index - expansion_length end = index + expansion_length while start > 0 and end < (len(text) - 1): if text[start - 1] == text[end + 1]: start -= 1 end += 1 expansion_length += 1 else: break return expansion_length assert f(0, 'ABCD') == 0
benchmark_functions_edited/f6503.py
def f(search, names): for name_index, name in enumerate(names): if search == name.split('|')[0]: return name_index return None assert f( 'A2', ['A2', 'B2', 'C2', 'D2', 'E2'] ) == 0
benchmark_functions_edited/f8527.py
def f(t, transcript, delay=0): for i in range(len(transcript)): stime = transcript[i][1] if stime-delay - t >= 0: return i return len(transcript)-1 assert f(0, [(1, 0), (2, 0)], 1) == 1
benchmark_functions_edited/f7735.py
def f(vertex_1, vertex_2, edge_type, edge_dict): query_key = (vertex_1, vertex_2, edge_type) try: return edge_dict[query_key] except: return None assert f(1, 2, 1, {(1, 2, 1): 1, (2, 1, 1): 1}) == 1