file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f8841.py
def f(val): if val == 0.1: return 1 else: return val assert f(1.0) == 1
benchmark_functions_edited/f12863.py
def f(arr): if len(arr) == 0 or len(arr) == 1: return 0 s = sorted(arr) m = range(s[0], s[len(s) - 1] + 1) return len(m) - len(s) assert f(range(10)) == 0
benchmark_functions_edited/f12296.py
def f(nelec, nspin, ispin): if nspin == 1: return nelec / 2.0 else: return nelec / 2 + (1 - ispin) * (nelec % 2) assert f(12, 1, 0) == 6
benchmark_functions_edited/f9447.py
def f(n, mod): x, y = 0, 1 # U_n, U_{n+1}, n=0 for b in bin(n)[2:]: x, y = ((y - x) * x + x * y) % mod, (x * x + y * y) % mod # double if b == "1": x, y = y, (x + y) % mod # add return x assert f(1, 10) == 1
benchmark_functions_edited/f2809.py
def f(i): if not i & 1: return i >> 1 return (i >> 1) ^ (~0) assert f(0) == 0
benchmark_functions_edited/f9906.py
def f(pattern, motiv): if len(pattern) != len(motiv): return -1 hamming_distance = 0 for i in range(0, len(motiv)): if pattern[i] != motiv[i]: hamming_distance += 1 return hamming_distance assert f( "ACGT", "AACT") == 2
benchmark_functions_edited/f11739.py
def f(puzzle, solved): sum = 0 for i, row in enumerate(puzzle): for j, num in enumerate(row): if puzzle[i][j] != solved[num]: solved_i, solved_j = solved[num] sum += abs(solved_i - i) + abs(solved_j - j) return sum assert f( [[1, 2, 3], [4, 5, 6], [0, 7, 8]], {1: (0, 0), 2: (0, 1), 3: (0, 2), 4: (1, 0), 5: (1, 1), 6: (1, 2), 7: (2, 0), 8: (2, 1), 0: (2, 2)}) == 4
benchmark_functions_edited/f12776.py
def f(data, key, default=None): if key in data: return data[key] else: return default assert f( { "a": 1, "b": 2 }, "b" ) == 2
benchmark_functions_edited/f8079.py
def f(value): if len(value) != 2: return 0 return 1 assert f(()) == 0
benchmark_functions_edited/f4607.py
def f(values): return sum(values) / len(values) assert f([0, 0, 0, 0, 0]) == 0
benchmark_functions_edited/f467.py
def f(data, index): return data.__getitem__(index) assert f(dict(zip(list(range(0, 5)), list(range(0, 5)))), 0) == 0
benchmark_functions_edited/f1302.py
def f(a,b): while b: a, b = b, a%b return a assert f(0,5) == 5
benchmark_functions_edited/f6615.py
def f(item, user, sim_dict): if user not in sim_dict or item not in sim_dict[user]: return 0 else: return sim_dict[user][item] assert f(1, 2, {1: {1: 1, 2: 0, 3: 0}, 2: {1: 0, 2: 1, 3: 0}, 3: {1: 0, 2: 0, 3: 1}}) == 0
benchmark_functions_edited/f189.py
def f(x): return int(str(x)) assert f(1) == 1
benchmark_functions_edited/f1391.py
def f(n): return bin(n).count("1") assert f(0b000000000000000000000000000000001) == 1
benchmark_functions_edited/f4424.py
def f(ri, rj): return sum([min(a, b) for a, b in zip(ri["texture_hist"], rj["texture_hist"])]) assert f( {"texture_hist": [1, 1, 1, 1]}, {"texture_hist": [1, 1, 1, 1]} ) == 4
benchmark_functions_edited/f702.py
def f(x, y): return (y + 1) + (8 * x) assert f(1, 0) == 9
benchmark_functions_edited/f2280.py
def f(data): return max(data[0][0], data[1][0], data[2][0], data[3][0]) assert f([(1, 1), (2, 1), (1, 2), (2, 2)]) == 2
benchmark_functions_edited/f13983.py
def f(index, strides): # ASSIGN2.1 position = 0 for ind, stride in zip(index, strides): position += ind * stride return position # END ASSIGN2.1 assert f( (1, 2), (1, 4) ) == 9
benchmark_functions_edited/f12721.py
def f(n): hamming = [1] i = j = k = 0 while n: while hamming[i] * 2 <= hamming[-1]: i += 1 while hamming[j] * 3 <= hamming[-1]: j += 1 while hamming[k] * 5 <= hamming[-1]: k += 1 hamming.append(min(hamming[i] * 2, hamming[j] * 3, hamming[k] * 5)) n -= 1 return hamming[-2] assert f(3) == 3
benchmark_functions_edited/f13245.py
def f(lon): return lon*1.0%360 assert f(361) == 1
benchmark_functions_edited/f9156.py
def f(p, i): if p[i] < 0xc0: if 97 <= p[i] <= 122: p[i] ^= 32 return 1 if p[i] < 0xe0: p[i + 1] ^= 32 return 2 p[i + 2] ^= 5 return 3 assert f(bytearray([0xc3, 0xb6]), 0) == 2
benchmark_functions_edited/f13571.py
def f(base, exp, p): e = "{0:b}".format(exp) # bitstring of the exponent z = 1 for c in e: z = z * z % p if int(c) == 1: z = z * base % p return z assert f(2, 5, 13) == 6
benchmark_functions_edited/f2631.py
def f(v, nelx, nely): return int(v[0]) + int(v[1])*nelx assert f((1, 2, 3, 4, 5, 6), 3, 3) == 7
benchmark_functions_edited/f5147.py
def f(id_value, data): for count, item in enumerate(data): if item['id'] == id_value: return count return None assert f(1, [{'id': 1}, {'id': 2}]) == 0
benchmark_functions_edited/f3900.py
def f(version): if version is None: raise ValueError("sbe:messageSchema/@version is required") return int(version) assert f('1') == 1
benchmark_functions_edited/f6452.py
def f(x, h, f): K1 = h*f(x) K2 = h*f(x+(K1 * 0.5)) K3 = h*f(x+(K2 * 0.5)) K4 = h*f(x+K3) return x+(1/6.0)*(K1 + 2*K2 + 2*K3 + K4) assert f(0, 1, lambda x: x**10) == 0
benchmark_functions_edited/f5616.py
def f(numbers, i): min_ = min(numbers) return min_ # if min_ != i: # return min_ # else: # return min_ assert f(list(range(0, 1001, 1)), 999) == 0
benchmark_functions_edited/f4014.py
def f(a, b): if a > b : return a else : return b assert f(4, 3) == 4
benchmark_functions_edited/f10584.py
def f(L,S,A,B,V,l,s,a,b,v,c): res = L*l+S*s+A*a+B*b+V*v+c return res assert f(1,0,0,0,0,1,0,0,0,0,0)==1
benchmark_functions_edited/f13371.py
def f(content: str) -> int: if content.endswith(" "): return f(content[:-1]) + 1 return 0 assert f( " hello ") == 4
benchmark_functions_edited/f6296.py
def f(z: float) -> float: return 1 / (1 + z) assert f(0) == 1
benchmark_functions_edited/f9078.py
def f(perimeter, apothem): perimeter = float(perimeter) apothem = float(apothem) if (perimeter < 0.0 or apothem < 0.0): raise ValueError('Negative numbers are not allowed') return perimeter * apothem / 2 assert f(3, 4) == 6
benchmark_functions_edited/f5459.py
def f(x): return int(x or 0) or None assert f(3) == 3
benchmark_functions_edited/f6924.py
def f(id, categories): id_to_idx = {id: index for index, id in enumerate(categories)} return id_to_idx[id] assert f(3, [1,2,3]) == 2
benchmark_functions_edited/f8148.py
def f(q, intercept, slope): inten = intercept + slope*q return inten assert f(2, -1, 1) == 1
benchmark_functions_edited/f1836.py
def f(cos: float) -> float: return ((1 - cos) * (1 + cos)) ** 0.5 / cos assert f(1) == 0
benchmark_functions_edited/f5560.py
def f(initial_velocity, t): n = t + 1 final_velocity = initial_velocity - t return n * (initial_velocity + final_velocity) / 2 assert f(2, 0) == 2
benchmark_functions_edited/f4216.py
def f(capacity): # type: (int) -> int if capacity < 8: return 8 return capacity * 2 assert f(6) == 8
benchmark_functions_edited/f3216.py
def f(x, k=8): return x + (x % k > 0) * (k - x % k) assert f(6) == 8
benchmark_functions_edited/f1607.py
def f(move): if move == 0: return 1 else: return 0 assert f(1) == 0
benchmark_functions_edited/f9939.py
def f(data): try: return int.from_bytes(data, 'big') except TypeError: return f(data.encode('utf-8')) except AttributeError: return int(data.encode('hex'), 16) assert f(b'\x00') == 0
benchmark_functions_edited/f3483.py
def f(coeffs, n): total = 0 for i, c in enumerate(coeffs): total += c * n**i return total assert f((1, 2, 3), 0) == 1
benchmark_functions_edited/f9471.py
def f(A,L=None): if L==None: L = range(len(A)) return sum([A[L[i]][L[j]] for j in range(len(L)) for i in range(j)]) assert f( [[1,2,3]], [0] ) == 0
benchmark_functions_edited/f5506.py
def f(principal, time_in_years, rate_of_intrest): return round(principal * (( 1 + rate_of_intrest/100 ) ** time_in_years), 2) assert f(0, 0, 10) == 0
benchmark_functions_edited/f10116.py
def f(true_row, inv=False): if inv: if true_row >= 7: return true_row + 1 return true_row if true_row >= 7: true_row -= 1 return true_row assert f(1) == 1
benchmark_functions_edited/f12243.py
def f(arr, target): low, high = 0, len(arr) - 1 while low <= high: mid = (high + low) // 2 if arr[mid] < target: low = mid + 1 elif arr[mid] > target: high = mid - 1 else: return mid return -1 assert f([1], 1) == 0
benchmark_functions_edited/f11669.py
def f(k, k0, mask, noise_lvl=None): v = noise_lvl if v: # noisy case out = (1 - mask) * k + mask * (k + v * k0) / (1 + v) else: # noiseless case out = (1 - mask) * k + mask * k0 return out assert f(1, 0, 0) == 1
benchmark_functions_edited/f8699.py
def f(views): largest_view = -1 lvid = -1 for i in views.items(): if largest_view < len(i[1]): largest_view = len(i[1]) lvid = i[0] return lvid assert f({1: 'a'}) == 1
benchmark_functions_edited/f8855.py
def f(x, period, amplitude): return (4*amplitude/period) * abs(((x - period/4) % period) - period/2) - amplitude assert f(5, 2, 0.5) == 0
benchmark_functions_edited/f1257.py
def f(text, character): return text.f(character) assert f('a string', 'z') == 0
benchmark_functions_edited/f3726.py
def f(value): try: return int(value) except ValueError: return None assert f("1") == 1
benchmark_functions_edited/f247.py
def f(x, y): result = x + y return result assert f(100, -100) == 0
benchmark_functions_edited/f2975.py
def f(term, tokenized_document): return tokenized_document.count(term) assert f(4, [1, 2, 1]) == 0
benchmark_functions_edited/f14272.py
def f(ceiling): # Trades space for time term_lengths = [0, 1] for i in range(2, ceiling): terms = 1 while i >= len(term_lengths): if i % 2 == 0: i = i // 2 else: i = 3 * i + 1 terms += 1 term_lengths.append(term_lengths[i] + terms) return term_lengths.index(max(term_lengths)) assert f(1) == 1
benchmark_functions_edited/f3004.py
def f(a, b): count = 0 for i in a: if i == b: count += 1 return count assert f(['a', 'b', 'c', 'd'], 'c') == 1
benchmark_functions_edited/f1118.py
def f(vec1, vec2): return vec1[0]*vec2[0] + vec1[1]*vec2[1] assert f( (1, 1), (1, 0) ) == 1
benchmark_functions_edited/f4244.py
def f(dict, key, default): val = dict[key] if key in dict else default return val assert f(dict(), 'x', 1) == 1
benchmark_functions_edited/f12743.py
def f(a, n): t, r = 0, n new_t, new_r = 1, a while new_r != 0: quotient = r // new_r t, new_t = new_t, t - quotient * new_t r, new_r = new_r, r - quotient * new_r if r > 1: raise Exception("a is not invertible") if t < 0: t = t + n return t assert f(3, 10) == 7
benchmark_functions_edited/f2245.py
def f(td, r_i): tau = 1 / r_i return 1. / (tau + td) assert f(0, 1) == 1
benchmark_functions_edited/f10899.py
def f(seq, val): max = 0 idx = len(seq) - 1 while idx >= 0: if seq[idx] < val and seq[idx] >= 0 and seq[idx] > max: max = seq[idx] idx -= 1 return max assert f(list(range(1, 6)), 6) == 5
benchmark_functions_edited/f12096.py
def f(glidein): glidein_cpus = 1 cpus = str(glidein['attrs'].get('GLIDEIN_CPUS', 1)) if cpus.upper() == 'AUTO': glidein_cpus = 1 else: glidein_cpus = int(cpus) return glidein_cpus assert f( { 'attrs': { 'GLIDEIN_CPUS': 'auto' } } ) == 1
benchmark_functions_edited/f583.py
def f(pack): return (pack >> 48) & 0xffff assert f(0x0000) == 0
benchmark_functions_edited/f8386.py
def f(input): valid_password = 0 for i in input: limit, char, password = i.split(" ") char_count = password.count(char[0]) min, max = limit.split("-") if char_count >= int(min) and char_count <= int(max): valid_password += 1 return valid_password assert f( [ "1-3 a: abcde", "1-3 b: cdefg", "2-9 c: ccccccccc" ] ) == 2
benchmark_functions_edited/f2401.py
def f(x): if x == True: return 1 elif x == False: return 0 return x assert f(False) == 0
benchmark_functions_edited/f704.py
def f(var, default_value): return default_value if var is None else var assert f(1, 'hi') == 1
benchmark_functions_edited/f2727.py
def f(pose1, pose2): return abs(pose1[0] - pose2[0]) + abs(pose1[1] - pose2[1]) assert f((1, 1), (2, 2)) == 2
benchmark_functions_edited/f2250.py
def f(value1, value2): dB = (value1*256 + value2)*0.1 return dB assert f(0, 0) == 0
benchmark_functions_edited/f4548.py
def f(value): if value in [0, 2]: out = 0 elif value in [1, 3]: out = 1 else: raise RuntimeError(value) return out assert f(1) == 1
benchmark_functions_edited/f994.py
def f(ns): return int(ns) / 10**9; assert f(0) == 0
benchmark_functions_edited/f6431.py
def f(v1, v2): diff_norm = sum((x1-x2)**2 for x1, x2 in zip(v1, v2))**0.5 if diff_norm == 0: return 0 else: return 1.0/diff_norm assert f( (1, 2, 3, 4, 5), (1, 2, 3, 4, 5) ) == 0
benchmark_functions_edited/f3024.py
def f(x1, y1, x2, y2): return ((x1 - y1) ** 2 + (x2 - y2) ** 2) ** 0.5 assert f(2, 0, 0, 0) == f(0, 2, 0, 0) == 2
benchmark_functions_edited/f963.py
def f(f, x, h): return (f(x + h) - f(x)) / h assert f(lambda x: x, 5, 1) == 1
benchmark_functions_edited/f8022.py
def f(vents): counter = 0 for n_vents in vents.values(): if n_vents > 1: counter += 1 return counter assert f( { (1, 1): 1, (2, 3): 1, (7, 3): 2, (3, 4): 1, (5, 5): 2, (8, 9): 1 } ) == 2
benchmark_functions_edited/f2478.py
def f( display ): global scene scene = display return display assert f(1) == 1
benchmark_functions_edited/f365.py
def f(x): return int(round(x)) assert f(1.1) == 1
benchmark_functions_edited/f8398.py
def f(dct, keys): for key in keys: if not isinstance(dct, dict): return None if key in dct: dct = dct[key] else: return None return dct assert f({"a": 1, "b": {"c": 3}}, ["b", "c"]) == 3
benchmark_functions_edited/f8505.py
def f(self, right): return self if isinstance(right, self.__class__) else self.value assert f(1, 2) == 1
benchmark_functions_edited/f7384.py
def f(a, b): return (int(a) + int(b) - 1) // int(b) assert f(15, 11) == 2
benchmark_functions_edited/f8510.py
def f(property_key: int) -> int: # We can get the binary representation of the property key, reverse it, # and find the first 1 return bin(property_key)[::-1].index("1") assert f(0x03) == 0
benchmark_functions_edited/f9626.py
def f(p, qs): min_dist = None min_i = None for i, q in enumerate(qs): dist = abs(q-p) if min_dist is None or dist < min_dist: min_dist = dist min_i = i return min_i assert f(3, [1, 2, 3, 4]) == 2
benchmark_functions_edited/f732.py
def f(a, b): if a >= b: return a else: return b assert f(0, 1) == 1
benchmark_functions_edited/f14433.py
def f(x, r_fn, shortcut_weight=0.6): blocks_per_group = (3, 4, 23, 3) res_branch_subnetwork_x = r_fn(r_fn(r_fn(x))) for i in range(4): for j in range(blocks_per_group[i]): res_x = r_fn(r_fn(r_fn(x))) shortcut_x = r_fn(x) if (j == 0) else x x = (shortcut_weight**2 * shortcut_x + (1.0 - shortcut_weight**2) * res_x) x = r_fn(x) return max(x, res_branch_subnetwork_x) assert f(1, lambda x: x) == 1
benchmark_functions_edited/f8724.py
def f(number): i = 2 a = set() while i < number**0.5 or number == 1: if number % i == 0: number = number/i a.add(i) i -= 1 i += 1 return (len(a)+1) assert f(38) == 2
benchmark_functions_edited/f14198.py
def f(classes): numCredits = 0 classList = list(classes.keys()) for c in classList: numCredits += classes[c]["credits"] return numCredits assert f({}) == 0
benchmark_functions_edited/f9262.py
def f(per_page: int, total_count: int) -> int: assert per_page > 0 and total_count >= 0 if total_count % per_page == 0: return total_count // per_page return total_count // per_page + 1 assert f(10, 40) == 4
benchmark_functions_edited/f2792.py
def f(Psta, mslp=1013.25): # METERS return (1-(Psta/mslp)**0.190284)*44307.69396 assert f(1013.25) == 0
benchmark_functions_edited/f2484.py
def f(l): if ".html" in str(l): return 1 else: return 0 assert f(list("index")) == 0
benchmark_functions_edited/f5008.py
def f(m, n): assert m >= 0 and n >= 0 while n != 0: m, n = n, m % n return m assert f(12, 4) == 4
benchmark_functions_edited/f12578.py
def f(n: int) -> int: digits = 0 n = abs(n) while True: n = n // 10 digits += 1 if n == 0: break return digits assert f(0) == 1
benchmark_functions_edited/f1962.py
def f(func, Xi, Xf): return func(Xf)*(Xf-Xi) assert f(lambda x: x, 0, 1) == 1
benchmark_functions_edited/f8634.py
def f(s, accept_none = False): if s is None and accept_none : return None try: return int(s) except ValueError: raise ValueError('Could not convert "%s" to int' % s) assert f("1") == 1
benchmark_functions_edited/f2841.py
def f(limit): if limit > 500: return 500 else: return limit assert f(1) == 1
benchmark_functions_edited/f11092.py
def f(obj, key): keys = key.split('.', 1) if len(keys) == 2: return f(obj.get(keys[0], {}), keys[1]) else: return obj.get(keys[0], None) assert f({'a': {'b': {'c': 1}}}, 'a.b.c') == 1
benchmark_functions_edited/f1167.py
def f(size_bytes): return size_bytes * 1024 * 1024 assert f(0) == 0
benchmark_functions_edited/f2477.py
def f(a1, b1, c1, a2, b2, c2): return abs(a1 - a2) + abs(b1 - b2) + abs(c1 - c2) assert f(1, 2, 3, 4, 5, 6) == 9
benchmark_functions_edited/f9957.py
def f(cat): if cat in [0, 1]: return (cat + 1) % 2 else: raise ValueError("Category should be Vi or Vj.") assert f(0) == 1
benchmark_functions_edited/f11174.py
def f(slopesBetweenJumps): currSlope = 10000 sides = 0 for x in slopesBetweenJumps: if(abs(x - currSlope) > 10): sides +=1 currSlope = x return sides assert f( []) == 0
benchmark_functions_edited/f12274.py
def f(xN, xNmas1, alfa, raiz): numerador = abs((xNmas1 - raiz)) denominador = abs(xN - raiz) ** alfa if denominador == 0: return None return numerador / denominador assert f(1, 3, 0.5, 2) == 1
benchmark_functions_edited/f1042.py
def f(kelvin): celsius = kelvin - 273.15 return celsius assert f(274.15) == 1