file_name
stringlengths 32
36
| content
stringlengths 44
898
|
|---|---|
benchmark_functions_edited/f4819.py
|
def f(array):
if array and isinstance(array, list) and len(array) >= 1:
return array[0]
return None
assert f([1]) == 1
|
benchmark_functions_edited/f398.py
|
def f(x, a, b):
return (a * x**b)
assert f(0, 0, 0) == 0
|
benchmark_functions_edited/f8054.py
|
def f(permission_level):
if permission_level == "RED":
return 0
if permission_level == "YELLOW":
return 1
if permission_level == "GREEN":
return 2
return 0
assert f("RED") == 0
|
benchmark_functions_edited/f11793.py
|
def f(mx, val, mn=0):
return max(mn, min(val, mx))
assert f(0, 5) == 0
|
benchmark_functions_edited/f1464.py
|
def f(distribution):
return max(distribution) - min(distribution)
assert f(range(3)) == 2
|
benchmark_functions_edited/f601.py
|
def f(a,b):
if a >= b:
r = a
else:
r = b
return r
assert f(1, 2) == 2
|
benchmark_functions_edited/f14334.py
|
def f(value: float, minimum: float, maximum: float) -> float:
if value > maximum:
return maximum
elif value < minimum:
return minimum
else:
return value
assert f(0, 3, 10) == 3
|
benchmark_functions_edited/f8599.py
|
def f(nums):
output = 0
for x in range(len(nums)):
output += nums[x]
return output / len(nums)
assert f([1, 2, 3]) == 2
|
benchmark_functions_edited/f5559.py
|
def f(num):
if num == 0:
return 1
else:
return num * f(num-1)
assert f(1) == 1
|
benchmark_functions_edited/f11891.py
|
def f(request, value_name, default=''):
if request is not None:
if request.method == 'GET':
return request.GET.get(value_name, default)
elif request.method == 'POST':
return request.POST.get(value_name, default)
return default
assert f(None, 'foo', 1) == 1
|
benchmark_functions_edited/f9458.py
|
def f(x, y):
sum = x + y
return sum
assert f(1, 1) == 2
|
benchmark_functions_edited/f8494.py
|
def f(arr, NaN=False):
if NaN:
s=0
for a in arr:
if a==a:
s+=a
else:
s=sum(arr)
return s
assert f([0, 0, 0, 0, 0]) == 0
|
benchmark_functions_edited/f10377.py
|
def f(seq):
# seq = [4,8,6,3,7,2]
count = 0
length = len(seq)
for i in range(length - 1):
sorted = True
for j in range(length - 1):
if seq[j] > seq[j+1]:
seq[j],seq[j+1] = seq[j+1],seq[j]
count += 1
sorted = False
if sorted:
break
return count
assert f([1]) == 0
|
benchmark_functions_edited/f4046.py
|
def f(callers):
nc = 0
for calls in callers.values():
nc += calls
return nc
assert f(dict()) == 0
|
benchmark_functions_edited/f6484.py
|
def f(r,c,shape):
assert len(shape) == 2
rows,cols = shape
return r * cols + c
assert f(0, 2, (1, 2)) == 2
|
benchmark_functions_edited/f11990.py
|
def f(time, period):
# If time is an exact multiple of period, don't round up
if time % period == 0:
return time
time = round(time)
return time + period - (time % period)
assert f(0, 1) == 0
|
benchmark_functions_edited/f11044.py
|
def f(algo):
prefix = algo.split("_")[0]
if prefix == "chords":
return 1
elif prefix == "melody":
return 3
else:
raise IOError("Unexpected algo type")
assert f("melody_3") == 3
|
benchmark_functions_edited/f6370.py
|
def f(co, x, y):
return co[0] + co[1]*x + co[2]*y + co[3]*x**2 + co[4]*x*y + co[5]*y**2 +co[6]*x**3 + co[7]*x**2*y + co[8]*x*y**2 + co[9]*y**3
assert f( [0, 0, 0, 0, 1, 0, 0, 0, 0, 0], 0, 0 ) == 0
|
benchmark_functions_edited/f6000.py
|
def f(point_1, point_2):
x1, y1 = point_1
x2, y2 = point_2
man_dist = abs(x1 - x2) + abs(y1 - y2)
return man_dist
assert f(
(-1, 0),
(0, -1)
) == 2
|
benchmark_functions_edited/f9812.py
|
def f(line, x):
p1 = line[0]
p2 = line[1]
if p2[0] == p1[0]:
if p1[0] == x:
return p1[1]
return None
m = (p2[1] - p1[1]) / (p2[0] - p1[0])
y = p1[1] + m * (x - p1[0])
return y
assert f(
(
(0, 0),
(1, 0),
),
2,
) == 0
|
benchmark_functions_edited/f8732.py
|
def f(poly, x, prime):
accum = 0
for coeff in reversed(poly):
accum *= x
accum += coeff
# accum %= prime
return accum
assert f(
(1, 1),
0,
2
) == 1
|
benchmark_functions_edited/f4105.py
|
def f(t, ps):
umt = 1 - t
return umt * umt * ps[0] + 2 * umt * t * ps[1] + t * t * ps[2]
assert f(0.5, [1, 2, 3]) == 2
|
benchmark_functions_edited/f13682.py
|
def f(priority):
if priority == "IDLE":
return 0
elif priority == "LOW":
return 1
elif priority == "HIGH":
return 2
elif priority == "URGENT":
return 3
else:
raise ValueError("Unknown priority: {}".format(priority))
assert f('HIGH') == 2
|
benchmark_functions_edited/f10158.py
|
def f(fname, newline=True):
try:
print(open(fname).read())
return 0
except PermissionError:
print(fname + ': Permission Denied')
return 1
except FileNotFoundError:
print(fname + ': File Not Found!')
return 1
assert f('nonexistent') == 1
|
benchmark_functions_edited/f5920.py
|
def f(x, xValues, dValues):
h = xValues[1] - xValues[0]
theta = (x - xValues[0]) / h
return (dValues[1] + 0.5 * (2*theta - 1)*dValues[2]) / h
assert f(1, [0,1,2], [1,0,0]) == 0
|
benchmark_functions_edited/f1458.py
|
def f(n):
num = len(str(abs(n)))
return num
assert f(42) == 2
|
benchmark_functions_edited/f177.py
|
def f(data):
return sum(data) / len(data)
assert f([1]) == 1
|
benchmark_functions_edited/f3418.py
|
def f(X):
N = 0
for x in X:
if len(x) > N:
N = len(x)
return N
assert f( [] ) == 0
|
benchmark_functions_edited/f5254.py
|
def f(item: str) -> int:
return int(item)
assert f(5) == 5
|
benchmark_functions_edited/f4818.py
|
def f(unicode_text):
from unicodedata import east_asian_width
return sum(1+(east_asian_width(c) in "WF") for c in unicode_text)
assert f(u" ") == 6
|
benchmark_functions_edited/f14201.py
|
def f(expr):
max_depth = 0
if type(expr) == list:
max_depth = 1
for exp in expr:
count = 0
if type(exp) == list:
count = 1 + f(exp)
if count > max_depth:
max_depth = count
return max_depth
assert f([list(), list()]) == 2
|
benchmark_functions_edited/f13739.py
|
def f(input_list):
result = []
for row in input_list:
for index, i in enumerate(row):
try:
match = [j for j in row if i % j == 0 and i != j][0]
except IndexError:
continue
else:
result.append(int(i / match))
break
return sum(result)
assert f(
[[1, 1, 1], [2, 1, 1], [1, 1, 1]]
) == 2
|
benchmark_functions_edited/f13708.py
|
def f(severity_str: str) -> int:
if severity_str == 'Info':
return 1
elif severity_str == 'Low':
return 2
elif severity_str == 'Medium':
return 3
elif severity_str == 'High':
return 4
elif severity_str == 'Critical':
return 5
return -1
assert f('High') == 4
|
benchmark_functions_edited/f2281.py
|
def f(lhs, rhs):
if lhs < 0:
return lhs
if rhs < 0:
return rhs
return max(lhs, rhs)
assert f(1, 1) == 1
|
benchmark_functions_edited/f12493.py
|
def f(int_str: str) -> int:
try:
return int(int_str)
except ValueError:
return 0
assert f(1.2) == 1
|
benchmark_functions_edited/f154.py
|
def f(i):
return max(0, min(2, i))
assert f(2) == 2
|
benchmark_functions_edited/f10793.py
|
def f(balance, annualInterestRate, monthlyPaymentRate):
balance = balance - monthlyPaymentRate * balance
balance = balance + (annualInterestRate/12) * balance
return balance
assert f(0, 0, 0) == 0
|
benchmark_functions_edited/f7985.py
|
def periodic (i, limit, add):
return (i+limit+add) % limit
assert f(3, 7, 2) == 5
|
benchmark_functions_edited/f2129.py
|
def f(rho, phi):
return 70 * rho**8 - 140 * rho**6 + 90 * rho**4 - 20 * rho**2 + 1
assert f(1, 1) == 1
|
benchmark_functions_edited/f9398.py
|
def f(dict):
output = 0
for key, value in dict.items():
output = max(output, int(key))
return output
assert f(dict({1: 2, 2: 0, 3: 1})) == 3
|
benchmark_functions_edited/f751.py
|
def f(a,b):
if(a < b):
return 1
else:
return 0
assert f(1,1) == 0
|
benchmark_functions_edited/f13025.py
|
def f(position):
min_fuel = float("Inf")
for i in range(min(position), max(position)):
dist = [0] * len(position)
dist = [
abs(position[j] - i) * (abs(position[j] - i) + 1) // 2
for j in range(len(position))
]
min_fuel = min(min_fuel, sum(dist))
return min_fuel
assert f([1, 2, 3]) == 2
|
benchmark_functions_edited/f13328.py
|
def f(data, value):
min_diff = abs(value - data[0])
min_i = 0
for i in range(1,len(data)):
diff = abs(value - data[i])
if diff < min_diff:
min_diff = diff
min_i = i
return min_i
assert f( [1, 2, 3, 4], 3) == 2
|
benchmark_functions_edited/f10869.py
|
def f(n, k):
if 2 * k > n:
return f(n, n - k)
if k < 0 or k > n:
return 0
r = 1
for i in range(1, k + 1):
r = (r * (n - i + 1)) // i
return r
assert f(2, 1) == 2
|
benchmark_functions_edited/f14120.py
|
def f(*args):
result = None
for i in range(1, len(args), 2):
if args[i]:
result = args[i-1]
break
else:
result = args[-1]
return result
assert f(True, 1, 2) == 1
|
benchmark_functions_edited/f14224.py
|
def f(m):
if not m:
return 0
tzd = m.group("tzd")
if not tzd:
return 0
if tzd == "Z":
return 0
hours = int(m.group("tzdhours"), 10)
minutes = m.group("tzdminutes")
if minutes:
minutes = int(minutes, 10)
else:
minutes = 0
offset = (hours*60 + minutes) * 60
if tzd[0] == "+":
return -offset
return offset
assert f(None) == 0
|
benchmark_functions_edited/f4047.py
|
def f(myList,myNumber):
return min(myList, key=lambda x:abs(x-myNumber))
assert f(
[1, 2, 3],
1.0) == 1
|
benchmark_functions_edited/f11000.py
|
def mean (num_list):
list_mean=sum(num_list)/len(num_list)
return list_mean
assert f([1, 2, 3, 4, 5]) == 3
|
benchmark_functions_edited/f12432.py
|
def f(arb_percent, stake):
return stake / arb_percent[0] - stake
assert f([1000, 1000], 0) == 0
|
benchmark_functions_edited/f5570.py
|
def f(string: str) -> int:
hashed = 0
results = map(ord, string)
for result in results:
hashed += result
return hashed
assert f('') == 0
|
benchmark_functions_edited/f6279.py
|
def f(sym):
return {'H': 0, 'HE': 1,
'C': 0,
'N': 1,
'O': 2, 'S': 2,
'F': 3, 'CL': 3,
'NE': 4, 'AR': 4}[sym.upper()]
assert f('AR') == 4
|
benchmark_functions_edited/f8453.py
|
def f(input_size,
kernel_size, stride=1, padding=0, dilation=1, **kwargs):
from math import floor
return floor((input_size + 2*padding - dilation*(kernel_size-1) - 1)/stride + 1)
assert f(10, 2, 2) == 5
|
benchmark_functions_edited/f2557.py
|
def f(vlist):
for val in vlist:
if val <= 0: return 0
return 1
assert f( [] ) == 1
|
benchmark_functions_edited/f11425.py
|
def f(t):
tmp = t[:]
tmp.sort()
count = 0
for i in range(len(t) - 1):
if tmp[i] == tmp[i + 1] and tmp[i] != tmp[i - 1]:
count += 1
return count
assert f([]) == 0
|
benchmark_functions_edited/f5383.py
|
def f(list1, list2):
if list1 is None or list2 is None:
return 0
return len(set(list1) & set(list2))
assert f(["foo", "bar", "baz"], ["foo", "bar", "baz", "wibble"]) == 3
|
benchmark_functions_edited/f4310.py
|
def f(start, end=(0, 0)):
return sum(abs(e - s) for e, s in zip(start, end))
assert f((0, 0), (0, 0)) == 0
|
benchmark_functions_edited/f5977.py
|
def f(ver_list, idx):
if idx < len(ver_list):
return ver_list[idx]
return 0
assert f(
(1, 2, 3), 2) == 3
|
benchmark_functions_edited/f831.py
|
def f(iterable):
return sum(1 for _ in iterable)
assert f([1, 2, 3, 4, 5]) == 5
|
benchmark_functions_edited/f3924.py
|
def f(n1, n2, n3):
return (n1 + n2 + n3) / 3
assert f(10, 8, 9) == 9
|
benchmark_functions_edited/f1480.py
|
def f(task):
...
return task
assert f(1) == 1
|
benchmark_functions_edited/f1613.py
|
def f(fahrenheit):
return (fahrenheit - 32.0) / 1.8
assert f(32) == 0
|
benchmark_functions_edited/f2079.py
|
def f(distance):
a = 0.5
b = 0.5
c = 0
return a * distance ** 2 + b * distance + c
assert f(1) == 1
|
benchmark_functions_edited/f3379.py
|
def f(list):
for x in list:
return x
assert f(range(1, 11)) == 1
|
benchmark_functions_edited/f9423.py
|
def f(current, target, before_previous, previous):
if current == target:
return before_previous + previous
return f(
current + 1, target, previous, before_previous + previous
)
assert f(1, 1, 0, 1) == 1
|
benchmark_functions_edited/f4836.py
|
def f(a, x):
return a[0] / (x + a[1]) + a[2]
assert f( [ 1, 0, 1 ], 1 ) == 2
|
benchmark_functions_edited/f7516.py
|
def f(values, excluded_values):
return max(set(values).difference(excluded_values))
assert f(range(10), set([1, 2, 3, 4, 5])) == 9
|
benchmark_functions_edited/f6725.py
|
def f(s):
d = 0
for ch in s:
d = d * 26 + (ord(ch) - 64)
return d
assert f("A") == 1
|
benchmark_functions_edited/f3993.py
|
def f(h, alpha):
for i in range(alpha, len(h)):
if h[i] != i:
return i
assert f(
[2, 3, 3, 4, 5, 5, 5, 7, 11, 11],
0,
) == 0
|
benchmark_functions_edited/f11761.py
|
def f(integers):
seen = set()
for integer in integers:
if integer in seen:
seen.remove(integer)
else:
seen.add(integer)
return seen.pop()
assert f(
[4, 1, 2, 1, 2]
) == 4
|
benchmark_functions_edited/f3596.py
|
def f(maybe_num) -> int:
try:
return int(maybe_num)
except ValueError:
return -1
assert f("2") == 2
|
benchmark_functions_edited/f2545.py
|
def f(fit_param, Y):
return fit_param[0]*Y**2 + fit_param[1]*Y + fit_param[2]
assert f( [1,2,3], 1 ) == 6
|
benchmark_functions_edited/f10226.py
|
def f(num):
if num > 128:
return num - 255
else:
return num
assert f(1) == 1
|
benchmark_functions_edited/f2614.py
|
def f(string):
try:
ret = int(string)
except ValueError:
ret = 0
return ret
assert f(5.0) == 5
|
benchmark_functions_edited/f3757.py
|
def f(n):
a, b = 0, 1
if n == 0:
return a
for _ in range(n - 1):
a, b = b, a + b
return b
assert f(0) == 0
|
benchmark_functions_edited/f1860.py
|
def f(i):
if i >= 0:
i += 1
return i
assert f(0) == 1
|
benchmark_functions_edited/f10747.py
|
def f(n):
global total
if n == 0:
return 1
if n < 0:
return 0
return f(n - 1) + f(n - 2)
assert f(2) == 2
|
benchmark_functions_edited/f9543.py
|
def f(inputmatrix, inputmin, inputmax, outputmin, outputmax):
inputrange = inputmax - inputmin
outputrange = outputmax - outputmin
outputmatrix = (inputmatrix-inputmin) * outputrange/inputrange + outputmin
return outputmatrix
assert f(1, 0, 2, -10, 10) == 0
|
benchmark_functions_edited/f8267.py
|
def f(chunks, pos):
pos = pos - 1
while pos > 0:
if chunks[pos][0] != 0x100 and chunks[pos][0] != 0x102:
# This is not a block
return pos
else:
pos = pos - 1
return pos
assert f(
[
(0x1000, 0x0000, 0x00, 0x00),
(0x0000, 0x0000, 0x00, 0x00),
(0x0000, 0x0000, 0x00, 0x00)
],
2
) == 1
|
benchmark_functions_edited/f273.py
|
def f(x, a, b):
return (a * x) + b
assert f(4, 0, 0) == 0
|
benchmark_functions_edited/f4966.py
|
def f(n):
if n < 1:
return 0
if n <= 2:
return (n - 1)
return f(n - 1) + f(n - 2)
assert f(1) == 0
|
benchmark_functions_edited/f562.py
|
def f(n):
return f(n - 1) + f(n - 2) if n > 2 else 1
assert f(1) == 1
|
benchmark_functions_edited/f382.py
|
def f(n):
if n < 2:
return n
return f(n-1) + f(n-2)
assert f(3) == 2
|
benchmark_functions_edited/f11591.py
|
def f(target_len, plasmid_len, target_mass):
return target_mass * plasmid_len / target_len
assert f(100, 20, 0) == 0
|
benchmark_functions_edited/f11141.py
|
def f(user_input, bound):
rules = {
"estavel": lambda x: x, # cenario estavel
"positivo": lambda x: x / 2, # cenario positivo
"negativo": lambda x: x * 2, # cenario negativo
}
return rules[user_input["strategy"]](user_input["rt_values"][bound])
assert f(
{
"rt_values": {
"upper": 5,
"lower": 0.01,
},
"strategy": "estavel",
},
"upper",
) == 5
|
benchmark_functions_edited/f1699.py
|
def f(signal: int) -> int:
return max(0, signal % 65536)
assert f(65537) == 1
|
benchmark_functions_edited/f539.py
|
def f(fn, arg):
return fn(fn(arg))
assert f(abs, 0) == 0
|
benchmark_functions_edited/f14434.py
|
def f(row: list) -> int:
max_array_count = 0
# get the max height of the cells.
for item in row:
if isinstance(item, list) and len(item) > max_array_count:
max_array_count = len(item)
elif isinstance(item, str) and max_array_count == 0:
max_array_count = 1
return max_array_count
assert f(
["Hello", "World", ["This", "Is", "My", "Row"]]) == 4
|
benchmark_functions_edited/f3884.py
|
def f(x0, y0, x1, y1):
dx = x1 - x0
dy = y1 - y0
dx *= dx
dy *= dy
return dx + dy
assert f(1, 1, 2, 2) == 2
|
benchmark_functions_edited/f12106.py
|
def f(input_data, workerlimit):
runners = len(input_data) if len(input_data) < workerlimit else workerlimit
return runners
assert f(range(1), 10) == 1
|
benchmark_functions_edited/f4192.py
|
def f(playerEventList):
return sum(1 for ce in playerEventList if ce.violation)
assert f([]) == 0
|
benchmark_functions_edited/f7019.py
|
def f(stage_boundaries, t):
return max([0] + [x for x in stage_boundaries if x <= t])
assert f(set([]), -1) == 0
|
benchmark_functions_edited/f9125.py
|
def f(m4039, m3739, m3639, pr):
atm4036 = 295.5
n = m4039 - atm4036 * m3639 + atm4036 * pr.get('ca3637') * m3739
d = 1 - pr.get('ca3937') * m3739
F = n / d - pr.get('k4039')
return F
assert f(0, 0, 0, {'ca3637': 0.0, 'ca3937': 0.0, 'k4039': 0.0}) == 0
|
benchmark_functions_edited/f12894.py
|
def f(p1, p2):
return (p1 - p2) ** 2
assert f(0, 1) == 1
|
benchmark_functions_edited/f3827.py
|
def f(*args):
sum = 0
for i in args:
sum = sum + i
return sum
assert f(0, 0, 0) == 0
|
benchmark_functions_edited/f8805.py
|
def f(n_nodes, n_times, node_index, time_index, layer_index):
index = n_nodes * n_times * layer_index + n_nodes * time_index + node_index
return index
assert f(1, 1, 0, 0, 0) == 0
|
benchmark_functions_edited/f359.py
|
def f(y):
d = y**0.3333333
return d
assert f(1) == 1
|
benchmark_functions_edited/f10405.py
|
def f(ugraph):
directed_edges = 0
for node in ugraph:
directed_edges += len(ugraph[node])
if directed_edges % 2 == 0:
return directed_edges / 2
else:
return "Not Undirected"
assert f(dict({1:[]})) == 0
|
benchmark_functions_edited/f1004.py
|
def f(values, puzzle_input):
return puzzle_input[values[0]]
assert f(
[0],
[1, 2, 3]
) == 1
|
benchmark_functions_edited/f3198.py
|
def f(w1, w2, t0, width, t):
return w1 + (w2 - w1) * (t > t0)
assert f(5, 10, 0, 1, 0) == 5
|
benchmark_functions_edited/f4582.py
|
def f(*args, func=None):
if func is None:
func = args[0]
return func(*args[1:])
else:
return func(*args)
assert f(lambda x, y=3: x, 1) == 1
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.