file_name stringlengths 32 36 | content stringlengths 44 898 |
|---|---|
benchmark_functions_edited/f3149.py | def f(f: float) -> float:
return 10 ** 6 / f
assert f(1000000) == 1 |
benchmark_functions_edited/f12406.py | def f(balance):
if 0.05 >= balance >= -0.05:
return 0
elif balance > 0.05:
return 1
else:
return -1
assert f(5) == 1 |
benchmark_functions_edited/f7945.py | def f(a, k, c):
if (k == 0):
return 1
elif (k & 1):
return ((a * f(a, k//2, c)**2) % c)
else:
return ((f(a, k//2, c)**2) % c)
assert f(2, 2, 13) == 4 |
benchmark_functions_edited/f12381.py | def f(func, *args, **kwds):
return func(*args, **kwds)
assert f(lambda a, b, c, d, e, f: a, 1, 2, 3, 4, 5, 6) == 1 |
benchmark_functions_edited/f10909.py | def f(number: float) -> int:
if number == 0:
return 0
if number < 0:
return -1
else:
return 1
assert f(3.14) == 1 |
benchmark_functions_edited/f6577.py | def f(input_feature, intercept, slope):
return intercept + slope * input_feature
assert f(1, 1, 1) == 2 |
benchmark_functions_edited/f10495.py | def f(list_of_nums):
largest_diff = 0
for i in range(len(list_of_nums)-1):
diff = abs(list_of_nums[i] - list_of_nums[i+1])
if diff > largest_diff:
largest_diff = diff
return largest_diff
assert f([3, 2, 1]) == 1 |
benchmark_functions_edited/f826.py | def f(x, y):
return x[0] < y[0]
assert f( [1,2], [1,2] ) == 0 |
benchmark_functions_edited/f5720.py | def f(grid, row, col, size):
return sum(
sum(cur_row[col:col + size])
for cur_row in grid[row: row + size]
)
assert f(
[[3, 3, 3, 3, 3], [3, 3, 3, 3, 3], [3, 3, 3, 3, 3]],
2, 2, 1
) == 3 |
benchmark_functions_edited/f210.py | def f(value):
result = int(value) & 0xFFFF
return result
assert f(int(0)) == 0 |
benchmark_functions_edited/f4587.py | def f(x):
s = 1
for i in range(2, x // 2 + 1):
if x % i == 0:
s += i
return s
assert f(23) == 1 |
benchmark_functions_edited/f8889.py | def f(value):
try:
temp = int(value)
except:
raise ValueError('Error in "in_decimalhours" filter. Variable must be in convertable to int format.')
output = value / 60
return output
assert f(120) == 2 |
benchmark_functions_edited/f7890.py | def f(x):
x = float(x)
if x <= 0:
raise ValueError("x cannot be converted to positive float")
return x
assert f(*[3]) == 3 |
benchmark_functions_edited/f3672.py | def f(function,*args):
try:
return function(*args)
except BaseException:
return None
assert f(lambda x: x+1, 2) == 3 |
benchmark_functions_edited/f11773.py | def f(text, column, tab_width=4):
text = text[:column]
while len(text.expandtabs(tab_width)) > column:
text = text[:(len(text)-1)]
return len(text)
assert f("a\t\t\nb", 0) == 0 |
benchmark_functions_edited/f7261.py | def f(num_a: int, num_b: int) -> int:
sum_two_numbers: int = num_a + num_b
return sum_two_numbers
assert f(3, 5) == 8 |
benchmark_functions_edited/f6111.py | def _gr_xmin_ ( graph ) :
#
_size = len ( graph )
if 0 == _size : return 0
#
x_ , y_ = graph.get_point ( 0 )
#
return x_
assert f( [] ) == 0 |
benchmark_functions_edited/f4687.py | def f(level):
if level == 40:
return 0
elif level == 20:
return 1
elif level == 10:
return 2
assert f(20) == 1 |
benchmark_functions_edited/f1518.py | def f(n: int) -> int:
return (n - 1) // 2
assert f(11) == 5 |
benchmark_functions_edited/f1269.py | def f(xv, yv):
return sum(abs(x-y) for (x,y) in zip(xv,yv))
assert f( (0, 0, 0), (0, 0, 0) ) == 0 |
benchmark_functions_edited/f6700.py | def f(data, pos):
for i, x in enumerate(data[pos:]):
if x.isspace():
return pos + i
return len(data)
assert f(b'a', 1) == 1 |
benchmark_functions_edited/f12360.py | def f(node):
if not node:
return 0
else:
# Compute the height of each subtree
left_height = f(node.left)
right_height = f(node.right)
# Use the larger one
if left_height > right_height:
return left_height + 1
else:
return right_height + 1
assert f(None) == 0 |
benchmark_functions_edited/f13082.py | def f(level, maxval):
return int(level * maxval / 10)
assert f(0, 5) == 0 |
benchmark_functions_edited/f11282.py | def f(matrix):
rows = len(matrix)
columns = len(matrix[0])
count = 0
for i in range(rows):
for j in range(columns):
if matrix[i][j] != 0:
count += 1
return count
assert f(
[
[1, 0, 0, 0, 0],
[0, 1, 0, 0, 0],
[0, 0, 1, 0, 0],
[0, 0, 0, 1, 0],
[0, 0, 0, 0, 1]
]
) == 5 |
benchmark_functions_edited/f4159.py | def f(x):
retVal = 0
if x > 0:
retVal = 1
elif x < 0:
retVal = -1
return retVal
assert f(1.1) == 1 |
benchmark_functions_edited/f861.py | def f(x):
return 1 * (x >= 0.5)
assert f(-1) == 0 |
benchmark_functions_edited/f1220.py | def f(s):
if not len(s):
return 0
return int(s.encode("hex"), 16)
assert f(b"") == 0 |
benchmark_functions_edited/f8888.py | def f(student_scores):
count = 0
for score in student_scores:
if score <= 40:
count += 1
return count
assert f([50, 50, 50]) == 0 |
benchmark_functions_edited/f11906.py | def f(text1,text2):
distance=0
if len(text1)!=len(text2):
return "Error"
else:
for i in range(len(text1)):
if text1[i]!=text2[i]:
distance+=1
else:
continue
return distance
assert f("ATAG", "ATAG") == 0 |
benchmark_functions_edited/f2652.py | def f(a, b):
return sum(1 for x,y in zip(a,b) if x!= y)
assert f(
'abcd',
'abcd',
) == 0 |
benchmark_functions_edited/f1592.py | def f(vector):
return (vector[0]**2 + vector[1]**2 + vector[2]**2) ** .5
assert f(
[0,0,0]
) == 0 |
benchmark_functions_edited/f5736.py | def f(input, *layers):
for layer in layers:
layer_func, layer_conf = layer
input = layer_func(input, **layer_conf)
return input
assert f(1, (lambda x: x+1, {})) == 2 |
benchmark_functions_edited/f9367.py | def f(a, r, m=64, n=32):
assert m >= n
mod = (r << (m - n)) ^ (1 << m)
mask = (2^n - 1)
rem = a
for i in range(m,n-1,-1):
if rem & (1 << i):
rem ^= mod
mod = mod >> 1
return rem
assert f(2, 1) == 2 |
benchmark_functions_edited/f12534.py | def f(b1: float, b2: float):
r = (b2 - b1) % 360.0
# Python modulus has same sign as divisor, which is positive here,
# so no need to consider negative case
if r >= 180.0:
r -= 360.0
return r
assert f(359, 359) == 0 |
benchmark_functions_edited/f8826.py | def f(tokens):
total = 1
for token in tokens:
value, label = token
total *= value
return total
assert f( [] ) == 1 |
benchmark_functions_edited/f7182.py | def f(x, y):
pct = round((abs(y - x) / x) * 100, 2)
print(str(pct) + '%')
return pct/100
assert f(100, 100) == 0 |
benchmark_functions_edited/f502.py | def f(n):
return int(n * (5*n - 3) / 2)
assert f(2) == 7 |
benchmark_functions_edited/f3411.py | def f(int_time):
float_time = float(int_time / 10000000)
return float_time
assert f(0) == 0 |
benchmark_functions_edited/f8933.py | def f(tp, fp, fn):
return float(tp) / (tp + fp + fn + 1.0e-9)
assert f(0, 0, 1) == 0 |
benchmark_functions_edited/f12173.py | def f(f, dl):
if isinstance(dl, list):
return map(lambda x: f(f, x), dl)
else:
return f(dl)
assert f(lambda x: x + 1, 0) == 1 |
benchmark_functions_edited/f10186.py | def formolIndex (NaOH_volume, NaOH_molarity, NaOH_fc, grams_of_honey):
number_of_NaOH_mols = NaOH_volume * NaOH_molarity * NaOH_fc
volume = number_of_NaOH_mols / NaOH_molarity
formol_index = (volume * 1000) / grams_of_honey
return formol_index
assert f(1, 1, 0, 4) == 0 |
benchmark_functions_edited/f10427.py | def f(x):
try:
return int(x)
except ValueError as e:
return e
assert f(3) == 3 |
benchmark_functions_edited/f14340.py | def f(num_container, num_children):
return num_container + num_container * num_children
assert f(1, 0) == 1 |
benchmark_functions_edited/f1582.py | def f(n):
i=1
while i*(i-1)/2<=n:
i+=1
return i-2
assert f(2) == 1 |
benchmark_functions_edited/f12089.py | def f(fun_args_tuple):
fun, args, kwargs = fun_args_tuple
return fun(*args, **kwargs)
assert f(
(
lambda: 1, # fun
(), # args
{}, # kwargs
),
) == 1 |
benchmark_functions_edited/f821.py | def f(b):
return len([x for x in bin(b) if x == "1"])
assert f(0) == 0 |
benchmark_functions_edited/f935.py | def f(longitude):
return ((longitude + 180) / 0.625)
assert f(-180) == 0 |
benchmark_functions_edited/f5462.py | def f( references, mapping ):
count = 0
for r in references:
if r in mapping:
count += 1
return count
assert f( [ 'a', 'b', 'c' ], { 'a' : 'A', 'b' : 'B', 'c' : 'C' } ) == 3 |
benchmark_functions_edited/f5214.py | def f(x: float, threshold: float) -> int:
if x <= threshold:
return 0
else:
return 1
assert f(-1, 1) == 0 |
benchmark_functions_edited/f8448.py | def f(nums):
count = 0
for num in nums:
if num > 0:
count += 1
return count
assert f([]) == 0 |
benchmark_functions_edited/f8238.py | def f(header):
for exptime_key in ("EXPTIME", "LEXPTIME", "SEXPTIME"):
if exptime_key in header:
exptime = float(header[exptime_key])
return exptime
assert f(
{'SEXPTIME': 1}
) == 1 |
benchmark_functions_edited/f10453.py | def f(r, g, b, base=256):
return (0.2126 * r + 0.7152 * g + 0.0722 * b) / base
assert f(0, 0, 0, 255) == 0 |
benchmark_functions_edited/f2669.py | def f(val):
if isinstance(val, str):
return "'{}'".format(val)
return val
assert f(5) == 5 |
benchmark_functions_edited/f14329.py | def f(func, yn,t,dt,**kwargs):
k1 = func(yn,t,**kwargs)
k2 = func(yn+dt/2*k1,t+dt/2,**kwargs)
k3 = func(yn+dt/2*k2,t+dt/2,**kwargs)
k4 = func(yn+dt*k3,t+dt,**kwargs)
a = k1+ 2 * k2 + 2 * k3 + k4
return yn + dt*a/6
assert f(lambda y, t: y, 0, 1, 1) == 0 |
benchmark_functions_edited/f12904.py | def f(original, new_val, name, log=False):
if new_val is None:
out_val = original
else:
out_val = new_val
if log:
print(' - ' + name + ' = {}'.format(out_val))
return out_val
assert f(5, None, 'x') == 5 |
benchmark_functions_edited/f11603.py | def f(s):
# Accumulator
count = 0
# Loop variable
i = 0
while i < len(s):
if s[i] == '/':
count= count + 1
i= i + 1
return count
assert f('hello/world/!') == 2 |
benchmark_functions_edited/f7558.py | def f(args):
x = args[0]
y = args[1]
return (1.5 - x + x * y) ** 2 + (2.25 - x + x * y ** 2) ** 2 + (2.625 - x + x * y ** 3) ** 2
assert f( (3.0, 0.5) ) == 0 |
benchmark_functions_edited/f1285.py | def f(value):
return max(0, min(255, round((value * 255.0) / 100.0)))
assert f(-0.0000001) == 0 |
benchmark_functions_edited/f5714.py | def f(x, means, widths, index=None):
if index is None:
return widths * x + means
return widths[index] * x + means[index]
assert f(1, [0,0,0], [1,1,1], 1) == 1 |
benchmark_functions_edited/f5456.py | def f(dictionary, key):
return dictionary.get(key)
assert f(
{'a': 1, 'b': 2},
'b'
) == 2 |
benchmark_functions_edited/f4859.py | def f(set1,set2):
if(len(set1) == 0 or len(set2) == 0):
return 0
return float(len(set1 & set2)) / len(set1 | set2)
assert f({1}, {1}) == 1 |
benchmark_functions_edited/f5514.py | def f(text):
if text is not None:
return int(text)
assert f(" 1 ") == 1 |
benchmark_functions_edited/f7635.py | def f(weights,args = None):
if args == None: args = range(len(weights))
return max(zip(weights,args))[1]
assert f([1,2,3]) == 2 |
benchmark_functions_edited/f12581.py | def f(state):
cell_id = 0
exponent = 15
for row in state:
for column in row:
if column == 1:
cell_id += pow(2, exponent)
exponent -= 1
return cell_id
assert f(
[
[0, 0, 0],
[0, 0, 0],
[0, 0, 0]
]
) == 0 |
benchmark_functions_edited/f4356.py | def f(word_list):
props = 0
for word in word_list:
if word.isprop:
props += 1
return props
assert f([]) == 0 |
benchmark_functions_edited/f12042.py | def f(arr, key):
lo, hi = 0, len(arr)
while lo < hi:
mi = (lo + hi) // 2
if arr[mi] < key:
lo = mi + 1
elif arr[mi] == key and (mi == 0 or arr[mi - 1] < key):
return mi
else:
hi = mi
return -1
assert f(list(range(10)), 9) == 9 |
benchmark_functions_edited/f10863.py | def f(n, mod):
P, Q = 1, -1
x, y = 0, 1 # U_n, U_{n+1}, n=0
for b in bin(n)[2:]:
x, y = ((y - P * x) * x + x * y) % mod, (-Q * x * x + y * y) % mod # double
if b == "1":
x, y = y, (-Q * x + P * y) % mod # add
return x
assert f(2, 2) == 1 |
benchmark_functions_edited/f13602.py | def f(count, value):
strlen = len(str(value))
if strlen > 0:
return count / strlen
else:
return 0
assert f(0, 0) == 0 |
benchmark_functions_edited/f954.py | def f(x, vmin, vmax):
return (x-vmin) % (vmax-vmin)+vmin
assert f(20, 0, 10) == 0 |
benchmark_functions_edited/f11050.py | def f(x: int, lower_bound: int, upper_bound: int):
return min(max(x, lower_bound), upper_bound)
assert f(-1, 0, 10) == 0 |
benchmark_functions_edited/f12126.py | def f(n):
"*** YOUR CODE HERE ***"
if n < 4:
return n
else:
return f(n-1) + 2*f(n-2) + 3*f(n-3)
assert f(1) == 1 |
benchmark_functions_edited/f11001.py | def f(n, k):
"*** YOUR CODE HERE ***"
sum = 1
while n and k:
sum *= n
n -= 1
k -= 1
return sum
assert f(2, 2) == 2 |
benchmark_functions_edited/f11863.py | def f(fprogress, msg):
newline = False
if fprogress != 0:
print("Progress is {:.2f} %".format(fprogress*100))
newline = True
if msg.decode() != '':
if newline:
print("\n")
print("C++ API message -> {:s}".format(msg.decode()))
return 1
assert f(0, b"") == 1 |
benchmark_functions_edited/f12821.py | def f(value: str, delimiter: str = " ") -> int:
return len(value.split(delimiter))
assert f("The first token, followed by the second token", ",") == 2 |
benchmark_functions_edited/f12917.py | def f(comment, word):
comment = comment.replace('?', ' ')
comment = comment.replace('.', ' ')
comment = comment.replace('-', ' ')
comment = comment.replace('/', ' ')
a = comment.split(" ")
count = 0
for i in range(len(a)):
if (word == a[i]):
count = count + 1
return count
assert f(
"I'm happy to be here!", "to") == 1 |
benchmark_functions_edited/f12822.py | def f(value, bitindex):
# bitstring = '{0:32b}'.format(value)
res = int((value >> bitindex) & 0x1)
if res >= 1:
return 1
else:
return 0
assert f(2, 4) == 0 |
benchmark_functions_edited/f1596.py | def f(x1, y1, x2, y2):
return (x1-x2)**2 + (y1-y2)**2
assert f(0, 0, 2, 0) == 4 |
benchmark_functions_edited/f4147.py | def f(n: int, litter: int) -> int:
nums = [0, 1]
for i in range(n - 1):
nums.append((nums[-2] * litter) + nums[-1])
return nums[-1]
assert f(4, 1) == 3 |
benchmark_functions_edited/f1633.py | def f(x_in, inf_point):
if x_in <= inf_point:
return inf_point - x_in
return 0
assert f(10, 5) == 0 |
benchmark_functions_edited/f11341.py | def f(ql, address, params):
_type = params['nTypeFlag']
if _type == 0: # 0: Keyboard Type, 1: Keyboard subtype, 2: num func keys
return 7
elif _type == 1:
return 0
elif _type == 2:
return 12
return 0
assert f(None, 0, {'nTypeFlag': 0, 'nSubTypeFlag': 2}) == 7 |
benchmark_functions_edited/f14170.py | def f(arr1, arr2):
new_arr = []
i = 0
j = 0
n = len(arr1)
while len(new_arr) < n + 1 and i < len(arr1) and j < len(arr2):
if arr1[i] < arr2[j]:
new_arr.append(arr1[i])
i += 1
else:
new_arr.append(arr2[j])
j += 1
return (new_arr[n-1] + new_arr[n]) /2
assert f(range(5), range(5)) == 2 |
benchmark_functions_edited/f12685.py | def f(highway_now: list, car_index: int) -> int:
distance = 0
cells = highway_now[car_index + 1 :]
for cell in range(len(cells)):
if cells[cell] != -1:
return distance
distance += 1
return distance + f(highway_now, -1)
assert f(
[6, -1, 6, -1, 6], 2
) == 1 |
benchmark_functions_edited/f2449.py | def f(obj):
if hasattr(obj, 'to_dense'):
return obj.to_dense()
return obj
assert f(1) == 1 |
benchmark_functions_edited/f4520.py | def f(iterable):
return sum(1 for _ in iterable)
assert f([1, 2, 3]) == 3 |
benchmark_functions_edited/f9509.py | def f(sort, low, high):
count = low
for index in range(low + 1, high + 1):
if sort[index] <= sort[low]:
count += 1
sort[count], sort[index] = sort[index], sort[count]
sort[count], sort[low] = sort[low], sort[count]
return count
assert f(list(range(10)), 9, 9) == 9 |
benchmark_functions_edited/f2774.py | def f(value):
value -= 1
result = 0
while value > 0:
result += 1
value >>= 1
return result
assert f(18) == 5 |
benchmark_functions_edited/f2313.py | def f(player_id):
if player_id == 1:
return 2
return 1
assert f(1) == 2 |
benchmark_functions_edited/f13493.py | def f(tf_row, entities, freq_matrix):
# Score is the sum of (freq in pos)-(freqs in neg) of the entities occurring in that text
n_ent_found = sum(tf_row)
if n_ent_found > 0:
score = sum(tf_row * freq_matrix[entities])/n_ent_found
else:
score = 0
return score
assert f(
[0, 0, 0],
["A", "A", "B"],
[
["A", "B", "C"],
["B", "C", "D"],
["A", "C", "D"],
]
) == 0 |
benchmark_functions_edited/f11013.py | def f(u, v):
assert len(u) == len(v)
# sum of products of pairs of corresponding coordinates of u and v
return sum([u_coord * v_coord for u_coord, v_coord in zip(u, v)])
assert f([1, 2, 3, 4], [0, 0, 0, 0]) == 0 |
benchmark_functions_edited/f6499.py | def f(height, time):
offset = time % ((height - 1) * 2)
if offset > height - 1:
return 2 * (height - 1)
else:
return offset
assert f(4, 0) == 0 |
benchmark_functions_edited/f729.py | def f(n):
return (n.bit_length() + 7) // 8
assert f(0x800) == 2 |
benchmark_functions_edited/f12078.py | def f(time, actual_time):
return round(float(actual_time) / float(time), 2)
assert f(10000, 10000) == 1 |
benchmark_functions_edited/f11978.py | def f(place1: float, place2: float,
cov1: float, cov2: float) -> float:
dist = abs(place2 - place1)
cov = cov1 + cov2
return max([dist - cov, 0])
assert f(10, 10, 0, 10) == 0 |
benchmark_functions_edited/f7460.py | def f(string_, default=1):
try:
ret = int(float(string_))
except ValueError:
return default
else:
return ret
assert f(1.0) == 1 |
benchmark_functions_edited/f2431.py | def f(lst):
for i in lst:
if i:
return(1)
return(0)
assert f(list(range(-10, 0))) == 1 |
benchmark_functions_edited/f5407.py | def f(data):
n = len(data)
if n < 1:
raise ValueError('mean requires at least one data point')
return sum(data)/n # in Python 2 use sum(data)/float(n)
assert f([1, 2, 3, 4, 5]) == 3 |
benchmark_functions_edited/f4584.py | def f(usage_key, children):
children = [str(child) for child in children]
return children.index(usage_key)
assert f(
"i4x://MITx/3.091x/problem/8964d0b65d794f269832477846d1c06a",
["i4x://MITx/3.091x/problem/8964d0b65d794f269832477846d1c06a", "i4x://MITx/3.091x/problem/286419d6472a4b1490c57545e0f0469a", "i4x://MITx/3.091x/problem/1043f68210e345528397f77224293b45"]
) == 0 |
benchmark_functions_edited/f886.py | def f(x: int) -> int:
return (x >> 10) + 1
assert f(2049) == 3 |
benchmark_functions_edited/f8589.py | def f(task):
func = task[0]
params = task[1]
return func(*params)
assert f(
(
lambda x, y: x + y,
(1, 2)
)
) == 3 |
benchmark_functions_edited/f13179.py | def f(name, map):
if name in map:
Id = map[name]
else:
Id = len(map.keys()) + 1
map[name] = Id
return Id
assert f(
'name',
{'name': 1, 'name2': 2}
) == 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.