file_name
stringlengths 32
36
| content
stringlengths 44
898
|
|---|---|
benchmark_functions_edited/f9164.py
|
def f(hex_str):
hex_char_set = set(hex_str[i*2:i*2+2] for i in range(len(hex_str)//2))
twozero = set(['20'])
if hex_char_set == twozero:
return 0
else:
return int(hex_str, 16)
assert f('2020202020202020202020202020202020202020202020202020202020202020') == 0
|
benchmark_functions_edited/f2183.py
|
def f(p, mach):
q = 0.7 * p * mach ** 2
return q
assert f(5000, 0) == 0
|
benchmark_functions_edited/f9053.py
|
def f(components_summary: dict) -> int:
n_components_li = [di['n_components'] for random_state, di in components_summary.items()]
n_components = int(sum(n_components_li) / len(n_components_li))
return n_components
assert f(
{0: {'n_components': 2, 'total_variance': 2.0}, 1: {'n_components': 1, 'total_variance': 1.0}}
) == 1
|
benchmark_functions_edited/f3157.py
|
def f(n: int):
result = 1
for i in range(1, n+1):
result = result * i
return result
assert f(1) == 1
|
benchmark_functions_edited/f10594.py
|
def f(obj, key, default=None):
if isinstance(obj, dict):
return obj.get(key, default)
elif isinstance(obj, list):
try:
return obj[key]
except IndexError:
return default
assert f({'a': 1, 'b': 2}, 'b', 2) == 2
|
benchmark_functions_edited/f6026.py
|
def f(f, start):
prev, current = start, f(start)
while current != prev:
prev, current = current, f(current)
return current
assert f(lambda x: x ** 2, 1) == 1
|
benchmark_functions_edited/f4032.py
|
def f(x):
return int(int(x) == 1)
assert f(2) == 0
|
benchmark_functions_edited/f7870.py
|
def f(header_row, pattern="rs"):
snp_columns = (index for index, column in enumerate(header_row) if column.startswith(pattern))
# return the first index
return next(snp_columns)
assert f(
["rs42", "rs4506", "gwas-rs666"]) == 0
|
benchmark_functions_edited/f13365.py
|
def f(team: int) -> int:
# Other creative ways to do it:
# return (1, -1)[team]
# return 1 if team == 0 else -1
# for i in range(team):
# return 1
# return -1
# return -range(-1, 2, -2)[team]
return -2 * team + 1
assert f(0) == 1
|
benchmark_functions_edited/f301.py
|
def f(x,a,b,c):
y = (-a*x - c) / b
return y
assert f(1, 0, 1, 0) == 0
|
benchmark_functions_edited/f2204.py
|
def f(value: bytes) -> int:
return int.from_bytes(value, byteorder="big", signed=True)
assert f(bytearray([0])) == 0
|
benchmark_functions_edited/f8219.py
|
def f(b, n, p, x_i):
if x_i % 3 == 2:
return (b + 1) % n
elif x_i % 3 == 0:
return 2*b % n
elif x_i % 3 == 1:
return b
else:
print("[-] Something's wrong!")
return -1
assert f(1, 10, 1, 7) == 1
|
benchmark_functions_edited/f6167.py
|
def f(k, n):
u, s = n, n+1
while u < s:
s = u
t = (k-1) * s + n // pow(s, k-1)
u = t // k
return s
assert f(3, 125) == 5
|
benchmark_functions_edited/f12701.py
|
def f(a, b):
# --- version 1 ---
# if a == b:
# return a
# elif a > b:
# return f(a - b, b)
# else: # a < b
# return f(a, b - a)
# --- version 2 ---
# if b == 0:
# return a
# else: # a < b
# return f(b, a%b)
# --- version 3 ---
return a if b == 0 else f(b, a % b)
assert f(2, 5) == 1
|
benchmark_functions_edited/f10644.py
|
def f(b, i, k):
retval = k
lowbits = k & ((1 << i) - 1) # get the low i bits
retval >>= i
retval <<= 1
retval |= b
retval <<= i
retval |= lowbits
return retval
assert f(True, 0, 2) == 5
|
benchmark_functions_edited/f11306.py
|
def f(a, b, lb=10, ub=19):
summ = a + b
if summ >= lb and summ <= ub:
return 20
else:
return summ
assert f(1, 2) == 3
|
benchmark_functions_edited/f12380.py
|
def f(side):
area = side * side
return area
assert f(3) == 9
|
benchmark_functions_edited/f4867.py
|
def f(numerator, denominator):
if not denominator:
return 0.0
else:
return numerator / denominator
assert f(0.0, 4.0) == 0
|
benchmark_functions_edited/f13917.py
|
def f(xs, x):
lft, rgt = 0, len(xs)
while lft < rgt:
mid = (lft + rgt) // 2
if xs[mid] == x:
return mid
if xs[mid] < x:
lft = mid + 1
else:
rgt = mid
return None
assert f(list(range(10)), 3) == 3
|
benchmark_functions_edited/f6255.py
|
def f(n): # this line defines the function 'fib' where n is the input value
i = 0
j = 1
n = n - 1
while n >= 0:
i, j = j, i + j
n = n - 1
return i
assert f(1) == 1
|
benchmark_functions_edited/f13136.py
|
def f(reducer, s, base):
result = base
for num in s:
result = reducer(result, num)
return result
assert f(lambda x,y: x*y, [1,2,3,4], 0) == 0
|
benchmark_functions_edited/f3594.py
|
def f(x: float, y: float) -> float:
if y == 0:
raise ValueError("Can not divide by zero!")
return x / y
assert f(10, 5) == 2
|
benchmark_functions_edited/f3354.py
|
def f(exp):
if isinstance(exp, tuple):
return 1 + max([f(sub) for sub in exp])
return 0
assert f(1) == 0
|
benchmark_functions_edited/f259.py
|
def f(v):
if v is None:
return 0
return v
assert f(1) == 1
|
benchmark_functions_edited/f2772.py
|
def f(acc, w1, w2):
return int(acc + w1 + w2 > 0)
assert f(1, 1, 2) == 1
|
benchmark_functions_edited/f6437.py
|
def f(func, data):
if isinstance(data, list):
return [f(func, elem) for elem in data]
else:
return func(data)
assert f(lambda x: x + 1, -1) == 0
|
benchmark_functions_edited/f14386.py
|
def f(player_id, players):
player = next(player for player in players
if player["id"] == player_id)
return player["element_type"]
assert f(5, [
{"id": 4, "element_type": 1},
{"id": 5, "element_type": 2},
{"id": 6, "element_type": 3},
{"id": 7, "element_type": 4}
]) == 2
|
benchmark_functions_edited/f9363.py
|
def f(r, g, b):
# This only uses RGB ... how can we integrate clear or calculate lux
# based exclusively on clear since this might be more reliable?
illuminance = (-0.32466 * r) + (1.57837 * g) + (-0.73191 * b)
return illuminance
assert f(0, 0, 0) == 0
|
benchmark_functions_edited/f12404.py
|
def f(n):
hams = [1]
iterators = [iter(map(i.__mul__, hams)) for i in [2, 3, 5]]
current = [next(it) for it in iterators]
while len(hams) < n:
value = min(current)
if value != hams[-1]:
hams.append(value)
i = current.index(value)
current[i] = next(iterators[i])
return hams[-1]
assert f(6) == 6
|
benchmark_functions_edited/f521.py
|
def f(offset: int) -> int:
return (offset + 1) & ~3 | 2
assert f(1) == 2
|
benchmark_functions_edited/f7864.py
|
def f(l_, l):
if l_ == l:
return 0
else:
return 1 * abs(l_ - l)
assert f(0, 0) == 0
|
benchmark_functions_edited/f6232.py
|
def f(k, size):
if k < 0: k += size
if not 0 <= k < size:
raise KeyError('Index out of bound!')
return k
assert f(-2, 10) == 8
|
benchmark_functions_edited/f9195.py
|
def f(year):
year = int(year)
if(year%400) ==0:
leap=1
elif (year%100) == 0:
leap = 0
elif (year%4) == 0:
leap = 1
else:
leap = 0
return leap
assert f(2017) == 0
|
benchmark_functions_edited/f13504.py
|
def f(spd: int, lph: float) -> float:
if spd <= 0 or lph <= 0:
return float(0)
return (lph / spd) * 100
assert f(100, 0) == 0
|
benchmark_functions_edited/f11023.py
|
def f(obj):
fp = obj[u'fingerprints']
print("sqlifingerprints = {")
for f in fp:
print(' ["{0}"]=true,'.format(f))
print("}")
return 0
assert f(
{u'fingerprints': [u'b']}
) == 0
|
benchmark_functions_edited/f12943.py
|
def f(k, n):
count = 0
for i in range(n + 1):
# treat number as string
# count digit character in the string
count += str(i).count(str(k))
return count
assert f(5, 5) == 1
|
benchmark_functions_edited/f7503.py
|
def f(function, *args):
return function(*args)
assert f(lambda a: a, 1) == 1
|
benchmark_functions_edited/f8248.py
|
def f(number: int) -> int:
while number > 10:
number = sum(map(int, str(number)))
return number
assert f(16) == 7
|
benchmark_functions_edited/f5781.py
|
def f(info, inner, *args, **kw):
__traceback_info__ = info
return inner(*args, **kw)
assert f("", pass_through, "", lambda a: a, 1) == 1
|
benchmark_functions_edited/f9674.py
|
def f(n: int):
if n < 0:
return 1
if n == 0:
return 0
return ((2 * n - 2) * 3) + f(n - 2)
assert f(-1) == 1
|
benchmark_functions_edited/f2612.py
|
def f(n):
if (n == 0):
return 1
if (n == -1):
return 1
if (n == 1):
return 1
return n * f(n-2)
assert f(2) == 2
|
benchmark_functions_edited/f14107.py
|
def f(A, B):
if len(A) == len(B):
return len([i for i in range(len(A)) if A[i] == B[i]])
return None
assert f(
"ATCGATCG",
"ATCGATCG"
) == 8
|
benchmark_functions_edited/f2293.py
|
def f(domain1, domain2):
return abs(domain1[1] - domain2[1])
assert f(
(1, 1),
(1, 1)
) == 0
|
benchmark_functions_edited/f12304.py
|
def f(pauli):
def _wt(p):
return p.count('X') + p.count('Y') + p.count('Z')
if isinstance(pauli, str):
return _wt(pauli)
else:
return sum(_wt(p) for p in pauli)
assert f(['X', 'Y', 'Z']) == 3
|
benchmark_functions_edited/f10378.py
|
def f(predictions_dict):
tokens_iter = enumerate(predictions_dict["predicted_tokens"])
return next(((i + 1) for i, _ in tokens_iter if _ == "</s>"),
len(predictions_dict["predicted_tokens"]))
assert f(
{"predicted_tokens": ["</s>", "c", "t", "a", "t", "i", "v", "e", "</s>"]}
) == 1
|
benchmark_functions_edited/f2053.py
|
def f(deg):
return (((deg + 180.) % 360.) - 180.)
assert f(-360) == 0
|
benchmark_functions_edited/f11087.py
|
def f(time, velocity):
meters = velocity * time
distance = meters * 1000
return(distance)
assert f(0, 1) == 0
|
benchmark_functions_edited/f6641.py
|
def f(n):
return int(3 * n**(1/3.0))
assert f(5) == 5
|
benchmark_functions_edited/f415.py
|
def f(x, y, w):
fin_out = (y - x) * w + x
return fin_out
assert f(-1, 1, 1) == 1
|
benchmark_functions_edited/f6672.py
|
def f(x):
if x == 0:
return 0
elif x == 1:
return 1
else:
return f(x-1) + f(x-2)
assert f(4) == 3
|
benchmark_functions_edited/f3607.py
|
def f(array, i, j):
if i == j:
return i
k = f(array, i+1, j)
return i if array[i] < array[k] else k
assert f(list(range(20)), 9, 19) == 9
|
benchmark_functions_edited/f10845.py
|
def f(value):
o = int(value)
if o == 0:
return 0
a = abs(o)
s = a*36+(a%100)*24
return (o//a)*s
assert f('-0000000') == 0
|
benchmark_functions_edited/f9601.py
|
def f(s):
digits = []
for char in s:
try:
digits.append(int(char))
except ValueError:
pass
return sum(digits)
assert f('34') == 7
|
benchmark_functions_edited/f2520.py
|
def f(x):
if x == 0 or x == 1: # NB: we need to base cases
return 1
else:
return f(x-1) + f(x-2)
assert f(5) == 8
|
benchmark_functions_edited/f223.py
|
def f(n):
for i in range(n - 1, 0, -1): n *= i
return n
assert f(3) == 6
|
benchmark_functions_edited/f13066.py
|
def f(dim, dim_per_gp=-1, num_groups=32):
assert dim_per_gp == -1 or num_groups == -1, \
'GroupNorm: can only specify G or C/G.'
if dim_per_gp > 0:
assert dim % dim_per_gp == 0
group_gn = dim // dim_per_gp
else:
assert dim % num_groups == 0
group_gn = num_groups
return group_gn
assert f(64, -1, 8) == 8
|
benchmark_functions_edited/f5261.py
|
def f(deg, order):
# The -1 here is because we typically exclude the degree=0 term
return deg * deg + deg + order - 1
assert f(1, 0) == 1
|
benchmark_functions_edited/f10632.py
|
def f(val: int, set_flag: int, clear_flag: int):
return (val & ~clear_flag) | set_flag
assert f(0, 1, 0) == 1
|
benchmark_functions_edited/f8421.py
|
def f(article):
numberOfWords = 0
heading = article[0].split()
for word in heading:
if word in article[1]:
numberOfWords += 1
return numberOfWords / len(heading)
assert f(
["The quick brown fox jumps over lazy dog",
"The quick brown fox jumps over lazy dog"],
) == 1
|
benchmark_functions_edited/f286.py
|
def f(x, y=3):
z = x + y
return z
assert f(**{'x': 3}) == 6
|
benchmark_functions_edited/f2677.py
|
def f(a,b):
if (b==0):
return a
else:
return(f(b,a % b))
assert f(1, 2) == 1
|
benchmark_functions_edited/f13362.py
|
def f(view, kwargs):
line = kwargs.get('line')
if line is None:
point = kwargs.get('point')
if point is None:
selection = view.sel()
if not selection:
return
point = selection[0].end()
# get line number from text point
line = view.rowcol(point)[0]
return line
assert f(None, {'line': 0}) == 0
|
benchmark_functions_edited/f4304.py
|
def f(ant1, ant2, shift=16):
return (ant1 << shift) | ant2
assert f(0, 0) == 0
|
benchmark_functions_edited/f6954.py
|
def f(n: int) -> int:
digits = 0
while n > 0:
n = n // 10
digits += 1
return digits
assert f(123456789) == 9
|
benchmark_functions_edited/f12479.py
|
def f(length: int, block_size: int, ceil: bool = True) -> int:
remainder = length % block_size
if ceil:
return (block_size - remainder) * int(remainder != 0) + length
else:
return length - remainder
assert f(2, 3) == 3
|
benchmark_functions_edited/f4676.py
|
def f(cp, cp0):
if cp == None: return cp0
else: return cp
assert f(1, 2) == 1
|
benchmark_functions_edited/f9263.py
|
def f(f, xs):
return max(xs, key=f)
assert f(lambda x: x, [0, 0]) == 0
|
benchmark_functions_edited/f5670.py
|
def f(ticks, BPM, resolution):
#return ticks2ms(ticks, BPM, resolution) / 1000. ## ===
#return (60. / BPM)/resolution ## ===
return ticks * 60. / (BPM * resolution)
assert f(0, 150, 4) == 0
|
benchmark_functions_edited/f8274.py
|
def f(simulation_time):
day = None
if simulation_time >= 0.0:
day = int((simulation_time + 0.00001) // 86400) + 1
return day
assert f(1.0) == 1
|
benchmark_functions_edited/f2693.py
|
def f(a1, a2, ctx=None):
if a2 == 0:
return float(f"{'-' if a1 < 0 else ''}Infinity")
return a1 / a2
assert f(4, 2) == 2
|
benchmark_functions_edited/f14268.py
|
def f(x, y, x0, y0, a, b):
return (x-x0)**2 / a**2 + (y-y0)**2 / b**2
assert f(0, 0, 0, 0, 3, 4) == 0
|
benchmark_functions_edited/f4039.py
|
def f(overall_paths):
cnt = 0
for path in overall_paths:
if not path:
cnt+=1
return cnt
assert f(
[
["", "", "", "", ""],
["", "", "", "", ""],
["", "", "", "", ""],
["", "", "", "", ""],
["", "", "", "", ""],
]
) == 0
|
benchmark_functions_edited/f3490.py
|
def f(seq):
f = lambda number: number != None
for item in seq:
if f(item):
return item
assert f((1, 2, 3)) == 1
|
benchmark_functions_edited/f13073.py
|
def f(count):
l = count
depth = 0
l = l>> 1
while l != 0:
depth = depth + 1
l = l>> 1
#more than one 1s in the binary representation
if( (count & (count -1)) != 0):
depth = depth + 1
return depth
assert f(23) == 5
|
benchmark_functions_edited/f13818.py
|
def f(schedule):
Cj = 0
tardiness = 0
for job in schedule:
Cj += job.processing
Tj = max(0, job.due - Cj)
tardiness += Tj
return tardiness
assert f([]) == 0
|
benchmark_functions_edited/f13506.py
|
def f(
gt_begin: float,
gt_end: float,
pred_begin: float,
pred_end: float
) -> float:
return max(min(gt_end, pred_end) - max(gt_begin, pred_begin), 0)
assert f(1, 2, 2, 3) == 0
|
benchmark_functions_edited/f2316.py
|
def f(time_str):
h, m, s = time_str.split(':')
return int(h) * 3600 + int(m) * 60 + float(s)
assert f('00:00:01') == 1
|
benchmark_functions_edited/f13865.py
|
def f(list1, list2):
for i in range(min(len(list1), len(list2)), 0, -1):
if list1[-i:] == list2[-i:]:
return i
return 0
assert f(
'test', 'toast'
) == 2
|
benchmark_functions_edited/f9882.py
|
def f(a, l):
return next((i for i, elem in enumerate(l) if elem == a), -1)
assert f(2, [1, 2, 3]) == 1
|
benchmark_functions_edited/f12791.py
|
def f(buckets):
m = 1
for k,v in buckets.items():
m = max(m, len(v))
return m
assert f(
{'a': [1, 2, 3, 4], 'b': [1, 2, 3], 'c': [1, 2, 3, 4, 5]}) == 5
|
benchmark_functions_edited/f7465.py
|
def f(estimate, real):
error = (estimate - real) / real
return error
assert f(100000000, 100000000) == 0
|
benchmark_functions_edited/f12358.py
|
def f(step):
if step < 0:
return 0
elif step == 0:
return 1
return f(step - 3) + \
f(step - 2) + \
f(step - 1)
assert f(2) == 2
|
benchmark_functions_edited/f715.py
|
def f(S, K):
return max(K-S, 0)
assert f(5, 10) == 5
|
benchmark_functions_edited/f3147.py
|
def f(n):
if n == 0:
result = 1
else:
result = n * f(n-1)
return result
assert f(1) == 1
|
benchmark_functions_edited/f9568.py
|
def sigma_k (n, k):
n = abs (n)
sum = n**k
for d in range (1, 1 + (n // 2)):
if n % d == 0:
sum = sum + d**k
return sum
assert f(1, 0) == 1
|
benchmark_functions_edited/f13417.py
|
def f(contact_rating_id: int, type_id: int) -> int:
if contact_rating_id > 0:
return contact_rating_id
return {1: 2, 2: 4, 3: 2, 4: 1, 5: 2, 6: 2}[type_id]
assert f(1, 1) == 1
|
benchmark_functions_edited/f885.py
|
def f(p1, p2):
return p1[0] * p2[0] + p1[1] * p2[1] + p1[2] * p2[2]
assert f((1, 1, 1), (1, 1, 0)) == 2
|
benchmark_functions_edited/f4775.py
|
def f(l,f=None):
if f:
l = [f(i) for i in l]
return max(enumerate(l), key=lambda x:x[1])[0]
assert f([1,3,2]) == 1
|
benchmark_functions_edited/f8702.py
|
def f(index, size):
if index < 0:
index = size + index
if index < 0:
raise ValueError("index is out of range")
if index >= size:
raise ValueError("index is out of range")
return index
assert f(1, 4) == 1
|
benchmark_functions_edited/f6829.py
|
def f(argdict, name, defaultvalue):
if not name in argdict or argdict[name] is None:
argdict[name] = defaultvalue
return argdict[name]
assert f({'a': 5}, 'a', 3) == 5
|
benchmark_functions_edited/f7957.py
|
def f(in_size, kernel_size, padding, stride):
out_size = (in_size - kernel_size + (2 * padding)) // stride
out_size += 1
return out_size
assert f(4, 1, 0, 1) == 4
|
benchmark_functions_edited/f3254.py
|
def f(function, *args, **kwargs):
return function(*args, **kwargs)
assert f(lambda: 5) == 5
|
benchmark_functions_edited/f13584.py
|
def f(x):
# Given in the problem
min = x[0]
l = len(x)
for i in range(l):
for j in range(i+1,l):
if x[i]<x[j] and x[i]<min:
min = x[i]
return min
assert f( [305, 862, 719, 964, 346, 761, 5, 13, 562, 854]) == 5
|
benchmark_functions_edited/f5481.py
|
def f(kind: int):
if kind == 0:
return 1
elif kind == 1:
return 2
elif kind == 2:
return 4
elif kind == 3:
return 4
elif kind == 4:
return 3
assert f(2) == 4
|
benchmark_functions_edited/f7946.py
|
def f(line, ch):
i, n = 0, len(line)
while i < n and line[i] == ch:
i += 1
return i
assert f( '\n\n\nabc', 'b' ) == 0
|
benchmark_functions_edited/f711.py
|
def f(val):
return val * 360. / 2**16
assert f(0) == 0
|
benchmark_functions_edited/f13885.py
|
def f(startBases, endBases):
motif = (startBases + endBases).upper()
if motif == "GTAG":
return 1
elif motif == "CTAC":
return 2
elif motif == "GCAG":
return 3
elif motif == "CTGC":
return 4
elif motif == "ATAC":
return 5
elif motif == "GTAT":
return 6
else:
return 0
assert f( "CT", "TC" ) == 0
|
benchmark_functions_edited/f892.py
|
def f(m: int, n: int) -> int:
while n:
m, n = n, m % n
return m
assert f(2, 4) == 2
|
benchmark_functions_edited/f9093.py
|
def f(interp, *args):
return interp(*args)
assert f(lambda x, y: x + y, 1, 0) == 1
|
benchmark_functions_edited/f9081.py
|
def f(Text, Pattern):
Text = str(Text)
Pattern = str(Pattern)
count = 0
for i in range(len(Text) - len(Pattern) + 1):
if Text.find(Pattern, i, i + len(Pattern)) != -1:
count = count + 1
return count
assert f('aba', 'a') == 2
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.