file_name
stringlengths 32
36
| content
stringlengths 44
898
|
|---|---|
benchmark_functions_edited/f14034.py
|
def f(n, k):
new_num = n >> k
return new_num & 1
assert f(32, 5) == 1
|
benchmark_functions_edited/f1338.py
|
def f(vals):
ssq = 0
for val in vals: ssq += (val*val)
return ssq
assert f( [0,0,0] ) == 0
|
benchmark_functions_edited/f877.py
|
def f(string):
return int(string, 2)
assert f( '00000000' ) == 0
|
benchmark_functions_edited/f11635.py
|
def f(val1, val2, t1, t2):
return ( (val1 / val2) ** (1 / (t1 - t2)) ) - 1
assert f(10, 10, 3, 2) == 0
|
benchmark_functions_edited/f5162.py
|
def f(list):
if(len(list) % 2 == 0):
median_index = len(list)//2 + 1
else:
median_index = len(list)//2
return list[median_index]
assert f([1, 2, 3, 4, 5, 6, 7, 8, 9]) == 5
|
benchmark_functions_edited/f33.py
|
def f(x):
print(x)
return 1
assert f("b") == 1
|
benchmark_functions_edited/f4622.py
|
def f(str1, str2):
assert len(str1) == len(str2)
return sum(c1 != c2 for c1, c2 in zip(str1, str2))
assert f(b'abcde', b'abcde') == 0
|
benchmark_functions_edited/f6048.py
|
def f(solutions, *args, **kwargs):
return sum([s.score or 0 for s in solutions if s is not None])
assert f([None], [None]) == 0
|
benchmark_functions_edited/f1183.py
|
def f(num, position):
return (num >> position) & 0b1
assert f(0b100100, 4) == 0
|
benchmark_functions_edited/f6731.py
|
def f(amount=1):
global DEBUG
DEBUG = amount
return DEBUG
assert f(2) == 2
|
benchmark_functions_edited/f4412.py
|
def f(x,logomega0, b, height):
return height / ((1 - b) + (b / (1 + b)) * (b * (10**logomega0 / x) + (x / 10**logomega0)**b))
assert f(10,1,1,0) == 0
|
benchmark_functions_edited/f5922.py
|
def f(angle_in_degrees):
return abs(((angle_in_degrees + 90) % 180) - 90.)
assert f(0) == 0
|
benchmark_functions_edited/f3861.py
|
def f(data):
try:
page = int(data.get('page', '1'))
except (ValueError, TypeError):
page = 1
return page
assert f({'page': '1', 'page_size': '10'}) == 1
|
benchmark_functions_edited/f7346.py
|
def f(cz, e):
if cz is None:
z = 0
else:
z = e.parent.pzf + cz * (e.css('cd', 0) + e.gd)
return z
assert f(None, 'e1') == 0
|
benchmark_functions_edited/f2633.py
|
def f(x, field):
a = len(field)
if x >= a:
return x - a
if x < 0:
return x + a
return x
assert f(-1, [1, 2]) == 1
|
benchmark_functions_edited/f3436.py
|
def f(rgb):
return (rgb[0] + rgb[1] + rgb[2]) / 765
assert f( (0,0,0) ) == 0
|
benchmark_functions_edited/f1240.py
|
def f(x, linear):
a,b,offset = linear
y = ((a * x) + b)//offset
return y
assert f(1, [1, 0, 1]) == 1
|
benchmark_functions_edited/f6136.py
|
def f(var_dist_params):
data_sim = var_dist_params
return data_sim
assert f(5) == 5
|
benchmark_functions_edited/f6714.py
|
def f(n):
if n == 0 or n == 1:
return 1
else:
return n*f(n-1)
assert f(3) == 6
|
benchmark_functions_edited/f3128.py
|
def f(a, b, n):
while n > 0:
a, b = b, a+b
n = n - 1
return b
assert f(1, 1, 3) == 5
|
benchmark_functions_edited/f4468.py
|
def f(value, arg):
if not value:
return arg
return value
assert f(None, 1) == 1
|
benchmark_functions_edited/f13750.py
|
def f(L, v):
i = 0
j = len(L) - 1
while i != j + 1:
m = (i + j) // 2
if L[m] < v:
i = m + 1
else:
j = m - 1
if 0 <= i < len(L) and L[i] == v:
return i
else:
return -1
assert f(range(10), 0) == 0
|
benchmark_functions_edited/f14508.py
|
def f(a: int, b: int) -> int:
return b if a == 0 else f(b % a, a)
assert f(24, 40) == 8
|
benchmark_functions_edited/f10702.py
|
def f(sequence):
try:
return next(iter(sequence))
except StopIteration:
return None
assert f(iter({1, 2, 3})) == 1
|
benchmark_functions_edited/f5215.py
|
def f(value, bins):
for i in range(0, len(bins)):
if bins[i][0] <= value < bins[i][1]:
return i
return -1
assert f(0.99, [(0, 1), (1, 2)]) == 0
|
benchmark_functions_edited/f2414.py
|
def f(string):
try:
return int(string)
except:
return None
assert f("0") == 0
|
benchmark_functions_edited/f10881.py
|
def f(metal):
len_metal = len("metal")
parse_num = ""
for idx in range(len_metal, len(metal)):
parse_num += metal[idx]
return int(parse_num)
assert f("metal2") == 2
|
benchmark_functions_edited/f3680.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, [2, 1, 3, 4, 5]) == 1
|
benchmark_functions_edited/f6689.py
|
def f( arr, idx, default ):
try:
return arr[idx]
except IndexError:
return default
assert f( [1,2], 0, 3 ) == 1
|
benchmark_functions_edited/f5949.py
|
def f(a, b):
d = 1 - 2 * (b % 2)
return a + d
assert f(3, 4) == 4
|
benchmark_functions_edited/f2713.py
|
def f(pt1, pt2):
return ((pt1[0] - pt2[0]) ** 2) + ((pt1[1] - pt2[1]) ** 2)
assert f( (3, 4), (3, 4) ) == 0
|
benchmark_functions_edited/f10967.py
|
def f(x_val: int, y_val: int) -> int:
assert isinstance(x_val, int) and isinstance(
y_val, int
), "Input parameters should be integers."
return x_val + y_val
assert f(1, 2) == 3
|
benchmark_functions_edited/f8592.py
|
def f(iterable, default=False, pred=None):
return next(filter(pred, iterable), default)
assert f( (0, False, None) ) == 0
|
benchmark_functions_edited/f949.py
|
def f(X, Y):
r = 0.0
for x,y in zip(X,Y):
r += abs(x-y)
return r/len(X)
assert f(list(range(10)), list(range(10))) == 0
|
benchmark_functions_edited/f12555.py
|
def f(n, k):
if 0 <= k <= n:
ntok = 1
ktok = 1
for t in range(1, min(k, n - k) + 1):
ntok *= n
ktok *= t
n -= 1
return ntok // ktok
else:
return 0
assert f(4, 3) == 4
|
benchmark_functions_edited/f7983.py
|
def f(kmph: float) -> float:
if not isinstance(kmph, (float, int)):
return 0
return kmph * 0.2777778
assert f(0) == 0
|
benchmark_functions_edited/f5753.py
|
def f(i: int, x: int, n: int):
return (x + i) % n
assert f(1, 2, 100) == 3
|
benchmark_functions_edited/f2937.py
|
def f(num):
return -num if num < 0 else num
assert f(-3) == 3
|
benchmark_functions_edited/f9394.py
|
def f(line):
try:
ix = 0
while line[ix] == ' ': ix += 1
return ix
except IndexError:
return len(line)
assert f( 'a') == 0
|
benchmark_functions_edited/f2141.py
|
def f(string):
return len(string) - len(string.lstrip(' '))
assert f(
''' # Comment
class SomeClass:
pass
'''
) == 4
|
benchmark_functions_edited/f1614.py
|
def f(_list, item):
return _list.count(item)
assert f([3.14, 3.14, 3.14, 3.14], 3.14) == 4
|
benchmark_functions_edited/f9694.py
|
def f(x):
if not isinstance(x, (list, tuple)): return len(x)
if len(x) > 3: sep_len = 2 * (len(x) - 3)
else: sep_len = 0
return sum(map(format_len, x)) + sep_len
assert f('12345') == 5
|
benchmark_functions_edited/f12143.py
|
def f(x, e, m):
X = x
E = e
Y = 1
while E > 0:
if E % 2 == 0:
X = (X * X) % m
E = E // 2
else:
Y = (X * Y) % m
E = E - 1
return Y
assert f(3, 2, 2) == 1
|
benchmark_functions_edited/f7974.py
|
def f(vals):
if len(vals)==0:
return []
try:
# If inputs are awesomediff.variable objects:
return sum([abs(v.val) for v in vals])
except:
return sum([abs(v) for v in vals])
assert f([-1, 0, 1]) == 2
|
benchmark_functions_edited/f5901.py
|
def f(kernel_size, dilation, stride):
return ((stride - 1) + dilation * (kernel_size - 1)) // 2
assert f(3, 1, 1) == 1
|
benchmark_functions_edited/f2104.py
|
def f(byte):
if byte > 127:
return (256-byte) * (-1)
else:
return byte
assert f(1) == 1
|
benchmark_functions_edited/f738.py
|
def f(a,b):
return (a > b) - (a < b)
assert f(1.0, 1) == 0
|
benchmark_functions_edited/f11292.py
|
def f(a, n):
if a == 0:
return 0
lm, hm = 1, 0
low, high = a % n, n
while low > 1:
r = high // low
nm, new = hm - lm * r, high - low * r
lm, low, hm, high = nm, new, lm, low
return lm % n
assert f(1, 5) == 1
|
benchmark_functions_edited/f9926.py
|
def f(bits, dist):
assert dist <= 29
if dist >= 4:
extra = (dist - 2) / 2
if extra:
ebits = bits.read(extra)
dist = 2**(extra+1) + ((dist % 2) * (2**extra)) + ebits
dist += 1
return dist
assert f(1, 2) == 3
|
benchmark_functions_edited/f11165.py
|
def f(S, idx1, idx2):
if idx1 == idx2:
return len(S) - idx1
match_count = 0
while idx1 < len(S) and idx2 < len(S) and S[idx1] == S[idx2]:
match_count += 1
idx1 += 1
idx2 += 1
return match_count
assert f(u'aa', 0, 1) == 1
|
benchmark_functions_edited/f6680.py
|
def f(x):
# Simply return non-numerical inputs.
return x
assert f(1.0) == 1
|
benchmark_functions_edited/f8877.py
|
def f(f, arg):
new_arg = arg
while True:
new_arg = f(arg)
if new_arg == arg:
break
arg = new_arg
return new_arg
assert f(lambda x: x * x, 1) == 1
|
benchmark_functions_edited/f11853.py
|
def f(pattern, str):
c = 0
sp = len(pattern)
while len(str) >= sp:
slice = str[:sp]
if pattern == slice:
c += 1
str = str[1:]
return c
assert f(
"a", "abc"
) == 1
|
benchmark_functions_edited/f926.py
|
def f(x, y):
return min(1, 1 - x + y)
assert f(1, 1) == 1
|
benchmark_functions_edited/f7095.py
|
def f(element, true=object(), false=object()):
if element is True:
return true
elif element is False:
return false
return element
assert f(1) == 1
|
benchmark_functions_edited/f10914.py
|
def f(arr1, arr2):
return sum((x1 - x2) ** 2 for x1, x2 in zip(arr1, arr2)) ** 0.5
assert f(
[1, 2, 3],
[1, 2, 3]
) == 0
|
benchmark_functions_edited/f10573.py
|
def f(XYs):
n = len(XYs) # of corners
area = 0.0
for i in range(n):
j = (i + 1) % n
area += XYs[i][0] * XYs[j][1]
area -= XYs[j][0] * XYs[i][1]
area = abs(area) / 2.0
# print ("XYs {0} area {1}".format(XYs, area))
return area
assert f(
[
(0, 0),
(1, 0),
(1, 1),
(0, 1),
(0, 0)
]
) == 1
|
benchmark_functions_edited/f8606.py
|
def f(l, sl) :
lLen = len(l)
slLen = len(sl)
for i in range(lLen - slLen + 1):
j = 0
while j < slLen and l[i + j] == sl[j]:
j += 1
if j == slLen:
return i
return None
assert f( [3], [3] ) == 0
|
benchmark_functions_edited/f6261.py
|
def f(cardName):
slot = (cardName.split("-")[2])
slot = int(slot.strip("amc"))
return slot
assert f("gem-shelf11-amc5") == 5
|
benchmark_functions_edited/f3233.py
|
def f(lst):
prod = 1
for itm in lst:
prod *= itm
return prod
assert f([]) == 1
|
benchmark_functions_edited/f7163.py
|
def f(inputs):
num_increased = 0
for i in range(1, len(inputs)):
if inputs[i] > inputs[i - 1]:
num_increased += 1
return num_increased
assert f( [ 1, 2, 3, 4, 5, 6 ] ) == 5
|
benchmark_functions_edited/f3182.py
|
def f(n):
x, y = 0, 1
for i in range(n - 1):
x, y = y, x + y
return x
assert f(2) == 1
|
benchmark_functions_edited/f7995.py
|
def f(input_dict):
value_list = []
for value in input_dict.values():
value_list.append(value)
return len(set(value_list))
assert f(
{"a": 1, "b": 1, "c": 1, "d": 2, "e": 2, "f": 3}) == 3
|
benchmark_functions_edited/f5077.py
|
def f(x):
if x is None:
return x
try:
return int(x)
except ValueError:
return None
assert f(0) == 0
|
benchmark_functions_edited/f934.py
|
def f(cond):
res = 1 if cond else 0
return res
assert f(False) == 0
|
benchmark_functions_edited/f6908.py
|
def f(nucleotides, val):
t = 0
for x in nucleotides:
if x == val:
t += 1
return t
assert f([], 'C') == 0
|
benchmark_functions_edited/f8282.py
|
def f(js, key, defval=None):
if key not in js:
return defval
return js[key]
assert f({'x': 1}, 'y', 2) == 2
|
benchmark_functions_edited/f7333.py
|
def f(data, n, m, ind):
pos_score = data[ind][0]
curr = data[ind:ind + m]
curr = sorted(curr, key=lambda x: x[0], reverse=True)
if curr[n - 1][0] <= pos_score:
return 1
return 0
assert f(
[(0, 0), (1, 1), (2, 2)], 2, 3, 1
) == 1
|
benchmark_functions_edited/f14353.py
|
def f(gt_label, label_list, K):
patk = 0
for i, pred_label in enumerate(label_list[:K]):
if gt_label == pred_label:
patk += 1
patk /= K
return patk
assert f(2, [3], 1) == 0
|
benchmark_functions_edited/f3743.py
|
def f(n):
if n == 0:
return 1
return n * f(n - 1)
assert f(3) == 6
|
benchmark_functions_edited/f10336.py
|
def f(x, y, after):
s = 0
for i in range(x + 1):
for j in range(y + 1):
if i != x or j != y:
s = s + after[i][j]
after[x][y] = after[x][y] - s
return after[x][y]
assert f(0, 1, [[1, 1]]) == 0
|
benchmark_functions_edited/f6159.py
|
def f(n,g,h,m,r):
return g**m*h**r % n
assert f(1000, 0, 1, 1, 0) == 0
|
benchmark_functions_edited/f76.py
|
def f(a, b):
return float(a) * float(b)
assert f(10, 0) == 0
|
benchmark_functions_edited/f8171.py
|
def f(word1, word2):
c = 0
for i in range(len(word1)):
if word1[i] != word2[i]:
c += 1
return c
assert f('123123', '123456') == 3
|
benchmark_functions_edited/f120.py
|
def f(a, b):
return (a >> 8) * (b >> 8)
assert f(-10, 0) == 0
|
benchmark_functions_edited/f4524.py
|
def f(value: str) -> int:
return int(float(value))
assert f(r'1E0') == 1
|
benchmark_functions_edited/f12970.py
|
def f(min, max):
target = range(min, max+1)
return sum(target)**2 - sum((i**2 for i in target))
assert f(1, 1) == 0
|
benchmark_functions_edited/f11550.py
|
def strtobool (val, yesvals = ["yes", "y"], novals = ["no", "n"]):
val = val.lower()
if val in yesvals:
return 1
elif val in novals:
return 0
else:
raise ValueError("invalid truth value {}".format(val))
assert f("Y") == 1
|
benchmark_functions_edited/f13698.py
|
def f(canonical_seqs, upstream_sequence):
hits = 0
for seq in canonical_seqs:
hits += upstream_sequence.count(seq)
return hits
assert f(['AATAAA','ATTAAA'], "TTAAATAAATTTAAATTAAATTAAATAAATAATAAACT") == 4
|
benchmark_functions_edited/f10503.py
|
def f(arr: list) -> int:
inv_count = 0
n = len(arr)
for i in range(n):
for j in range(i + 1, n):
if arr[i] > arr[j]:
inv_count += 1
return inv_count
assert f(list(range(7))) == 0
|
benchmark_functions_edited/f14481.py
|
def f(p, s):
return 1 / ((1-p) + p/s)
assert f(1, 4) == 4
|
benchmark_functions_edited/f5468.py
|
def f(drafts):
return drafts.get('not-submitted', 0)
assert f(
{
"submitted": 2,
"not-submitted": 1
}
) == 1
|
benchmark_functions_edited/f6004.py
|
def f(start, swaps):
for swap in swaps:
if swap[0] == start:
start = swap[1]
elif swap[1] == start:
start = swap[0]
return start
assert f(3, [(5, 1), (4, 2), (1, 3)]) == 1
|
benchmark_functions_edited/f854.py
|
def f(longitude):
return (int(1 + (longitude + 180.0) / 6.0))
assert f(-178) == 1
|
benchmark_functions_edited/f2594.py
|
def f(viewport_size, cursor_size):
return int((viewport_size - cursor_size) / -2)
assert f(0, 1) == 0
|
benchmark_functions_edited/f624.py
|
def f(t):
return 1*(t>=0)
assert f(1) == 1
|
benchmark_functions_edited/f2696.py
|
def f(lst):
if type(lst) != list or len(lst) == 0:
return lst
else:
return lst[0]
assert f([1, 2, 3, [4]]) == 1
|
benchmark_functions_edited/f3212.py
|
def f(kinetic_energy,velocity):
result = (2*kinetic_energy)/velocity**2
return result
assert f(10,2) == 5
|
benchmark_functions_edited/f14398.py
|
def f(a, b):
if a == b:
return a
if (a & 1) == 0 and (b & 1) == 0:
return f(a >> 1, b >> 1) << 1
elif (a & 1) == 0 and (b & 1) != 0:
return f(a >> 1, b)
elif (a & 1) != 0 and (b & 1) == 0:
return f(a, b >> 1)
else:
big = max(a, b)
small = min(a, b)
return f(big - small, small)
assert f(1, 5) == 1
|
benchmark_functions_edited/f3847.py
|
def f(int_type: int, offset: int) -> int:
mask = ~(1 << offset)
return int_type & mask
assert f(2, 3) == 2
|
benchmark_functions_edited/f11255.py
|
def f(x: int):
count = 0
while x:
# bitwise AND number with itself minus 1
x &= x - 1
count += 1
return count
assert f(2**64) == 1
|
benchmark_functions_edited/f14409.py
|
def f(value):
if value is True or value is False:
raise TypeError("Even though int(False) and int(True) work, we disallow it.")
inted = int(value)
if inted != value:
raise ValueError("%r cannot be converted to identical integer" % (value,))
return inted
assert f(0.0) == 0
|
benchmark_functions_edited/f10834.py
|
def f(n, base=2):
vdc, denom = 0.0, 1.0
while n:
denom *= base
n, remainder = divmod(n, base)
vdc += remainder / denom
return vdc
assert f(0) == 0
|
benchmark_functions_edited/f8660.py
|
def f(timestamp):
return timestamp - (timestamp % 86400)
assert f(43200) == 0
|
benchmark_functions_edited/f13654.py
|
def f(a, b, t):
return a + (b - a) * t
assert f(10, 20, -0.5) == 5
|
benchmark_functions_edited/f381.py
|
def f(result):
return next(iter(result))
assert f(iter(range(3))) == 0
|
benchmark_functions_edited/f7453.py
|
def f(l1, l2, v2):
return (l2*v2)/l1
assert f(1,1,1) == 1
|
benchmark_functions_edited/f4736.py
|
def f(tfmin, deltaT):
return int( (tfmin - deltaT) + 2 )
assert f(2, 0.2) == 3
|
benchmark_functions_edited/f3369.py
|
def f(phrase):
src, tgt, rela = phrase
if type(tgt) == int:
return tgt
else:
return f(tgt)
assert f(('a', 1, 'c')) == 1
|
benchmark_functions_edited/f6306.py
|
def f(M1, M2):
return (M2 - 2*M1**2)**2
assert f(0, 1) == 1
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.