file_name stringlengths 32 36 | content stringlengths 44 898 |
|---|---|
benchmark_functions_edited/f1734.py | def f(n):
if n < 2:
return 1
else:
return f(n-1) + f(n-2)
assert f(5) == 8 |
benchmark_functions_edited/f4742.py | def f(x: int, y: int, z: int) -> int:
w = x * y / z
iw = int(w)
if iw - w != 0:
return iw + 1
return iw
assert f(3, 3, 3) == 3 |
benchmark_functions_edited/f5789.py | def sub2indSH (m,n):
i = n**2 + n + m
return i
assert f(2, -3) == 8 |
benchmark_functions_edited/f1863.py | def f(x,p):
y = p[0] + p[1]*x
return y
assert f(1, (0,1)) == 1 |
benchmark_functions_edited/f1590.py | def f(line):
return len(line)-len(line.lstrip(' '))
assert f("Hi") == 0 |
benchmark_functions_edited/f14325.py | def f(theta_1, theta_2):
theta_1 = theta_1 % 360
theta_2 = theta_2 % 360
delta_theta = theta_2 - theta_1
if 180 <= delta_theta and delta_theta <= 360:
delta_theta -= 360
elif -360 <= delta_theta and delta_theta <= -180:
delta_theta += 360
return delta_theta
assert f(-180, -180) == 0 |
benchmark_functions_edited/f1631.py | def f(labels):
return sum("XlaLaunch(" in x for x in labels)
assert f(
["XlaLaunch(foo, bar)", "XlaLaunch(baz, spam, egg)"]) == 2 |
benchmark_functions_edited/f8055.py | def f(x):
if len(x) == 0:
return 0
return x[0] + f(x[1:])
assert f([1, 1, 1, 1, 1]) == 5 |
benchmark_functions_edited/f2384.py | def f(pos_a, pos_b):
return int(((pos_a[0] - pos_b[0])**2 + (pos_a[1] - pos_b[1])**2)**0.5)
assert f((5, 0), (10, 0)) == 5 |
benchmark_functions_edited/f7569.py | def f(L, X, Y):
P = 0.0
if (L <= 0) :
return P
for I in range(L):
J = L - I - 1
P += X[I] * Y[J]
return P
assert f(1, [1], [1]) == 1 |
benchmark_functions_edited/f11656.py | def f(coords, point_list):
for p in point_list:
if p["coordinates"] == coords:
return p["idx"]
print("Couldn't find the point -- {}!\n".format(str(point_list)))
assert f( [1,1], [{"idx":0, "coordinates":[0,1]}, {"idx":1, "coordinates":[1,1]}] ) == 1 |
benchmark_functions_edited/f7022.py | def f(coordenadas, base=1/12):
return base * round(coordenadas/base)
assert f(0.0, 1/12) == 0 |
benchmark_functions_edited/f6194.py | def f(geometry):
import numpy as np
pos = np.array(geometry)
vec = np.diff(pos,axis=0)**2
return (vec.sum(axis=1)**.5)
assert f([(0,0,0),(1,0,0)]) == 1 |
benchmark_functions_edited/f12551.py | def f(values):
occurrences = dict()
for value in values:
occurrences.setdefault(value, 0)
occurrences[value] += 1
return max(occurrences.items(), key=lambda x: x[1])[0]
assert f([0, 0, 1]) == 0 |
benchmark_functions_edited/f403.py | def f(s):
r = 1
for x in list(s):
r *= int(x)
return r
assert f("5") == 5 |
benchmark_functions_edited/f13474.py | def f(td, k_mD=10, phi=0.2, mu_cP=1, ct_1atm=1e-5, rw_m=0.1):
return td * phi * mu_cP * ct_1atm * rw_m * rw_m / k_mD / 0.00036
assert f(0) == 0 |
benchmark_functions_edited/f14536.py | def f(i, nns):
if i < nns[1]:
target = 0
elif i < nns[2]:
target = 1
elif i < nns[3]:
target = 2
else:
target = 3
return target
assert f(1, [5, 10, 15, 20]) == 0 |
benchmark_functions_edited/f1821.py | def f(oct_str):
return int(oct_str, 8) if oct_str else None
assert f("0") == 0 |
benchmark_functions_edited/f4508.py | def f(n,B=10):
s = 1
while True:
n,r = divmod(n,B)
s *= r
if n == 0:
return s
assert f(12) == 2 |
benchmark_functions_edited/f1129.py | def f(nums: list) -> int:
return sum(sorted(nums)[::2])
assert f(
[1, 4, 3, 2]
) == 4 |
benchmark_functions_edited/f11933.py | def f(total_items, total_orders):
return (total_items / total_orders) * 100
assert f(0, 2) == 0 |
benchmark_functions_edited/f8662.py | def f(string: str, letter: str) -> int:
count_letter = 0
for i in string:
if i == letter:
count_letter += 1
return count_letter
assert f("Hello, world!", "x") == 0 |
benchmark_functions_edited/f443.py | def f(ref):
return ref * ref * ref
assert f(0) == 0 |
benchmark_functions_edited/f2666.py | def f(x: int, y: int) -> int:
while x % y != 0:
r = x % y
x = y
y = r
return abs(y)
assert f(0, 1) == 1 |
benchmark_functions_edited/f13933.py | def f(f, *args):
assert len(args) > 0, 'Must have at least one argument.'
arg = args[0]
if isinstance(arg, tuple) or isinstance(arg, list):
return [f(f, *a) for a in zip(*args)]
elif isinstance(arg, dict):
return {
k: f(f, *[a[k] for a in args])
for k in arg
}
else:
return f(*args)
assert f(lambda x, y: x + y, 1, 2) == 3 |
benchmark_functions_edited/f3681.py | def f(p1, p2):
return ((p1[0]-p2[0])**2 + (p1[1]-p2[1])**2)**0.5
assert f([x for x in range(2)], [x for x in range(2)]) == 0 |
benchmark_functions_edited/f12748.py | def f(b, e, m):
x = 1
y = b
while e > 0:
if e % 2 == 0:
x = (x * y) % m
y = (y * y) % m
e = int(e / 2)
return x % m
assert f(10, 10, 3) == 1 |
benchmark_functions_edited/f5390.py | def f(n, k):
if (k > n): return 0
if (k < 0): return 0
if (k > int(n/2)):
k = n - k
rv = 1
for j in range(0, k):
rv *= n - j
rv /= j + 1
return int(rv)
assert f(5, -1) == 0 |
benchmark_functions_edited/f10482.py | def f(a, b):
if a == 0:
return b
return f(b % a, a)
assert f(2, 5) == 1 |
benchmark_functions_edited/f548.py | def f(P1, P2, f):
return P1 + (P2 - P1) * f
assert f(0, 1, 0) == 0 |
benchmark_functions_edited/f2505.py | def f(value):
if value is not None:
return int(value)
return None
assert f('1') == 1 |
benchmark_functions_edited/f12579.py | def f(x, y, max_iters):
c = complex(x, y)
z = 0.0j
for i in range(max_iters):
z = z * z + c
if (z.real * z.real + z.imag * z.imag) >= 4:
return i
return max_iters
assert f(1, 0, 10) == 1 |
benchmark_functions_edited/f4668.py | def f(lines, start):
for i in range(len(lines)):
if lines[i][:len(start)] == start:
return i
return -1
assert f(
["first line", "second line"],
"second line",
) == 1 |
benchmark_functions_edited/f2094.py | def f(alpha, beta, n):
return n * alpha / (alpha + beta)
assert f(0, 1, 10) == 0 |
benchmark_functions_edited/f13705.py | def f(x, a, b, e):
return a*x**b+e
assert f(1, 2, 2, 0) == 2 |
benchmark_functions_edited/f13446.py | def f(kernel, stride, n0=1, n_lyrs=1):
n1 = n0
for i in range(n_lyrs):
n1 = kernel + (n1 - 1) * stride
return n1
assert f(2, 1) == 2 |
benchmark_functions_edited/f8197.py | def f(dsv):
if dsv < 15:
return 1
elif 15 <= dsv < 100:
return 2
elif 100 <= dsv < 150:
return 3
else:
return 4
assert f(149) == 3 |
benchmark_functions_edited/f941.py | def f(a: int, b: int) -> int:
j = 0
return b
assert f(3, 4) == 4 |
benchmark_functions_edited/f10053.py | def f(root):
def traverse(node, depth=0):
if node is None:
return depth
l_depth = traverse(node.left, depth + 1)
r_depth = traverse(node.right, depth + 1)
return max(l_depth, r_depth)
return traverse(root)
assert f(None) == 0 |
benchmark_functions_edited/f4163.py | def f(int_type, offset):
mask = 1 << offset
return int_type & mask
assert f(0x00, 0) == 0 |
benchmark_functions_edited/f5763.py | def f(t_number, last_time_timeout):
if last_time_timeout:
t_number += 1
return t_number
else:
return 0
assert f(0, False) == 0 |
benchmark_functions_edited/f9934.py | def f(mtl: int) -> int:
if mtl == 1 or mtl == 6:
return mtl + 2
return mtl + 1
assert f(5) == 6 |
benchmark_functions_edited/f6706.py | def f(lst):
n = len(lst)
if n < 1:
return None
if n % 2 == 1:
return sorted(lst)[n//2]
else:
return sum(sorted(lst)[n//2-1:n//2+1])/2.0
assert f([1]) == 1 |
benchmark_functions_edited/f12305.py | def f(J_content, J_style, alpha = 0.5):
J = alpha * J_content + J_style
return J
assert f(1, 1, 1) == 2 |
benchmark_functions_edited/f6006.py | def f(journey):
return round(sum(trip.distance for trip in journey),1)
pass
assert f([]) == 0 |
benchmark_functions_edited/f11333.py | def f(x):
if x == 'crew':
return 3
elif x == 'first':
return 2
elif x == 'second':
return 1
else:
return 0
assert f(1) == 0 |
benchmark_functions_edited/f863.py | def f(x,a,tau):
return a + x*tau
assert f(1,3,1) == 4 |
benchmark_functions_edited/f5941.py | def f(int_string):
if int_string:
try:
return int(int_string)
except ValueError:
pass
return None
assert f("02") == 2 |
benchmark_functions_edited/f5686.py | def f(s):
i = 0
try:
i=int(s)
except ValueError:
i = 0
except TypeError:
i = 0
return i
assert f("1a") == 0 |
benchmark_functions_edited/f2577.py | def get_case_value (my_case, dict_cases) :
if my_case in dict_cases:
return dict_cases[my_case]
return 0
assert f(3, {1: 10}) == 0 |
benchmark_functions_edited/f12921.py | def f(locations, new):
ret = 0
for loc in locations:
if loc['url'] == new['url'] and loc['metadata'] == new['metadata']:
ret += 1
return ret
assert f([], {'url': 'http://some_url_1','metadata': {'foo': 1, 'bar': 2}}) == 0 |
benchmark_functions_edited/f9457.py | def f(a, b):
d = b
x0, x1, y0, y1 = 0, 1, 1, 0
while a != 0:
(q, a), b = divmod(b, a), a
y0, y1 = y1, y0 - q * y1
x0, x1 = x1, x0 - q * x1
return x0 % d
assert f(1, 20) == 1 |
benchmark_functions_edited/f10579.py | def f(hledane, cisla, verbose=True):
kolik = 0
for cislo in cisla:
if cislo == hledane:
kolik += 1
if verbose:
print("Cislo {0} je v seznamu cisel {1}krat.".format(hledane, kolik))
return kolik
assert f(5, [1, 2, 3, 4]) == 0 |
benchmark_functions_edited/f5756.py | def f(X,Tolerance=0):
if X < (.5-(Tolerance/2)):
return(0)
elif X > (.5+(Tolerance/2)):
return(1)
else:
return(.5)
assert f(1.5) == 1 |
benchmark_functions_edited/f3273.py | def f(vector, index):
return vector[index % len(vector)]
assert f(
[3, 45, 6], 12) == 3 |
benchmark_functions_edited/f6507.py | def f(*args, **kwargs):
# pylint: disable=unused-argument
# Here, kwargs will be ignored.
if len(args) == 1:
return args[0]
return args
assert f(1) == 1 |
benchmark_functions_edited/f6745.py | def f(b, a, j, i, no, nv):
nov = no*nv
aa = i*nv + a
bb = j*nv + b
baji = int(nov*(nov-1)/2 - (nov-1-aa)*(nov-aa)/2 + bb)
return baji
assert f(0, 0, 0, 0, 3, 3) == 0 |
benchmark_functions_edited/f6137.py | def f(obj):
return getattr(obj, 'id', obj)
assert f(1) == 1 |
benchmark_functions_edited/f7834.py | def f(graph, i, vertices):
min = float('inf')
for j in range(vertices):
x = graph[i][j]
if(x < min and i != j):
min = x
return min
assert f(
[[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0]], 3, 7) == 0 |
benchmark_functions_edited/f9419.py | def f(n):
fibPrev1, fibPrev2 = 1, 0
result = 0
if n == 1:
result = fibPrev1
elif n == 0:
result = fibPrev2
while n > 1:
result = fibPrev1 + fibPrev2
fibPrev2 = fibPrev1
fibPrev1 = result
n -= 1
return result
assert f(2) == 1 |
benchmark_functions_edited/f11653.py | def f(text):
splitted_by_full_stop = text.split(".")
print("")
for sentence in splitted_by_full_stop:
print("sentence: " + sentence)
no_of_sentences = len(splitted_by_full_stop)
return no_of_sentences
assert f(
"No punctuation here!"
) == 1 |
benchmark_functions_edited/f14511.py | def f(seq, index, default=None):
# Valid index
if isinstance(index, int) and index>=0 and index<len(seq):
return seq[index]
# Fallback to default value
else:
return default
assert f(list(range(3)), 2, None) == 2 |
benchmark_functions_edited/f5980.py | def f(num, denum):
return -(-num//denum)
assert f(-10, -3) == 4 |
benchmark_functions_edited/f3830.py | def f(f,c,dx=0.0001):
return (f(c+dx)-f(c-dx))/(2*dx)
assert f(lambda x:x**2, 3, 1) == 6 |
benchmark_functions_edited/f3450.py | def f(offset, size):
return ((size - (offset % size)) % size) + offset
assert f(8, 1) == 8 |
benchmark_functions_edited/f10021.py | def f(p):
max_c = max(p)
min_c = min(p)
if max_c == 0:
return 0
return (max_c - min_c) / float(max_c)
assert f( (0, 0, 255) ) == 1 |
benchmark_functions_edited/f9624.py | def f(input_size, hidden_size, direction):
single_rnn_size = 8 * hidden_size + 4 * (hidden_size * input_size) + 4 * (hidden_size * hidden_size)
return direction * single_rnn_size
assert f(7, 8, 0) == 0 |
benchmark_functions_edited/f4961.py | def f(point1, point2):
x0, y0 = point1
x1, y1 = point2
return abs(x1 - x0) + abs(y1 - y0)
assert f( (1, 1), (0, 0) ) == 2 |
benchmark_functions_edited/f12447.py | def f(list_in):
value = []
count = []
for val in list_in:
if val in value:
ind = value.index(val)
count[ind] += 1
else:
value.append(val)
count.append(1)
v = max(count)
max_ind = count.index(v)
return float(value[max_ind])
assert f([1, 2, 2, 1]) == 1 |
benchmark_functions_edited/f8565.py | def f(lst, item, start=0):
for i, x in enumerate(lst):
if x == item and i >= start:
return i
return -1
assert f( [1], 1) == 0 |
benchmark_functions_edited/f9131.py | def f(MW, CoSp):
try:
# density
den = MW*CoSp
return den
except Exception as e:
pass
assert f(0.5,2) == 1 |
benchmark_functions_edited/f2016.py | def f(code):
print(code)
return code
assert f(1) == 1 |
benchmark_functions_edited/f3528.py | def f(s,l):
idx = 0
while idx < l.__len__() and l[idx] != s:
idx = idx + 1
return idx
assert f( 'a', 'apple' ) == 0 |
benchmark_functions_edited/f12666.py | def f(velocity):
if velocity < 0:
return 0
apogee = velocity**2 / (2 * 9.80665)
return apogee
assert f(-10000) == 0 |
benchmark_functions_edited/f11058.py | def f(s):
count = 0
for i in range(0, len(s), 2):
if s[i] in "AEIOU":
count = 1
return count
assert f("aBCdEf") == 1 |
benchmark_functions_edited/f3028.py | def f(*args):
for arg in args:
if arg is not None:
return arg
return None
assert f(None, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20) == 0 |
benchmark_functions_edited/f1110.py | def f(a, b):
def inner(x):
return x * b
return inner(b) * inner(a)
assert f(2, 1) == 2 |
benchmark_functions_edited/f2791.py | def f(items, predicate):
return next((x for x in items if predicate(x)), None)
assert f(range(10), lambda x: x >= 0) == 0 |
benchmark_functions_edited/f6120.py | def f(key, my_dictionary):
return (my_dictionary[key])
assert f(1, [1, 2, 3]) == 2 |
benchmark_functions_edited/f5055.py | def f(x):
return sum(1 for i in x)
assert f(range(5)) == 5 |
benchmark_functions_edited/f6374.py | def f(point,line):
return (point[1] - line[0]*point[0]-line[1])**2
assert f( (1,2), (1,3) ) == 4 |
benchmark_functions_edited/f7427.py | def f(proxy):
return proxy.__repr__.__self__
assert f(1) == 1 |
benchmark_functions_edited/f11243.py | def f(ChargeSA):
res=0.0
for i in ChargeSA:
if float(i[1])>0:
res=res+float(i[1])*i[2]
return res
assert f([('C2', '-1', '12.0107')])==0 |
benchmark_functions_edited/f5597.py | def f(val):
if type(val) == str:
ret_val = float(val) if '.' in val else int(val)
return ret_val
return val
assert f("01") == 1 |
benchmark_functions_edited/f12321.py | def f(freqs,delt):
return (delt[0]+delt[1]*freqs+delt[2]*freqs**2+delt[3]*freqs**3+delt[4]*freqs**4)
assert f(1, [0, 1, 0, 0, 0]) == 1 |
benchmark_functions_edited/f4301.py | def f(f, args):
return f(*args)
assert f(lambda x: x, (1, )) == 1 |
benchmark_functions_edited/f9989.py | def f(value, exponent, modulus):
result = 1
factor = value
while exponent != 0:
if (exponent % 2 == 1):
result = (result * factor) % modulus
factor = (factor * factor) % modulus
exponent /= 2
return result
assert f(2, 0, 3) == 1 |
benchmark_functions_edited/f9722.py | def f(hand):
# TO DO... <-- Remove this comment when you code this function
length = 0
for i in hand:
length += hand[i]
return length
assert f({ 'F':1, 'L':1, 'U':2, 'N':1 }) == 5 |
benchmark_functions_edited/f897.py | def f(a):
return sum(a) / float(len(a))
assert f([1, 3, 5, 7, 9]) == 5 |
benchmark_functions_edited/f13948.py | def f(xbar1, xbar2, ms_with):
return (xbar1 - xbar2) / (ms_with ** 0.5)
assert f(0, 0, 0.01) == 0 |
benchmark_functions_edited/f7357.py | def f(a, ds, fs):
total = 0
for d, f in zip(ds, fs):
total += (d**(1-a)) * (f**(a))
return total
assert f(0, [0, 0], [1, 0]) == 0 |
benchmark_functions_edited/f5050.py | def f(s: str) -> int:
i = sum(pow(int(c), 5) for c in s)
return i if i == int(s) else 0
assert f(str(10)) == 0 |
benchmark_functions_edited/f11820.py | def f(current, epaddr, v):
if v:
return current | 1 << epaddr
else:
return current & ~(1 << epaddr)
assert f(0, 2, 1) == 4 |
benchmark_functions_edited/f1348.py | def f(self, args=(), kwargs={}):
return self(*args, **kwargs)
assert f(lambda a, b, c: a + b + c, (2, 3, 4)) == 9 |
benchmark_functions_edited/f10973.py | def f( ZACompound, ZAOther, minus = True ) :
if( ( ZACompound % 1000 ) == 0 ) : ZAOther = 1000 * ( ZAOther // 1000 )
if( minus ) : return( ZACompound - ZAOther )
return( ZACompound + ZAOther )
assert f( 92235, 92235 ) == 0 |
benchmark_functions_edited/f13159.py | def f(x, theta):
# (approx. 1 line)
dtheta = x
# YOUR CODE STARTS HERE
# YOUR CODE ENDS HERE
return dtheta
assert f(2, 4) == 2 |
benchmark_functions_edited/f7508.py | def f(n: int) -> int:
def f(x, y, z):
if x < y:
return 0 ** x
return f(x - y, y + z, y) + f(x, y + z, y)
return f(n, 1, 1)
assert f(4) == 1 |
benchmark_functions_edited/f9910.py | def length_of_vlint (value):
octets = 1
while (1 << (8 * octets)) <= value:
octets += 1
return octets
assert f(65545) == 3 |
benchmark_functions_edited/f13956.py | def f(frame,channel=1,digital=False):
if channel == 1:
if not digital :
return ((frame[0] & 0x3f) << 6 ) | (frame[1] & 0x3f)
else:
return (frame[0] & 0x40) >> 6
elif channel == 2:
if not digital:
return ((frame[2] & 0x3f) << 6 ) | (frame[3] & 0x3f)
else:
return (frame[1] & 0x40) >> 6
assert f(b"\x00\x40\x00\x00") == 0 |
benchmark_functions_edited/f12984.py | def f(curr_records, prev_records):
records = zip(curr_records, prev_records)
for i, (curr_record, prev_record) in enumerate(records):
if curr_record != prev_record:
return i
# last row was deleted
return len(curr_records)
assert f(
[("M", 23), ("F", 31), ("F", 26), ("F", 32)],
[("M", 23), ("F", 31), ("F", 29)],
) == 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.