file_name
stringlengths 32
36
| content
stringlengths 44
898
|
|---|---|
benchmark_functions_edited/f6707.py
|
def f(num1: int, num2: int) -> int:
while num1 % num2 != 0:
old_num1 = num1
old_num2 = num2
num1 = old_num2
num2 = old_num1 % old_num2
return num2
assert f(20, 12) == 4
|
benchmark_functions_edited/f7087.py
|
def f(seq1, seq2):
res = 0
for i1 in range(len(seq1)):
i2 = seq2.index(seq1[i1])
res += abs(i1 - i2)
return res / 2
assert f(b"123", b"132") == 1
|
benchmark_functions_edited/f9585.py
|
def f(uuids, step=4, maxlen=32):
full = set(uuids)
for n in range(step, maxlen, step):
prefixes = {u[:n] for u in uuids}
if len(prefixes) == len(full):
return n
return maxlen
assert f({"0123456789abcdef0123456789abcdef01"}) == 4
|
benchmark_functions_edited/f3230.py
|
def f(nsp_src, nsp_win, len_hop):
return (nsp_src - (nsp_win - len_hop)) // len_hop
assert f(10, 10, 1) == 1
|
benchmark_functions_edited/f2800.py
|
def f(l):
if len(l) == 0:
return 1
else:
return l[0] * f(l[1:])
assert f([2, 2, 2]) == 8
|
benchmark_functions_edited/f1897.py
|
def f(node, default=0):
return getattr(node, 'lineno', default)
assert f(1) == 0
|
benchmark_functions_edited/f5771.py
|
def f(point1, point2):
return (point1[0] - point2[0]) ** 2 + (point1[1] - point2[1]) ** 2
assert f( (0,0), (1,1) ) == 2
|
benchmark_functions_edited/f12644.py
|
def f(slots):
index = 0
for i in list(zip(*list(slots.values())[::])):
if sum([1 for j in list(i) if j]) == 0:
return index
index += 1
return 6
assert f(
{'1a': [0, 0, 1, 0, 0], '1b': [0, 0, 1, 0, 0],
'2a': [0, 0, 1, 0, 0], '2b': [0, 0, 1, 0, 0],
'3a': [0, 0, 1, 0, 0], '3b': [0, 0, 1, 0, 0],
'4a': [0, 0, 1, 0, 0], '4b': [0, 0, 1, 0, 0],
'5a': [0, 0, 1, 0, 0], '5b': [0, 0, 1, 0, 0]}
) == 0
|
benchmark_functions_edited/f3692.py
|
def f(cls, val, default):
try:
val = cls(val)
except Exception:
val = default
return val
assert f(int, '1', 2.0) == 1
|
benchmark_functions_edited/f5663.py
|
def f(values) -> int:
values = values[::-1]
total = 0
for i in range(len(values)):
total += values[i]*2**i
return total
assert f([0, 0, 0]) == 0
|
benchmark_functions_edited/f10354.py
|
def f(marked_locations):
counter = 0
for row in marked_locations:
for point, is_lowest, _ in row:
if is_lowest:
counter += 1 + point
return counter
assert f(
[[(0, 0, False), (1, 1, False)],
[(1, 0, False), (0, 1, False)]]) == 3
|
benchmark_functions_edited/f7702.py
|
def f(a, b):
while b:
a, b = b, (a % b)
return a
assert f(1, 1) == 1
|
benchmark_functions_edited/f3040.py
|
def product (*args):
tot = 1
for num in args:
tot *= num
return tot
assert f(1, 2, 3) == 6
|
benchmark_functions_edited/f5648.py
|
def f(new_type, value, default=None):
try:
default = new_type(value)
finally:
return default
assert f(int, 'a', 1) == 1
|
benchmark_functions_edited/f12900.py
|
def f(n: float, r: float, s: float) -> int:
lst = [n, r, s]
maximum = max(lst)
max_index = lst.index(maximum)
return [0, 1, 2][max_index]
assert f(0.0, 0.0, 0.0) == 0
|
benchmark_functions_edited/f12602.py
|
def f(*args):
if args[2]==0:
return args[0]
else:
return (args[1]/args[2])
assert f(1, 0, 5) == 0
|
benchmark_functions_edited/f11647.py
|
def f(config):
out = 0
for bit in config:
out = (out << 1) | (bit > 0)
return out
assert f((1, 0, 0, 0)) == 8
|
benchmark_functions_edited/f2820.py
|
def f(job):
return 1 if job['jobstatus'] in ('finished', 'failed', 'cancelled', 'closed') else 0
assert f({'jobstatus': 'anythingelse'}) == 0
|
benchmark_functions_edited/f7227.py
|
def f(kargs):
func=kargs['func']
del kargs['func']
out=func(**kargs)
return out
assert f(
{'func': lambda x,y: x+y, 'x': 2, 'y': -1}) == 1
|
benchmark_functions_edited/f7279.py
|
def f(lst):
mins = dict()
for j in range(len(lst)):
mins[j] = min(lst[j])
for j in mins:
if mins[j] == max([mins[key] for key in mins]):
return j
assert f( [[2, 3, 4], [1, 5, 6], [7, 8, 9]] ) == 2
|
benchmark_functions_edited/f9406.py
|
def f(host_port, cluster_spec):
index = 0
for entry in cluster_spec["cluster"]["worker"]:
if entry == host_port:
return index
else:
index = index + 1
return -1
assert f(
"1.1.1.1:8080",
{
"cluster": {
"worker": [
"1.1.1.1:8080",
"1.1.1.2:8080",
"1.1.1.3:8080",
"1.1.1.4:8080",
]
}
}
) == 0
|
benchmark_functions_edited/f10250.py
|
def f(TP, POP):
try:
length = POP
return (length - sum(TP.values()))
except Exception:
return "None"
assert f(dict(zip(['a', 'b', 'c'], [0, 0, 1])), 3) == 2
|
benchmark_functions_edited/f2071.py
|
def f(x):
if x == 360:
return 360
else:
return x % 360
assert f(-360) == 0
|
benchmark_functions_edited/f2435.py
|
def f(data):
if data >= 0 :
return 1
else :
return 0
assert f(-1000000) == 0
|
benchmark_functions_edited/f6450.py
|
def f(guess, bad):
if bad==1:
return 3 if guess==2 else 2
if bad==2:
return 1 if guess==3 else 3
if bad==3:
return 2 if guess==1 else 1
assert f(1, 2) == 3
|
benchmark_functions_edited/f14271.py
|
def f(num_in, x, direction="up"):
if direction == "down":
num_out = int(num_in) - int(num_in) % int(x)
else:
num_out = num_in + (x - num_in) % int(x)
return num_out
assert f(9, 3) == 9
|
benchmark_functions_edited/f7083.py
|
def f(x):
# Example
distribution = [0, 2000, 4000, 6000, 8000, 10000]
x_class = 0
for i in range(len(distribution)):
if x > distribution[i]:
x_class += 1
return x_class
assert f(2000) == 1
|
benchmark_functions_edited/f5792.py
|
def f(al, br, delta):
if br < al:
ch = 18446744073709551615 - al
return (ch + br) / float(delta)
return (br - al) / float(delta)
assert f(10, 10, 3) == 0
|
benchmark_functions_edited/f758.py
|
def f(x):
i = int(x)
return i if x == i else x
assert f(False) == 0
|
benchmark_functions_edited/f1306.py
|
def f(list, position):
return list[int(position)]
assert f(list(range(10)), 9) == 9
|
benchmark_functions_edited/f6708.py
|
def f(list_of_integers):
if list_of_integers:
list_of_integers.sort()
return list_of_integers[-1]
else:
return None
assert f([1, 2]) == 2
|
benchmark_functions_edited/f12635.py
|
def f(i, j, k):
assert i>=0 and i<3, "Index i goes from 0 to 2 included"
assert j>=0 and j<3, "Index j goes from 0 to 2 included"
assert k>=0 and k<3, "Index k goes from 0 to 2 included"
if (i, j, k) in [(0, 1, 2), (1, 2, 0), (2, 0, 1)]:
return +1
if (i, j, k) in [(2, 1, 0), (0, 2, 1), (1, 0, 2)]:
return -1
return 0
assert f(2, 2, 2) == 0
|
benchmark_functions_edited/f12016.py
|
def f(key: int, cipher: int, rest: int):
base = (key-rest) // cipher
return base
assert f(10, 4, 2) == 2
|
benchmark_functions_edited/f3811.py
|
def f(ref_label, test_label):
return int(ref_label in test_label or test_label in ref_label)
assert f("ab", "abc") == 1
|
benchmark_functions_edited/f4839.py
|
def f(wins: int, losses: int, ties: int) -> int:
return (wins * 1) + (losses * -1) + (ties * 0)
assert f(10, 1, 1) == 9
|
benchmark_functions_edited/f7485.py
|
def f(data):
chat_id = data['message']['chat']['id']
if not isinstance(chat_id, int):
raise TypeError('Please chat_id must be an integer')
return chat_id
assert f(
{'message': {
'chat': {
'id': 0
}
}}) == 0
|
benchmark_functions_edited/f6399.py
|
def f(rand, jitter, n):
if jitter <= 0.001:
return n
v = n - int(n * rand.uniform(0, jitter))
if v:
return v
else:
return 1
assert f(0, -0.1, 2) == 2
|
benchmark_functions_edited/f1379.py
|
def f(a, b):
return max(0, min(a[1], b[1]) - max(a[0], b[0]))
assert f( (1, 5), (8, 8) ) == 0
|
benchmark_functions_edited/f5965.py
|
def f(time_raw):
offset = 719529 # offset between 1970-1-1 und 0000-1-1
time = (time_raw - offset) * 86400
return time
assert f(719529) == 0
|
benchmark_functions_edited/f6321.py
|
def f(dout, cache):
x = cache
return x * (x - 1) * dout
assert f(1, 1) == 0
|
benchmark_functions_edited/f10574.py
|
def f(words):
if words[3] == 'class':
end = 5
if words[5] == 'method':
end = 7
elif words[3] == 'function':
end = 5
else: # if words == 'module':
end = 6
return end
assert f(
['module','module.py','module','module']) == 6
|
benchmark_functions_edited/f12241.py
|
def f(spreading, drying):
return (drying-spreading) / (drying+spreading)
assert f(0,1) == 1
|
benchmark_functions_edited/f321.py
|
def f(x: int) -> int:
return int(x>=0)+1
assert f(4) == 2
|
benchmark_functions_edited/f5212.py
|
def f(root):
if not root:
return 0
return 1 + max(f(root.left), f(root.right))
assert f(None) == 0
|
benchmark_functions_edited/f3083.py
|
def f(width):
return int((width + 32 - width % 32 if (width % 32) > 0 else width) / 8)
assert f(31) == 4
|
benchmark_functions_edited/f8509.py
|
def f(a):
n = len(a)
flag = [False]*n
for x in a:
if x < 1 or x > n:
continue
flag[x-1] = True
for i, f in enumerate(flag):
if not f:
return i+1
assert f(
[0, 1, 2, 3, 4, 5]) == 6
|
benchmark_functions_edited/f992.py
|
def f(x,alpha=0.0):
return 3*x**2
assert f(0) == 0
|
benchmark_functions_edited/f13132.py
|
def f(num, div, prec=2):
num = float(num)
div = float(div)
if div == 0:
return 0.0 # no division by zero
p = round(100 * num / div, prec)
return p
assert f(-1, -100) == 1
|
benchmark_functions_edited/f9879.py
|
def f(b):
i = int(b)
if i < 0:
i = 0
elif i > 255:
i = 255
return i
assert f(1.5) == 1
|
benchmark_functions_edited/f5167.py
|
def f(array: list):
maxValue = array[0]
for number in array[1:]:
if number > maxValue:
maxValue = number
return maxValue
assert f([0, 1, 2, 3, 4, 5]) == 5
|
benchmark_functions_edited/f1146.py
|
def f(arg1, arg2, arg3):
return arg1 + arg2 + arg3
assert f(1, 2, 3) == 6
|
benchmark_functions_edited/f9248.py
|
def f(n):
if n == 0:
res = 0
elif n == 1:
res = 1
else:
res = f(n - 1) + f(n - 2)
return res
assert f(3) == 2
|
benchmark_functions_edited/f364.py
|
def f(line):
_, t = line
return t
assert f((1, 0)) == 0
|
benchmark_functions_edited/f10165.py
|
def f(r, success_msg=''):
if r[0]:
s1 = '\n'.join(r[1])
s2 = '\n'.join(r[2])
if s1 or s2:
print('%s' % '\n'.join([s1, 'Error:', s2]))
elif success_msg:
print('%s' % success_msg)
return r[0]
assert f(
(0, [''], [''])
) == 0
|
benchmark_functions_edited/f11563.py
|
def f(x:float, a:float, b:float, c:float):
t1 = (x - a) / (b - a)
t2 = (c - x) / (c - b)
if (a == b) and (b == c):
return float(x == a)
if (a == b):
return (t2 * float(b <= x) * float(x <= c))
if (b == c):
return (t1 * float(a <= x) * float(x <= b))
return max(min(t1, t2), 0)
assert f(-1, 0, 2, 1) == 0
|
benchmark_functions_edited/f11493.py
|
def f(url_to_test):
if not isinstance(url_to_test, str):
return 103
url = str(url_to_test).strip()
if not url:
return 101
if ' ' in url:
return 102
return 0
assert f('http://test.com') == 0
|
benchmark_functions_edited/f11298.py
|
def f(df, dfd, dfdd, times):
f_delays = df * times
fd_delays = dfd * times**2 / 2.0
fdd_delays = dfdd * times**3 / 6.0
return (f_delays + fd_delays + fdd_delays)
assert f(0, 0, 0, 0) == 0
|
benchmark_functions_edited/f10546.py
|
def f(num):
assert -128 <= num <= 127, 'Value out of range (-128 - 127)!'
ret = num if num >= 0 else (256 + num)
return ret
assert f(1) == 1
|
benchmark_functions_edited/f3999.py
|
def f(x, y, z=1):
return x * y / z
assert f(2, 1) == 2
|
benchmark_functions_edited/f5639.py
|
def f(mapping, key, value):
if key not in mapping:
mapping[key] = value
elif isinstance(value, list):
mapping[key] += value
return mapping[key]
assert f(dict(), 1, 2) == 2
|
benchmark_functions_edited/f8774.py
|
def f(src, lineno):
assert lineno >= 1
pos = 0
for _ in range(lineno - 1):
pos = src.find('\n', pos) + 1
return pos
assert f(
"aaa\nbb\nc",
1,
) == 0
|
benchmark_functions_edited/f5378.py
|
def f(b: bytes) -> int:
return int.from_bytes(b, 'little')
assert f(bytes([1, 0, 0])) == 1
|
benchmark_functions_edited/f632.py
|
def f(i, j):
return 1 if i == j else 0
assert f(6, 2) == 0
|
benchmark_functions_edited/f13561.py
|
def f(text, character=None, target=None):
count = 0
qcount = 0
for c in text:
if c == "?":
qcount = qcount + 1
if c == target:
return count
if c not in ("?", "*", character):
return count - qcount
count = count + 1
return count
assert f(r"Hello*?", "*") == 0
|
benchmark_functions_edited/f1099.py
|
def f(num: str):
return int(num) - 1
assert f(6) == 5
|
benchmark_functions_edited/f12184.py
|
def f(n):
total = 0
while n > 0:
total += (n % 10)
n //= 10
return total
assert f(0) == 0
|
benchmark_functions_edited/f8834.py
|
def f(
dimensionality: float, num_points: int, num_samples: int
) -> float:
return (num_points / float(num_samples)) ** (1.0 / dimensionality)
assert f(3, 1, 1) == 1
|
benchmark_functions_edited/f5618.py
|
def f(key, argdict):
try:
return argdict[key]
except KeyError:
return 0
assert f(0, {1:0,2:0}) == 0
|
benchmark_functions_edited/f3360.py
|
def f(values):
try:
return float(sum(values) / len(values))
except ZeroDivisionError:
return 0
assert f(range(1, 6)) == 3
|
benchmark_functions_edited/f14318.py
|
def f(num,a,i1,i2):
if num>a[i2-1]:
return i2-i1+1
elif num<a[i1-1]:
return 0
hi=i2-1; lo=i1-1
mid = int((lo+hi)/2)
while hi>lo:
if num==a[mid] or hi-lo<=1:
return mid+1-i1+1
elif num>a[mid]:
lo=mid
else:
hi=mid
mid = int((lo+hi)/2)
return lo+1-i1+1
assert f(0, [1, 1, 1, 1, 1], 1, 5) == 0
|
benchmark_functions_edited/f10683.py
|
def f(a, b):
if a < b:
a = a + b
b = a - b
a = a - b
if b == 0:
return a
while a % b != 0:
a = a + b
b = a - b
a = a - b
b = b % a
return b
assert f(2, 4) == 2
|
benchmark_functions_edited/f13051.py
|
def f(angle_a: float, angle_b: float) -> float:
delta_mod = (angle_b - angle_a) % 360
if delta_mod > 180:
delta_mod -= 360
return delta_mod
assert f(360, 0) == 0
|
benchmark_functions_edited/f10533.py
|
def f(x, a, b):
return a * x + b
assert f(2, 1, 1) == 3
|
benchmark_functions_edited/f13965.py
|
def f(dic, key):
key = key.strip("[]'").replace("']['", '#').split('#')
key_val = dic
for elem in key:
key_val = key_val[elem]
return key_val
assert f(
{'a': {'b': 1, 'c': 2}, 'd': {'e': {'f': 3}}},
'a#c'
) == 2
|
benchmark_functions_edited/f221.py
|
def f(n: int) -> int:
return 2*n - 1
assert f(4) == 7
|
benchmark_functions_edited/f7101.py
|
def f(text: str, char_to_count: str) -> int:
count = 0
for char in text:
if char == char_to_count:
count += 1
return count
assert f("hello", "x") == 0
|
benchmark_functions_edited/f9334.py
|
def f(a, b):
q_start = int(a[0])
q_end = int(a[1])
r_start = int(b[0])
r_end = int(b[1])
if q_start == q_end:
q_end += 1 # otherwise it doesnt work for SNPs
ret = max(0, min(q_end, r_end) - max(q_start, r_start))
return(ret)
assert f(
(10, 20),
(30, 40)) == 0
|
benchmark_functions_edited/f9132.py
|
def f(n_classes, queue):
if n_classes is not None:
return int(n_classes)
else:
with queue.get_random_study() as ss:
return ss.n_classes
assert f(9, None) == 9
|
benchmark_functions_edited/f5108.py
|
def f(start, end):
diff = (end - start) * 1000
print('{:.2f} milliseconds elapsed'.format(diff))
return diff
assert f(0, 0) == 0
|
benchmark_functions_edited/f9175.py
|
def f(ckpt):
assert type(ckpt) == str, ckpt
try:
i = int(ckpt.split('_')[-1].split('.')[0])
except:
print('unknown checkpoint string format %s setting iteration to 0' % ckpt)
i = 0
return i
assert f('ckpt-123456789.pkl') == 0
|
benchmark_functions_edited/f8240.py
|
def f(prio):
return { 'urgmust': 1,
'must' : 2,
'high' : 3,
'medium' : 4,
'low' : 5 }.get(prio, 5)
assert f( 'urgmust' ) == 1
|
benchmark_functions_edited/f11311.py
|
def f(start, end, alpha):
return (start + alpha * (end - start))
assert f(0, 1, 0) == 0
|
benchmark_functions_edited/f534.py
|
def f(value):
return int(value + 0.5)
assert f(0) == 0
|
benchmark_functions_edited/f11822.py
|
def f(n, i=0, a=0, b=1):
if not n >= 0:
raise ValueError("n must be >= 0")
if i < n:
return f(n, i+1, b, a+b)
return a
assert f(3) == 2
|
benchmark_functions_edited/f9184.py
|
def f(fget, fset, fdel, apply_func, value_not_found=None):
for f in filter(None, (fget, fset, fdel)):
result = apply_func(f)
if result:
return result
return value_not_found
assert f(lambda: [], lambda: 1, lambda: [], lambda f: f()) == 1
|
benchmark_functions_edited/f11271.py
|
def f(sA, sB):
if len(sA) != len(sB):
raise ValueError('Sequences must be of equal length to compute hamming distance')
return sum(ele1 != ele2 for ele1, ele2 in zip(sA, sB))
assert f('GGGCCGTTGGT', 'GGACCGTTGAC') == 3
|
benchmark_functions_edited/f1274.py
|
def f(review_str)->int:
return len(review_str.split())
assert f('Hello world!') == 2
|
benchmark_functions_edited/f4049.py
|
def f(filename="", text=""):
with open(filename, 'w', encoding='utf-8') as myFile:
return myFile.write(text)
assert f(
"testing.txt",
" "
) == 3
|
benchmark_functions_edited/f12387.py
|
def f(list1, list2, nr1, nr2, maxcount=3):
i = 0
len1 = len(list1)
len2 = len(list2)
while nr1 < len1 and nr2 < len2 and list1[nr1] == list2[nr2]:
nr1 += 1
nr2 += 1
i += 1
if i >= maxcount and maxcount>0: break
return i
assert f( ["a","b","c","d"],
["a","b","c","e"],
0,
3,
0,
) == 0
|
benchmark_functions_edited/f5762.py
|
def f(s):
s_lower = s.lower()
return \
s_lower.startswith('ldap://') or \
s_lower.startswith('ldaps://') or \
s_lower.startswith('ldapi://')
assert f('ldaps://ldap.openldap.org:1234/dc=example,dc=com?uid=user;uid=user2;uid=user3') == 1
|
benchmark_functions_edited/f2475.py
|
def f(limit, count):
return int(count / limit) + (limit % count > 0)
assert f(5, 4) == 1
|
benchmark_functions_edited/f1471.py
|
def f(word):
a = ord('A')
return sum([ord(char) - a + 1 for char in word])
assert f(
'A') == 1
|
benchmark_functions_edited/f9792.py
|
def f(value, minimum, maximum):
return (min(max(value, minimum), maximum))
assert f(1, 2, 3) == 2
|
benchmark_functions_edited/f374.py
|
def f(x):
return x.real**2 + x.imag**2
assert f(1-2j) == 5
|
benchmark_functions_edited/f3694.py
|
def f(field: str):
total = 0
for f in field:
if f == ',':
total += 1
return total
assert f('a,b,c,d,e') == 4
|
benchmark_functions_edited/f6244.py
|
def f(ligne):
ind_courant = 0
for case in ligne:
if case !="":
ind_courant+=1
return ind_courant
assert f(list("aaaa")) == 4
|
benchmark_functions_edited/f10189.py
|
def f(processes: list) -> int:
return sum(process.num_threads() for process in processes)
assert f([]) == 0
|
benchmark_functions_edited/f3561.py
|
def f(x, l, i):
return x % (10 ** (l - i + 1)) // 10 ** (l - i)
assert f(1234567, 7, 3) == 3
|
benchmark_functions_edited/f11580.py
|
def f(i, j, n):
return (n * (n + 1) // 2) - ((n - i) * (n - i + 1) // 2) + (j - i)
assert f(0, 1, 2) == 1
|
benchmark_functions_edited/f6318.py
|
def f(fraction_bound, l, kdax):
return (-(kdax*fraction_bound) - l*fraction_bound + l*fraction_bound*fraction_bound)/(-1 + fraction_bound)
assert f(0.5, -2, 3) == 2
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.