file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f8449.py
def f(valores_acumulados): for val in valores_acumulados: if val == 4: return 1 return 0 assert f([1, 1, 1, 1, 2, 2]) == 0
benchmark_functions_edited/f6189.py
def f(a: int, b: int) -> int: a = a & 0xFFFF r = a % b if a > 0x7FFF: return -b + (r - 0x10000) % b return r assert f(-0, -5) == 0
benchmark_functions_edited/f4386.py
def f(int_list): for k in int_list: if int_list.count(k) % 2: return k return None assert f([1, 2, 3, 4, 5, 6, 7, 8, 9]) == 1
benchmark_functions_edited/f9268.py
def f(number): init_array = [0, 1] for idx in range(2, number + 1): init_array.append(init_array[idx - 1] + init_array[idx - 2]) return init_array[number] assert f(4) == 3
benchmark_functions_edited/f4696.py
def f(gamma, A_mean): I_1 = 1 return gamma * A_mean * I_1 assert f(0.5, 2) == 1
benchmark_functions_edited/f5145.py
def f(x): if isinstance(x, str): x = ''.join(e for e in x if e.isnumeric() or e == '.') return x assert f(2) == 2
benchmark_functions_edited/f4969.py
def f(L1, L2): used = dict([(k, None) for k in L1]) for k in L2: if k in used: return 0 return 1 assert f((1, 2, 3), (4, 5, 6)) == 1
benchmark_functions_edited/f12953.py
def f(matchId): idSum = 0 for letter in matchId: value = ord(letter.upper()) - 64 if value < 1 or value > 26: raise ValueError("Match identifier should only contain letters (got '{}')".format(letter)) # A = 65, but we want A = 1 idSum += value return idSum assert f(u'b') == 2
benchmark_functions_edited/f13892.py
def f(value): decimals = '' try: decimals = str(value).split('.', 1)[1] except IndexError: pass return len(decimals) assert f(5.2321) == 4
benchmark_functions_edited/f10986.py
def f(num_tasks, last_task=None): if last_task is None: return 0 return (last_task + 1) % num_tasks assert f(2, 1) == 0
benchmark_functions_edited/f5853.py
def f(value, amount): try: return float(value) * amount except ValueError: # If value can't be converted to float return value assert f(0, 0) == 0
benchmark_functions_edited/f4772.py
def f(phi, gamma): # return gamma * (phi**2-1.)**2 # func = 1.-phi**2 # return 0.75 * gamma * max_value(func, 0.) return gamma assert f(0, 0) == 0
benchmark_functions_edited/f5011.py
def f( x, y ): if x == 0 and y == 0: return 0 else: return 1.0 / pow( x*x + y*y, 0.5 ) assert f( 0, 1 ) == 1
benchmark_functions_edited/f10471.py
def f(cid): if '.dend[' in cid: stype = 3 elif '.dend_' in cid: stype = int(cid.split('_')[-1].split('[')[0]) elif 'soma' in cid: stype = 1 elif 'axon' in cid: stype = 2 else: stype = 0 return stype assert f('1axon') == 2
benchmark_functions_edited/f1327.py
def f(a,b): return a[0]*b[0] + a[1]*b[1] + a[2]*b[2] assert f( [1, 2, 1], [1, 1, 1]) == 4
benchmark_functions_edited/f6398.py
def f(bitboard): return (1 << 64) - 1 - bitboard assert f((1 << 64) - 1 - 1) == 1
benchmark_functions_edited/f7259.py
def f(n: int) -> int: weight = 0 while n != 0: weight += 1 n &= n - 1 return weight assert f(0b101101) == 4
benchmark_functions_edited/f13982.py
def f(list_containing_list, item): for _list in list_containing_list: if item in _list: return list_containing_list.index(_list) return None assert f( [[1,2,3],[4,5,6]],5) == 1
benchmark_functions_edited/f5630.py
def f(value='0'): try: return int(value) except ValueError: return None assert f("3") == 3
benchmark_functions_edited/f13419.py
def f(a, loc = False): max = a[0] maxelem = 0 try: for i in range(0, len(a)): if a[i] > max: max = a[i] maxelem = i if (loc): return (max, maxelem) return max except TypeError: print("Type Error") except: print("Unexpected error") raise assert f([1, 2, 3, 4, 5, 6]) == 6
benchmark_functions_edited/f11367.py
def f(phrase): # pragma: no cover key_pad = {'1ADGJMPTW ': 1, 'BEHKNQUX0': 2, 'CFILORVY': 3, 'SZ234568': 4, '79': 5} presses = 0 for i in phrase.upper(): for k, v in key_pad.items(): if i in k: presses += v return presses assert f( "1") == 1
benchmark_functions_edited/f7025.py
def f(a: int, b: int = 1) -> int: return int(a/b) assert f(1, 2) == 0
benchmark_functions_edited/f6502.py
def f(f, xs): return max(xs, key=f) assert f(lambda x: x, [1]) == 1
benchmark_functions_edited/f7352.py
def f(x): return min(max(-1., x), 1.) assert f(1000.5) == 1
benchmark_functions_edited/f10858.py
def f(x, b0, b1, b2, b3, b4, b5, b6): return ( b0 + b1 * x + b2 * x ** 2 + b3 * x ** 3 + b4 * x ** 4 + b5 * x ** 5 + b6 * x ** 6 ) assert f(0.0, 0, 1, 2, 3, 4, 5, 6) == 0
benchmark_functions_edited/f2879.py
def f(str, set): for c in str: if c not in set: return 0 return 1 assert f(u"abc", set("a")) == 0
benchmark_functions_edited/f4351.py
def f(sq): root = sq**0.5 return -1 if root % 1 else (root+1)**2 assert f(0) == 1
benchmark_functions_edited/f4444.py
def f(volume, primerinitial, primerfinal, samples): primers = round((volume / primerinitial) * primerfinal * samples, 1) return primers assert f(5, 1, 1, 1) == 5
benchmark_functions_edited/f6957.py
def f(soil, H, D): if "sand" in soil: return min(0.01 * H, 0.1 * D) elif "clay" in soil: return min(0.1 * H, 0.2 * D) else: raise ValueError("Unknown soil type.") assert f("clay", 10, 0) == 0
benchmark_functions_edited/f11178.py
def f(scheduling_factor, max_epochs): return (1 / scheduling_factor) ** (1 / max_epochs) assert f(1, 2) == 1
benchmark_functions_edited/f1599.py
def f(value): value = value & 0xffffffffffffffff return value assert f(False) == 0
benchmark_functions_edited/f9283.py
def f(grid): overlapping = 0 for pos in grid: # count how many ids are stored at each position # any inches with more than one claim id are considered overlapping if len(grid[pos]) > 1: overlapping += 1 return overlapping assert f( {(1,1): set(['a', 'b']), (2,2): set(['b'])}) == 1
benchmark_functions_edited/f1549.py
def f(longitude): return ((longitude + 180.0) % 360) - 180.0 assert f(-360) == 0
benchmark_functions_edited/f7750.py
def f(x, limit): x_gr_limit = x > limit x_le_limit = x_gr_limit * limit + (1 - x_gr_limit) * x x_gr_zero = x > 0.0 x_norm = x_gr_zero * x_le_limit return x_norm assert f(10, 5) == 5
benchmark_functions_edited/f2775.py
def f(line: str): return len(line) - len(line.lstrip(" ")) assert f("") == 0
benchmark_functions_edited/f1617.py
def f(ymax, ymin, xmax, xmin): return (ymax - ymin) * (xmax - xmin) assert f(0, 0, 0, 0) == 0
benchmark_functions_edited/f10671.py
def f(sentence, dictionary): # encode = torch.zeros((len(dictionary) + 1)).type(torch.LongTensor) idx = len(dictionary) if sentence in dictionary.keys(): idx = dictionary[sentence] return idx assert f("hello world", {"hello world": 1}) == 1
benchmark_functions_edited/f4313.py
def f(*args): count = 0 for arg in args: if (arg): count += 1 return(count) assert f(False, True, True, True) == 3
benchmark_functions_edited/f8279.py
def f(Nstrips): width = 1/Nstrips integral = 0 for point in range(Nstrips): height = (point / Nstrips) integral = integral + width * height return integral assert f(1) == 0
benchmark_functions_edited/f13625.py
def f(words, word_sentiments): word_ratings = [word_sentiments[wd] for wd in words if wd in word_sentiments] if len(word_ratings) == 0: return None return sum(word_ratings) / len(word_ratings) assert f(['dog', 'cat'], {'cat': 1, 'dog': 1}) == 1
benchmark_functions_edited/f14356.py
def f(arr: list) -> int: beg, end = 0, len(arr) - 1 while beg <= end: if arr[beg] != beg: return beg m = (beg + end) >> 1 if arr[m] == m: beg = m + 1 else: end = m - 1 return end + 1 assert f( [0, 1, 2, 5, 6, 100]) == 3
benchmark_functions_edited/f7779.py
def f(n, nemo): if n <= 0: return 0 elif n ==1: return 1 elif nemo[n] == 0: nemo[n] = f(n-2, nemo) + f(n-1, nemo) return nemo[n] assert f(6, [0]*10) == 8
benchmark_functions_edited/f1542.py
def f(z, zmin, zrng, a_min=0): alpha = a_min + (1-a_min)*(z-zmin)/zrng return alpha assert f(1.0, 0, 1) == 1
benchmark_functions_edited/f770.py
def f(n, smallest, largest): return max(smallest, min(n, largest)) assert f(3, 0, 2) == 2
benchmark_functions_edited/f4229.py
def f(t): if not isinstance(t, tuple): return t h, bs = t cs = map(to_lterm, bs) ds = list(cs) return (h, ds) assert f(7) == 7
benchmark_functions_edited/f6894.py
def f( boxstart: float, boxsize: float, itemsize: float, just: float = 0.0) -> float: return boxstart + (boxsize - itemsize) * just assert f(0, 10, 4) == 0
benchmark_functions_edited/f13537.py
def f(send_fn, messages): for i in range(len(messages)-1): # # Need the x = i bit to capture the current value of i, # otherwise all the messages have the same finalizer. # messages[i].finalizer = lambda x = i: send_fn(messages[x+1]) return messages[0] assert f(lambda x: x, [1]) == 1
benchmark_functions_edited/f13309.py
def f(d): if type(d) in [int, float, bool, str]: return d try: new_d = {} for k, v in d.items(): new_d[k] = f(v) return new_d except AttributeError: try: new_d = [] for v in d: new_d.append(v) return new_d except TypeError: return d assert f(0) == 0
benchmark_functions_edited/f12165.py
def f(num): if num < 0: raise ValueError("expected num >= 0") par = 0 while num: par ^= (num & 1) num >>= 1 return par assert f(9) == 0
benchmark_functions_edited/f8008.py
def f(kwargs): # Expand the arguments of a callback function, kwargs['func'] func = kwargs['func'] del kwargs['func'] out = func(**kwargs) return out assert f( {'func': lambda x, y: x + y, 'x': 1, 'y': 2}) == 3
benchmark_functions_edited/f7039.py
def f(numbers): Total = 0 for i in range(len(numbers)): if numbers[i] == numbers[i - 1]: Total += int(numbers[i]) return Total assert f( "1234") == 0
benchmark_functions_edited/f1223.py
def f(a, b): while b: a, b = b, a % b return a assert f(10, 5) == 5
benchmark_functions_edited/f8846.py
def f(arr: list) -> int: return sum(arr[i-1] < arr[i] for i in range(1, len(arr))) assert f( [199, 200, 208, 210, 200, 207, 240, 269, 260, 263] ) == 7
benchmark_functions_edited/f13646.py
def f(val) -> int: if val is True: return 1 elif val is None: return 0 elif val is False: return -1 elif val == 1: return 1 elif val == 0: return 0 else: return -1 assert f(True) == 1
benchmark_functions_edited/f3565.py
def f(n): if n == 1: return 1 elif n == 2: return 1 else: return f(n - 1) + f(n - 2) assert f(5) == 5
benchmark_functions_edited/f7046.py
def f(vector1, vector2): dot = 0 for key1 in vector1: if key1 in vector2: dot = dot + vector1[key1] * vector2[key1] return dot assert f({1: 0, 3: 0}, {2: 4, 3: 5, 5: 6}) == 0
benchmark_functions_edited/f9272.py
def f(n: int, p: float) -> float: def recur(n: int, happy: float) -> float: return happy if n == 0 else recur(n-1, (-2*p + 1)*happy + p) return recur(n, 1) assert f(2, 1) == 1
benchmark_functions_edited/f12983.py
def f(t_class, parents_info_level): if t_class in parents_info_level: assert len(parents_info_level[t_class]) < 2, f"{t_class} has two or more parents {parents_info_level[t_class]}" parent = parents_info_level[t_class][0] else: parent = t_class return parent assert f(0, {}) == 0
benchmark_functions_edited/f10927.py
def f(argument): try: return argument._missing except AttributeError: return 0 assert f(3.14) == 0
benchmark_functions_edited/f13330.py
def f(A): l = 0 r = len(A)-1 if A[l] < A[r]: return 0 while r-l > 1 and A[l] >= A[r]: m = l + (r-l)//2 if A[l] > A[m]: r = m continue if A[m] > A[r]: l = m continue return 0 return r assert f([10, 20, 30, 40, 50, 60, 70, 10, 20, 30]) == 0
benchmark_functions_edited/f4338.py
def f(bits): value = 0 for chunk in bits: value = value << 7 value = value | chunk return value assert f(b'\x06') == 6
benchmark_functions_edited/f13944.py
def f(triangle): length = len(triangle) for _ in range(length - 1): a = triangle[-1] b = triangle[-2] for y in range(len(b)): b[y] += max(a[y], a[y + 1]) triangle.pop(-1) triangle[-1] = b return triangle[0][0] assert f( [[1]]) == 1
benchmark_functions_edited/f3172.py
def f(li: list, idx: int, default): try: return li[idx] except IndexError: return default assert f(list(range(10)), 4, 4) == 4
benchmark_functions_edited/f2667.py
def f(t, Tau): if t < Tau: output = 0 else: output = 1 return output assert f(19, 20) == 0
benchmark_functions_edited/f5894.py
def f(registers, opcodes): return int(registers[opcodes[1]] == opcodes[2]) assert f( [1, 1, 1], [0, 1, 0], ) == 0
benchmark_functions_edited/f9499.py
def f(pair): return -pair[1] assert f( ("b", 0) ) == 0
benchmark_functions_edited/f1272.py
def f(x): return int("".join(map(str, map(int, x))), 2) assert f(list(0 for _ in range(3)) + [1, 1, 1]) == 7
benchmark_functions_edited/f2372.py
def f(divident, divisor): quot, r = divmod(divident, divisor) return quot + int(bool(r)) assert f(1, 1) == 1
benchmark_functions_edited/f8973.py
def f(width, height, tWidth, tHeight): area = width * height tile = tWidth * tHeight return area / tile assert f(1, 2, 1, 2) == 1
benchmark_functions_edited/f13489.py
def f(list1, list2): c = [common_item for common_item in list1 if common_item in list2] return float(len(c))/(len(list1) + len(list2) - len(c)) assert f( [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) == 1
benchmark_functions_edited/f8388.py
def f(x, max_value, padding_center, decay_rate): x_value = max_value - abs(padding_center - x) * decay_rate if x_value < 0: x_value = 1 return x_value assert f(2, 2, 1, 1) == 1
benchmark_functions_edited/f11746.py
def f(x, y): x, y = min(x, y), max(x, y) while y: carry = x & y x = x ^ y y = carry << 1 return x assert f(4, 3) == 7
benchmark_functions_edited/f473.py
def f(a, b): return -(-a//b) assert f(13, 11) == 2
benchmark_functions_edited/f10417.py
def f(k, params): l = params[0] a = params[1] b = params[2] d = params[3] a4b2=a*a*a*a + b*b aak2=a*a*k*2 ddk=d*d*k num = (k*k + aak2 + a4b2) * (1 + ddk) den = a4b2 + aak2 + ddk*a4b2 return l * num / den assert f(0, [2, 1, 1, 1]) == 2
benchmark_functions_edited/f951.py
def f(b, i): return b & (1 << i) assert f(23, 0) == 1
benchmark_functions_edited/f6005.py
def f(lower, upper): #base case if lower > upper: return 0 #recursive case return lower + f(lower + 1, upper) assert f(1, 3) == 6
benchmark_functions_edited/f2923.py
def f(a, b, p): return (p[0]-a[0])*(b[1]-a[1]) - (p[1]-a[1])*(b[0]-a[0]) assert f( (0, 0), (1, 1), (0, 0) ) == 0
benchmark_functions_edited/f5954.py
def f(n: int) -> int: if n == 0: return 0 if n == 1: return 1 return f(n-1) + f(n-2) assert f(0) == 0
benchmark_functions_edited/f6742.py
def f(item1, item2): item1, item2 = item1[:2], item2[:2] if item1 != item2: if item1 > item2: return 1 return -1 return 0 assert f("b", "a") == 1
benchmark_functions_edited/f11832.py
def f(bp_version=1): if bp_version == 1: return 3 # TxRctType.Bulletproof elif bp_version == 2: return 4 # TxRctType.Bulletproof2 else: raise ValueError("Unsupported BP version") assert f(2) == 4
benchmark_functions_edited/f12816.py
def f(val, exp, modulus): return pow(int(val), int(exp), int(modulus)) assert f(2, 0, 7) == 1
benchmark_functions_edited/f4318.py
def f(porcentaje, pvp): return (pvp * porcentaje) / 100 assert f(0, 1000) == 0
benchmark_functions_edited/f8869.py
def f(rec, yds, tds): print(yds) # works here since we're inside fn return yds*0.1 + rec*1 + tds*6 assert f(0, 0, 0) == 0
benchmark_functions_edited/f14109.py
def f(arr, n): sh = {} for i in range(n-1): for j in range(i+1, n): s = arr[i]+arr[j] k = sorted((i, j)) if s in sh and k not in sh[s]: return 1 else: sh[s] = [k] return 0 assert f( [2, 1, 3, 4, 5, 7, 8, 6, 9], 8) == 1
benchmark_functions_edited/f13372.py
def f(f,x0,x1, TOL=0.001, NMAX=100): n=1 while n<=NMAX: x2 = x1 - f(x1)*((x1-x0)/(f(x0)-f(x1))) if x2-x1 < TOL: return x2 else: x0 = x1 x1 = x2 return False assert f(lambda x: x**2 - 25, -2, 5) == 5
benchmark_functions_edited/f12207.py
def f(v, s, e=-1): # end-bit not specified? use start bit (thus extract one bit) if e == -1: e = s # swap start and end if start > end if s > e: e, s = s, e mask = ~(((1 << (e-s+1))-1) << s) return (v & mask) >> s assert f(1, 2, 2) == 0
benchmark_functions_edited/f11339.py
def f(lines, lineix): while lineix < len(lines): if lines[lineix].strip().startswith('/*'): # Only return this marker if the comment goes beyond this line if lines[lineix].strip().find('*/', 2) < 0: return lineix lineix += 1 return len(lines) assert f( ['// a',' /* b */', 'c'], 3) == 3
benchmark_functions_edited/f449.py
def f(G): return len(G.keys()) assert f({1: [2, 3], 2: [4, 5], 3: [1, 5], 4: [2], 5: [2]}) == 5
benchmark_functions_edited/f5366.py
def f(start, end, gal): return (end-start)/gal assert f(0, 3000, 1000) == 3
benchmark_functions_edited/f2246.py
def f(x,n): return ((x << n) | (x >> (32-n))) & 0xffffffff assert f(1,3) == 8
benchmark_functions_edited/f7072.py
def f(n): product = 1 if n == 0: return 0 for thing in range(1, n+1): product *= thing return product assert f(2) == 2
benchmark_functions_edited/f5888.py
def f(text): count = 0 for c in text: if c in ['a', 'e', 'i', 'o', 'u']: count = count + 1 return count assert f(u"abracadabra") == 5
benchmark_functions_edited/f11569.py
def f(image_len, crop_num, crop_size): return int((image_len - crop_size)/(crop_num - 1)) assert f(20, 3, 7) == 6
benchmark_functions_edited/f4097.py
def f(integer): return sum(x for x in range(integer) if x % 3 == 0 or x % 5 == 0) assert f(0) == 0
benchmark_functions_edited/f3161.py
def f(euclid_dis): return (euclid_dis ** 2) / 2 assert f(0) == 0
benchmark_functions_edited/f8897.py
def f(N, R): result = 1 while N > R: result *= N N -= 1 return result assert f(4, 3) == 4
benchmark_functions_edited/f11915.py
def f(alpha_damage_score: float) -> float: if alpha_damage_score < 3: return 1 if alpha_damage_score < 8: return 0.5 return 0 assert f(1.000000001) == 1
benchmark_functions_edited/f8183.py
def f(x_1, x_2, s1, s2, n1, n2): if (n1 <= 30 or n2 <= 30): print("The sample sizes must be greater than 30.") else: s_error = ((s1**2 / n1) + (s2**2 / n2))**0.5 z = (x_1 - x_2) / s_error return z assert f(100, 100, 10, 10, 100, 100) == 0
benchmark_functions_edited/f7472.py
def f(num): power_of_two = 0 sevenish = 0 while num > 0: val = pow(7, power_of_two) if num % 2 == 1 else 0 sevenish += val power_of_two += 1 num //= 2 return sevenish assert f(1) == 1
benchmark_functions_edited/f13403.py
def f(bces): # Selects the appropriate BCES fitting method import sys if bces=='ort': i=3 elif bces=='y|x': i=0 elif bces=='x|y': i=1 elif bces=='bis': i=2 else: sys.exit("Invalid BCES method selected! Please select bis, ort, y|x or x|y.") return i assert f('y|x') == 0