file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f13356.py
def f(num): num = float(num) / 100 num = round(num * 4) / 4 num = num * 100 return int(num) assert f(5) == 0
benchmark_functions_edited/f12524.py
def f(distance_km: float, litres_per_100km: float): return distance_km * litres_per_100km / 100.0 assert f(0, 100) == 0
benchmark_functions_edited/f9846.py
def f(number_of_layers, elapsed_bake_time): return elapsed_bake_time + (number_of_layers * 2) assert f(0, 3) == 3
benchmark_functions_edited/f8784.py
def f(x1, y1, x2, y2, x, y): px = x2 - x1 py = y2 - y1 dd = px * px + py * py u = ((x - x1) * px + (y - y1) * py) / max(1e-9, float(dd)) dx = x1 + u * px - x dy = y1 + u * py - y return dx * dx + dy * dy assert f(1, 1, 1, 2, 3, 3) == 4
benchmark_functions_edited/f13491.py
def f(p, q, r): # We use Sarrus' Rule to calculate the determinant. # (could also use the Numeric package...) sum1 = q[0]*r[1] + p[0]*q[1] + r[0]*p[1] sum2 = q[0]*p[1] + r[0]*q[1] + p[0]*r[1] return sum1 - sum2 assert f( (1, 1), (3, 2), (2, 3) ) == 3
benchmark_functions_edited/f1737.py
def f(a, b): return sum([va * vb for va, vb in zip(a, b)]) assert f( [1, 0], [0, 1], ) == 0
benchmark_functions_edited/f2318.py
def f(l): if ".mp3" in str(l): return 1 else: return 0 assert f(1) == 0
benchmark_functions_edited/f9122.py
def f(dict, key, default): try: return dict[key] except KeyError: value = default() dict[key] = value return value assert f(dict(), 'bar', lambda: 2) == 2
benchmark_functions_edited/f13011.py
def f(datapoint_from_settings, column, data_type): if column in datapoint_from_settings: return datapoint_from_settings[column] else: if data_type == int or data_type == float: return 0 elif data_type == str: return "" elif data_type == bool: return False assert f( {'b': 2}, 'b', int) == 2
benchmark_functions_edited/f4936.py
def f(val, _min, _max): if val > _max: return _max if val < _min: return _min return val assert f(-1, 0, 100) == 0
benchmark_functions_edited/f1130.py
def f(o, copy): if copy: return copy(o) else: return o assert f(3, lambda x: x+1) == 4
benchmark_functions_edited/f14423.py
def f(target, y): if len(y) - 1 <= target <= 0: raise(ValueError("Invalid target, array size {}, given {}".format(len(y), target))) return (y[target + 1] - 2*y[target] + y[target - 1])/4 assert f(2, [1, 1, 1, 1]) == 0
benchmark_functions_edited/f3290.py
def f(a, b): if a > b: return a return b assert f(3, 4) == 4
benchmark_functions_edited/f13184.py
def f(S): o = 0 for i, s in enumerate(S, 1): o += s == "(" c = 0 for g in S[i:]: c += g == ")" if o == c: return i assert f( "())(" ) == 2
benchmark_functions_edited/f7611.py
def f(kmer_size: str) -> int: value = int(kmer_size) assert 1 <= value <= 32 return value assert f(1) == 1
benchmark_functions_edited/f2762.py
def f(byte: int, index: int) -> int: assert 0 <= byte <= 255 assert 0 <= index <= 7 return (byte >> index) & 1 assert f(255, 0) == 1
benchmark_functions_edited/f3910.py
def f(i): i ^= i >> 16 i = (i * 0x85ebca6b) & 0xffffffff i ^= i >>13 i = (i * 0xc2b2ae35) & 0xffffffff i ^= i >> 16 return i assert f(0) == 0
benchmark_functions_edited/f11802.py
def f(d: dict, key_path: str): keys = key_path.split('.') d0 = d while len(keys) > 1: d0 = d0.get(keys.pop(0), {}) return d0.get(keys.pop(0)) assert f( {'a': {'b': 1}}, 'a.b') == 1
benchmark_functions_edited/f3159.py
def f(n): result = 1 while n > 1: result = result * n n -= 1 return result assert f(1) == 1
benchmark_functions_edited/f8288.py
def f(efficiencies): if type(efficiencies) == list or type(efficiencies) == tuple: return max(map(float,efficiencies)) else: return float(efficiencies) assert f((4, 5, 6)) == 6
benchmark_functions_edited/f14155.py
def f(n: int, ind: int, command: str): # ensure index exists in indices if -n <= ind < n: return ind else: raise IndexError(f"Index {ind} does not exist... Run `kaos {command} list` again") assert f(10, 5, "index") == 5
benchmark_functions_edited/f8194.py
def f(start, end, divisor): counter = start num_multiples = 0 while counter <= end: if counter % divisor == 0: num_multiples += 1 counter += 1 return num_multiples assert f(1, 10, 10) == 1
benchmark_functions_edited/f9919.py
def f(list): result = 0 for index, number in enumerate(list): result += index * number return result assert f( [1, 1, 1] ) == 3
benchmark_functions_edited/f13269.py
def f(n): "*** YOUR CODE HERE ***" factor = n - 1 while factor > 0: if n % factor == 0: return factor factor -= 1 assert f(15) == 5
benchmark_functions_edited/f8162.py
def f(kernel_size, stride): rem = (kernel_size + stride) % stride return kernel_size if rem == 0 else kernel_size + stride - rem assert f(5, 1) == 5
benchmark_functions_edited/f7419.py
def f(*args): for a in args: if a is not None: return a return None assert f(1, 2) == 1
benchmark_functions_edited/f12971.py
def f(num): num = str(num) length = len(num) armstrong_value = 0 for char in num: armstrong_value += int(char)**length return armstrong_value assert f(1) == 1
benchmark_functions_edited/f13433.py
def f(x, a, b, c): return a * (b ** 2) * x + c * x - a * b * (x ** 2) + (a * (x ** 3)) / 3 assert f(0, 4, 0, 0) == 0
benchmark_functions_edited/f5239.py
def f(s, eps): mysum = 0.0 k=-1 while (mysum < 1-eps): k += 1 mysum += s[k]**2 return k+1 assert f([1,2,3], 0.03) == 1
benchmark_functions_edited/f7406.py
def f(bool_value): if bool_value: return 1 else: return 0 assert f(True) == 1
benchmark_functions_edited/f1719.py
def f(set_1: set, set_2: set) -> float: return len(set_1.symmetric_difference(set_2)) assert f(set([1, 2]), set([1, 2])) == 0
benchmark_functions_edited/f9652.py
def f(a, loc=False): maxval= a[0] maxloc= 0 for i in range(1, len(a)): if a[i] > maxval: maxval = a[i] maxloc =i if loc==True: return maxval, maxloc else: return maxval assert f([0, 1]) == 1
benchmark_functions_edited/f10952.py
def f(s, l, toks): n = toks[0] try: return int(n) except ValueError: return float(n) assert f(None, None, [1]) == 1
benchmark_functions_edited/f6918.py
def f(registers, opcodes): test_result = registers[opcodes[1]] & registers[opcodes[2]] return test_result assert f( {0: 1, 1: 0, 2: 0}, [0, 2, 0, 1]) == 0
benchmark_functions_edited/f2459.py
def f(msg): num_favorited = msg['favorited_by'] return len(num_favorited) assert f({'favorited_by': ['a', 'b']}) == 2
benchmark_functions_edited/f9943.py
def f(a, b): try: return a ** b except: raise ValueError assert f(1, 2) == 1
benchmark_functions_edited/f2722.py
def f(test, if_result, else_result): if(test): return if_result return else_result assert f(True, 1, 2) == 1
benchmark_functions_edited/f950.py
def f(numbers): return sum(numbers) / len(numbers) assert f([0, 1, 2]) == 1
benchmark_functions_edited/f12187.py
def f(guess): if len(guess) > 1: return 0 else: if guess.isalpha(): return 1 else: return 0 assert f("hello") == 0
benchmark_functions_edited/f6372.py
def f(x, n): if n == 0: return 1 else: partial = f(x, n // 2) result = partial * partial if n % 2 == 1: result *= x return result assert f(4, 1) == 4
benchmark_functions_edited/f9778.py
def f(arg): return int(bool(arg)) assert f({False}) == 1
benchmark_functions_edited/f7500.py
def f(previous_sequence, next_sequence): if previous_sequence is None: return 0 delta = next_sequence - (previous_sequence + 1) return delta & 0xFFFFFFFF assert f(0, 1) == 0
benchmark_functions_edited/f12458.py
def f(dictTotal): totalVal = 0.0 for keyVal in dictTotal.keys(): for keyVal2 in dictTotal[keyVal].keys(): totalVal += dictTotal[keyVal][keyVal2] return round(totalVal, 2) assert f( { 'cat': { 'legs': 4, 'eyes': 2, }, }, ) == 6
benchmark_functions_edited/f6040.py
def f(string): if string: size = string.count(string[0]) return size + 4 if string[0] == "'" else -size + 5 else: return 5 assert f("C'") == 4
benchmark_functions_edited/f2165.py
def f(code): code = str(code) if code[0] == '3': return 0 return 1 assert f(399001) == 0
benchmark_functions_edited/f9422.py
def f(list): # test sum = 0 for entry in list: sum += entry avg = sum / len(list) return int(avg) assert f([10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]) == 5
benchmark_functions_edited/f3718.py
def f(x): if isinstance(x["base_count"], list): return int(x["base_count"][0] or 0) else: return 0 assert f({"base_count": ""}) == 0
benchmark_functions_edited/f2897.py
def f(val=None): global _special_effect if val is not None: _special_effect = val return _special_effect assert f(1) == 1
benchmark_functions_edited/f5605.py
def f(rot,twotheta,ccwrot): if ccwrot: return(rot-twotheta/2.0) else: return(-rot-twotheta/2.0) assert f(0,0,1) == 0
benchmark_functions_edited/f1411.py
def f(pair, x): return ((pair[0] - x) / pair[1])**2 assert f((1, 2), 1) == 0
benchmark_functions_edited/f2211.py
def f(b, n): return 0 if n==0 else (1 if b&1==1 else 0) + f(b>>1, n-1) assert f(0, 0) == 0
benchmark_functions_edited/f3181.py
def f(str, set): for c in set: if c not in str: return 0 return 1 assert f( 'abcde', set( 'de' ) ) == 1
benchmark_functions_edited/f14499.py
def f(dataset_output, binning_array): label = 0 for j in range(len(binning_array) - 1): if dataset_output >= binning_array[j] and dataset_output <= binning_array[j + 1]: label = j break return label assert f(15, [10, 20, 25]) == 0
benchmark_functions_edited/f8932.py
def f(state_vector): return state_vector.index(1) assert f([0, 1, 0, 0]) == 1
benchmark_functions_edited/f5076.py
def f(x3, x4): if x3 > x4: return x3 elif x3 == x4: return x3 elif x4 > x3: return x4 assert f(2, 3) == 3
benchmark_functions_edited/f11759.py
def f(a, b): r0 = range(0, len(b) + 1) r1 = [0] * (len(b) + 1) for i in range(0, len(a)): r1[0] = i + 1 for j in range(0, len(b)): c = 0 if a[i] is b[j] else 1 r1[j + 1] = min(r1[j] + 1, r0[j + 1] + 1, r0[j] + c) r0 = r1[:] return r1[len(b)] assert f('ab', 'ab') == 0
benchmark_functions_edited/f589.py
def f(y, y_pred): return (y - y_pred)**2 assert f(1, 1) == 0
benchmark_functions_edited/f14424.py
def f(mask): if isinstance(mask, (list, tuple)): return list(map(nested_list_elements_to_int, mask)) else: return int(mask) assert f(5) == 5
benchmark_functions_edited/f6988.py
def f(dic, path): parts = path.split('.') loc = dic for part in parts: if part not in loc: raise KeyError(path) loc = loc[part] return loc assert f( {"a": 1, "b": {"c": 2}}, 'b.c' ) == 2
benchmark_functions_edited/f14436.py
def f(input_list, item, first=0, last=None): if last is None: last = len(input_list) - 1 if first > last: return None mid_ix = (first + last) // 2 if input_list[mid_ix] == item: return mid_ix elif input_list[mid_ix] < item: return f(input_list, item, mid_ix + 1, last) else: return f(input_list, item, first, mid_ix - 1) assert f( [1, 2, 3, 4, 5], 3 ) == 2
benchmark_functions_edited/f1232.py
def f(num, factor): return (num // factor) * factor assert f(2, 2) == 2
benchmark_functions_edited/f4114.py
def f(lines): return sum(map(len, lines)) assert f([]) == 0
benchmark_functions_edited/f12299.py
def f(times, ref_time): return next(i[0] for i in enumerate(times) if i[1] > ref_time) assert f(list(range(100)), -1) == 0
benchmark_functions_edited/f1211.py
def f(l): return 4 * ((l + 3) // 4) - l assert f(4) == 0
benchmark_functions_edited/f6872.py
def f(x, y): return 2*(y < 0) + 1*((x < 0) ^ (y < 0)) assert f(0, 0) == 0
benchmark_functions_edited/f7187.py
def f(base: int, exp: int, modulus: int) -> int: return pow(base, exp, modulus) assert f(2, 4, 3) == 1
benchmark_functions_edited/f2045.py
def f(val1, val2): return int(val1 + int(val2[0])) assert f(2, '3') == 5
benchmark_functions_edited/f4984.py
def f(siblings, index): try: return siblings[index] except IndexError: pass assert f(range(5), 3) == 3
benchmark_functions_edited/f3255.py
def f(lis): if isinstance(lis, list): return list(map(complete_copy, lis)) return lis assert f(1) == 1
benchmark_functions_edited/f710.py
def f(arg): return len(arg.encode('utf-8')) assert f(u'\u0419\u0438\u043c') == 6
benchmark_functions_edited/f5700.py
def f(spot, guess): if spot==1: return 2 if guess==3 else 3 if spot==2: return 1 if guess==3 else 3 if spot==3: return 1 if guess==2 else 2 assert f(1, 1) == 3
benchmark_functions_edited/f3408.py
def f(x, a, b): return a*x + b assert f(1, 1, 1) == 2
benchmark_functions_edited/f1009.py
def f(xs): return len([x for x in xs if x is None]) assert f({'a': 1, 'b': 2}) == 0
benchmark_functions_edited/f13258.py
def f(payload, payload_size): checksum = 0 length = min(payload_size, len(payload)) for i in range (0, length): checksum += ord(payload[i]) return checksum assert f(b'abc', 0) == 0
benchmark_functions_edited/f10979.py
def f(lista_palavras): freq = dict() for palavra in lista_palavras: p = palavra.lower() if p in freq: freq[p] += 1 else: freq[p] = 1 return len(freq) assert f( ['a', 'a', 'b', 'b', 'b', 'c', 'c', 'c'] ) == 3
benchmark_functions_edited/f5780.py
def f(line): index = 0 for i in line: if i == " ": index += 1 else: break return index assert f( " " ) == 4
benchmark_functions_edited/f3243.py
def f(registers, register): if register >= 'a' and register <= 'z': return registers[register] return int(register) assert f({'a': 1}, 'a') == 1
benchmark_functions_edited/f8063.py
def f(array, item): for i in range(len(array)): if array[i] == item: return i return len(array) assert f([1, 2], 2) == 1
benchmark_functions_edited/f3433.py
def f(lst): total = 0 for v in lst: total = total + v return total assert f( [1,2,3] ) == 6
benchmark_functions_edited/f13176.py
def f(v, index, x): mask = 1 << index # Compute mask, an integer with just bit 'index' set. v &= ~mask # Clear the bit indicated by the mask (if x is False) if x: v |= mask # If x was True, set the bit indicated by the mask. return v # Return the result, we're done. assert f(1, 1, 1) == 3
benchmark_functions_edited/f11491.py
def f(x): assert type(x) is int, "`x` should be of type `int`" assert 0 <= x, "`x` should be >= 0" size = 0 while True: x >>= 8 size += 1 if x == 0: return size assert f(72057594037927935) == 7
benchmark_functions_edited/f133.py
def f(dx, dy): return max(dx, dy) assert f(2, 0) == 2
benchmark_functions_edited/f7158.py
def f(string_of_ints): numbers = string_of_ints.split() answer = 0 for i in numbers: answer = answer + int(i) return answer assert f( "4") == 4
benchmark_functions_edited/f14207.py
def f(u, f, dt): return u + dt * f(u) assert f(1, lambda x: 2*x, 2) == 5
benchmark_functions_edited/f6783.py
def f(n: int) -> int: if n <= 2: return 1 return f(n - 1) + f(n - 2) assert f(0) == 1
benchmark_functions_edited/f6141.py
def f(row): if row: count = row.c # c as count by name convention else: count = 0 return count assert f(None) == 0
benchmark_functions_edited/f13729.py
def f(checker, items): returncode = 0 for item in items: check = checker(item) if check > 0: returncode = 1 return returncode assert f(lambda item: 0, [1,2]) == 0
benchmark_functions_edited/f3131.py
def f(number): if number == 0: return 1 else: return number * f(number - 1) assert f(2) == 2
benchmark_functions_edited/f13139.py
def f(value1, value2): distance = value1 ^ value2 length = -1 while (distance): distance >>= 1 length += 1 return max(0, length) assert f(0x0000000000000001, 0x0000000000000000) == 0
benchmark_functions_edited/f4856.py
def f(m: int): if int(m) != m or m < 0: raise ValueError("Window length m must be a non-negative integer") return m <= 1 assert f(0) == 1
benchmark_functions_edited/f11073.py
def f(plugins, name, group): for index, item in enumerate(plugins): if ( item[0] is not None and item[0] == name and item[3] is not None and item[3] == group ): return index + 1 return 0 assert f([], "NotMyName", "NotMyGroup") == 0
benchmark_functions_edited/f4698.py
def f(positions, total, index, length): return positions - total / 2 + length / 2 + index * length assert f(0, 0, 0, 0) == 0
benchmark_functions_edited/f5038.py
def f(x): return bin(x).count('1') assert f(0x01) == 1
benchmark_functions_edited/f4896.py
def f(bit_list): out = 0 for bit in bit_list: out = (out << 1) | bit return out assert f([1, 0, 1]) == 5
benchmark_functions_edited/f3838.py
def f(datum): result = datum['s'] if datum['m'] > 0: result += datum['m'] * 60 return result assert f({'s': 3,'m': 0}) == 3
benchmark_functions_edited/f7361.py
def f(n, k): return 1 if k==0 else 0 if n == 0 else (f(n-1, k) + f(n-1, k-1)) assert f(4,4) == 1
benchmark_functions_edited/f9024.py
def f(n): d = 0 m = 1 while True: for c in str(m): d += 1 if d == n: return int(c) m += 1 assert f(5) == 5
benchmark_functions_edited/f1539.py
def f(vmfObject, idPropName='id'): return int(vmfObject[idPropName]) assert f({'id': '0'}) == 0
benchmark_functions_edited/f8333.py
def f(ep, ed): k = ep return k*(ed[1]-ed[0]) assert f(1, [2, 3]) == 1
benchmark_functions_edited/f9293.py
def f(x,p,d): if x <= d[p][0.20]: return 1 elif x <= d[p][0.4]: return 2 elif x <= d[p][0.6]: return 3 elif x <= d[p][0.8]: return 4 else: return 5 assert f(0.01, 'a', {'a': {0.2: 100, 0.4: 200, 0.6: 300, 0.8: 400, 1.0: 500}}) == 1