file_name
stringlengths 32
36
| content
stringlengths 44
898
|
|---|---|
benchmark_functions_edited/f13859.py
|
def f(cell_end_marker, next_cell_start,
total, explicit_eoc):
if cell_end_marker < total:
lines_to_next_cell = next_cell_start - cell_end_marker
if explicit_eoc:
lines_to_next_cell -= 1
if next_cell_start >= total:
lines_to_next_cell += 1
return lines_to_next_cell
return 1
assert f(1, 2, 2, True) == 1
|
benchmark_functions_edited/f1654.py
|
def f(n):
if(n==0):
return 1
return 2**f(n-1)
assert f(0) == 1
|
benchmark_functions_edited/f7208.py
|
def f(row, score_cols):
cutoffs = {'is_domain':1, 'mpc':2, 'revel':.375, 'ccr':90}
for col in score_cols:
if row[col] < cutoffs[col]:
return 0
return 1
assert f(
{'mpc': 1,'revel': 1, 'is_domain': 1, 'ccr': 1},
{'mpc': 1,'revel':.2, 'is_domain': 1, 'ccr': 1}
) == 0
|
benchmark_functions_edited/f5273.py
|
def f(hand):
return sum([hand[x] for x in hand])
assert f({"C": 1}) == 1
|
benchmark_functions_edited/f265.py
|
def f(x, y):
return abs(0-x) + abs(0-y)
assert f(1, 6) == 7
|
benchmark_functions_edited/f578.py
|
def f(mask):
rgb_mask = mask
return rgb_mask
assert f(0) == 0
|
benchmark_functions_edited/f3355.py
|
def f(a):
# Special case:
if (a <= 0):
return 0
res = [a,1,a+1,0]
return res[a%4]
assert f(29) == 1
|
benchmark_functions_edited/f5822.py
|
def f(fn, args, kwargs):
try:
return fn(*args, **kwargs)
except TypeError:
return fn(*args)
assert f(lambda a, b: a + b, (1, 2), {'c': 3}) == 3
|
benchmark_functions_edited/f13114.py
|
def f(age, boost_function):
if not boost_function:
return 0
vertex = -1 * boost_function[1] / (2 * boost_function[0])
if age >= vertex:
return 0
else:
max = boost_function[2] - (boost_function[1] * boost_function[1] / (4 * boost_function[0]))
return max - boost_function[0] * age * age - boost_function[1] * age - boost_function[2]
assert f(10, None) == 0
|
benchmark_functions_edited/f12000.py
|
def f(a, x, left=0, right=-1):
n = len(a)
if right < 0:
right += n
while left <= right:
mid = left + (right - left) // 2
if x < a[mid]:
right = mid - 1
else:
left = mid + 1
return left
assert f(
[1, 2, 3, 4, 5], -1) == 0
|
benchmark_functions_edited/f7711.py
|
def f(list_obj):
min = None
best_idx = None
for idx, val in enumerate(list_obj):
if min is None or val < min:
min = val
best_idx = idx
return best_idx
assert f([1, 2, 0]) == 2
|
benchmark_functions_edited/f1441.py
|
def f(word):
return sum(map(str.isalpha, word))
assert f('1234') == 0
|
benchmark_functions_edited/f7339.py
|
def f(number1, number2, number3):
return number1 + number2 + number3
assert f(0, 0, 0) == 0
|
benchmark_functions_edited/f8112.py
|
def f(n, k):
k = min(k, n - k)
if k < 0:
return 0
r = 1
for j in range(k):
r *= n - j
r //= j + 1
return r
assert f(0, 0) == 1
|
benchmark_functions_edited/f692.py
|
def f(value):
new_value = value ** 2
return new_value
assert f(-2) == 4
|
benchmark_functions_edited/f11692.py
|
def f(idx1, idx2):
dist = None
for k in idx1:
for j in idx2:
curdist = abs(k - j)
if dist is None:
dist = curdist
else:
dist = min(dist, curdist)
return dist
assert f( (1, 1), (1, 1) ) == 0
|
benchmark_functions_edited/f5935.py
|
def f(*args):
# Handle the case that a list is provided
if len(args) == 1 and type(args[0]) is list:
return sum(*args[0])
return sum(args)
assert f(1, 2, 3) == 6
|
benchmark_functions_edited/f5197.py
|
def f(V, volume):
return (volume - V)**2/V
assert f(100, 100) == 0
|
benchmark_functions_edited/f13023.py
|
def f(value):
if value <= 0x7f: return 1
if value <= 0x3fff: return 2
if value <= 0x1fffff: return 3
if value <= 0xfffffff: return 4
if value <= 0x7ffffffff: return 5
if value <= 0x3ffffffffff: return 6
if value <= 0x1ffffffffffff: return 7
if value <= 0xffffffffffffff: return 8
if value <= 0x7fffffffffffffff: return 9
return 10
assert f(64) == 1
|
benchmark_functions_edited/f3579.py
|
def f(n: int) -> int:
x = n
y = (x + 1) // 2
while y < x:
x, y = y, (y + n // y) // 2
return x
assert f(31) == 5
|
benchmark_functions_edited/f4320.py
|
def f(x, min_val, max_val):
x_norm = (x - min_val) / (max_val - min_val)
return x_norm
assert f(0, 0, 2) == 0
|
benchmark_functions_edited/f5786.py
|
def f(df, id_global_assignment, num_objects, idfn):
del df, id_global_assignment # unused
return num_objects - idfn
assert f(None, None, 1, 0) == 1
|
benchmark_functions_edited/f3123.py
|
def f(dict_data, key):
if key:
return dict_data.get(key)
assert f(
{"a": 1, "b": 2},
"a"
) == 1
|
benchmark_functions_edited/f10435.py
|
def f(func, partition):
return sum(func(point) * (right - left) for left, right, point in partition)
assert f(lambda x: x, [(0, 1, 0.25), (1, 2, 0.75)]) == 1
|
benchmark_functions_edited/f13391.py
|
def f(g, bare_res, pushed_res):
push = pushed_res - bare_res
delta = g**2 / push
return bare_res - delta
assert f(0, 2, 3) == 2
|
benchmark_functions_edited/f10286.py
|
def f(a, n):
s = a
t = n
u = 1
v = 0
while s > 0:
q = t // s
w = t - q*s
t = s
s = w
w = v - q*u
v = u
u = w
return (v+n) % n
assert f(12, 5) == 3
|
benchmark_functions_edited/f9607.py
|
def f(x):
# print(x)
try:
return x[3]/x[4]
except ZeroDivisionError:
return 0
assert f(
[1, 1, 1, 1, 0]
) == 0
|
benchmark_functions_edited/f10258.py
|
def f(prediction, label):
return 1 if prediction != label else 0
assert f(1, 2) == 1
|
benchmark_functions_edited/f7840.py
|
def f(generator: int, modulus: int) -> int:
for exponent in range(1, modulus):
if pow(generator, exponent) % modulus == 1:
return exponent
return -1
assert f(2, 3) == 2
|
benchmark_functions_edited/f7616.py
|
def f(c: str, d: str) -> int:
if len(c) == 1 and len(d) == 1:
return ord(c) - ord(d)
else:
SyntaxError(f'the inputs need to be char not string: {c}, {d}')
return 0
assert f( 'a', 'a' ) == 0
|
benchmark_functions_edited/f6750.py
|
def f(num):
# Factorial of 0 equals 1
if num == 0 or 1:
return 1
else:
return num*f(num)
assert f(0) == 1
|
benchmark_functions_edited/f1219.py
|
def f(a, b, c=1):
return a * b * c
assert f(1, 2) == 2
|
benchmark_functions_edited/f8109.py
|
def f(a, b):
count = 0
for item in a:
for other in b:
if item == other:
count += 1
return count
assert f(range(10), range(2, 10, 4)) == 2
|
benchmark_functions_edited/f8411.py
|
def f(n):
for i in range(0,15):
N=2**i
if N-i-1>=n: return i
assert f(24) == 5
|
benchmark_functions_edited/f1308.py
|
def f(twa):
if twa < 0.0:
return 1
else:
return 0
assert f(-1) == 1
|
benchmark_functions_edited/f278.py
|
def f(a, b, R):
return a * R + b
assert f(2, 1, 1) == 3
|
benchmark_functions_edited/f1188.py
|
def f(data):
if data:
return min(data)
return None
assert f(range(100)) == 0
|
benchmark_functions_edited/f30.py
|
def f(a, b):
a &= b
return a
assert f(-255, 0) == 0
|
benchmark_functions_edited/f14242.py
|
def f(A, pred):
# invariant: last False lies in [l, r) and A[l] is False
if pred(A[0]):
return 0
l = 0
r = len(A)
while r-l > 1:
m = l + (r-l)//2
result = pred(A[m])
if result:
r = m
else:
l = m
return l+1
assert f(range(10), lambda x: x >= 0) == 0
|
benchmark_functions_edited/f9173.py
|
def f(mat, m, n):
c = 0
j = n-1
i = 0
while i < m and j > -1:
if mat[i][j] == 1:
c = i
j-=1
else:
i+=1
return c
assert f(
[[0, 1, 0],
[1, 0, 0],
[0, 0, 0]],
3,
3
) == 0
|
benchmark_functions_edited/f11912.py
|
def f(file_handle, file_blocks):
return file_handle.write(file_blocks)
assert f(open('test_file', 'w'), 'test') == 4
|
benchmark_functions_edited/f634.py
|
def f(items):
return len(max(items, key=len))
assert f(["a", "bb", "ccc"]) == 3
|
benchmark_functions_edited/f10043.py
|
def f(rows):
maxColumns = 0
for row in rows:
count = float(row.xpath('count(*)').extract()[0])
if count > maxColumns:
maxColumns = count
return int(maxColumns)
assert f([]) == 0
|
benchmark_functions_edited/f8108.py
|
def f(dayinput):
result = dayinput.count('(') - dayinput.count(')')
return result
assert f(
"()()"
) == 0
|
benchmark_functions_edited/f4341.py
|
def f(income):
return int(income/10000)
assert f(20000) == 2
|
benchmark_functions_edited/f2227.py
|
def f(ch_block, be_block):
return min(ch_block[1], be_block[1]) - max(ch_block[0], be_block[0])
assert f( (1, 5), (5, 6) ) == 0
|
benchmark_functions_edited/f156.py
|
def f(List, i):
return List[int(i)]
assert f(range(0, 10), 0) == 0
|
benchmark_functions_edited/f11732.py
|
def f(terms, i):
if terms[i] is None:
return 0
if terms[i].is_constant():
return hash(terms[i])
return i + 1
assert f([None, None, None], 1) == 0
|
benchmark_functions_edited/f12794.py
|
def f(dist_in_interval, min_val, max_val, interval_length):
if dist_in_interval > interval_length:
raise ValueError
if min_val > max_val:
raise ValueError
diff = max_val - min_val
weight = dist_in_interval / interval_length
return min_val + diff * weight
assert f(3, 0, 10, 10) == 3
|
benchmark_functions_edited/f243.py
|
def f(elems):
return elems[-1]
assert f(range(10)) == 9
|
benchmark_functions_edited/f6882.py
|
def f(dic):
m=1
for k in dic.keys():
c=len(dic[k])
if c>m:
m=c
return m
assert f(
{'dog':['NN','NNS','NNP'],
'cat':['NN','NNS','NNP'],
'cow':['NN','NNS','NNP']}) == 3
|
benchmark_functions_edited/f12353.py
|
def f(prices, start, end):
matching_index = start
for i in range(start, end + 1):
if prices[matching_index] < prices[i]:
matching_index = i
return matching_index
assert f(
[10, 7, 4, 3, 2, 1],
1,
1
) == 1
|
benchmark_functions_edited/f14083.py
|
def f(r, rc, rt, sigma_0, alpha=2):
def z(x):
return 1/(1+(x/rc)**2)**(1./alpha)
term1 = (1 - z(rt))**-alpha
term2 = (z(r) - z(rt))**alpha
sigma = sigma_0 * term1 * term2
return sigma
assert f(3, 3, 3, 4) == 0
|
benchmark_functions_edited/f9653.py
|
def f(RGBAquadlet):
r = RGBAquadlet[0] << 24 # Red
g = RGBAquadlet[1] << 16 # Green
b = RGBAquadlet[2] << 8 # Blue
a = RGBAquadlet[3] # Alpha
idOut = r | g | b | a
return(idOut)
assert f( [ 0, 0, 0, 0 ] ) == 0
|
benchmark_functions_edited/f6217.py
|
def f(list, index, substitute):
if list is None:
return substitute
else:
return list[index]
assert f([1, 2, 3], 2, 'a') == 3
|
benchmark_functions_edited/f2961.py
|
def f(values, register):
if register >= 'a' and register <= 'z':
return values[register]
return int(register)
assert f(dict(), '3') == 3
|
benchmark_functions_edited/f9180.py
|
def f(s):
l = len(s)-1
rslt = 0
while l>=0 and s[l] == ' ': # l>=0 should occur first as l=-1 will fail for
# empty string ('')
l-=1
while l>=0 and s[l] != ' ':
rslt +=1
l-=1
return rslt
assert f( "" ) == 0
|
benchmark_functions_edited/f12653.py
|
def f(source):
try:
with open(source, "r", encoding="utf-8") as f:
max = 0
for ligne in f:
if len(ligne) > max:
max = len(ligne)
return max
except IOError:
print("Lecture du fichier", source, "impossible.")
return 0
assert f(
"sources/mon_troisième_fichier.txt") == 0
|
benchmark_functions_edited/f11944.py
|
def f(psmid):
psmid = psmid.split('_')
charge = int(psmid[-2])
return charge
assert f(
'20200323_SII_138765_1_372678_1_1'
) == 1
|
benchmark_functions_edited/f2051.py
|
def f(a, b, N):
if b < a:
tmp = a
a = b
b = tmp
return min(b - a, N - (b - a))
assert f(2, 2, 4) == 0
|
benchmark_functions_edited/f12994.py
|
def f(input_data, field_name, required=False):
if field_name in input_data:
return input_data[field_name]
elif required:
raise Exception('ERROR: Invalid MMTF File, field: {} is missing!'.format(field_name))
else:
return None
assert f({'field': 1}, 'field') == 1
|
benchmark_functions_edited/f6922.py
|
def f(cards_ids):
counter = 0
for card_id in cards_ids:
if card_id is not None:
counter += 1
return counter
assert f([None, None, None]) == 0
|
benchmark_functions_edited/f4703.py
|
def f(i, j, m, n): # calculate `v`
return i*n + j
assert f(0, 0, 3, 4) == 0
|
benchmark_functions_edited/f9645.py
|
def f(x, y):
xsum = x[1]+x[2]
ysum = y[1]+y[2]
if xsum < ysum:
return -1
if xsum > ysum:
return 1
return 0
assert f(
[ "foo", 2, 5 ],
[ "foo", 1, 2 ]
) == 1
|
benchmark_functions_edited/f13049.py
|
def f(hd):
cdelt = None
if str('CDELT1') in hd:
cdelt = hd[str('CDELT1')]
elif str('CD1_1') in hd:
cdelt = hd[str('CD1_1')]
return cdelt
assert f({'CDELT1': 1}) == 1
|
benchmark_functions_edited/f866.py
|
def f(val, n_bits):
return (val >> n_bits) << n_bits
assert f(0b00000000, 3) == 0
|
benchmark_functions_edited/f2844.py
|
def f(num, place): # found this on Stack Overflow, I think
return int(num / 10 ** (place - 1)) % 10
assert f(123, 4) == 0
|
benchmark_functions_edited/f6762.py
|
def f(p1, p2):
distance = 0
for i in range(len(p1)-1):
distance += abs(p1[i]-p2[i])
return distance
assert f(
[1, 2, 3, 4, 5], [1, 2, 3, 4, 5]) == 0
|
benchmark_functions_edited/f2198.py
|
def f(v1, v2):
return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2]
assert f( (1, 0, 0), (0, 1, 0) ) == 0
|
benchmark_functions_edited/f3980.py
|
def f(lvl):
assert isinstance(lvl, int)
if lvl <= 40 and lvl > 0:
return 1
else:
return 0
assert f(7) == 1
|
benchmark_functions_edited/f10769.py
|
def f(logfile_path):
with open(logfile_path, "r") as logfile:
logged_solutions = 0
for line in logfile:
if "s SATISFIABLE" in line:
logged_solutions += 1
return logged_solutions
return -1
assert f("log.txt") == 0
|
benchmark_functions_edited/f257.py
|
def f(num, den):
return -(-num // den)
assert f(3, 3) == 1
|
benchmark_functions_edited/f567.py
|
def f(ch):
return int(ch,16)
assert f(b'0') == 0
|
benchmark_functions_edited/f8647.py
|
def f(set1, set2):
return len(set(set1) & set(set2))
assert f(set(''), set('ac')) == 0
|
benchmark_functions_edited/f13481.py
|
def f(i, shape):
if callable(i):
return i(shape)
else:
return i
assert f(1, (3, 4)) == 1
|
benchmark_functions_edited/f1697.py
|
def f(low, high):
return low + high // 2
assert f(1, 3) == 2
|
benchmark_functions_edited/f610.py
|
def f(sprites):
return sprites["block"][0]
assert f({"block":[0, 0, 0]}) == 0
|
benchmark_functions_edited/f524.py
|
def f(values:list)->float:
return sum(values)*1.0/len(values)
assert f([1,2,3,4,5]) == 3
|
benchmark_functions_edited/f1109.py
|
def f(a, b):
result = a + b
return result
assert f(1, -1) == 0
|
benchmark_functions_edited/f5613.py
|
def f(d=None, level=0):
if not isinstance(d, dict) or not d:
return level
return max(f(d[k], level=level + 1) for k in d)
assert f({"a": {"b": 10}}) == 2
|
benchmark_functions_edited/f10395.py
|
def f(rep):
if not isinstance(rep, (str, float, int)):
return 0
if float(rep) == 25:
return 0
rep = float(rep) - 25
rep = rep / 9
sign = 1 if rep >= 0 else -1
rep = abs(rep) + 9
return int(sign * pow(10, rep))
assert f(25) == 0
|
benchmark_functions_edited/f9817.py
|
def f(cell_value):
if cell_value.startswith('"') and cell_value.endswith('"'):
cell_value = cell_value[1:-1]
if len(cell_value) > 0:
cell_value = int(cell_value)
else:
cell_value = None
return cell_value
assert f("1") == 1
|
benchmark_functions_edited/f5562.py
|
def f(sequence_lengths):
# return (5 + sequence_lengths) ** 0.9 / (5 + 1) ** 0.9
# return torch.sqrt(sequence_lengths)
return sequence_lengths
assert f(1) == 1
|
benchmark_functions_edited/f2884.py
|
def f(phi, gamma):
#func = 1.-phi**2
#return 0.75 * gamma * max_value(0., func)
return gamma
assert f(0, 0) == 0
|
benchmark_functions_edited/f2358.py
|
def f(t, y, ydot, solver):
if t > 28:
return 1
return 0
assert f(2, 0, 0, None) == 0
|
benchmark_functions_edited/f6581.py
|
def f(u):
s = format(u, 'b').split('1')
return 0 if len(s) < 3 else len(max(s))
assert f(32) == 0
|
benchmark_functions_edited/f6711.py
|
def f(x):
# Start checking with 2, then move up one by one
n = 2
while n <= x:
if x % n == 0:
return n
n += 1
assert f(24) == 2
|
benchmark_functions_edited/f8507.py
|
def f(x, thresh, fallback):
x = 10**-x
return x if (x and x > thresh) else fallback
assert f(1, 1, 1) == 1
|
benchmark_functions_edited/f9617.py
|
def f(string):
consonants = "bcdfghjklmnpqrstvwxz"
counter = 0
if string:
for ch in string.lower():
if ch in consonants:
counter += 1
return counter
assert f("1234567890") == 0
|
benchmark_functions_edited/f61.py
|
def f(ns):
return ns / (10**9)
assert f(10**9) == 1
|
benchmark_functions_edited/f2931.py
|
def f(values: bytes, unsigned=False) -> int:
return int.from_bytes(values, byteorder="little", signed=(not unsigned))
assert f(b"\0\0\0\0\0\0\0\0") == 0
|
benchmark_functions_edited/f3876.py
|
def f(n, asx=25., agx=5.):
return (asx + agx) * n
assert f(0) == 0
|
benchmark_functions_edited/f9784.py
|
def f(func):
while True:
returned_value = func()
if returned_value is None:
continue
else:
break
return returned_value
assert f(lambda: 2) == 2
|
benchmark_functions_edited/f7536.py
|
def f(array: list) -> list:
biggest = array[0]
for i in array:
if i > biggest:
biggest = i
return biggest
assert f(
[3, 5, 7, 2, 9, 4, 1]
) == 9
|
benchmark_functions_edited/f12854.py
|
def f(m,a=.241367,b=.241367,c=.497056):
# a,b,c = (.241367,.241367,.497056)
# a=b=c=1/3.6631098624
if .1 <= m <= .3:
res = c*( m**(-1.2) )
elif .3 < m <= 1.:
res = b*( m**(-1.8) )
elif 1. < m <= 100.:
# res = a*( m**(-1.3)-100**(-1.3) )/1.3
res = a*( m**(-2.3) )
else:
res = 0
return res
assert f(1000.) == 0
|
benchmark_functions_edited/f11930.py
|
def f(experimental, accepted, denominator):
return (experimental - accepted) / (denominator * 100)
assert f(10, 10, 100) == 0
|
benchmark_functions_edited/f1510.py
|
def f(board):
return len([ch for ch in board if ch == 'x'])
assert f(list("xxxooox")) == 4
|
benchmark_functions_edited/f11394.py
|
def f(item_count):
if item_count > 100000:
log_interval = item_count // 100
elif item_count > 30:
log_interval = item_count // 10
else:
log_interval = 1
return log_interval
assert f(10) == 1
|
benchmark_functions_edited/f11147.py
|
def f(s):
hash = 0
x = 0
for c in s:
hash = (hash << 4) + c
x = hash & 0xF0000000
if x:
hash ^= (x >> 24)
hash &= ~x
return (hash & 0x7FFFFFFF)
assert f(b"") == 0
|
benchmark_functions_edited/f3365.py
|
def f(x, i, j):
if i < j:
return x[i] + f(x, i + 1, j)
if i == j:
return x[i]
return 0
assert f(range(1), 0, 0) == 0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.