file_name stringlengths 32 36 | content stringlengths 44 898 |
|---|---|
benchmark_functions_edited/f10372.py | def f(items, item, offer):
amount = 0
if items[item] >= offer['num']:
offer_count = items[item] / offer['num']
items[item] = items[item] % offer['num']
amount = offer_count * offer['value']
return amount
assert f(
{ 'A': 2, 'B': 2, 'C': 1, 'D': 1, 'E': 1, 'F': 1, 'G': 1, '... |
benchmark_functions_edited/f5851.py | def f(n):
i = 1
result = 0
while i * i < n:
if n % i == 0:
result += 2 # i and n/i are divisors
i += 1
if i * i == n:
result += 1
return result
assert f(1) == 1 |
benchmark_functions_edited/f2725.py | def f(color_frequencies: dict) -> int:
return len([p for p in color_frequencies.values() if p])
assert f(
{"red": True, "blue": True, "yellow": True, "black": True}
) == 4 |
benchmark_functions_edited/f6666.py | def f(a,b,c):
discriminant = b*b-4*a*c
return discriminant
assert f(0,0,0) == 0 |
benchmark_functions_edited/f844.py | def f(n):
return n if n < 2 else n + f(n - 2)
assert f(0) == 0 |
benchmark_functions_edited/f12337.py | def f(str,ref,match=0,start=0):
if start<0: start = 0
if start>=len(str): return -1
for i in range(start,len(str)):
found = ref.find(str[i])==-1
if found ^ match:
return i
return -1
assert f( "abc", "a") == 1 |
benchmark_functions_edited/f8214.py | def f(rho, fun, dt, *args):
dt2 = dt/2.0
k1 = fun(rho, *args )
k2 = fun(rho + k1*dt2, *args)
k3 = fun(rho + k2*dt2, *args)
k4 = fun(rho + k3*dt, *args)
rho += (k1 + 2*k2 + 2*k3 + k4)/6. * dt
return rho
assert f(1, lambda x: 1, 1) == 2 |
benchmark_functions_edited/f2615.py | def f(*args):
# type: (*bool) -> int
return len(list(filter(lambda b: b, args)))
assert f(False, False, False, False, False) == 0 |
benchmark_functions_edited/f12147.py | def f(offset, inArr):
#for i in range(0, len(inArr)):
# inArr[i] = float(inArr[i]) + offset
#return inArr
return inArr + offset
assert f(5, 3) == 8 |
benchmark_functions_edited/f6884.py | def f(jobs):
return sum(
[
(1.0 - j.cratio) * j.request.get_min_energy()
for j in jobs
if not j.is_terminated()
]
)
assert f([]) == 0 |
benchmark_functions_edited/f7591.py | def f(lst):
if len(lst) != 0:
return lst[-1]
return None
assert f([1, 2, 3]) == 3 |
benchmark_functions_edited/f11252.py | def f(tag):
if type(tag) is str:
return 0
if len(tag.children) == 0:
return 0
return max([f(t) for t in tag.children])
assert f(**{'tag': "str"}) == 0 |
benchmark_functions_edited/f11527.py | def f(sym: str) -> str:
return {
'backslash': '\\',
'comma': ',',
'period': '.',
'slash': '/',
'bracketleft': '[',
'bracketright': ']',
'semicolon': ';',
'apostrophe': "'",
'minus': '-',
'equal': '=',
}.get(sym, sym)
assert f(1) ==... |
benchmark_functions_edited/f731.py | def f(x: int, y: int) -> int:
while y: x, y = y, x%y
return abs(x)
assert f(42, 13) == 1 |
benchmark_functions_edited/f3381.py | def f(xlist, ylist):
return(max(abs(x-y) for x, y in zip(xlist, ylist)))
assert f([1, 2, 3, 4], [1, 2, 3, 4]) == 0 |
benchmark_functions_edited/f4786.py | def f(val):
return -1 if val == -1 else abs(val)
assert f(-4) == 4 |
benchmark_functions_edited/f5335.py | def f(predicate, iterable):
try: return next(filter(predicate, iterable))
except StopIteration: return None
assert f(lambda x: x == 1, (1, 2, 3)) == 1 |
benchmark_functions_edited/f10139.py | def f(bri_str: str) -> int:
bri = 100
if not bri_str:
bri = int(bri_str)
current = bri / 100
return int(current * 255)
assert f(0.0) == 0 |
benchmark_functions_edited/f8104.py | def f(cuts):
min_index = 0
for i in range(0, len(cuts), 2):
if cuts[i] < cuts[min_index]:
min_index = i
return min_index
assert f([]) == 0 |
benchmark_functions_edited/f638.py | def f(numbers):
return sum(numbers) / len(numbers)
assert f([0, 0, 0, 0]) == 0 |
benchmark_functions_edited/f12240.py | def f(x):
### --------------------------------------------------------------
## LABEL ENCODE : With Voice = 1 No Voice = 2 Else NaN = 0 - Others x
if x == 'With Voice':
return 1
elif x == 'No Voice':
return 2
# elif math.isnan(x): ## if value Nan = 0 then 0
# return 0
e... |
benchmark_functions_edited/f1691.py | def f(values):
return max(enumerate(values), key=lambda x: x[1])[0]
assert f(
['x', 'y', 'y']
) == 1 |
benchmark_functions_edited/f9731.py | def f(dim):
if not isinstance(dim, tuple):
dim = (dim,)
# create axes bitmask for reduce layer
axes = 0
for d in dim:
axes |= 1 << (d - 1) # -1 to remove batch dimension
return axes
assert f(4) == 8 |
benchmark_functions_edited/f12538.py | def f(ns):
trib = {0: 1, 1: 1, 2: 2, 3: 4, 4: 7}
count = 1
one_seq = 0
for n in ns:
if n == 1:
one_seq += 1
if n == 3:
count *= trib[one_seq]
one_seq = 0
return count
# # one-liner...
# return reduce(lambda c, n: (c[0]*trib[c[1]], 0) if n == 3 else (c[0], c[1]+1), ns, (1,0))[0]
assert f( [1, 1, ... |
benchmark_functions_edited/f6130.py | def f(dim, exp):
if exp >= 2:
# 1 MUL + 1 POW
return 2
else:
# 1 MUL
return 1
assert f(4, 1) == 1 |
benchmark_functions_edited/f14264.py | def f(c1, c2):
result = len(c2.keys()) - len(c1.keys())
while result > -1:
for k, v in c1.items():
delta = c2[k] - v
if delta < 0:
result = -1
else:
result += delta
break
return result
assert f(
{'a': 3, 'b': 10, 'c': 1... |
benchmark_functions_edited/f4486.py | def f(value, offset, period):
i1 = (value + offset) // period
i0 = value // period
return i1 - i0
assert f(0, 2, 2) == 1 |
benchmark_functions_edited/f10701.py | def f(data):
count = 0
for i in range(1, len(data) - 2):
previous = sum(data[i - 1:i + 2])
value = sum(data[i:i + 3])
if value > previous:
count += 1
return count
assert f(
[199, 200, 208, 210, 200, 207, 240, 269, 260, 263]) == 5 |
benchmark_functions_edited/f6552.py | def f(line) -> int:
spaces = 0
for i in reversed(line):
if i == " ":
spaces += 1
else:
break
return spaces
assert f(
"This is a line of text that has no ending spaces") == 0 |
benchmark_functions_edited/f12400.py | def f(T, Cr, n):
tau = (Cr**(-1))*(T**(-n))
return tau
assert f(1,1,1) == 1 |
benchmark_functions_edited/f7379.py | def f(R, H, r):
if 0 <= r <= R:
h = H - (H * r) / R
return h
else:
print("height function: radius is not in range")
assert f(1, 1, 1) == 0 |
benchmark_functions_edited/f7804.py | def f(n,k):
if n == k:
return 1
if n == 0 and k == 0:
return 1
if n == 0 or k == 0:
return 0
return (n-1)*f(n-1,k) + f(n-1,k-1)
assert f(3,1) == 2 |
benchmark_functions_edited/f9097.py | def f(port_range):
if port_range is None:
return 65535
if isinstance(port_range, int):
return port_range
if ':' in port_range:
return int(port_range[port_range.find(':') + 1:])
return int(port_range)
assert f('1') == 1 |
benchmark_functions_edited/f1828.py | def f(x: int) -> int:
return int(x) if x and x != 0 else 1
assert f(False) == 1 |
benchmark_functions_edited/f4121.py | def f(args, key):
return args[key] if args.__contains__(key) else f'ERROR'
assert f(
{'a': 1, 'b': 2, 'c': 3}, 'a'
) == 1 |
benchmark_functions_edited/f8953.py | def f(bday1, bday2):
if bday1 > bday2:
delta = bday1 - bday2
double_day = bday1 + delta
else:
delta = bday2 - bday1
double_day = bday2 + delta
return double_day
assert f(1, 2) == 3 |
benchmark_functions_edited/f2200.py | def f(a, b) -> int:
return 0 if a < b else 1 if a == b else 2
assert f(2, 2) == 1 |
benchmark_functions_edited/f13.py | def f(a, b):
return a + b + 3
assert f(*(1, 2)) == 6 |
benchmark_functions_edited/f4753.py | def f(data):
n = len(data)
if n < 1:
raise ValueError('mean requires at least one data point')
return sum(data)/n
assert f([1, 2, 3, 4, 5]) == 3 |
benchmark_functions_edited/f8018.py | def f(sequence):
max_ending_here = max_so_far = 0
for x in sequence:
max_ending_here = max(0, max_ending_here + x)
max_so_far = max(max_so_far, max_ending_here)
return max_so_far
assert f([1]) == 1 |
benchmark_functions_edited/f12090.py | def f(a, b, n):
return (n * a * b / (a + b) ** 2) * (a + b + n) / (a + b + 1)
assert f(0, 1, 10) == 0 |
benchmark_functions_edited/f9245.py | def f(val, bits):
if (val & (1 << (bits - 1))) != 0: # if sign bit is set e.g., 8bit: 128-255
val = val - (1 << bits) # compute negative value
return val # return positive value as is
assert f(0, 8) == 0 |
benchmark_functions_edited/f13579.py | def f(l, k):
if l[-1] <= k:
return -1
i = len(l) // 2
start, end = 0, len(l) - 1
while start < end:
if l[i] > k:
end = i
else:
start = i + 1
i = start + (end - start) // 2
return i
assert f([1, 2, 2, 3, 4], 2) == 3 |
benchmark_functions_edited/f12946.py | def f(n_core, n_clad):
return (n_core**2 - n_clad**2) / (2 * n_core**2)
assert f(1.45, 1.45) == 0 |
benchmark_functions_edited/f6722.py | def f(input_time):
return int(input_time*1000)
assert f(0) == 0 |
benchmark_functions_edited/f4432.py | def f(abData, off):
return abData[off] \
+ abData[off + 1] * 256 \
+ abData[off + 2] * 65536 \
+ abData[off + 3] * 16777216;
assert f(b'\x00\x00\x00\x00', 0) == 0 |
benchmark_functions_edited/f4020.py | def f(grid):
num = 0
if isinstance(grid, list):
num += f(grid[0]) + 1
return num
return num
assert f(None) == 0 |
benchmark_functions_edited/f6453.py | def f(labels, position, prototype):
#print('providing label')
return labels[position]
assert f(
[0, 0, 0, 0], 2, 1) == 0 |
benchmark_functions_edited/f2584.py | def f(limit, count):
return int(count / limit) + (limit % count > 0)
assert f(10, 21) == 3 |
benchmark_functions_edited/f2726.py | def f(x, epsilon):
return sum([epsilon[i] * abs(x[i]) ** (i + 1) for i in range(len(x))])
assert f([10, 10, 10, 10, 10], [0, 0, 0, 0, 0]) == 0 |
benchmark_functions_edited/f13240.py | def f(n, k):
coeff = {}
for i in range(n + 1):
coeff[i] = {}
coeff[i][0] = 1
for j in range(k + 1):
coeff[j][j] = 1
for i in range(1, n + 1):
for j in range(1, i):
print(i, j)
coeff[i][j] = coeff[i-1][j-1] + coeff[i-1][j]
return coeff[n][k]... |
benchmark_functions_edited/f12948.py | def f(params, k, ksq, lmbda, sigma):
l0, a, b = params
A, B = a**2, b**2
TA = 2*A
A2B = A*A + B
f1 = ksq + TA*k + A2B
den = A2B + TA*k
f=l0 * f1 / den
return (f - lmbda)*sigma
assert f( (1, 1, 1), 2, 4, 6, 0) == 0 |
benchmark_functions_edited/f4623.py | def f(qr_code):
size = 0
while qr_code[size] != "\n":
size += 1
return size
assert f(
"A\n"
) == 1 |
benchmark_functions_edited/f3377.py | def f(session):
return len([r for r in session if 'is_pageview' in r and r['is_pageview'] == 'true'])
assert f(
[
{'is_pageview': 'false'},
{'is_pageview': 'true'},
{'is_pageview': 'false'}
]
) == 1 |
benchmark_functions_edited/f2798.py | def f(signal, factor):
scaled_signal = signal * factor
return scaled_signal
assert f(4, 1) == 4 |
benchmark_functions_edited/f12236.py | def f(cash: float, list: dict) -> float:
# values = list.values()
total = sum(list.values())
change = cash - total
return change
# pass # implement me
assert f(10, {'A': 1, 'B': 1, 'C': 1, 'D': 1, 'E': 1}) == 5 |
benchmark_functions_edited/f4740.py | def f(group_input: str) -> int:
return len(set("".join([line.strip() for line in group_input.split("\n")])))
assert f(
) == 6 |
benchmark_functions_edited/f9352.py | def f(lst, ind, default=None):
if len(lst)-1 < ind:
return default
return lst[ind]
assert f( [1], 0 ) == 1 |
benchmark_functions_edited/f11962.py | def f(base, exponent, modulus):
if modulus == -1:
return 0
result = 1
base %= modulus
while exponent > 0:
if exponent % 2:
result = (result * base) % modulus
exponent >>= 1
base = (base * base) % modulus
return result
assert f(2, 17, 2) == 0 |
benchmark_functions_edited/f12663.py | def f(s):
sum_of_digits = 0
count = 0
for item in s:
if item in list('0123456789'):
sum_of_digits += int(item)
count += 1
if not count:
raise ValueError
return sum_of_digits
assert f("-123") == 6 |
benchmark_functions_edited/f12448.py | def f(nums):
arr_set = set(nums)
to_return = 0
for elem in arr_set:
if elem-1 in arr_set:
continue
curr_val, max_streak = elem, 0
while curr_val in arr_set:
max_streak += 1
curr_val += 1
to_return = max(to_return, max_streak)
return to_... |
benchmark_functions_edited/f9705.py | def f(data, crc_init=0):
crc = crc_init
for c in data:
crc ^= c << 8
for _ in range(8):
temp = crc << 1
if crc & 0x8000:
temp ^= 0x1021
crc = temp
return crc
assert f(b"") == 0 |
benchmark_functions_edited/f7464.py | def f(n, m):
return m + n * (n + 1)
assert f(0, 1) == 1 |
benchmark_functions_edited/f913.py | def f(glavna_sila, brzina_rezanja):
return glavna_sila*brzina_rezanja/60e3
assert f(0, 0) == 0 |
benchmark_functions_edited/f12034.py | def f(bit_num):
return 1 << (bit_num)
assert f(3) == 8 |
benchmark_functions_edited/f4425.py | def f(x, y=None, dx=None, dy=None):
if dx is None:
dx = 0
return dx
assert f(2, 1) == 0 |
benchmark_functions_edited/f11216.py | def f(pts):
dists = [(abs(pt[0]) + abs(pt[1])) for pt in pts]
return min(dists)
assert f([(1, 2)]) == 3 |
benchmark_functions_edited/f11671.py | def f(sets_redeemed):
if sets_redeemed <= 4:
return 4 + 2 * sets_redeemed
return 5 * sets_redeemed - 10
assert f(2) == 8 |
benchmark_functions_edited/f9062.py | def f(predicate, collection):
for item in collection:
if predicate(item):
return item
return None
assert f(lambda x: x == 3, [1, 2, 3]) == 3 |
benchmark_functions_edited/f1855.py | def f(s):
return len(max(s, key=len))
assert f(list('a')) == 1 |
benchmark_functions_edited/f888.py | def f(b):
return 0 if b==0 else 1+f(b>>1)
assert f(0b1111111) == 7 |
benchmark_functions_edited/f5940.py | def f(lst, el):
for i in reversed(range(len(lst))):
if lst[i] == el:
return i
return None
assert f(range(10), 5) == 5 |
benchmark_functions_edited/f7595.py | def f(individual):
return sum(x**2 for x in individual)
assert f([1]) == 1 |
benchmark_functions_edited/f293.py | def f(x):
return x / 127.5 - 1
assert f(255) == 1 |
benchmark_functions_edited/f10329.py | def f(x, y):
if x > y:
return 1
elif x < y:
return -1
else:
return 0
assert f(2, 1) == 1 |
benchmark_functions_edited/f13363.py | def f(sequence, n_ahead=0):
if n_ahead == 0:
n_ahead = int(len(sequence) / 2)
total = 0
for idx, val in enumerate(sequence):
n_ahead_val = (idx + n_ahead) % len(sequence)
# print(f"{idx}, {n_ahead_val}")
if int(val) == int(sequence[n_ahead_val]):
total += int(val... |
benchmark_functions_edited/f10505.py | def f(x: float, exp: float = 2.0, mult: float = 3) -> float:
return x ** (1 / exp) if x > 0 else -mult * (-x) ** (1 / exp)
assert f(0, 2, 3) == 0 |
benchmark_functions_edited/f7355.py | def f(a, b):
if (a is None) or (b is None):
return None
return a + b
assert f(1, 2) == 3 |
benchmark_functions_edited/f7680.py | def f(s, p):
return (2-p) ** 2 * s
assert f(1, 1) == 1 |
benchmark_functions_edited/f8230.py | def f(set_a, set_b):
if len(set_a) == 0 or len(set_b) == 0:
index = 0
else:
index = len(set(set_a).intersection(set(set_b))) / len(
set(set_a).union(set(set_b))
)
return index
assert f(set(['A', 'B']), set(['C'])) == 0 |
benchmark_functions_edited/f7981.py | def f(data):
digit = 0
while data != 0:
digit += 1
data >>= 1
return digit
assert f(2) == 2 |
benchmark_functions_edited/f8122.py | def f(n, k):
import functools as ft
import operator as op
k = min(k, n - k)
n = ft.reduce(op.mul, range(n, n - k, -1), 1)
d = ft.reduce(op.mul, range(1, k + 1), 1)
return n / d
assert f(5, 1) == 5 |
benchmark_functions_edited/f12780.py | def f(d, d2):
if d2 is None:
return d
if isinstance(d, dict) and isinstance(d2, dict):
for k in set(d2.keys()) & set(d.keys()):
d[k] = f(d.get(k, None), d2.get(k, None))
return d
else:
# prefer keys from d2
return d2
assert f(None, 1) == 1 |
benchmark_functions_edited/f4426.py | def f(val, ref):
if ref == 0.0:
return float("nan")
else:
return abs(val - ref) / ref
assert f(1, 1) == 0 |
benchmark_functions_edited/f9872.py | def f(strand_a, strand_b):
if len(strand_a) != len(strand_b):
raise ValueError('Strands must be of equal length.')
return sum(i != j for i, j in zip(strand_a, strand_b))
assert f('GAGCCTACTAACGGGAT', 'CATCGTAATGACGGCCT') == 7 |
benchmark_functions_edited/f222.py | def f(x):
return x[-1]-x[-2]
assert f([3, 4, 7, 11, 18]) == 7 |
benchmark_functions_edited/f10146.py | def f(func,**kwargs):
response = func(**kwargs)
if response["status_code"] != 200:
print(response["content"])
raise RuntimeError("Error in call to sheep-server")
return response["content"]
assert f(lambda: {"status_code": 200, "content": 1}) == 1 |
benchmark_functions_edited/f6351.py | def f(jobs):
if jobs == 0:
print("Jobs must be >= 1 or == -1")
elif jobs < 0:
import multiprocessing
jobs = multiprocessing.cpu_count()
return jobs
assert f(8.0) == 8 |
benchmark_functions_edited/f2777.py | def f(lst1,lst2):
sum = 0
for i in range(0,len(lst1)):
sum += lst1[i]*lst2[i]/100
return sum
assert f( [5, 5, 5, 5, 5],
[0, 0, 0, 0, 0]) == 0 |
benchmark_functions_edited/f1256.py | def f(x, bounds):
return min(max(x, bounds[0]), bounds[1])
assert f(0, [1, 2]) == 1 |
benchmark_functions_edited/f10157.py | def f(obj):
states = obj['InstanceStates']
in_service = 0
for state in states:
if state['State'] == 'InService':
in_service += 1
return in_service
assert f({"InstanceStates": [{"State": "InService"}]}) == 1 |
benchmark_functions_edited/f1977.py | def f(batch_idx: int, mesh_idx: int) -> int:
_ = batch_idx
_ = mesh_idx
return 1
assert f(1, 0) == 1 |
benchmark_functions_edited/f8069.py | def f(x):
assert x >= 0, "f(x) requires integer x >= 0"
while x > 0xffffffff:
x = (x >> 32) ^ (x & 0xffffffff)
x ^= x >> 16
x ^= x >> 8
x ^= x >> 4
return (0x6996 >> (x & 15)) & 1
assert f(0xfffffffe) == 1 |
benchmark_functions_edited/f9316.py | def f(mel):
return 700*(10**(mel/2595.0)-1)
assert f(0) == 0 |
benchmark_functions_edited/f9704.py | def f(expr):
if not isinstance(expr, list):
return 0
return max(map(expression_depth, expr)) + 1
assert f(100) == 0 |
benchmark_functions_edited/f1716.py | def f(char):
return ord(char) - 64
assert f("A") == 1 |
benchmark_functions_edited/f1021.py | def f(x):
return x*(x > 0)
assert f(0) == 0 |
benchmark_functions_edited/f11938.py | def f(n, k, r):
return n - k + 2 ** r
assert f(10, 10, 1) == 2 |
benchmark_functions_edited/f10156.py | def f(x1024, y1024, vignette_at_1024, adu_saturation):
dist2 = x1024 ** 2 + y1024 ** 2
fraction_decreased = vignette_at_1024 * (dist2 / 1024) ** 2
return adu_saturation * (1.0 - fraction_decreased)
assert f(0, 0, 0, 1) == 1 |
benchmark_functions_edited/f10716.py | def f(concentrations, para_dict):
rate = para_dict['k1']*concentrations[0]*(concentrations[1]**3/concentrations[0]**2)**para_dict['alpha'] -\
para_dict['k2']*(concentrations[2]**2/concentrations[1]**3)**para_dict['beta']
return rate
assert f(
(1,1,1), {'k1': 1.0, 'k2': 1.0, 'alpha': 1.0, 'beta': 1... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.