file_name
stringlengths 32
36
| content
stringlengths 44
898
|
|---|---|
benchmark_functions_edited/f1649.py
|
def f(m, n):
res = 1
for i in range(n):
res *= (m - i)
return res
assert f(365, 0) == 1
|
benchmark_functions_edited/f7435.py
|
def f(f, args):
if None in args:
return None
else:
return f(*args)
assert f(lambda x, y, z: x+y+z, (2, 3, 4)) == 9
|
benchmark_functions_edited/f10141.py
|
def f(n):
if n == 1:
return 1
return f(n - 1) * n
assert f(2) == 2
|
benchmark_functions_edited/f2336.py
|
def f(A,x,y0,func):
err=y0 - func(x,A)
return err
assert f(1,1,2,lambda x,y:x+y) == 0
|
benchmark_functions_edited/f6200.py
|
def f(in_val, mask_vec):
and_val = in_val & mask_vec
return (bin(and_val).count('1') % 2)
assert f(0x0000, 0x0002) == 0
|
benchmark_functions_edited/f10324.py
|
def f(token):
if token.startswith("0x"):
return int(token, base=16)
elif token.startswith("0o"):
return int(token, base=8)
else:
return int(token)
assert f("1") == 1
|
benchmark_functions_edited/f2108.py
|
def f(pulse):
if pulse >= 0: # Se define el umbral en 0
return 1
else:
return -1
assert f(0) == 1
|
benchmark_functions_edited/f1179.py
|
def f(xmin, alpha):
return xmin * pow(2, 1/alpha)
assert f(2, 1) == 4
|
benchmark_functions_edited/f11513.py
|
def f(radicand, index, printed=False):
# Example: The square root of a number can be gotten by raising that
# number to the power of 1/2.
if radicand < 0:
root = f'{(radicand*-1)**(1/index)}i'
else:
root = radicand**(1/index)
if printed:
print(root)
else:
return root
assert f(4, 2, False) == 2
|
benchmark_functions_edited/f6554.py
|
def f(string, i):
return string.count('\n', 0, max(0, i)) + 1
assert f(u'foo\n', 4) == 2
|
benchmark_functions_edited/f6748.py
|
def f(list_one, list_two):
for element in list_one:
if element in list_two:
return element
return None
assert f([1], [1]) == 1
|
benchmark_functions_edited/f2684.py
|
def f(pos):
return pos['l']
assert f({'l': 1, 'c': 0}) == 1
|
benchmark_functions_edited/f1448.py
|
def f( a, b ):
return ( ( a[0] - b[0] )**2 + ( a[1] - b[1] )**2 )**.5
assert f( (-1,0), (0,0) ) == 1
|
benchmark_functions_edited/f7399.py
|
def f(list_of_lists):
if not list_of_lists:
return 0
count = 1
for lst in list_of_lists:
count *= len(lst)
return count
assert f(
[[1, 2], [3], [4, 5, 6]]) == 6
|
benchmark_functions_edited/f2917.py
|
def f(value, thresh=4.0):
return int(value > thresh)
assert f(10.0, 4.0) == 1
|
benchmark_functions_edited/f9622.py
|
def f(head) -> int:
i = 0
if head is None:
return 0
while head.next is not None:
head = head.next
i += 1
return i + 1
assert f(None) == 0
|
benchmark_functions_edited/f3330.py
|
def f(matrix):
return len(matrix[0])
assert f([[1,2,3],[4,5,6],[7,8,9]]) == 3
|
benchmark_functions_edited/f1291.py
|
def f(b):
return 0 if b&1==0 else 1+f(b>>1)
assert f(511) == 9
|
benchmark_functions_edited/f5970.py
|
def f(*args):
# Unpack arguments
x = args[0]
a = args[1]
b = args[2]
print(args)
fx = a*x + b*(x**2)
return fx
assert f(1, 1, 2) == 3
|
benchmark_functions_edited/f11667.py
|
def f(u_values, v_values):
dist = sum([abs(p-q) for (p, q) in zip(u_values, v_values)])
return dist
assert f(
[1, 2, 3],
[1, 2, 3]) == 0
|
benchmark_functions_edited/f1541.py
|
def f(u, um, t, dt, F):
up = 2*u - um + dt*dt*F(u, t)
return up
assert f(0, 1, 1, 1, lambda u,t: 1) == 0
|
benchmark_functions_edited/f10849.py
|
def f(high_scores):
# uses linear search
min_index, minimum = 0, high_scores[0]
for i in range(len(high_scores)):
score = high_scores[i]
if score < minimum:
minimum = score
min_index = i
return min_index
assert f([5, 3, 1, 2, 4]) == 2
|
benchmark_functions_edited/f13188.py
|
def f(list_, i):
smallest = i
# for j in range(i + 1, len(list_)):
list_len = len(list_)
for j in range(i + 1, list_len):
if list_[j] < list_[smallest]:
smallest = j
return smallest
assert f(
[1, 2, 3], 1) == 1
|
benchmark_functions_edited/f10070.py
|
def f(item):
if type(item) == list:
return sum(f(subitem) for subitem in item)
else:
return 1
assert f([0, '1']) == 2
|
benchmark_functions_edited/f585.py
|
def f(value):
return value/10**12
assert f(1000000000000) == 1
|
benchmark_functions_edited/f7823.py
|
def f(a, b):
if(b == 0):
raise TypeError("Divide by Zero Not Allowed")
else:
return a/b
assert f(2, 2) == 1
|
benchmark_functions_edited/f1818.py
|
def f(x):
if x >= 0:
return 1
else:
return -1
assert f(1.5) == 1
|
benchmark_functions_edited/f9497.py
|
def f(severity):
if severity == 'Informational':
return 0.5
elif severity == 'Low':
return 1
elif severity == 'Medium':
return 2
elif severity == 'High':
return 3
return 0
assert f('Unknown') == 0
|
benchmark_functions_edited/f7123.py
|
def f(wordcount: int, words_per_minute=300):
return max(1, round(wordcount / 300))
assert f(60) == 1
|
benchmark_functions_edited/f4172.py
|
def f(value, base):
return int(value - (value % base))
assert f(7, 4) == 4
|
benchmark_functions_edited/f9286.py
|
def f(i, arr):
if i < 0:
i = 0
elif i > len(arr) - 1:
i = len(arr) - 1
return i
assert f(3, ['A', 'B', 'C', 'D', 'E', 'F']) == 3
|
benchmark_functions_edited/f12951.py
|
def f(start, stop):
numfactors = (stop - start) >> 1
if not numfactors:
return 1
elif numfactors == 1:
return start
else:
mid = (start + numfactors) | 1
return f(start, mid) * f(mid, stop)
assert f(1, 6) == 3
|
benchmark_functions_edited/f683.py
|
def f(num):
x = [i for i in range(num + 1)]
return sum(x)
assert f(1) == 1
|
benchmark_functions_edited/f6225.py
|
def f(_list, _start_idx, _match):
for _curr_idx in range(_start_idx, len(_list)):
if _list[_curr_idx] == _match:
return _curr_idx
return -1
assert f(list(range(20)), 0, 2) == 2
|
benchmark_functions_edited/f4392.py
|
def f(x):
for T in int, float, complex:
if isinstance(x, T):
return 1
return 0
assert f(1.0+0j) == 1
|
benchmark_functions_edited/f13135.py
|
def f(attack: int, defence: int) -> int:
attack_advantage = attack - defence
goals = round(attack_advantage * 0.007874 + 1.25)
return goals if goals > 0 else 0
assert f(1, 1) == 1
|
benchmark_functions_edited/f7360.py
|
def f(x):
if x <= 0:
return 0
if x >= 1:
return 1
assert f(2) == 1
|
benchmark_functions_edited/f8927.py
|
def f(a,b):
greater = b if a < b else a
while(True):
if ((greater % a == 0) & (greater % b == 0)):
lcm = greater
break
greater += 1
return lcm
assert f(3, 9) == 9
|
benchmark_functions_edited/f5868.py
|
def f(value, min_v, max_v):
return max(min(value, max_v), min_v)
assert f(-1, 0, 0) == 0
|
benchmark_functions_edited/f596.py
|
def f(i: int = 0) -> int:
return len(f"{i:b}")
assert f(4) == 3
|
benchmark_functions_edited/f13964.py
|
def f(lu, size):
(mib, remainder) = divmod(size, 1024 * 1024)
if remainder != 0:
lu.LogWarning("Disk size is not an even multiple of 1 MiB; rounding up"
" to not overwrite existing data (%s bytes will not be"
" wiped)", (1024 * 1024) - remainder)
mib += 1
return mib
assert f(None, 1024 * 1024) == 1
|
benchmark_functions_edited/f1545.py
|
def f(n):
n = n & 0xffffffff
return (n ^ 0x80000000) - 0x80000000
assert f(6) == 6
|
benchmark_functions_edited/f14301.py
|
def f(L):
for i in range(len(L)):
if L[i] <= 1:
continue
for j in range(2, L[i]):
if L[i] % j == 0:
break
else:
firstPrime = L[i]
return firstPrime
else:
return 0
assert f(range(100)) == 2
|
benchmark_functions_edited/f6376.py
|
def f(registers, opcodes):
test_result = registers[opcodes[1]] & opcodes[2]
return test_result
assert f(
[2, 0, 0, 0],
[9, 2, 3]
) == 0
|
benchmark_functions_edited/f8904.py
|
def f(number, N, site):
return number >> (N-site) & 1
assert f(1, 4, 2) == 0
|
benchmark_functions_edited/f8366.py
|
def f(source: int, target: int) -> int:
assert source != target
if target < source:
return target
return target - 1
assert f(1, 10) == 9
|
benchmark_functions_edited/f8443.py
|
def f(f, orValue):
r = orValue
try:
r = f()
except:
r = orValue
return r
assert f(lambda: 2 + 3, 'orValue') == 5
|
benchmark_functions_edited/f5371.py
|
def f(amount):
return amount // 10 ** 8
assert f(2) == 0
|
benchmark_functions_edited/f8169.py
|
def f(cy, e):
if cy is None:
y = 0
else:
paddingY = e.pb
y = paddingY + cy * (e.css('ch', 0) + e.gh)
return y
assert f(None, None) == 0
|
benchmark_functions_edited/f10734.py
|
def f(n: int) -> int:
alternatives = [
(lambda n: 1) if n == 0 else None,
(lambda n: 1) if n == 1 else None,
(lambda n: 2) if n == 2 else None,
(lambda n: f(n-2)*n) if n > 2 else None
]
f = next(filter(None, alternatives))
return f(n)
assert f(0) == 1
|
benchmark_functions_edited/f6402.py
|
def f(t1b: tuple, t2b: tuple) -> int:
t1x, t1y = t1b
t2x, t2y = t2b
return abs(t1x - t2x) + abs(t1y - t2y)
assert f( (2,3), (4,5) ) == 4
|
benchmark_functions_edited/f12450.py
|
def f(value):
# Google spreadsheet separates values by command
return len(value.split(","))
assert f("C") == 1
|
benchmark_functions_edited/f3435.py
|
def f(lists, indices):
result = lists
for i in indices:
result = result[i]
return result
assert f(
[[[1, 2, 3], [4, 5, 6]],
[[7, 8, 9], [10, 11, 12]]],
[0, 0, 0]) == 1
|
benchmark_functions_edited/f7547.py
|
def f(registers, opcodes):
test_result = int(opcodes[1] > registers[opcodes[2]])
return test_result
assert f(
[2, 4, 2, 4],
[71, 4, 3]) == 0
|
benchmark_functions_edited/f8105.py
|
def f(n):
if n <= 2:
return 1
# Setting the cache variable that is 'attached' to this function
if not hasattr(fibonacci_top_down_1, "cache"):
fibonacci_top_down_1.cache = {}
assert f(2) == 1
|
benchmark_functions_edited/f1894.py
|
def f(values):
m = 0.0
for value in values:
m = m + value/len(values)
return m
assert f([1, 2, 3]) == 2
|
benchmark_functions_edited/f10754.py
|
def f(window):
return min(window, key=lambda x: x[1])[1]
assert f( [(0, 1), (1, 1000), (2, 1), (3, 20), (4, 1)] ) == 1
|
benchmark_functions_edited/f11943.py
|
def f(files):
if isinstance(files, list):
return files[int(len(files) / 2)]
else:
return files
assert f([1, 2, 3]) == 2
|
benchmark_functions_edited/f6487.py
|
def f(number: float) -> float:
return pow(number, 0.5)
assert f(9) == 3
|
benchmark_functions_edited/f8911.py
|
def f(inputList):
assert(len(inputList) > 0)
index = 0
maxVal = inputList[0]
for i, val in enumerate(inputList[1:]):
if val > maxVal:
maxVal = val
index = i + 1
return index
assert f( [ 1, 2, 3, 4, 5, 6 ] ) == 5
|
benchmark_functions_edited/f4101.py
|
def f(y):
sum3=0
for i in range(1, y+1):
num_to_add=3*i
sum3=sum3+num_to_add
return sum3
assert f(2) == 9
|
benchmark_functions_edited/f7031.py
|
def f(string, sub_string):
return string.count(sub_string)
assert f("ABCDCDC", "ABD") == 0
|
benchmark_functions_edited/f13953.py
|
def f(value, info):
zone = 0
if value <= info['low_warning_threshold']:
zone = -2
elif value <= info['low_caution_threshold']:
zone = -1
elif value <= info['high_caution_threshold']:
zone = 0
elif value <= info['high_warning_threshold']:
zone = 1
else:
zone = 2
return zone
assert f(0, { 'high_warning_threshold': 0, 'high_caution_threshold': 10, 'low_warning_threshold': -10, 'low_caution_threshold': -10 }) == 0
|
benchmark_functions_edited/f3678.py
|
def f(numbers):
order = sorted(numbers, key=int)
return order[0] + order[1]
assert f([1, 5, 4, 2, 3]) == 3
|
benchmark_functions_edited/f12139.py
|
def f(x):
n = len(x)
if n == 0:
return 0
if n == 1:
return x[0]
# sum of 1st half plus sum of 2nd half
return f(x[:n/2]) + f(x[n/2:])
assert f([1]) == 1
|
benchmark_functions_edited/f1709.py
|
def f(*args):
return sum(args) % (2**32)
assert f(1, 2) == 3
|
benchmark_functions_edited/f5257.py
|
def f(constants, variables):
if variables:
pow2 = pow(2, variables - 1, 1_000_000_007)
return pow2 * (constants * 2 + variables)
return constants
assert f(0, 1) == 1
|
benchmark_functions_edited/f2112.py
|
def f(my_list=[]):
return (sum({ele for ele in my_list}))
assert f([1, 2, 3, 2, 1]) == 6
|
benchmark_functions_edited/f13846.py
|
def f(deltaT_sub, Q_drop):
R_total = deltaT_sub / Q_drop
return R_total
assert f(1, 1) == 1
|
benchmark_functions_edited/f3313.py
|
def f(d):
if d is None:
return 0
return int(d.strftime('%Y%m%d'))
assert f(None) == 0
|
benchmark_functions_edited/f3487.py
|
def f(name):
if name == "nsec":
return 1e-6
elif name == "msec":
return 1
elif name == "sec":
return 1e3
assert f("msec") == 1
|
benchmark_functions_edited/f7470.py
|
def f(part, whole):
return 100 * float(part) / float(whole)
assert f(0, 2) == 0
|
benchmark_functions_edited/f5505.py
|
def f(obj, key):
val = "0"
if obj and type(obj) == dict:
val = len(obj.get(key, []))
return val
assert f({"x": [1, 2, 3]}, "x") == 3
|
benchmark_functions_edited/f7349.py
|
def f(date: float):
date /= 100
month = int(date) - int(date / 100) * 100
date /= 100
year = int(date) - 2014
return year * 12 + month
assert f(20140102) == 1
|
benchmark_functions_edited/f1500.py
|
def f(a, b) -> float:
return (float(a[0]) * b[1]) - (float(a[1]) * b[0])
assert f( (1, 1), (1, 1) ) == 0
|
benchmark_functions_edited/f3984.py
|
def f(score):
if score < 0.5:
return 0
else:
return 1
assert f(0.75) == 1
|
benchmark_functions_edited/f4241.py
|
def f(str):
# return int(float(str)+0.5)
x = float(str)
if x >= 0: return int(x+0.5)
else: return int(x-0.5)
assert f(0.6) == 1
|
benchmark_functions_edited/f5152.py
|
def f(predicate, seq):
for element in seq:
if predicate(element):
return element
return None
assert f(lambda a: a % 2 == 0, [2]) == 2
|
benchmark_functions_edited/f5891.py
|
def f(x: int, bits: int) -> int:
return x << bits if bits >= 0 else x >> -bits
assert f(2, 1) == 4
|
benchmark_functions_edited/f846.py
|
def f(byte):
return byte / (1024.0 ** 3)
assert f(0) == 0
|
benchmark_functions_edited/f745.py
|
def f(l, v):
return len(l) - 1 - l[::-1].index(v)
assert f(list('abcde'), 'e') == 4
|
benchmark_functions_edited/f6799.py
|
def f(a, fn):
return next((x for x in a if fn(x)), None)
assert f(range(10), lambda x: x % 2 == 0) == 0
|
benchmark_functions_edited/f8014.py
|
def f(focal_point,distance_object):
numerator = focal_point * distance_object
denominator = distance_object - focal_point
return numerator / denominator
assert f(10, 0) == 0
|
benchmark_functions_edited/f2872.py
|
def f(value):
slowness = int(-30 * value + 31)
return slowness
assert f(1.0) == 1
|
benchmark_functions_edited/f6109.py
|
def f(x, p):
return x * p / (1e6 + x)
assert f(0, 1) == 0
|
benchmark_functions_edited/f7609.py
|
def f(n):
if n < 2:
return n
return f(n - 1) + f(n - 2)
assert f(0) == 0
|
benchmark_functions_edited/f10693.py
|
def f(fx, *args, **kwargs):
return fx(*args, **kwargs)
assert f(lambda x, y: x + y, 2, 3) == 5
|
benchmark_functions_edited/f12487.py
|
def f(num):
if not isinstance(num, int):
raise TypeError("Must be a positive int")
# Base Case
if num == 0:
return 0
return num % 10 + f(num / 10)
assert f(0) == 0
|
benchmark_functions_edited/f9647.py
|
def f(sheet):
# Internal representation?
if (hasattr(sheet, "num_rows")):
return sheet.num_rows()
# xlrd sheet?
if (hasattr(sheet, "nrows")):
return sheet.nrows
# Unhandled sheet object.
return 0
assert f(123) == 0
|
benchmark_functions_edited/f13302.py
|
def f(config):
if config == "g":
return 2
if config == "k":
return 1
if config == "kg":
return 3
if config == "":
return 0
print("Unknown config in deep_dss.utils.lensing_channels. Please try again.")
assert f("") == 0
|
benchmark_functions_edited/f7601.py
|
def f(player):
return sum(val * ind
for ind, val in enumerate(reversed(player), start=1))
assert f(list(reversed([2, 1]))) == 4
|
benchmark_functions_edited/f3716.py
|
def f(draw, picks):
match = 0
for ball in draw:
if ball in picks:
match += 1
return match
assert f(range(1, 4), [1]) == 1
|
benchmark_functions_edited/f12830.py
|
def f(f, xmin, xmax, eps=1e-9):
middle = (xmax + xmin) / 2.
while xmax - xmin > eps:
assert xmin < xmax
middle = (xmax + xmin) / 2.
if f(xmax):
return xmax
if not f(xmin):
return xmin
if f(middle):
xmin = middle
else:
xmax = middle
return middle
assert f(lambda x: x < 0, 0, 100) == 0
|
benchmark_functions_edited/f8523.py
|
def f(cd, e):
if cd is None:
d = 0
else:
# Overwrite style from here.
d = cd * (e.css('cd', 0) + e.gd) - e.gd
return d
assert f(None, None) == 0
|
benchmark_functions_edited/f1363.py
|
def f(gr_val, skoo_sz):
k = 0
while gr_val > skoo_sz:
gr_val -= skoo_sz
k += 1
return k
assert f(1, 1) == 0
|
benchmark_functions_edited/f7263.py
|
def f(graph, nodes):
count = 0
for v1 in nodes:
for v2 in nodes:
if v1 != v2 and v2 not in graph[v1]:
count += 1
return count / 2
assert f(
{'a': {'b'},
'b': {'a', 'c'},
'c': {'b'}},
{'a', 'b', 'c'}) == 1
|
benchmark_functions_edited/f8124.py
|
def f(coordinate, change, limit):
next_coordinate = coordinate + change
if next_coordinate < 0:
return 0
elif next_coordinate >= limit:
return limit - 1
return next_coordinate
assert f(0, 0, 10) == 0
|
benchmark_functions_edited/f4410.py
|
def f(a, b):
scale = a * 0.1
if b <= a + scale and b >= a - scale:
return 1
else:
return 0
assert f(1, 1) == 1
|
benchmark_functions_edited/f11657.py
|
def f(obj, attrName, *args):
checkExists = len(args) > 0
value = obj
attrs = attrName.split('.')
for attr in attrs:
if not checkExists or hasattr(value, attr):
value = getattr(value, attr)
else:
return args[0]
return value
assert f({'x': {'y': {'z': 1}}}, 'x.z.y', 2) == 2
|
benchmark_functions_edited/f12531.py
|
def f(a, b):
for i in range(len(b) - len(a) + 1):
flag = True
if b[i] == a[0]:
for j in range(len(a) - 1):
if b[i + j + 1] != a[j + 1]:
flag = False
if not flag:
continue
return i + 1
return False
assert f(b'horse', b'horsemanship a') == 1
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.