file_name
stringlengths 32
36
| content
stringlengths 44
898
|
|---|---|
benchmark_functions_edited/f3921.py
|
def f(x_0, y_0, x_1, y_1):
return (x_0 - x_1)**2 + (y_0 - y_1)**2
assert f(0, 0, 1, 1) == 2
|
benchmark_functions_edited/f6613.py
|
def f(base, exp):
if exp == 0:
return 1
if exp != 0:
return base * f(base, exp - 1)
assert f(-2, 2) == 4
|
benchmark_functions_edited/f3935.py
|
def f(i, n):
return n * ((i - 2) * n + 4 - i) // 2
assert f(5, 1) == 1
|
benchmark_functions_edited/f9201.py
|
def f(naming_data):
if naming_data:
scenario_indices = [val["scenario_index"] for val in naming_data.values()]
return max(scenario_indices) + 1
return 1
assert f(
{
"scenario1": {"scenario_index": 0},
"scenario2": {"scenario_index": 1},
"scenario3": {"scenario_index": 2},
}
) == 3
|
benchmark_functions_edited/f198.py
|
def f(m,Vdc):
return m*(Vdc/2)
assert f(1, 2) == 1
|
benchmark_functions_edited/f6381.py
|
def f(value, max=float('inf'), min=float('-inf')):
if value > max:
return max
elif value < min:
return min
else:
return value
assert f(100, 0) == 0
|
benchmark_functions_edited/f10213.py
|
def f(number, alphabet='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'):
modulus = len(alphabet)
check = modulus // 2
for n in number:
check = (((check or modulus) * 2) % (modulus + 1) + alphabet.index(n)) % modulus
return check
assert f('1') == 1
|
benchmark_functions_edited/f10530.py
|
def f(n: int, k: int) -> int:
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(10, 0) == 1
|
benchmark_functions_edited/f6892.py
|
def f(array_length_samples, overlap_ms, sr):
length_ms = array_length_samples / sr * 1000
return (length_ms + overlap_ms) / length_ms
assert f(100, 0.0, 10000) == 1
|
benchmark_functions_edited/f8161.py
|
def f(q, Kt):
return 1 + q * (Kt - 1)
assert f(1, 0) == 0
|
benchmark_functions_edited/f10490.py
|
def f(element, value, score):
if element <= value:
return score
assert f(2.0, 3.0, 1) == 1
|
benchmark_functions_edited/f5696.py
|
def f(n: int) -> int:
i = 2
while i * i <= n:
if n % i:
i += 1
else:
n //= i
return n
assert f(5) == 5
|
benchmark_functions_edited/f12245.py
|
def f(a, b):
while b:
a, b = b, a % b
return a
assert f(21, 55) == 1
|
benchmark_functions_edited/f12320.py
|
def f(number_class):
try:
n = int(number_class[-1])
except ValueError:
n = 0
return n
assert f(
'star1'
) == 1
|
benchmark_functions_edited/f5493.py
|
def f(value, arg):
assert hasattr(value, str(arg)), "Invalid %s in %s" % (arg, value)
return getattr(value, str(arg))
assert f(1, "real") == 1
|
benchmark_functions_edited/f10381.py
|
def f(seq):
valid_bases = ['A', 'T', 'G', 'C']
valid_base_count = 0
for base in seq:
if base not in valid_bases:
continue
else:
valid_base_count += 1
continue
return valid_base_count
assert f("ACTG-") == 4
|
benchmark_functions_edited/f3658.py
|
def f(tick_val, tick_pos):
if tick_val == 0:
return ''
return tick_val
assert f(1, 1) == 1
|
benchmark_functions_edited/f10599.py
|
def ord_modulo (a, n):
prod = a % n
for count in range (1, n):
if prod == 1:
return count
else:
prod = (a * prod) % n
return "Not relatively prime to n"
assert f(2, 3) == 2
|
benchmark_functions_edited/f10991.py
|
def f(levels , ps, check=False):
aa= (levels < ps)
if check is True:
print('ratio ' + str( aa.sum()/float(aa.size)) )
return aa*1
assert f(100,200) == 1
|
benchmark_functions_edited/f8432.py
|
def f(bcd):
count = 0
while bcd > 0:
count += 1
bcd >>= 4
return count
assert f(0xABCD) == 4
|
benchmark_functions_edited/f13669.py
|
def f(n_0, n_curr):
n_bar = 0.5 * (n_0 + n_curr)
return n_bar
assert f(4, 0) == 2
|
benchmark_functions_edited/f5521.py
|
def f(lista):
n_max = 0
for item in lista:
if len(item) > n_max:
n_max = len(item)
return n_max
assert f( ["a", "bbb"] ) == 3
|
benchmark_functions_edited/f13959.py
|
def f(prec=None):
global _prn_prec
if prec is not None:
_prn_prec = prec
return _prn_prec
assert f(6) == 6
|
benchmark_functions_edited/f2538.py
|
def f(n, N, pos):
return (n >> (N-1-pos) & 1)
assert f(0, 2, 0) == 0
|
benchmark_functions_edited/f13819.py
|
def f(current_step, steps_per_eval, steps_per_loop):
if steps_per_loop <= 0:
raise ValueError('steps_per_loop should be positive integer.')
if steps_per_loop == 1:
return steps_per_loop
remainder_in_eval = current_step % steps_per_eval
if remainder_in_eval != 0:
return min(steps_per_eval - remainder_in_eval, steps_per_loop)
else:
return steps_per_loop
assert f(1, 2, 1) == 1
|
benchmark_functions_edited/f8118.py
|
def f(seq1, seq2):
if len(seq1) != len(seq2):
raise ValueError('Undefined for sequences of unequal length')
return sum(elem1 != elem2 for elem1, elem2 in zip(seq1, seq2))
assert f('123', '124') == 1
|
benchmark_functions_edited/f4364.py
|
def f(precision, recall):
if precision or recall:
return 2 * precision * recall / (precision + recall)
else:
return 0
assert f(1, 0) == 0
|
benchmark_functions_edited/f12777.py
|
def f(x):
x -= 1
i = 0
while True:
if x <= 0:
break
x = x >> 1
i += 1
return i
assert f(3) == 2
|
benchmark_functions_edited/f8536.py
|
def f(am, i, j):
return 0 if (i == am) else ((((am - i + 1) * (am - i)) >> 1) + am - i - j)
assert f(5, 3, 0) == 5
|
benchmark_functions_edited/f13760.py
|
def f(header, desiredValue):
i = 0
for item in header:
if desiredValue not in item:
i = i + 1
else:
return i
assert f(["A", "B", "C"], "B") == 1
|
benchmark_functions_edited/f587.py
|
def f(d, key_name):
return d.get(key_name)
assert f({'a': 1, 'b': 2}, 'b') == 2
|
benchmark_functions_edited/f3158.py
|
def f(s1, s2):
assert len(s1) == len(s2)
return sum(c1 != c2 for c1, c2 in zip(s1, s2))
assert f('GGACTGAAATCTG', 'GGACTGAAATCTG') == 0
|
benchmark_functions_edited/f2378.py
|
def f(level):
return int((level * 100) // 255)
assert f(0) == 0
|
benchmark_functions_edited/f13596.py
|
def f(log):
max_seq_length = 0
for sequence in log:
max_seq_length_temp = 0
for activity_ in sequence:
max_seq_length_temp += 1
if max_seq_length_temp > max_seq_length:
max_seq_length = max_seq_length_temp
return max_seq_length
assert f([['a', 'b', 'c'], ['b', 'c']]) == 3
|
benchmark_functions_edited/f2779.py
|
def f(e1, e2, c):
#recommend c between 25 (football, 10 pts = 1.5 scores) and ~15
return (e1-e2)/c
assert f(1, 1, 25) == 0
|
benchmark_functions_edited/f6156.py
|
def f(l1, l2):
result = 0
for num in l1 + l2:
result ^= num
return result
assert f([1, 2, 3, 4], [5, 6]) == 7
|
benchmark_functions_edited/f7825.py
|
def f(lista):
soma = 0
for i in lista:
soma += i
return soma
assert f([1]) == 1
|
benchmark_functions_edited/f6781.py
|
def f(lowerTaps, pos):
# Hmmm... is it this simple?
posOut = pos - lowerTaps
return posOut
assert f(8, 13) == 5
|
benchmark_functions_edited/f12189.py
|
def f(content):
if isinstance(content, dict):
for k, v in content.items():
content[k] = f(v)
return content
elif isinstance(content, list):
for i, v in enumerate(list(content)):
content[i] = f(v)
return content
else:
return float(content)
assert f(1) == 1
|
benchmark_functions_edited/f3104.py
|
def f(n):
p = 1
a = 0
b = 1
for i in range(n):
p += a + b
c = a
a = b
b += c
return p * 4
assert f(1) == 8
|
benchmark_functions_edited/f1548.py
|
def f(iterator):
ret = None
for x in iterator:
ret = x
return ret
assert f(iter([1])) == 1
|
benchmark_functions_edited/f12421.py
|
def f(a, b):
if abs(a) < abs(b):
return f(b, a)
while abs(b) > 0:
_, r = divmod(a, b)
a, b = b, r
return a
assert f(9, 7) == 1
|
benchmark_functions_edited/f10516.py
|
def f(pawn, on_board_cards):
i, j = pawn
for card in on_board_cards:
if i >= card["top_left"][0] and i < card["top_left"][0] + 4 and j >= card["top_left"][1] and j < card["top_left"][1] + 4:
return card["id"]
assert f(
(1, 2),
[
{"id": 1, "top_left": (1, 1)},
{"id": 2, "top_left": (1, 1)},
{"id": 3, "top_left": (1, 1)},
]
) == 1
|
benchmark_functions_edited/f11861.py
|
def f(auth):
return auth[1] if isinstance(auth, tuple) else auth.key
assert f((1, 2)) == 2
|
benchmark_functions_edited/f4920.py
|
def f(cfs, SA_sq_ft):
return(cfs/SA_sq_ft * 24 * 60 * 60 * 304.8)
assert f(0, 10) == 0
|
benchmark_functions_edited/f242.py
|
def f(x, base=5):
return int(base * round(float(x)/base))
assert f(1, 1) == 1
|
benchmark_functions_edited/f1316.py
|
def f(d):
return sum(d.values())
assert f({1: 1, 2: 2, 3: 3}) == 6
|
benchmark_functions_edited/f1120.py
|
def f(rot_type):
return 0 if rot_type >= 4 else 1
assert f(1) == 1
|
benchmark_functions_edited/f5930.py
|
def f(fileobj):
currpos = fileobj.tell()
fileobj.seek(0, 2)
total_size = fileobj.tell()
fileobj.seek(currpos)
return total_size
assert f(open("/etc/passwd", "a")) == 0
|
benchmark_functions_edited/f10761.py
|
def f(val1, val2):
return int(val1 + int(val2[0]))
assert f(1.8, ['2']) == 3
|
benchmark_functions_edited/f8811.py
|
def f(data):
return len(data["data"])
assert f(
{
"data": [1, 2, 3, 4]
}
) == 4
|
benchmark_functions_edited/f3340.py
|
def f(a, b, c, d):
if (a & d) ^ (b & c):
return 2
if a or b or c or d:
return 1
return 0
assert f(0, 0, 1, 0) == 1
|
benchmark_functions_edited/f7310.py
|
def f(my_dict: dict):
x_keys = my_dict.keys()
# list of s
s_in_keys = [k[0] for k in x_keys]
# max s
m = max(s_in_keys)
return m
assert f(dict({(1, 2, 3): 4, (4, 5, 6): 7})) == 4
|
benchmark_functions_edited/f7839.py
|
def f(value):
if not value.isnumeric:
raise TypeError("Select a valid vlaue.")
elif int(value) == 0:
return int(value)
else:
raise TypeError("Select a valid vlaue.")
assert f("0") == 0
|
benchmark_functions_edited/f8471.py
|
def f(x, c):
f_x = 0
for i in range(len(c)):
f_x += pow(x, i) * c[i]
return f_x
assert f(0, [1]) == 1
|
benchmark_functions_edited/f3538.py
|
def f(GPE,gravity,height):
result=GPE/gravity*height
return result
assert f(0, 9.81, 70) == 0
|
benchmark_functions_edited/f4784.py
|
def f(x: dict) -> int:
res = 1
for p, r in x.items(): res *= p**r
return res
assert f( {2:2} ) == 4
|
benchmark_functions_edited/f10830.py
|
def f(selfies: str) -> int:
return selfies.count("[") + selfies.count(".")
assert f(
"[C][=C][F].[C]"
) == 5
|
benchmark_functions_edited/f9473.py
|
def f(c):
if c < 0:
return 0
elif (c >= 0 and c < 31):
return 1
elif (c >= 31 and c < 91):
return 2
elif (c >= 91 and c < 183):
return 3
elif (c >= 183 and c < 366):
return 4
else:
return 5
assert f(367) == 5
|
benchmark_functions_edited/f13222.py
|
def f(number, index):
return (int(number) & (1 << index)) >> index
assert f(5, 8) == 0
|
benchmark_functions_edited/f12546.py
|
def f(n: int, steps: list):
if n < min(steps):
return 0
ways = 0
for step in steps:
if n == step:
ways += 1
elif n > step:
ways += f(n - step, steps)
return ways
assert f(2, [2]) == 1
|
benchmark_functions_edited/f9840.py
|
def f(number: int) -> int:
return number.bit_length() - 1
assert f(25) == 4
|
benchmark_functions_edited/f3772.py
|
def f(*c):
i = 0
best = 0
for j in range(len(c)):
if c[j] > best:
i = j
best = c[j]
return i
assert f(3) == 0
|
benchmark_functions_edited/f1610.py
|
def f(patch, mult_by, add_to):
return mult_by * patch + add_to
assert f(0, 0, 0) == 0
|
benchmark_functions_edited/f12061.py
|
def f(obj, keys):
cur = obj
for nr, key in enumerate(keys):
cur = cur[key]
return cur
assert f(
{"a": {"b": [0, 1, 2, 3]}},
("a", "b", 2)
) == 2
|
benchmark_functions_edited/f5397.py
|
def f(size):
if size == 0:
return 0
else:
return size.bit_length()
assert f(22) == 5
|
benchmark_functions_edited/f5441.py
|
def f(iterable):
product = 1
for x in iterable:
product *= x
return product
assert f([1, 2, 3]) == 6
|
benchmark_functions_edited/f8764.py
|
def f(count_words):
letters = {}
for word in count_words.keys():
for letter in word:
letters.setdefault(letter, 0)
letters[letter] += count_words[word]
return len(letters.keys())
assert f({" ": 1}) == 1
|
benchmark_functions_edited/f8951.py
|
def f(arg1, arg2):
try:
return arg1 - arg2
except TypeError:
return 'Unsupported operation: {0} - {1} '.format(type(arg1), type(arg2))
assert f(-2, -3) == 1
|
benchmark_functions_edited/f13958.py
|
def f(arr1, arr2):
numerator = sum(x1 * x2 for x1, x2 in zip(arr1, arr2))
denominator = (sum(x1 ** 2 for x1 in arr1) *
sum(x2 ** 2 for x2 in arr2)) ** 0.5
return numerator / denominator
assert f([1, 2, 3], [1, 2, 3]) == 1
|
benchmark_functions_edited/f6760.py
|
def f(min, max, value):
x = (value - min)/(max - min)
return x
assert f(0, 1, 0) == 0
|
benchmark_functions_edited/f8440.py
|
def f(x):
if x == '>50K':
return 1
else:
return 0
assert f(4) == 0
|
benchmark_functions_edited/f4275.py
|
def f(c):
if c < -3:
return 0
if c < 3:
return 1
return 2
assert f(10) == 2
|
benchmark_functions_edited/f1668.py
|
def f(a, b):
return int(abs(a - b) + 0.5)
assert f(0, 1) == 1
|
benchmark_functions_edited/f12056.py
|
def f(s, t):
count, i, j = 0, 0, 0
while i < len(s) and j < len(t):
if s[i] == t[j]:
count, i, j = count + 1, i + 1, j + 1
elif s[i] < t[j]:
i += 1
else:
j += 1
return count
assert f(range(1), range(1)) == 1
|
benchmark_functions_edited/f10230.py
|
def f(fks,id):
for i,j in fks.items():
if fks[i][1]==id:
return i
return None
assert f(
{0: [0, "a"], 1: [1, "b"]},
"a"
) == 0
|
benchmark_functions_edited/f6294.py
|
def f(x):
formula = 2*x + 6
return formula
assert f(-1) == 4
|
benchmark_functions_edited/f10194.py
|
def f(marks, min, max):
counter = 0
for mark in marks:
if min <= mark <= max:
counter += 1
return counter
assert f(
[50, 60, 70, 80, 90], 51, 59) == 0
|
benchmark_functions_edited/f9485.py
|
def f(dH,dS,temp=37):
return dH*1000 - (temp+273.15)*dS
assert f(0,0) == 0
|
benchmark_functions_edited/f2537.py
|
def f(temperature):
return (temperature - 154) / 346
assert f(154) == 0
|
benchmark_functions_edited/f4744.py
|
def f(node_s, node_w):
if isinstance(node_s, int):
return node_w[node_s]
else:
return sum([node_w[n] for n in node_s])
assert f(0, [1,1,1]) == 1
|
benchmark_functions_edited/f4214.py
|
def f(item, vec):
for i in range(len(vec)):
if item == vec[i]:
return i
return -1
assert f(10, [1, 2, 3, 4, 10, 11, 12]) == 4
|
benchmark_functions_edited/f5353.py
|
def f(position, to_position):
return sum(abs(pos_coord - to_coord)
for pos_coord, to_coord in zip(position, to_position))
assert f(
(3, 4), (1, 1)) == 5
|
benchmark_functions_edited/f8940.py
|
def f(arr, x):
l = len(arr)
for i in range(l):
if arr[i] == x:
return i
return None
assert f([1, 2, 3], 3) == 2
|
benchmark_functions_edited/f5987.py
|
def f(parameters, path):
root = parameters
for key in path.split('/'):
root = root[key]
if 'value' in root:
return root['value']
return root
assert f(
{
'a': {
'b': {
'c': {
'value': 5,
},
},
},
},
'a/b/c',
) == 5
|
benchmark_functions_edited/f13510.py
|
def f(percent: int, min: int, max: int) -> int:
return round(float(percent) / 100 * (max - min) + min)
assert f(0, 0, 100) == 0
|
benchmark_functions_edited/f10590.py
|
def f(s, chao1):
return s * (s - 1) / 2 + s * (2 * s - 1) ** 2 / 4 - s ** 4 / (4 * chao1)
assert f(1, 1) == 0
|
benchmark_functions_edited/f9843.py
|
def f(array, left, right):
pivot = array[right]
i = left - 1
for j in range(left, right):
if array[j] < pivot:
i += 1
array[i], array[j] = array[j], array[i]
array[right], array[i + 1] = array[i + 1], array[right]
return i + 1
assert f(list(range(10)), 0, 5) == 5
|
benchmark_functions_edited/f13413.py
|
def f(x, derivative=False):
a = 0.02
if x > 0:
if derivative:
return 1
else: return x
else:
if derivative:
return a
else: return a*x
assert f(5) == 5
|
benchmark_functions_edited/f3276.py
|
def f( x, img_width=640, fov_angle=44 ):
return( -( ( img_width / 2 ) - x ) * fov_angle )
assert f( 320, 640, 44 ) == 0
|
benchmark_functions_edited/f6455.py
|
def f(line) -> int:
if line.strip().startswith("*"):
return len(line.strip().split(" ")[0])
else:
return 0
assert f("* This is not a line of a tree.") == 1
|
benchmark_functions_edited/f11354.py
|
def f(queue: list, person_name: str) -> int:
cnt = 0
for name in queue:
if name == person_name:
cnt += 1
return cnt
assert f(
['Jimmy', 'Kieran', 'Jason', 'Kieran', 'Kieran', 'Kieran'],
'James') == 0
|
benchmark_functions_edited/f10633.py
|
def f(d, key):
if '.' in key:
key, rest = key.split('.', 1)
if key not in d:
raise KeyError(key)
return f(d[key], rest)
else:
if key not in d:
raise KeyError(key)
return d.pop(key)
assert f(
{'a': 1, 'b': {'c': 2}}, 'a'
) == 1
|
benchmark_functions_edited/f3737.py
|
def f(length: float, breadth: float, height: float) -> float:
volume: float = length * breadth * height
return volume
assert f(1, 3, 1) == 3
|
benchmark_functions_edited/f6340.py
|
def f(x):
if x >= 0:
return 1
else:
return 0
assert f(3.0) == 1
|
benchmark_functions_edited/f8335.py
|
def f(line):
import re
# your code here
sol = 0
for i in range(len(line)):
sol=max(sol,len(max(re.findall(line[i]+"+",line),key=len)))
return sol
assert f(
"ddvvrwwwrggg") == 3
|
benchmark_functions_edited/f1922.py
|
def f(price: str) -> float:
return float(price.lstrip('$'))
assert f('$0') == 0
|
benchmark_functions_edited/f13210.py
|
def f(x, lo, hi, func):
while lo < hi:
mid = (lo + hi) // 2
k = func(mid)
if k is not None and x < k:
hi = mid
else:
lo = mid + 1
return lo
assert f(0, 0, 10, lambda i: i if i > 0 else None) == 1
|
benchmark_functions_edited/f7084.py
|
def f(a, C, f, eref=1):
return (f/C)**(1/-a)*eref
assert f(1, 1, 1) == 1
|
benchmark_functions_edited/f11498.py
|
def f(invalue, dictionary):
value = invalue
for key in dictionary.keys():
value -= dictionary[key]
if value < 0:
return key
raise Exception("The value asked is out of the dictionary.")
assert f(10, {1: 30, 2: 10}) == 1
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.