file_name
stringlengths 32
36
| content
stringlengths 44
898
|
|---|---|
benchmark_functions_edited/f11029.py
|
def f(equity_share, interest, return_on_investment, corporate_tax):
e = equity_share
d = 1 - e
i = interest
roi = return_on_investment
t = corporate_tax
tf = 1-t
wi = e*roi + d*i*tf
return wi
assert f(1, 1, 0, 0) == 0
|
benchmark_functions_edited/f11985.py
|
def f(f, p, q):
m = 0
# Loop in f(x,y)
for x in range(0, len(f)):
for y in range(0, len(f[0])):
# +1 is used because if it wasn't, the first row and column would
# be ignored
m += ((x+1)**p)*((y+1)**q)*f[x][y]
return m
assert f([], 0, 0) == 0
|
benchmark_functions_edited/f13565.py
|
def f(n):
if n < 0:
n = (1 << 32) + n
count = 0
for i in range(32):
count += n & 1
n >>= 1
return count
assert f(13) == 3
|
benchmark_functions_edited/f6074.py
|
def f(n, res):
if n % res == 0:
return n
return (n // res + 1) * res
assert f(6, 6) == 6
|
benchmark_functions_edited/f7856.py
|
def f( binary_string ):
decimal = 0
for i in range( len( binary_string ) ):
decimal += 2**i * int( binary_string[-i-1] )
return decimal
assert f( '11' ) == 3
|
benchmark_functions_edited/f14487.py
|
def f(line):
ncommands = 0
for word in line:
if word[0] != '#':
ncommands += 1
else:
break
ncommands -= 1 # Ignore first word which must be the variable name
if ncommands < 0:
ncommands = 0 # If this is just a comment line, there's no variable name
return ncommands
assert f( ['set', 'a', '# This is a comment','set', 'b'] ) == 1
|
benchmark_functions_edited/f9887.py
|
def f(value):
if isinstance(value, str):
return [value]
else:
return value
assert f(1) == 1
|
benchmark_functions_edited/f410.py
|
def f(X, MOD):
return pow(X, MOD - 2, MOD)
assert f(7, 10) == 1
|
benchmark_functions_edited/f5528.py
|
def f(node_1, node_2):
x1, y1 = node_1
x2, y2 = node_2
return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5
assert f(
(0, 0),
(5, 0)
) == 5
|
benchmark_functions_edited/f5010.py
|
def util_key_index ( keys, key ):
result = -1
n = 0
for i in keys:
if (i == key):
result = n
n += 1
return result
assert f( ["a","b"], "b" ) == 1
|
benchmark_functions_edited/f4702.py
|
def f(n, p):
cnt = 0
while n:
n //= p
cnt += n
return cnt
assert f(30, 7) == 4
|
benchmark_functions_edited/f11065.py
|
def f(a: list) -> int:
count = 0
step = 0
for num in a:
count = count + step * num
step = step + 1 - num
return count
assert f(
[1, 0]
) == 0
|
benchmark_functions_edited/f7367.py
|
def f(terms):
max = 0
for term, frequency in terms:
if frequency > max:
max = frequency
return max
assert f(
[('a', 5), ('b', 7), ('c', 3)]
) == 7
|
benchmark_functions_edited/f8654.py
|
def f(ip):
if ip is None:
return 0
result = 0
for part in ip.split('.'):
result = (result << 8) + int(part)
return result
assert f(None) == 0
|
benchmark_functions_edited/f3724.py
|
def f(m):
m -= 1
if m < 0:
m += 12
if m >= 12:
m -= 12
return m
assert f(4) == 3
|
benchmark_functions_edited/f11507.py
|
def f(in_size, ker_size, stride, pad):
return (in_size + pad * 2 - ker_size) // stride + 1
assert f(8, 3, 1, 1) == 8
|
benchmark_functions_edited/f14157.py
|
def f(initial_velocity, acceleration, time):
dist = initial_velocity * time + 0.5 * (acceleration * time ** 2)
return dist
assert f(0, 0, 2) == 0
|
benchmark_functions_edited/f9953.py
|
def f(num_of_items: int, page_size: int) -> int:
return int((num_of_items / float(page_size)) + int(num_of_items % float(page_size) > 0))
assert f(0, 10) == 0
|
benchmark_functions_edited/f11624.py
|
def f(x):
return 0 if x < 0 else x
assert f(-100) == 0
|
benchmark_functions_edited/f2132.py
|
def f(_data, rec, _arg):
if rec is None:
return 1
return 0
assert f([1, 2, 3], [None], None) == 0
|
benchmark_functions_edited/f3300.py
|
def f(obj):
return isinstance(obj, (list, tuple)) and max(map(_depth, obj)) + 1
assert f([1000, [2000]]) == 2
|
benchmark_functions_edited/f7687.py
|
def f(c, x):
n = len(c)
p = 0.0
for i in range(0, n-1):
p = (p + c[i])*x
p += c[n-1]
return p
assert f((1, 2, 1), 0) == 1
|
benchmark_functions_edited/f5778.py
|
def f(value):
if value == "never":
return value
time_str = value.rstrip("s")
return float(time_str)
assert f("1") == 1
|
benchmark_functions_edited/f14520.py
|
def f(price_div, m_bet_size):
return (price_div**2) * ((m_bet_size**(-2)) - 1)
assert f(0, 2) == 0
|
benchmark_functions_edited/f7548.py
|
def f(point, points):
if point < points[0]:
return -1
for i in range(len(points) - 1):
if point < points[i + 1]:
return i
return len(points)
assert f(4, [1, 2, 3]) == 3
|
benchmark_functions_edited/f12740.py
|
def f(pad, in_siz, out_siz, stride, ksize):
if pad == 'SAME':
return max((out_siz - 1) * stride + ksize - in_siz, 0)
elif pad == 'VALID':
return 0
else:
return pad
assert f(1, 1, 1, 1, 2) == 1
|
benchmark_functions_edited/f1398.py
|
def f(text):
if text == "four":
return 4
return 0
assert f('zero') == 0
|
benchmark_functions_edited/f14285.py
|
def f(speed_list):
speed_mb = 0
if speed_list:
for obj in speed_list:
if not speed_mb:
speed_mb = obj.get_speed_mb()
elif obj.get_speed_mb() < speed_mb:
speed_mb = obj.get_speed_mb()
return speed_mb
assert f([]) == 0
|
benchmark_functions_edited/f14558.py
|
def f(dictionary):
seen_values = set()
duplicates = set()
for i in dictionary:
if dictionary[i] in seen_values:
duplicates.add(dictionary[i])
else:
seen_values.add(dictionary[i])
return (len(duplicates))
assert f( {'a': 2, 'b': 2, 'c': 4, 'd': 4} ) == 2
|
benchmark_functions_edited/f1282.py
|
def f(a, B, p):
return pow(B, a, p)
assert f(1, 4, 31) == 4
|
benchmark_functions_edited/f8477.py
|
def f(a, b):
assert a in (0, 1)
assert b in (0, 1)
if a == b:
return 1
else:
return 0
assert f(0, 1) == 0
|
benchmark_functions_edited/f6912.py
|
def f(dur, anal):
total_samples = dur * anal["sample_rate"]
return int(total_samples / anal["hop_size"])
assert f(0.5, {"sample_rate": 2, "hop_size": 1.0}) == 1
|
benchmark_functions_edited/f6223.py
|
def f(m=5):
if m > 1:
return 3 * 2 ** (m - 2)
return 1
assert f(1) == 1
|
benchmark_functions_edited/f11469.py
|
def f(nums):
left, right = 0, len(nums) - 1
while left <= right:
mid = (left + right) // 2
if nums[mid] == mid:
left = mid + 1
else:
if nums[mid - 1] == mid - 1:
return mid
right = mid - 1
return left
assert f([1]) == 0
|
benchmark_functions_edited/f4402.py
|
def f(iterable):
try:
return next(iterable)
except StopIteration:
return None
finally:
del iterable
assert f(reversed(range(10))) == 9
|
benchmark_functions_edited/f4362.py
|
def f(lst):
try:
return sum(f(a) for a in lst)
except TypeError:
return lst ** 2
assert f([1, [0, [2]]]) == 5
|
benchmark_functions_edited/f9928.py
|
def f(val):
try:
return int(val)
except ValueError:
return 0
assert f('') == 0
|
benchmark_functions_edited/f5518.py
|
def f(number, divisor):
# type: (int, int) -> int
if number % divisor:
number = (number // divisor + 1) * divisor
return number
assert f(7, 3) == 9
|
benchmark_functions_edited/f7967.py
|
def f(n):
if n < 0:
raise ValueError('')
return 1 if n<=2 else f(n-1) + f(n-2)
assert f(3) == 2
|
benchmark_functions_edited/f12537.py
|
def f(dim, index, start, stop):
length = stop - start
if -length <= index < 0:
normindex = index + length
elif start <= index < stop:
normindex = index - start
else:
fstr = "expected dim {} index in range [{}, {})"
raise IndexError(fstr.format(dim, start, stop))
return normindex
assert f(1, 0, 0, 2) == 0
|
benchmark_functions_edited/f13335.py
|
def f(value, old_min, old_max, new_min, new_max):
return new_min + (((value - old_min) / (old_max - old_min)) * (new_max - new_min))
assert f(20, 0, 10, 0, 1) == 2
|
benchmark_functions_edited/f4557.py
|
def f(list_var, index, default=None):
if index < len(list_var):
return list_var[index]
else:
return default
assert f(list(range(10)), -1) == 9
|
benchmark_functions_edited/f4823.py
|
def f(bytes):
n = 0
for (i, byte) in enumerate(bytes):
n += ord(byte) << (8 * i)
return n
assert f(b'') == 0
|
benchmark_functions_edited/f11589.py
|
def f(filename="", text=""):
with open(filename, 'a', encoding="utf-8") as fl_opened:
return fl_opened.write(text)
assert f("test.txt", "") == 0
|
benchmark_functions_edited/f5174.py
|
def f(param1, param2, msg="{},{}"):
if param1 != param2:
raise ValueError(msg.format(param1, param2))
return param1
assert f(1, 1) == 1
|
benchmark_functions_edited/f3553.py
|
def f(s, SC):
if len(s) == len(SC):
return 1
else:
return 0
assert f('a', 'ab') == 0
|
benchmark_functions_edited/f6769.py
|
def f(x, a, b):
return max(a, min(x, b))
assert f(0, 0, 20) == 0
|
benchmark_functions_edited/f8863.py
|
def f(year, month, day):
date = '%d-%d-%d' % (year, month, day)
if month <= 2:
month += 12
year -= 1
q = day
m = month
k = year % 100
j = year // 100
h = (q + ((13 * (m + 1)) // 5) + k + (k // 4) + (j // 4) - (2 * j)) % 7
return h
assert f(2021, 1, 1) == 6
|
benchmark_functions_edited/f11895.py
|
def f(assists, turnovers):
try:
ratio = float(assists) / turnovers
except ZeroDivisionError:
ratio = float(assists)
return round(ratio, 2)
assert f(0, 1) == 0
|
benchmark_functions_edited/f5265.py
|
def f(string):
if string is not None:
r = string.replace("b-sprite stars ratings_stars_","")
r = r.replace("star_track","")
r = r.strip()
else:
r = 0
return r
assert f(None) == 0
|
benchmark_functions_edited/f8860.py
|
def f(s, sentence_delimiters=set([".", "!", "?"])):
cs = " ".join([p.strip() for p in s.split("\n")])
count = 0
for c in cs:
if c in sentence_delimiters:
count += 1
return count
assert f("Hello. And hello again.") == 2
|
benchmark_functions_edited/f4766.py
|
def f(step, warmup_step=4000):
if step <= warmup_step:
return step / warmup_step
return (warmup_step ** 0.5) * (step ** -0.5)
assert f(0, 5) == 0
|
benchmark_functions_edited/f11018.py
|
def f(root):
if root is None:
return 0
return root.data + f(root.lchild) + f(root.rchild)
assert f(None) == 0
|
benchmark_functions_edited/f9643.py
|
def f(spellbook, level):
try:
return spellbook.slot_level(level).max_capacity
except AttributeError:
return 0
assert f(None, 2) == 0
|
benchmark_functions_edited/f3690.py
|
def f(val, fncn, new_val):
if val is None: return new_val
else: return fncn(val, new_val)
assert f(3, min, 1) == 1
|
benchmark_functions_edited/f3902.py
|
def f(conf):
TN, FP, FN, TP = conf
if (TN + FP) == 0:
return float('nan')
return TP/float(TP+FN)
assert f( (1, 0, 0, 2) ) == 1
|
benchmark_functions_edited/f3461.py
|
def f(number1, number2):
while number2 != 0:
number1, number2 = number2, number1 % number2
return number1
assert f(3, 2) == 1
|
benchmark_functions_edited/f11562.py
|
def f(n, k):
"*** YOUR CODE HERE ***"
i = 0
total = 1
while i < k:
total = total * n
n -= 1
i += 1
return total
assert f(2, 1) == 2
|
benchmark_functions_edited/f14237.py
|
def f(responses, derived):
try:
amount_1 = float(responses.get('your_child_support_paid_b', 0))
except ValueError:
amount_1 = 0
try:
amount_2 = float(responses.get('your_spouse_child_support_paid_b', 0))
except ValueError:
amount_2 = 0
return abs(amount_1 - amount_2)
assert f(
{'your_child_support_paid_b': 0, 'your_spouse_child_support_paid_b': 1},
{}
) == 1
|
benchmark_functions_edited/f13660.py
|
def f(l1, x, y, z):
j = 0
for i in l1:
if (
sum(i) - 2 * (i[x] + i[y] + i[z]) < 0
):
j += 1
return j
assert f(
[ [1,1,1], [0,1,1] ], 0, 1, 2
) == 2
|
benchmark_functions_edited/f9941.py
|
def f(a: int, b: int) -> int:
try:
return a // b
except ArithmeticError:
raise ValueError("divisor can't be zero")
finally:
pass
assert f(10, 2) == 5
|
benchmark_functions_edited/f2019.py
|
def f(coords):
return (coords[1][0] - coords[0][0] + 1)*(coords[1][1] - coords[0][1] + 1)
assert f( ((1, 1), (1, 1)) ) == 1
|
benchmark_functions_edited/f9700.py
|
def f(array: list):
newArray = array.copy()
for index in range(1, len(newArray)):
j = index
while j > 0 and newArray[j] < newArray[j-1]:
newArray[j], newArray[j-1] = newArray[j-1], newArray[j]
j -= 1
return newArray[-1]
assert f(list(range(10))) == 9
|
benchmark_functions_edited/f8982.py
|
def f(words, n):
return max(len(words) - n + 1, 0)
assert f(list(range(3)), 1) == 3
|
benchmark_functions_edited/f2288.py
|
def f(row, L, A):
return row * L / A
assert f(2, 1, 2) == 1
|
benchmark_functions_edited/f10950.py
|
def f(image_name):
values = image_name.split("_")
values1 = values[4].split(".")
rotation = values1[0]
return(int(rotation))
assert f("flipped_1_1_1_0_1.jpg") == 0
|
benchmark_functions_edited/f230.py
|
def f(key):
return len(key[1])
assert f(("k1", "1111111")) == 7
|
benchmark_functions_edited/f3079.py
|
def f(number: int):
return sum(i * i for i in range(number + 1))
assert f(2) == 5
|
benchmark_functions_edited/f13752.py
|
def f(input):
output = dict()
if isinstance(input, list):
for map in input:
output.update(map)
else: # Not a list of dictionaries
output = input
return output
assert f(3) == 3
|
benchmark_functions_edited/f4043.py
|
def f(list_object):
min_value = min(list_object)
max_value = max(list_object)
return max_value - min_value
assert f([1, 2, 3, 4, 5]) == 4
|
benchmark_functions_edited/f10167.py
|
def f( n ):
parity = 0
while( n ):
parity ^= (n&1)
n >>= 1
return parity
assert f( 10 ) == 0
|
benchmark_functions_edited/f12008.py
|
def f(numLeft: int) -> int:
# If the number left is greater than the max, call 200
if numLeft >= 200:
return 200
# else call the number left
else:
return numLeft
assert f(5) == 5
|
benchmark_functions_edited/f13414.py
|
def f(x):
# Check that x is positive
if x < 0:
print("Error: negative value supplied")
return -1
else:
print("Here we go again...")
# Initial guess for the square root.
z = x / 2.0
# Continuously improve the guess.
# Adapted from https://tour.golang.org/flowcontrol/8
while abs(x - (z*z)) > 0.0000001:
z = z - (((z * z) - x) / (2 * z))
return z
assert f(0) == 0
|
benchmark_functions_edited/f7115.py
|
def f(obj):
try:
return obj.id
except AttributeError:
return obj
assert f(0) == 0
|
benchmark_functions_edited/f13975.py
|
def f(parentOp, childOp):
if parentOp == childOp:
return 0
parentLev = 1
while True:
parent = childOp.parent(parentLev)
if parent is None:
return None
elif parent is parentOp:
return parentLev
parentLev += 1
assert f(None, None) == 0
|
benchmark_functions_edited/f14345.py
|
def f(n):
def staircase(m):
if m == 0:
return 1
if m < 0:
return 0
return staircase(m - 1) + staircase(m - 2) + staircase(m - 3)
return staircase(n)
assert f(3) == 4
|
benchmark_functions_edited/f7343.py
|
def f(node):
size = 0
if node:
size += 1
if node.left:
size += node.left.size
if node.right:
size += node.right.size
return size
return size
assert f(None) == 0
|
benchmark_functions_edited/f1296.py
|
def f(a, b) -> bool:
return (a > b) - (a < b)
assert f(4, 3) == 1
|
benchmark_functions_edited/f10281.py
|
def f(d_rev):
maxs = 0
for x in d_rev:
len_bit = len(x)
if(len_bit > maxs):
maxs = len_bit
return maxs
assert f(dict()) == 0
|
benchmark_functions_edited/f10612.py
|
def f(energy_joule):
energy_kwh = energy_joule / (1000 * 3600)
return energy_kwh
assert f(0) == 0
|
benchmark_functions_edited/f358.py
|
def f(s):
i = int(s, 16)
return i
assert f("0x0000") == 0
|
benchmark_functions_edited/f6989.py
|
def f(row):
value_squared = row[-2]
value = row[-3]
if value_squared != value_squared:
return value
else:
return value_squared
assert f(
["a", "b", "c", "a", "a", "b", "b", "c", "a", 1, 0, 3]) == 0
|
benchmark_functions_edited/f13448.py
|
def f(mask: int) -> int:
if mask == 0:
raise ValueError("mask is all zeros")
count = 0
for i in range(mask.bit_length()):
if mask & 1:
return count
count += 1
mask >>= 1
return count
assert f(0b11111111) == 0
|
benchmark_functions_edited/f4417.py
|
def f(num_voters, lang_votes):
return sum([int(100 * i / num_voters + 0.5) for i in lang_votes])
assert f(10, []) == 0
|
benchmark_functions_edited/f1082.py
|
def f(a, b, Rv = 3.1):
a_lam_aV = a + b / Rv
return a_lam_aV
assert f(0,0) == 0
|
benchmark_functions_edited/f2795.py
|
def f(score1, score2):
return score1*score1 + score2*score2
assert f(1, 0) == 1
|
benchmark_functions_edited/f654.py
|
def f(**kwargs):
return kwargs['a']
assert f(**{'a': 1, 'b': 2}) == 1
|
benchmark_functions_edited/f13355.py
|
def f(complete, incomplete):
s = 0
for a, b in zip(complete[:-1], incomplete):
s += a
s -= b
return s + complete[len(complete) - 1]
assert f(list(range(10)), [0, 1, 3, 4, 5, 6, 7, 8, 9]) == 2
|
benchmark_functions_edited/f165.py
|
def f(Kp_GCC,u,x):
return Kp_GCC*u + x
assert f(0,0,2) == 2
|
benchmark_functions_edited/f9345.py
|
def f(state):
if state == "S":
return 0
if state == "E":
return 1
if state == "I":
return 2
if state == "R":
return 3
assert f("I") == 2
|
benchmark_functions_edited/f402.py
|
def f(m, n, e):
enc_m = pow(m, e, n)
return enc_m
assert f(1, 2, 3) == 1
|
benchmark_functions_edited/f1141.py
|
def f(x):
return 1 * (x > 0)
assert f(2) == 1
|
benchmark_functions_edited/f2942.py
|
def f(val: int, min_val: int, max_val: int) -> int:
return min(max_val, max(min_val, val))
assert f(-3, 1, 3) == 1
|
benchmark_functions_edited/f3476.py
|
def f(a):
cnt = 0
while a:
a &= a - 1
cnt += 1
return cnt
assert f(9) == 2
|
benchmark_functions_edited/f3609.py
|
def f(number: int, euler: int):
if number % euler == 0:
return euler
return f(euler, number % euler)
assert f(12, 1) == 1
|
benchmark_functions_edited/f7386.py
|
def f(queue_dict):
return max(
[
queue_dict[r]["max_jobs"]
for r in queue_dict
if "max_jobs" in queue_dict[r]
]
)
assert f(
{
"queue1": {},
"queue2": {
"max_jobs": 0
},
"queue3": {}
}
) == 0
|
benchmark_functions_edited/f4976.py
|
def f(the_list):
count = sum(len(x) for x in the_list)
return count
assert f([]) == 0
|
benchmark_functions_edited/f2873.py
|
def f(value: str) -> int:
return len(value.encode("utf-8"))
assert f("test") == 4
|
benchmark_functions_edited/f3148.py
|
def f(name):
if name %2 ==0:
target = 0
else:
target = 1
return target
assert f(13) == 1
|
benchmark_functions_edited/f3938.py
|
def f(p, l):
pos = l.index(p)
if pos + 1 >= len(l):
return l[0]
else:
return l[pos + 1]
assert f(2, [1, 2, 2]) == 2
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.