file_name stringlengths 32 36 | content stringlengths 44 898 |
|---|---|
benchmark_functions_edited/f13083.py | def f(old_prime,values):
for multiple,state in enumerate(values,1):
if multiple > old_prime and state is False:
return multiple
assert f(1, [True, False, False, False, False, False, False, False, False, False]) == 2 |
benchmark_functions_edited/f3027.py | def f(num):
return 1 if num == 0 else num * f(num - 1)
assert f(3) == 6 |
benchmark_functions_edited/f12698.py | def f(previous, current, property_name):
n0 = previous[property_name]
n1 = current[property_name]
d0 = previous["Timestamp_Sys100NS"]
d1 = current["Timestamp_Sys100NS"]
if n0 is None or n1 is None:
return
return (n1 - n0) / (d1 - d0) * 100
assert f(
{"Timestamp_Sys100NS": 14800000... |
benchmark_functions_edited/f1446.py | def f(binary_string):
return binary_string.count('1')
assert f(bin(1)) == 1 |
benchmark_functions_edited/f1184.py | def f(I, surface_area=1):
j = I / surface_area
return j
assert f(1) == 1 |
benchmark_functions_edited/f5392.py | def f(function, list):
for item in list:
if function(item) == True:
return item
assert f(lambda x: x % 3 == 0, [1, 2, 3, 4, 5, 6]) == 3 |
benchmark_functions_edited/f9240.py | def fibonacci (nth):
if nth <= 2:
return 1 if nth > 0 else 0
else:
return f(nth - 2) + f(nth - 1)
assert f(0) == 0 |
benchmark_functions_edited/f13725.py | def f(n, m):
q = int(n / m)
n1 = m * q
if((n * m) > 0) :
n2 = (m * (q + 1))
else :
n2 = (m * (q - 1))
if (abs(n - n1) < abs(n - n2)) :
if n1 < n:
n1 += m
return n1
if n2 < n:
n2 += m
return n2
assert f(-1, 2) == 0 |
benchmark_functions_edited/f814.py | def f(a, b):
return a if b is None else a + b
assert f(1, 1) == 2 |
benchmark_functions_edited/f5743.py | def f(a1,b1,a2,b2):#{{{
return (min(b1,b2)-max(a1,a2))
assert f(0,2,1,3) == 1 |
benchmark_functions_edited/f5252.py | def f(x, l, u):
return l if x < l else u if x > u else x
assert f(-1, 1, 10) == 1 |
benchmark_functions_edited/f13937.py | def f(max_x, x):
return ((-1/max_x) * x) + 1
assert f(1, 0) == 1 |
benchmark_functions_edited/f10827.py | def f(val, bits):
if (val & (1 << (bits - 1))) != 0: # if sign bit is set e.g., 8bit: 128-255
val = val - (1 << bits) # compute negative value
return val
assert f(3, 3) == 3 |
benchmark_functions_edited/f602.py | def f(collection, id_, cont):
return 11 <= len(str(cont)) <= 18
assert f('collection', 'id_', 'cont') == 0 |
benchmark_functions_edited/f9963.py | def f(number: int) -> int:
result = 0
for index, digit in enumerate(reversed(str(number))):
if index == 0:
result += int(digit)
else:
result += 2 ** index * int(digit)
return int(result)
assert f(8) == 8 |
benchmark_functions_edited/f2076.py | def f(base_minor, base_major, height):
return ((base_minor+base_major)/2)*height
assert f(3, 1, 2) == 4 |
benchmark_functions_edited/f176.py | def f(val):
return int(val, 8)
assert f("0") == 0 |
benchmark_functions_edited/f5602.py | def f(total, good, draws):
drawn = int(round(draws * (good / total)))
return min(max(drawn, 0), int(round(good)))
assert f(0.1, 0.0, 0.1) == 0 |
benchmark_functions_edited/f4646.py | def f(values, p=0.5):
m = min(values)
interval = max(values) - m
return m + p*interval
assert f([-10, 0, 10], 0.5) == 0 |
benchmark_functions_edited/f6393.py | def f(obj, method_name, *args):
method = getattr(obj, method_name)
return method(*args)
assert f({'a': 1}, 'get', 'a', 2) == 1 |
benchmark_functions_edited/f13774.py | def f(x, amountToShift, totalBits):
x = x%(2**totalBits)
n_mod = ((amountToShift % totalBits) + totalBits) % totalBits
return ((x >> n_mod) | ((x << (totalBits-n_mod)))&((2**totalBits)-1))
assert f(0, 2, 4) == 0 |
benchmark_functions_edited/f536.py | def f(phi):
return phi**3-phi
assert f(0) == 0 |
benchmark_functions_edited/f939.py | def f(a_dictionary):
return (len(a_dictionary))
assert f([('a', 1), ('b', 2), ('c', 3)]) == 3 |
benchmark_functions_edited/f6357.py | def f(number):
count = 0
while number > 0:
if number % 2 == 1:
count = count + 1
number = number // 2
return count
assert f(4) == 1 |
benchmark_functions_edited/f11426.py | def f(str1, str2):
try:
num1 = float(str1)
except ValueError:
num1 = 0.0
try:
num2 = float(str2)
except ValueError:
num2 = 0.0
difference = int(1000 * (num2 - num1))
return difference
assert f(1.2, 1.2) == 0 |
benchmark_functions_edited/f5096.py | def f(coord, blksiz, totsiz):
if (coord + blksiz) < totsiz:
return blksiz
else:
return totsiz - coord
assert f(1, 2, 4) == 2 |
benchmark_functions_edited/f4512.py | def f(string):
try:
value = int(string)
except ValueError:
value = 0
return value
assert f(0) == 0 |
benchmark_functions_edited/f2999.py | def f(x):
return int(x, 0)
assert f("0o1") == 1 |
benchmark_functions_edited/f8158.py | def f(segment, column):
segment['columns'].append(column)
segment['length'] += 3 + segment['table']['lengths'][column]
return len(segment['columns']) - 1
assert f(
{'table': {'columns': ['a', 'b', 'c'], 'lengths': {
'a': 3,
'b': 3,
'c': 3,
}, 'length': 10}, 'columns': ['a', ... |
benchmark_functions_edited/f2708.py | def f(xx:list,yy:list):
return sum([x*y for (x,y) in zip(xx,yy)])
assert f([],[])==0 |
benchmark_functions_edited/f5347.py | def f(flag):
bonus = 0
if flag:
pass
else:
pass
return bonus
assert f(False) == 0 |
benchmark_functions_edited/f7585.py | def f(row: int, column: int):
if row == 1 or column == 1: # base case
return 1
else:
return f(row - 1, column)\
+ f(row, column - 1)
assert f(1, 1) == 1 |
benchmark_functions_edited/f10340.py | def f(state, address, init=0, end=15):
if state is None:
return 0
binary = format(state[address], '016b')
r_init = len(binary)-1-init
r_end = len(binary)-1-end
kBitSubStr = binary[r_end: r_init+1]
return int(kBitSubStr, 2)
assert f(None, 15) == 0 |
benchmark_functions_edited/f11781.py | def f(col):
curr_val = col
while isinstance(curr_val, tuple):
curr_val = curr_val[-1]
return curr_val
assert f((('a.b', 2), 3, 0)) == 0 |
benchmark_functions_edited/f9080.py | def f(texts):
if type(texts) is list:
return sum(len(t.split()) for t in texts)
return len(texts.split())
assert f(["one", "two", "three"]) == 3 |
benchmark_functions_edited/f6776.py | def f(n):
for i in range(n, 0, -1):
if i&(i-1) == 0:
return i
assert f(15) == 8 |
benchmark_functions_edited/f3950.py | def f(prob):
return 1 if prob >= .5 else 0
assert f(1) == 1 |
benchmark_functions_edited/f1335.py | def f(x):
ret = 1 if x>0 else 0
return ret
assert f(-100.0) == 0 |
benchmark_functions_edited/f12608.py | def f(layers):
sum = 0
for l in range(0, len(layers) - 1):
sum += layers[l] * layers[l + 1] + layers[l + 1]
return sum
assert f(list()) == 0 |
benchmark_functions_edited/f6679.py | def f(degrees1, degrees2):
diff = abs(degrees1 - degrees2)
if diff > 180:
diff = abs(diff - 360)
return diff
assert f(180, 180) == 0 |
benchmark_functions_edited/f6422.py | def f(c):
return ord(c) & 0x07
assert f(u'0') == 0 |
benchmark_functions_edited/f14374.py | def f(n, cache):
if n == 1:
return 1
if n in cache:
return cache[n]
if n % 2 == 0:
cache[n] = f(n // 2, cache) + 1
else:
cache[n] = f(3 * n + 1, cache) + 1
return cache[n]
assert f(1, {}) == 1 |
benchmark_functions_edited/f4171.py | def f(*values):
for value in values:
if value is not None:
return value
return None
assert f(None, None, None, 4) == 4 |
benchmark_functions_edited/f12085.py | def f(x):
# check that x is positive
if x < 0:
print("error:negative number value was supplied")
return -1
else:
print("here we go..")
# z is an initial guess for the root.
z = x / 2.0
# continuously improve the guess .
while abs(x - (z*z)) > 0.0000001:
z = z - (((z*z) - x) / ( 2 * z))
... |
benchmark_functions_edited/f1216.py | def f(Ft, Fo):
dF_F = (Ft-Fo)/Fo
return(dF_F)
assert f(100, 100) == 0 |
benchmark_functions_edited/f10876.py | def f(year):
if year < 1600:
if year % 4:
return 0
else:
return 1
elif year % 4 != 0:
return 0
elif year % 100 != 0:
return 1
elif year % 400 != 0:
return 0
else:
return 1
assert f(2016) == 1 |
benchmark_functions_edited/f2241.py | def f(n):
return n if n < 2 else f(n - 2) + f(n - 1)
assert f(0) == 0 |
benchmark_functions_edited/f7093.py | def f(my_dict: dict):
keys = my_dict.keys()
# list of times
all_t = [k[-1] for k in keys]
# max t
h = max(all_t)
return h
assert f(
{(0, 1): 1, (1, 1): 1, (1, 2): 1, (1, 2): 1}) == 2 |
benchmark_functions_edited/f2482.py | def f(string):
return len(string) - len(string.lstrip(' '))
assert f(
'''
# Hello world!
'''
) == 0 |
benchmark_functions_edited/f13882.py | def f(n, accumulator=1):
if n == 0:
return accumulator
else:
return f(n-1, accumulator * n)
assert f(2) == 2 |
benchmark_functions_edited/f9949.py | def f(nest, index):
ret = nest
for i in index:
ret = ret[i]
return ret
assert f({'a': 1, 'b': 2}, 'b') == 2 |
benchmark_functions_edited/f8560.py | def f(number1, number2, number3):
return (number1 + number2 + number3) / 3.0
assert f(2, 6, 10) == 6 |
benchmark_functions_edited/f4395.py | def f(swup_sfc, swup_sfc_clr, swdn_sfc, swdn_sfc_clr):
return swup_sfc - swup_sfc_clr - swdn_sfc + swdn_sfc_clr
assert f(0, 0, 0, 0) == 0 |
benchmark_functions_edited/f2436.py | def f(n):
k = -1
assert n >= 0
while n:
k += 1
n >>= 1
return k
assert f(29) == 4 |
benchmark_functions_edited/f12852.py | def f(cp):
if 0 <= cp <= 0x7F:
return 1
if 0x80 <= cp <= 0x7FF:
return 2
if 0x800 <= cp <= 0xFFFF:
return 3
if 0x10000 <= cp <= 0x10FFFF:
return 4
raise(ValueError("Code point not in valid range [0, 1114111]"))
assert f(1234) == 2 |
benchmark_functions_edited/f5961.py | def f(image_urls):
return image_urls.count("|") + 1
assert f(
"https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png|https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png"
) == 2 |
benchmark_functions_edited/f7322.py | def f(n, k):
return n & ~(1 << k - 1)
assert f(4, 6) == 4 |
benchmark_functions_edited/f9368.py | def f(pixel_index, offset):
if pixel_index - offset < 0:
samp_out = 0
else:
samp_out = pixel_index - offset
return samp_out
assert f(3, 1) == 2 |
benchmark_functions_edited/f11214.py | def f(N, K, k):
return k*(N+1)/(K+1)
assert f(3, 3, 1) == 1 |
benchmark_functions_edited/f12422.py | def f(a, val, lo, hi):
while lo < hi:
mid = (lo + hi) // 2
if a[mid] < val:
lo = mid + 1
else:
hi = mid
return lo
assert f(range(20), 1, 0, 20) == 1 |
benchmark_functions_edited/f5243.py | def f(new_mode=None):
global _rocket_mode
if new_mode is not None:
_rocket_mode = new_mode
return _rocket_mode
assert f(2) == 2 |
benchmark_functions_edited/f8512.py | def f(year):
if year <= 0:
return 0
return year + f(year-1)
assert f(2) == 3 |
benchmark_functions_edited/f7509.py | def f(pt):
if 1 <= pt <= 100:
global PERCENTAGE
PERCENTAGE = pt
else:
return 1
assert f(0) == 1 |
benchmark_functions_edited/f75.py | def f(a):
return 1./a-1
assert f(1/2.) == 1 |
benchmark_functions_edited/f10539.py | def f(rating1, rating2):
distance = 0
commonRatings = False
for key in rating1:
if key in rating2:
distance += abs(rating1[key] - rating2[key])
commonRatings = True
if commonRatings:
return distance
else:
return -1
assert f(
{"a": 1, "b": 2}, {"a... |
benchmark_functions_edited/f10685.py | def f(n):
if n <= 0:
return 0
if n == 1:
return 1
if n == 2:
return 2
if n == 3:
return 4
return f(n-1) + f(n-2) + f(n-3)
assert f(0) == 0 |
benchmark_functions_edited/f538.py | def f(x, y, func):
return func(x, y).imag
assert f(1, 2, lambda x, y: 0) == 0 |
benchmark_functions_edited/f3641.py | def f(word, index):
if index >= 0:
return index
else:
return len(word) + index
assert f('candle', 4) == 4 |
benchmark_functions_edited/f11205.py | def f(x,C0,C1,C2):
return C0+C1*x+C2*x**2
assert f(0, 1, 2, 3) == 1 |
benchmark_functions_edited/f13538.py | def f(cache, estimator, method, *args, **kwargs):
if cache is None:
return getattr(estimator, method)(*args, **kwargs)
try:
return cache[method]
except KeyError:
result = getattr(estimator, method)(*args, **kwargs)
cache[method] = result
return result
assert f(None,... |
benchmark_functions_edited/f7947.py | def f(a, b):
result = min(a, b)
return result
assert f(2, 3) == 2 |
benchmark_functions_edited/f10694.py | def f(n, k):
r = 0
for x in range(1, n + 1):
r = (r + k) % x
return r + 1
assert f(2, 2) == 1 |
benchmark_functions_edited/f7627.py | def f(n):
cnt = 1
if n > 1:
cnt += 1
half = n//2
for i in range(2, half+1):
if n % i == 0:
cnt += 1
return cnt
assert f(1) == 1 |
benchmark_functions_edited/f2519.py | def f(dictionary):
keys = list(dictionary.keys())
if len(keys) > 0:
return keys[0]
return ""
assert f(dict({1: 1})) == 1 |
benchmark_functions_edited/f4737.py | def f(arr):
count = 0
for x in arr:
if x == True:
count += 1
return count
assert f([False, False]) == 0 |
benchmark_functions_edited/f4515.py | def f(sents):
return sum([len(triple) for sent in sents for triple in sent.span_triples])
assert f([]) == 0 |
benchmark_functions_edited/f12687.py | def f(accounts: int, deploy_idx: int) -> int:
return deploy_idx if accounts == 0 else \
deploy_idx % accounts or accounts
assert f(3, 1) == 1 |
benchmark_functions_edited/f14284.py | def f(bond_symbol: str) -> int:
if bond_symbol == "=":
return 2
elif bond_symbol == "#":
return 3
else:
return 1
assert f("=") == 2 |
benchmark_functions_edited/f10987.py | def f(input, unit):
output = 0
multipliers_dict = {
'HS06sPerEvent': 1,
'mHS06sPerEvent': 1.0/1000,
}
if unit in multipliers_dict:
output = input * multipliers_dict[unit]
return output
assert f(2, 'HS06sPerEvent') == 2 |
benchmark_functions_edited/f6236.py | def f(method):
number = 0
while hasattr(method, '__aspects_orig'):
number += 1
method = method.__aspects_orig
return number
assert f(lambda x: 1) == 0 |
benchmark_functions_edited/f11008.py | def f(height, top, bottom):
return (
# triangle based on longer - shorter of the top/bottom
0.5 * abs(top - bottom) * height
# plus parallelogram based on shorter edge
+ min(top, bottom) * height
)
assert f(0, 0, 2) == 0 |
benchmark_functions_edited/f9325.py | def f(a, p, n):
result = a%n
remainders = []
while p != 1:
remainders.append(p & 1)
p = p >> 1
while remainders:
rem = remainders.pop()
result = ((a ** rem) * result ** 2) % n
return result
assert f(4, 2, 5) == 1 |
benchmark_functions_edited/f12083.py | def f(li, index):
#ex :[[0,9,8],[1,2,3],[3,4,5]] the min at index 1 is 2
if (len(li)>0):
return max([e[index] for e in li])
return 0
assert f( [], 1 ) == 0 |
benchmark_functions_edited/f1475.py | def f(data):
data = data.hex()
return int(data[5])
assert f(bytes.fromhex('02 01 00 02 00 01 00')) == 0 |
benchmark_functions_edited/f12679.py | def f(array, element):
try:
index = array.index(element)
return index
except ValueError:
return None
assert f(list(range(0, 10)), 3) == 3 |
benchmark_functions_edited/f7469.py | def f(comment, word):
a = comment.split(" ")
count = 0
for i in range(len(a)):
if (word == a[i]):
count = count + 1
return count
assert f(
"Hello world", "hello") == 0 |
benchmark_functions_edited/f9616.py | def f(x, y):
return (x > y) - (x < y)
assert f(1.5, 1.5) == 0 |
benchmark_functions_edited/f12980.py | def f(n):
calculate_index = sum([num for num in range(1, n)])
odd_numbers = []
m = 1
while len(odd_numbers) != calculate_index + n:
odd_numbers.append(m)
m += 2
numbers = []
for i in range(calculate_index, calculate_index + n):
numbers.append(odd_numbers[i])
return su... |
benchmark_functions_edited/f2640.py | def f(a, b):
if a == b:
return 1
else:
return 0
assert f(1, 'a') == 0 |
benchmark_functions_edited/f13771.py | def f(string: str, n: int, char: str = "a") -> int:
string_size = len(string)
if string_size == 1:
return n if string == char else 0
whole, remainder = divmod(n, string_size)
char_count = string.count(char), string[:remainder].count(char)
ret = (whole * char_count[0]) + char_count[1]
ret... |
benchmark_functions_edited/f4685.py | def f(*args):
total = 0
for elem in args:
total += elem
return total
assert f(1, 2, -3) == 0 |
benchmark_functions_edited/f6719.py | def f(input):
try:
if len(input) == 1:
return input[0]
raise ValueError(f"Not a scalar: {input}")
except:
return input
assert f(1) == 1 |
benchmark_functions_edited/f13128.py | def f(gram, phrase2index, tot_phrase_list):
if gram in phrase2index:
index = phrase2index[gram]
return index
else:
index = len(tot_phrase_list)
phrase2index[gram] = index
tot_phrase_list.append(gram)
return index
assert f(
'hi',
{'hi': 2},
['hello', '... |
benchmark_functions_edited/f13084.py | def f(tword,codetree):
pos = 0
while True:
s = tword[pos]
if s not in codetree:
return 0
elif codetree[s][0]>0:
return codetree[s][0]
elif pos==len(tword)-1:
return 0
else:
pos += 1
codetree = codetree[s][1]
ass... |
benchmark_functions_edited/f8850.py | def f(name):
h = 0
for c in name:
h = (h << 4) + ord(c)
g = h & 0xF0000000
if g:
h ^= g >> 24
h &= ~g
assert h >= 0
return h
assert f(b"") == 0 |
benchmark_functions_edited/f2127.py | def f(f, x: float) -> float:
if type(f) is str:
return eval(f)
return f(x)
assert f(lambda x: 1, 2) == 1 |
benchmark_functions_edited/f1383.py | def f(x, param):
a = param['a']
b = param['b']
y = a*x + b
return y
assert f(1, {'a': 1, 'b': 2}) == 3 |
benchmark_functions_edited/f12696.py | def f(mreq,qcat,deltaGcat,kd):
if mreq > qcat and deltaGcat <= 0:
return(kd*(mreq-qcat)/mreq)
elif deltaGcat > 0:
return(kd)
else:
return(0)
assert f(10, 10, 0, 0) == 0 |
benchmark_functions_edited/f4777.py | def f(p, q):
return abs(p[0]-q[0])
assert f( (-1, 1), (1, 1) ) == 2 |
benchmark_functions_edited/f14429.py | def f(n, largest):
remainder = n % 10
if n < 10: # Base case!
if remainder > largest:
return remainder
else:
return largest
elif remainder > largest: # Recursive
largest = remainder
return f((n-remainder)//10, largest)
else: # Recursive
return f((n-remainder)//10, largest)
assert f(255255, 0) ==... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.