file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f2822.py
def f(v, default=None): try: return int(v) except: return default assert f("false", 0) == 0
benchmark_functions_edited/f187.py
def f(n): return ((n ** 2) * (n + 1) ** 2) / 4 assert f(1) == 1
benchmark_functions_edited/f7785.py
def f(r, g=0, b=0): try: r, g, b = r # see if the first var is a tuple/list except TypeError: pass return (r & 0xf8) << 8 | (g & 0xfc) << 3 | b >> 3 assert f(0) == 0
benchmark_functions_edited/f5553.py
def f(minValue, maxValue, value): if value < minValue: return minValue if value > maxValue: return maxValue return value assert f(3, 5, 5) == 5
benchmark_functions_edited/f10333.py
def f(value, replace_string='None', replace_with=0): if value == replace_string: return int(replace_with) else: return int(value) assert f('0') == 0
benchmark_functions_edited/f2755.py
def f(data): try: return data.magnitude except AttributeError: return data assert f(1) == 1
benchmark_functions_edited/f1992.py
def f(a, b): return (a > b) - (a < b) assert f(1.0, 1) == 0
benchmark_functions_edited/f9378.py
def f(time): intervals = [1, 60, 60*60, 60*60*24] return sum(iv*int(t) for iv, t in zip(intervals, reversed(time.replace('-', ':').split(':')))) assert f( "00:00:00:00") == 0
benchmark_functions_edited/f10603.py
def f(value, bit_width=8): count = 0 for _ in range(bit_width): if value & 1: return count count += 1 value >>= 1 return count assert f(0b1111111111) == 0
benchmark_functions_edited/f8710.py
def f(indicator): return {"URBANIDAD": 3, "HOMBRES": 5, "ALFABETIZACION": 11, "ESCOLARIDAD": 14, "ASISTENCIA": 17, "PARTICIPACION": 23 }[indicator] assert f("HOMBRES") == 5
benchmark_functions_edited/f3783.py
def f(growth, eps, pe): return (2*growth+pe)*eps assert f(1, 1, 3) == 5
benchmark_functions_edited/f10469.py
def f(n): if 0 <= n <= 9: return n else: if n < 0: n = -n if n % 10 > (n % 100 - n % 10) // 10: n = (n - n % 100 + n % 10 * 10) // 10 return f(n) else: n = n//10 return f(n) assert f(111_111_111_111) == 1
benchmark_functions_edited/f10951.py
def f(n): x = n y = (x + 1) // 2 while y < x: x = y y = (x + n // x) // 2 return x assert f(8) == 2
benchmark_functions_edited/f3335.py
def f(group): return len(set([x['station']['station'] for x in group])) assert f([]) == 0
benchmark_functions_edited/f12763.py
def f(num_literals): return 4 * num_literals * (num_literals - 1) / 2 assert f(2) == 4
benchmark_functions_edited/f24.py
def f(x): print(x) return 1 assert f(7) == 1
benchmark_functions_edited/f679.py
def f(x, y, i, j): return ((x - i) ** 2 + (y - j) ** 2) assert f(2, 2, 2, 2) == 0
benchmark_functions_edited/f10467.py
def f(argumentValues,k): if argumentValues.count(1) >= k: outcome = 1 else: outcome = 0 return outcome assert f( [1,1,1,1,0,0,0], 3 ) == 1
benchmark_functions_edited/f3728.py
def f(progname): print(("Usage: %s /path/to/tables " "/path/to/generated output[_amalgamation.cpp]") % progname) return 1 assert f(1) == 1
benchmark_functions_edited/f3274.py
def f(x, r): return x + r - x % r assert f(2, 5) == 5
benchmark_functions_edited/f4523.py
def f(a, b): c = b acc = 0 i = 0 while c >> i!= 0: if (c >> i) & 1: acc ^= a << i i += 1 return acc assert f(3, 1) == 3
benchmark_functions_edited/f9101.py
def f(some_list, current_index): try: return some_list[int(current_index) - 1] # access the previous element except: return '' assert f(list(range(1, 4)), 3) == 3
benchmark_functions_edited/f12231.py
def f(atom, atomic_valence_electrons, BO_valence): if atom == 1: charge = 1 - BO_valence elif atom == 5: charge = 3 - BO_valence elif atom == 15 and BO_valence == 5: charge = 0 elif atom == 16 and BO_valence == 6: charge = 0 else: charge = atomic_valence_electrons - 8 + BO_valence return charge assert f(1, 4, 1) == 0
benchmark_functions_edited/f6317.py
def f(list, index): if len(list) == 0: return None if index >= 0 and index < len(list): return list[index] return None assert f(range(10), 0) == 0
benchmark_functions_edited/f9070.py
def f(infile, outfile, chunksize=8192): size = 0 while True: chunk = infile.read(chunksize) if not chunk: break outfile.write(chunk) size += len(chunk) return size assert f(open('test.txt', 'rb'), open('test.out', 'wb')) == 0
benchmark_functions_edited/f958.py
def f(a: int, b: int) -> int: return (a + b) ** 2 assert f(0, 0) == 0
benchmark_functions_edited/f8144.py
def f(dev_type: str) -> int: try: return len(dev_type.split(';')) except: return 0 assert f(None) == 0
benchmark_functions_edited/f111.py
def f(x): return int(round(x)) assert f(0.4) == 0
benchmark_functions_edited/f9459.py
def f(line): for idx, char in enumerate(line): if not char.isspace(): return idx return len(line) assert f(r" foo ") == 2
benchmark_functions_edited/f5329.py
def f(name): n = 0 for c in name: n = n * 26 + 1 + ord(c) - ord('A') return n assert f('B') == 2
benchmark_functions_edited/f3531.py
def f(*args): for arg in args: if arg is not None: return arg return None assert f(None, 2) == 2
benchmark_functions_edited/f13488.py
def f(x, y, p=2): # get the words that occur in both x and y (for all others the product is 0 anyways) s = set(x.keys()) & set(y.keys()) # nothing in common? if not s: return 0. return float(sum([x[word] * y[word] for word in s]))**p assert f({'a': 1, 'b': 2}, {'c': 3, 'd': 4}) == 0
benchmark_functions_edited/f4951.py
def f(val, array): res = [i for i, v in enumerate(array) if v == val] return res[0] assert f(1, [3, 1, 2]) == 1
benchmark_functions_edited/f2896.py
def f(in_size: int) -> int: conv = 1024 return in_size // conv assert f(1) == 0
benchmark_functions_edited/f5202.py
def f(number: int) -> int: return int(list(str(number * 2))[0]) assert f(2) == 4
benchmark_functions_edited/f9178.py
def f(x, y): tot = 0 consts = (1.5, 2.25, 2.625) for i in range(1, 4): tot += 2 * i * x * (x * (y**i - 1) + consts[i-1]) return tot assert f(0, 0) == 0
benchmark_functions_edited/f6051.py
def f(a): if not hasattr(a, "__iter__"): return a if len(a) == 1: return a[0] return tuple(a) assert f(0) == 0
benchmark_functions_edited/f14172.py
def f(c, a, b, c50, n): return (a*(c/c50)**n + b)/((c/c50)**n + 1) assert f(1, 1, 1, 1, 1.25) == 1
benchmark_functions_edited/f9885.py
def f(function, iterable, **attr): if iterable: it = iter(iterable) value = next(it) for element in it: value = function(value, element, **attr) return value else: return None assert f(lambda a, b: a + b, [1, 2, 3]) == 6
benchmark_functions_edited/f526.py
def f(x): y = 1/(1-x) return y assert f(0) == 1
benchmark_functions_edited/f10411.py
def f(_input, _min=0, _max=127, left='f', right='b'): for i in _input.lower(): _mid = (_max + _min) // 2 if i == left: _max = _mid elif i == right: _min = _mid + 1 if _min == _max: return _max return 0 assert f('-0') == 0
benchmark_functions_edited/f5905.py
def f(values): if len(values) > 0: return float(sum(values)) / len(values) return None assert f([1, 3, 5]) == 3
benchmark_functions_edited/f13325.py
def f(n): # similar to hw01, but asked for a recursive solution here print(n) if n == 1: return 1 if n % 2 == 0: return 1 + f(n // 2) else: return 1 + f(n * 3 + 1) assert f(1) == 1
benchmark_functions_edited/f10363.py
def f(input_list): length = len(input_list) if length == 0: return -1 curr_min = input_list[0] curr_min_index = 0 for j in range(1, length): if curr_min > input_list[j]: curr_min = input_list[j] curr_min_index = j return curr_min_index assert f( [1, 2, 3, 4, 5, 1] ) == 0
benchmark_functions_edited/f7553.py
def f(key): if key == 'none': return 0 elif key == 'hold': return 1 elif key == 'buy': return 2 elif key == 'strong_buy': return 3 assert f('none') == 0
benchmark_functions_edited/f8539.py
def f(plist, alpha): m = len(plist) plist = sorted(plist) for k in range(0, m): if (k+1) / float(m) * alpha >= plist[k]: return k assert f((0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0), 0.0) == 0
benchmark_functions_edited/f9717.py
def f(k): if not isinstance(k, int): raise TypeError( "window_size must be integer type, got {}".format(type(k).__name__) ) if k <= 0: raise ValueError("window_size must be positive") return k assert f(1) == 1
benchmark_functions_edited/f2950.py
def f(minimum, n, maximum): return max(minimum, min(n, maximum)) assert f(1, 5, 5) == 5
benchmark_functions_edited/f6032.py
def f(mag, low, high): isGood = 0 if mag <= high and mag >= low: isGood = 1 return isGood assert f(100, 30, 20) == 0
benchmark_functions_edited/f13321.py
def f(length): if length % 8 != 0: floor = length // 8 return ((floor + 1) * 8) - length return 0 assert f(4096) == 0
benchmark_functions_edited/f3569.py
def f(f, *args, **kwargs): return f(*args, **kwargs) assert f(lambda a, b: a + b, 1, 2) == 3
benchmark_functions_edited/f11474.py
def f(x, y): parity_x = x % 2 parity_y = y % 2 if parity_x == 1: if parity_y == 1: return min(x, y) else: return y if parity_x == 0: if parity_y == 0: return max(x, y) else: return x assert f(1, 2) == 2
benchmark_functions_edited/f12060.py
def f(L, i): # The index of the smallest item so far. index_of_smallest = i for j in range(i + 1, len(L)): if L[j] < L[index_of_smallest]: index_of_smallest = j return index_of_smallest assert f([], 0) == 0
benchmark_functions_edited/f9598.py
def f(str1, str2): distance = 0 for ch1, ch2 in zip(str1, str2): if ch1 != ch2: distance += 1 return distance assert f('a', 'b') == 1
benchmark_functions_edited/f7382.py
def f(x, warmup=0.002): if x < warmup: return x / warmup return 1.0 assert f(10000, 0.00001) == 1
benchmark_functions_edited/f5750.py
def f(s): try: return int(s) except ValueError: return int(float(s)) assert f(' 1.0 ') == 1
benchmark_functions_edited/f11718.py
def f(index: int) -> int: assert 0 <= index <= 3, f"index out of range: {index}" if index == 0: # batch (N) return 0 elif index == 1: # channel (C) return 3 else: return index - 1 assert f(2) == 1
benchmark_functions_edited/f4878.py
def f(val, lower_bound, upper_bound): val = max(val, lower_bound) val = min(val, upper_bound) return val assert f(1, 1, 4) == 1
benchmark_functions_edited/f14202.py
def f(sortedCollection, item, key=lambda x: x): lo = 0 hi = len(sortedCollection) while lo < hi: mid = (lo + hi) // 2 if item > key(sortedCollection[mid]): lo = mid + 1 else: hi = mid return lo - 1 assert f(list(range(10)), 1) == 0
benchmark_functions_edited/f6099.py
def f(num): if num == 1: return num else: return num * f(num - 1) assert f(3) == 6
benchmark_functions_edited/f1873.py
def f(request, data): # echo data back to the client return data assert f(1, 2) == 2
benchmark_functions_edited/f11231.py
def f(iterable): try: return max(iterable) except ValueError: # The TypeError is not caught here as that should be thrown. return 0 assert f([3]) == 3
benchmark_functions_edited/f4578.py
def f(*variables): return max(variables) - min(variables) assert f(10, 10, 10, 10, 10, 10, 10, 10, 10, 10) == 0
benchmark_functions_edited/f1731.py
def f(t, a, t0): return a*(t-t0)**(0.5) assert f(1, 0, 0) == 0
benchmark_functions_edited/f9761.py
def f(positions, i, border_pt=42): i = 0 while i < len(positions) - 1 and positions[i][1] < border_pt: i += 1 return i assert f( [(1, 10), (10, 10), (100, 10), (1000, 10)], 3, ) == 3
benchmark_functions_edited/f3445.py
def f(msg): ret = 0 for ch in msg: ret = ret + ord(ch) return ret & 0xff assert f(b"") == 0
benchmark_functions_edited/f2.py
def f(x,y=0): return x+y+1 assert f(3) == 4
benchmark_functions_edited/f7056.py
def f(causal_prefetch_item): if causal_prefetch_item is None: return -1 return 1 assert f(3.14) == 1
benchmark_functions_edited/f14344.py
def f(a,findLoc=False): try: maxVal = a[0] maxLoc = 0 for i in range(1,len(a)): if a[i] > maxVal: maxVal = a[i] maxLoc = i if findLoc == True: return maxVal, maxLoc return maxVal except TypeError: print("Can't Find Max or Location, Error in Types") return -1,-1 except: raise assert f([1, 2, 3]) == 3
benchmark_functions_edited/f13559.py
def f(num1, num2, sgn): if num2 == 0: return None elif sgn == "+": return num1 + num2 elif sgn == "-": return num2 - num1 elif sgn == "/": return num1 / num2 elif sgn == "*": return num1 * num2 else: return None assert f(3, 3, "/") == 1
benchmark_functions_edited/f1770.py
def f(distances): return max(max(row) for row in distances) assert f( [[1, 1], [2, 1], [1, 1]] ) == 2
benchmark_functions_edited/f12438.py
def f(c, t): return 20 * c[0] * t**3 + 12 * c[1] * t**2 + 6 * c[2] * t + 2 * c[3] assert f( [1, 0, 0, 0], 0) == 0
benchmark_functions_edited/f5017.py
def f(term): while hasattr(term, 'orig'): term = term.orig return term assert f(5) == 5
benchmark_functions_edited/f9961.py
def f(value, offset): mask = 1 << offset return int(value | mask) assert f(0, 3) == 8
benchmark_functions_edited/f3322.py
def f(freqs, intercept, slope): return slope * freqs + intercept assert f(1, 0, 1) == 1
benchmark_functions_edited/f6216.py
def f(a, b): base = a res = 1 while b > 0: if b & 1: res *= base base *= base b >>= 1 return res assert f(0, 0) == 1
benchmark_functions_edited/f11052.py
def f(J, M, c): return J / (M * c) assert f(1, 1, 1) == 1
benchmark_functions_edited/f12661.py
def f(summ, assumed_idx, word, neighborhood=5): for i in range(1, neighborhood + 1): if assumed_idx + i < len(summ) and summ[assumed_idx + i] == word: return assumed_idx + i elif 0 <= assumed_idx - i < len(summ) and summ[assumed_idx - i] == word: return assumed_idx - i return None assert f( [0, 1, 2, 3, 4, 5], 0, 1, 3) == 1
benchmark_functions_edited/f5828.py
def f(value): try: return int(value) except ValueError: return value assert f('1') == 1
benchmark_functions_edited/f3372.py
def f(x, n): x_digits = str(x) for degree in range(n): x_digits += '0' return int(x_digits) assert f(0, 2) == 00
benchmark_functions_edited/f2056.py
def f(score): moves, pushes, steps = score return moves + pushes + steps assert f((3, 0, 0)) == 3
benchmark_functions_edited/f1354.py
def f(x, inf=0, sup=1): return inf if x < inf else sup if x > sup else x assert f(2, 0, 1) == 1
benchmark_functions_edited/f2239.py
def f(criterion, xs, y): loss = 0. for x in xs: loss += criterion(x, y) return loss assert f(lambda x, y: x+y, [1, 2, 3], 0) == 6
benchmark_functions_edited/f5541.py
def f(base_lr, epoch, step_epoch, multiplier=0.1): lr = base_lr * (multiplier**(epoch // step_epoch)) return lr assert f(1, 2, 3) == 1
benchmark_functions_edited/f3421.py
def f(x): return x[0] ** 2 assert f([0, 0]) == 0
benchmark_functions_edited/f2493.py
def f(n): i = 1 log = 0 while n > i: log += 1 i *= 2 return log assert f(64) == 6
benchmark_functions_edited/f741.py
def f(doc): _, terms = doc return len(terms) assert f(('', {})) == 0
benchmark_functions_edited/f14382.py
def f(tab): if not(isinstance(tab, list)): raise ValueError('Expected a list as input') numberMaxi=0 for val in tab: if val > numberMaxi: numberMaxi=val return numberMaxi assert f([2, -1, 3, 5, 4]) == 5
benchmark_functions_edited/f3323.py
def f(v1, v2): x1, y1, z1 = v1 x2, y2, z2 = v2 x = x1 * x2 y = y1 * y2 z = z1 * z2 return x + y + z assert f( (0, 0, 1), (0, 0, 1) ) == 1
benchmark_functions_edited/f8311.py
def f(precision: float, recall: float) -> float: if precision == recall == 0: return 0 return 2 * precision * recall / (precision + recall) assert f(0, 0) == 0
benchmark_functions_edited/f7594.py
def f(key, cfg, error_msg=None): error_msg = error_msg or f'Missing field `{key}` in the config file.' val = cfg.get(key) if not val: raise ValueError(error_msg) return val assert f('a', {'a': 1}) == 1
benchmark_functions_edited/f2070.py
def f(i, length): return i + 1 if i + 1 < length else 0 assert f(1, 2) == 0
benchmark_functions_edited/f9944.py
def f(total_candies): print("Splitting", total_candies, "candy" if total_candies == 1 else "candies") return total_candies % 3 assert f(91) == 1
benchmark_functions_edited/f11800.py
def f(message): score = 0 common_letters = 'etaoin shrdlu' for c in message: if c in common_letters: score += 3 else: score -= 1 return score assert f( 's') == 3
benchmark_functions_edited/f8867.py
def f(directionPointer: int) -> int: if directionPointer != 3: return directionPointer + 1 return 0 assert f(0) == 1
benchmark_functions_edited/f7015.py
def f(s1, s2) -> int: if len(s1) != len(s2): raise ValueError('Unequal lengths of input objects') return sum((x != y) for x, y in zip(s1, s2)) assert f(b'ACT', b'ACG') == 1
benchmark_functions_edited/f2605.py
def f(bider, bids, item): return bids[item] if item in bids.keys() else 0 assert f(1, {'a':10, 'b':5, 'c':15}, 'd') == 0
benchmark_functions_edited/f3592.py
def f(s): if len(s) <= 2: return int(s) else: return int(s[0:2]) assert f('0') == 0
benchmark_functions_edited/f2947.py
def f(count, length, nb_read): length /= 10**3 pm = nb_read / (10**6) rpk = count / length return rpk / pm assert f(0, 100, 100000) == 0
benchmark_functions_edited/f2487.py
def f(value, *funcs): for func in funcs: value = func(value) return value assert f(1, lambda x: x*2, lambda x: x**2) == 4