file_name stringlengths 32 36 | content stringlengths 44 898 |
|---|---|
benchmark_functions_edited/f83.py | def f(lst):
return max(set(lst), key=lst.count)
assert f([1, 1, 2, 2, 2, 3, 4, 4, 4, 5]) == 2 |
benchmark_functions_edited/f1645.py | def f(number_of_freq_estimations):
return 2*number_of_freq_estimations + 1
assert f(0) == 1 |
benchmark_functions_edited/f11789.py | def f(variables, classes, noc):
res = 0
for i in variables:
if i in classes:
res += 1
return res / noc
assert f(
[0, 0, 0, 0],
[0, 0],
4
) == 1 |
benchmark_functions_edited/f1726.py | def f(x, y):
# everything gets 1 vote
return 1
assert f(10, 10) == 1 |
benchmark_functions_edited/f7348.py | def f(p, a, b):
return a+p*(b-a)
assert f(0, 0, 1) == 0 |
benchmark_functions_edited/f14369.py | def f(kwargs, key, default):
if kwargs is not None:
if key in kwargs.keys():
return kwargs[key]
return default
assert f({"other": 42}, "test", 0) == 0 |
benchmark_functions_edited/f13070.py | def f(d):
sorted_keys = sorted([key for key in d.keys()])
values = [d[key] for key in sorted_keys]
max_value = max(values)
for key, value in zip(sorted_keys, values):
if value == max_value:
return key
assert f( {1: 100, 2: 100, 3: 200} ) == 3 |
benchmark_functions_edited/f1727.py | def f(string):
s = string.replace('.', '')
s = int(s)
return s
assert f('1') == 1 |
benchmark_functions_edited/f11969.py | def f(agents):
networks = []
for agent_networks in agents.values():
networks += agent_networks
return len(set(networks))
assert f(
{
1: ["network1", "network2"],
2: ["network3"],
}
) == 3 |
benchmark_functions_edited/f9855.py | def f(*values):
if not len(values):
raise ValueError("Cannot coalesce an empty list of arguments.")
for value in values:
if value is not None:
return value
return None
assert f(None, None, 3, 4, 5) == 3 |
benchmark_functions_edited/f7700.py | def f(bpm):
if bpm > 60:
return 0
elif bpm > 50:
return 1
else:
return 2
assert f(50) == 2 |
benchmark_functions_edited/f107.py | def f( a, b):
z = a + b
return z
assert f(1, 0) == 1 |
benchmark_functions_edited/f10732.py | def f(seq):
count = 0
for _ in seq:
count += 1
return count
assert f(iter(range(3))) == 3 |
benchmark_functions_edited/f12426.py | def f(arr, l, r, x):
while l <= r:
mid = (l + r) // 2
# Check if x is present at mid
if arr[mid] == x:
return mid
# If x is greater, ignore left half
elif arr[mid] < x:
l = mid + 1
# If x is smaller, ignore right half
else:
r = mid - 1
# If we reach here, then the element
# was not present
return -1
assert f(list(range(0, 10)), 0, 9, 0) == 0 |
benchmark_functions_edited/f14213.py | def f(clock_us, reference_clock_us, reference_timestamp):
return reference_timestamp + (clock_us - reference_clock_us) / 1.0e6
assert f(10, 10, 2) == 2 |
benchmark_functions_edited/f11753.py | def f(labels, predictions):
loss = 0
for l, p in zip(labels, predictions):
loss = loss + (l - p) ** 2
loss = loss / len(labels)
return loss
assert f([10, 20, 30], [10, 20, 30]) == 0 |
benchmark_functions_edited/f12772.py | def f(seq, indices, cur_size):
seqlen = len(seq)
j = cur_size+1
while j < seqlen-indices[-1]:
firstnt = seq[indices[0]+j]
if not all(seq[i+j]==firstnt for i in indices[1:]):
return j
j += 1
return j
assert f(list("ACTGC"), [1, 3, 5], 1) == 2 |
benchmark_functions_edited/f10172.py | def f(a, b):
if (a[0] * b[0] + a[1] * b[1]) > 0:
return 1
else:
return 0
assert f(
(1, 0), (0, -1)
) == 0 |
benchmark_functions_edited/f11066.py | def f(num1,num2,limit):
sum = 0
if num1 > limit and num2 > limit:
return sum
for i in range(1,(limit+1)):
if i % num1 == 0 or i % num2 == 0:
sum += i
return sum
assert f(3, 5, 1) == 0 |
benchmark_functions_edited/f646.py | def f(scores):
return scores[-1]
assert f([1, 2, 3]) == 3 |
benchmark_functions_edited/f5048.py | def f(port_mask):
ports_in_binary = format(int(port_mask, 16), 'b')
nof_ports = ports_in_binary.count('1')
return nof_ports
assert f("0x1") == 1 |
benchmark_functions_edited/f3347.py | def f(string):
try:
string = float(string)
except:
string = 0
return string
assert f("a.0a") == 0 |
benchmark_functions_edited/f393.py | def f(uid):
return int(uid) // (32000-2)
assert f(32000*2) == 2 |
benchmark_functions_edited/f553.py | def f(x, y):
return sum(abs(i - j) for i, j in zip(x, y))
assert f((), ()) == 0 |
benchmark_functions_edited/f11815.py | def f(ins_1, ins_2, norm=2):
dist = abs(ins_1 - ins_2)**norm
return dist
assert f(1, 2) == 1 |
benchmark_functions_edited/f12269.py | def f(text, line, col):
if type(text) != list:
lines = text.splitlines(True)[:line+1]
else:
lines = text[:line+1]
b = len(''.join(lines[:line])) + len(lines[line][:col])
return b
assert f(u'ab\n\r\n\n\r\r', 0, 1) == 1 |
benchmark_functions_edited/f12547.py | def f(a, x):
lo = 0
hi = len(a)
while lo < hi:
mid = (lo + hi) // 2
if x > a[mid]:
hi = mid
else:
lo = mid + 1
# makes sure to insert to the left
if (lo < len(a)):
while lo > 0 and a[lo - 1] == x:
lo -= 1
return lo
assert f([], 0) == 0 |
benchmark_functions_edited/f2935.py | def f(n):
count = 0
while (n):
count += n & 1
n >>= 1
return count
assert f(8) == 1 |
benchmark_functions_edited/f4323.py | def f(num):
if num == 0:
return 0
return num + f(num - 1)
assert f(0) == 0 |
benchmark_functions_edited/f3422.py | def f(ax: int, ay: int, bx: int, by: int) -> int:
return (ax - bx) ** 2 + (ay - by) ** 2
assert f(0, 0, 0, 0) == 0 |
benchmark_functions_edited/f10737.py | def f(base_lr, epoch, total_epochs):
alpha = epoch / total_epochs
if alpha <= 0.5:
factor = 1.0
elif alpha <= 0.9:
factor = 1.0 - (alpha - 0.5) / 0.4 * 0.99
else:
factor = 0.01
return factor * base_lr
assert f(1, 0, 100) == 1 |
benchmark_functions_edited/f4941.py | def f(lst):
if len(lst) == 1:
return lst[0]
m = f(lst[1:])
if lst[0] > m:
return lst[0]
else:
return m
assert f([1, 2, 3]) == 3 |
benchmark_functions_edited/f5382.py | def f(token, default=0):
return int(token) if token.isdigit() else default
assert f(str(1)) == 1 |
benchmark_functions_edited/f7334.py | def f(a, b):
if b == 0:
raise ValueError("Cannot divide by zero!")
return a / b
assert f(0, 1) == 0 |
benchmark_functions_edited/f14138.py | def f(m: int, n: int) -> int:
if m == 1 and n == 1: return 1
if m == 0 or n == 0: return 0
return f(m - 1, n) + f(m, n - 1)
assert f(3, 3) == 6 |
benchmark_functions_edited/f2242.py | def f(list):
sum = 0
for num in list:
sum += num
return sum/len(list)
assert f( [2, 4, 6] ) == 4 |
benchmark_functions_edited/f2421.py | def f(line_str):
return len(line_str) - len(line_str.lstrip())
assert f( "return 42") == 0 |
benchmark_functions_edited/f5885.py | def f(basket, date_id):
total = 0
for type_id in basket[date_id]:
total += basket[date_id][type_id]
return total
assert f({ 1: { 1: 0 } }, 1) == 0 |
benchmark_functions_edited/f8517.py | def f(model, umap, keys):
u = tuple(model[k] for k in keys)
u = umap.setdefault(u, len(umap))
return u
assert f(
{'a': 1, 'b': 2},
{},
['a', 'b'],
) == 0 |
benchmark_functions_edited/f9905.py | def f(param, user_defined_work_func, register_cleanup, touch_files_only):
assert(user_defined_work_func)
#try:
# print sys._MEIPASS
# os.system("rm -rf %s"%(sys._MEIPASS))
#except Exception:
# pass
return user_defined_work_func(*param)
assert f((1, 2, 3),
lambda a, b, c: a + b + c,
lambda: None,
True) == 6 |
benchmark_functions_edited/f2899.py | def f(x):
a, b = x
res = a
for v in b:
res += v
return res
assert f( (1, [2, 3]) ) == 6 |
benchmark_functions_edited/f9861.py | def f(a, b):
print("a:", a, "- b:", b)
if a % b == 0:
return b
return f(b, a % b)
assert f(20, 15) == 5 |
benchmark_functions_edited/f427.py | def f(n):
return 1 << (n-1).bit_length()
assert f(1) == 1 |
benchmark_functions_edited/f13881.py | def f(data, stringlength):
value_buffer = 0
for count in range(0, stringlength):
value_buffer = value_buffer ^ data[count]
return value_buffer&0xFE
assert f(bytearray([0x00, 0x00, 0x00, 0x00, 0x00, 0x04]), 6) == 4 |
benchmark_functions_edited/f4413.py | def f(section, name):
try:
return int(section[name])
except (ValueError, TypeError, KeyError):
return 0
assert f(
{ "key": False },
"key"
) == 0 |
benchmark_functions_edited/f9723.py | def f(maximize, total_util, payoffs):
if maximize:
return int(total_util > payoffs[2])
else:
return total_util
assert f(True, 1.1, [1.1, 0, 1, 0.4]) == 1 |
benchmark_functions_edited/f13702.py | def f(cve, field):
return cve[field] if field in cve else {}
assert f(
{'a': 1, 'b': 2, 'c': 3}, 'b') == 2 |
benchmark_functions_edited/f3983.py | def f(n):
if n <= 1:
return n
return f(n - 1) + f(n - 2)
assert f(3) == 2 |
benchmark_functions_edited/f2664.py | def f(scene):
return scene[1]['_order']
assert f(
(
'key_1',
{
'_order': 0,
}
)
) == 0 |
benchmark_functions_edited/f14518.py | def f(line_or_func, lines):
if hasattr(line_or_func, '__call__'):
return line_or_func(lines)
elif line_or_func:
if line_or_func >= 0:
return line_or_func
else:
n_lines = sum(1 for line in lines)
return n_lines + line_or_func
else:
return line_or_func
assert f(1, []) == 1 |
benchmark_functions_edited/f7089.py | def f(table):
return max((len(row) for row in table))
assert f([
[1, 2, 3],
[4, 5],
[6, 7, 8, 9]
]) == 4 |
benchmark_functions_edited/f10253.py | def f(column):
try:
_=column[0]
try:
_=column[0][0]
return 2
except: return 1
except:
return 0
assert f(0) == 0 |
benchmark_functions_edited/f714.py | def f(x, col):
return x[0] * col + x[1] + 1
assert f( (0,0), 2) == 1 |
benchmark_functions_edited/f10704.py | def f(n300, n100, n50, nMiss):
return (50 * n50 + 100 * n100 + 300 * n300) / (300 * (nMiss + n50 + n100 + n300))
assert f(0, 0, 0, 3) == 0 |
benchmark_functions_edited/f7838.py | def f(step, rate, decay_steps, start_step=0):
return rate ** (max(step - start_step + decay_steps, 0) // decay_steps)
assert f(100, 1, 1) == 1 |
benchmark_functions_edited/f11770.py | def f(results):
new_result = list(results)
num_zeros = new_result.count([0])
num_ones = new_result.count([1])
if num_zeros >= num_ones: return 0
elif num_zeros < num_ones: return 1
assert f([[0]]) == 0 |
benchmark_functions_edited/f10522.py | def f(x1, w1, x2, w2):
l1 = x1 - w1 / 2.0
l2 = x2 - w2 / 2.0
left = l1 if l1 > l2 else l2
r1 = x1 + w1 / 2.0
r2 = x2 + w2 / 2.0
right = r1 if r1 < r2 else r2
return right - left
assert f(0, 1, 0, 2) == 1 |
benchmark_functions_edited/f45.py | def f(x):
return x**2 + 5
assert f(0) == 5 |
benchmark_functions_edited/f3464.py | def f(number):
return len(str(number))
assert f(3) == 1 |
benchmark_functions_edited/f5118.py | def f(args, dt_version):
if args.force_v2:
return 2
elif args.force_v3:
return 3
else:
return dt_version
assert f(type('MockNamespace', (), {'force_v2': True, 'force_v3': True}), 2) == 2 |
benchmark_functions_edited/f13346.py | def f(a,f,x):
answer = (x-a[1])*(x-a[2])/(a[0]-a[1])/(a[0]-a[2])*f[0]
answer += (x-a[0])*(x-a[2])/(a[1]-a[0])/(a[1]-a[2])*f[1]
answer += (x-a[0])*(x-a[1])/(a[2]-a[0])/(a[2]-a[1])*f[2]
return answer
assert f( [1,2,3], [3,2,1], 3) == 1 |
benchmark_functions_edited/f4024.py | def f(response):
if response['next']:
return int(response['next'].split('=')[1])
return None
assert f({
'next': '?page=3',
'other':'something'
}) == 3 |
benchmark_functions_edited/f10816.py | def f(bitfield):
count = 0
if len(bitfield) < 2:
return 0
for i in range(0, len(bitfield), 2):
count += bitfield[i+1]
return count
assert f(b"\x01\x07") == 7 |
benchmark_functions_edited/f2930.py | def f(S2,R_acq,mv_per_bin):
return S2*(mv_per_bin*1.0e-3)**2/(R_acq**2)
assert f(0,1,1) == 0 |
benchmark_functions_edited/f13221.py | def f(score: float) -> float:
if score >= 95:
return 4.0
if score <= 65:
return 0.0
return (score * 0.1) - 5.5
assert f(95.01) == 4 |
benchmark_functions_edited/f1053.py | def f(addr, mem_align):
return ((addr + (mem_align - 1)) & (~(mem_align - 1)))
assert f(0, 0x100000) == 0 |
benchmark_functions_edited/f14297.py | def f(timeseries, second_order_resolution_seconds):
try:
t = (timeseries[-1][1] + timeseries[-2][1] + timeseries[-3][1]) / 3
return t
except IndexError:
return timeseries[-1][1]
assert f(
[
[1, 1],
[2, 2],
[3, 3],
[4, 4],
[5, 5],
],
60
) == 4 |
benchmark_functions_edited/f9965.py | def f(iterable):
max_i = -1
max_v = float('-inf')
for i, iter in enumerate(iterable):
temp = max_v
max_v = max(iter,max_v)
if max_v != temp:
max_i = i
return max_i
assert f( [1, 4, 3, 3, 3] ) == 1 |
benchmark_functions_edited/f2824.py | def f(x: int) -> int:
return 5 + x * (3 + x * (4))
assert f(0) == 5 |
benchmark_functions_edited/f6975.py | def f(labels, x_min: float, x_max: float) -> float:
return 1 - 5 * ((x_max - labels[-1]) ** 2 + (x_min - labels[0]) ** 2) / (
(x_max - x_min) ** 2
)
assert f(
[3, 5, 6], 3, 6
) == 1 |
benchmark_functions_edited/f5001.py | def f(jewels, stones):
count = 0
for j in jewels:
count += stones.count(j)
return count
assert f("z", "ZZ") == 0 |
benchmark_functions_edited/f6107.py | def f(text):
return int(text) if text.isdigit() else text
assert f('0') == 0 |
benchmark_functions_edited/f11881.py | def f(a):
if isinstance(a, (list, tuple)):
depth = 1 + max(f(item) for item in a)
else:
depth = 0
return depth
assert f([1, 2, 3, 4, 5]) == 1 |
benchmark_functions_edited/f3130.py | def f(n):
count = 0
while (n):
count += n & 1
n >>= 1
return count
assert f(3) == 2 |
benchmark_functions_edited/f5549.py | def f(items):
return min([(item, index) for index, item in enumerate(items)])[1]
assert f([-1]) == 0 |
benchmark_functions_edited/f225.py | def f(x):
return (2 * x**3 - 3 * x) * 3**-0.5
assert f(0) == 0 |
benchmark_functions_edited/f9181.py | def f(s):
try:
return int(s)
except ValueError:
if s.lower() == "adaptive":
return s.lower()
else:
raise ValueError(f'String {s} must be integer or string "adaptive".')
assert f("5") == 5 |
benchmark_functions_edited/f14121.py | def f(set1, set2):
diffs = [x for x in set1 if x not in set2] + [x for x in set2 if x not in set1]
return len(diffs)
assert f(set([1,2]), set([1,2])) == 0 |
benchmark_functions_edited/f13199.py | def f(a, b):
if a.real < b.real: return -1
elif a.real > b.real: return 1
elif a.imag < b.imag: return -1
elif a.imag > b.imag: return 1
else: return 0
assert f(2+1j, 1) == 1 |
benchmark_functions_edited/f11752.py | def f(s):
was = dict()
n = len(s)
for i in range(n):
for j in range(i, n):
cur = s[i:j + 1]
cur = ''.join(sorted(cur))
was[cur] = was.get(cur, 0) + 1
ans = 0
for x in was:
v = was[x]
ans += (v * (v - 1)) // 2
return ans
assert f(
'ifailuhkqq') == 3 |
benchmark_functions_edited/f3087.py | def f(node, root):
count = 0
for c in node:
if c == root: count += 1
return count
assert f(
"x*y**2-1",
"+"
) == 0 |
benchmark_functions_edited/f6193.py | def f(a, b):
if 0 in [a,b]: return False # You can never divide by 0, so this should fail
while b:
a, b = b, a%b
return a
assert f(10, 0) == 0 |
benchmark_functions_edited/f8298.py | def f(v, lo, hi):
assert lo <= hi
if v < lo:
return lo
elif v > hi:
return hi
else:
return v
assert f(4, 0, 1) == 1 |
benchmark_functions_edited/f2604.py | def f(value, alignment):
return (value + (alignment - 1)) // alignment * alignment
assert f(1, 1) == 1 |
benchmark_functions_edited/f14354.py | def f(errors1, prob1, errors2, prob2, alpha):
result = errors1 + ((errors2 - errors1) * ((1 - alpha) - prob1) / (prob2 - prob1))
if result < 0:
#Happens only for very-short high qual sequences in which the probability of having 0 errors is higher than 1 - alpha.
result = 0
return result
assert f(2, 0.75, 0, 0.25, 0.75) == 0 |
benchmark_functions_edited/f12125.py | def f(marks):
top6 = []
for x in marks:
if len(top6) >= 6:
if x > min(top6):
top6.pop(top6.index(min(top6)))
top6.append(x)
else:
top6.append(x)
top6.sort()
return top6[2]
assert f([1,2,3,4,5,5]) == 3 |
benchmark_functions_edited/f8546.py | def f(seq, func, maxobj=None):
maxscore = None
for obj in seq:
score = func(obj)
if maxscore is None or maxscore < score:
(maxscore, maxobj) = (score, obj)
return maxobj
assert f(range(10), lambda i: 10-i) == 0 |
benchmark_functions_edited/f7692.py | def f(val: int, bits: int) -> int:
if (val & (1 << (bits - 1))) != 0:
val = val - (1 << bits)
return val
assert f(0, 8) == 0 |
benchmark_functions_edited/f5218.py | def f(result):
if result == 'notapplicable':
return -1
if result == 'pass':
return 1
return 0
assert f("pass") == 1 |
benchmark_functions_edited/f7646.py | def f(item, transactions):
occurence = 0
for transaction in transactions:
if set(item) <= set(transaction):
occurence +=1
return occurence
assert f(frozenset({'a', 'b', 'c'}),
[{'a', 'b', 'c', 'd', 'e'}]) == 1 |
benchmark_functions_edited/f7710.py | def f(v1, v2):
if v1 is None:
return v2
if v2 is None:
return v1
return min(v1, v2)
assert f(3, 3) == 3 |
benchmark_functions_edited/f9651.py | def f(data: dict, Dict_map: list):
for index in Dict_map:
try:
data = data[index]
except (IndexError, KeyError):
return
return data
assert f(
{"a": [{"b": {"c": 0}}]},
[
"a",
0,
"b",
"c",
],
) == 0 |
benchmark_functions_edited/f4267.py | def f(k):
return int((k*k)/4)
assert f(2) == 1 |
benchmark_functions_edited/f10997.py | def f(card):
if card[0] >= '2' and card[0] <= '9':
return int(card[0])
elif card[0] == 'T':
return 10
elif card[0] == 'J':
return 11
elif card[0] == 'Q':
return 12
elif card[0] == 'K':
return 13
elif card[0] == 'A':
return 14
assert f('2') == 2 |
benchmark_functions_edited/f11599.py | def f(length_descriptor):
assert 0 <= length_descriptor <= 0xFF
length = 0
for i in range(8): # big endian
if (length_descriptor & (0x80 >> i)) != 0: # 128, 64, 32, ..., 1
length = i + 1
break
assert 0 <= length <= 8
return length
assert f(0b00000101) == 6 |
benchmark_functions_edited/f8126.py | def f(x, y):
if len(x) != len(y):
raise Exception("The sequences must be of the same lenght.")
prod = 0
for i in range(len(x)):
prod += x[i] * y[i]
return prod
assert f( [1, 1, 1, 1], [0, 0, 0, 0] ) == 0 |
benchmark_functions_edited/f1128.py | def f(x, a, b, c) :
return a*x*x + b*x + c
assert f(1, 1, 2, 3) == 6 |
benchmark_functions_edited/f1973.py | def f(d):
return d.get('H', 0) + d.get('G', 0) + d.get('I', 0)
assert f(dict()) == 0 |
benchmark_functions_edited/f2143.py | def f(curve):
# this should be optimized
return sum(curve)
assert f(
(0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0)
) == 1 |
benchmark_functions_edited/f12916.py | def f(se):
varcope = se ** 2
return varcope
assert f(0) == 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.