file_name stringlengths 32 36 | content stringlengths 44 898 |
|---|---|
benchmark_functions_edited/f11261.py | def f(a):
x = 0
while a * x % 97 != 1:
x = x + 1
return x
assert f(1) == 1 |
benchmark_functions_edited/f217.py | def f(l):
a = sorted(l)
return a[0]
assert f([11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) == 1 |
benchmark_functions_edited/f10980.py | def f(seq1, seq2):
distance = 0
for i, letter in enumerate(seq1):
if letter != seq2[i]:
distance += 1
return distance
assert f(
"ACGTA", "ACGTA") == 0 |
benchmark_functions_edited/f13387.py | def f(probability: float) -> float:
return 4 * probability - 3
assert f(1) == 1 |
benchmark_functions_edited/f3719.py | def f(x1: float, y1: float, x2: float, y2: float) -> complex:
return ((x2 - x1) ** 2) + ((y2 - y1) ** 2)
assert f(0, 0, 1, 1) == 2 |
benchmark_functions_edited/f3898.py | def f(number, digit):
return int(str(number)[-digit])
assert f(12345, 0) == 1 |
benchmark_functions_edited/f10535.py | def f(spiketrains):
if spiketrains is None or spiketrains == 0:
return 0
max_val = -1000000
for spiketrain in spiketrains:
if len(spiketrain) > max_val:
max_val = len(spiketrain)
return max_val
assert f(None) == 0 |
benchmark_functions_edited/f1094.py | def f(u):
return len([val for val in u if val != 0])
assert f([0, 1, 2, 0, 3, 0]) == 3 |
benchmark_functions_edited/f2990.py | def f(dates):
return sum([day - 40 for day in dates if day > 40])
assert f(list(range(40))) == 0 |
benchmark_functions_edited/f8429.py | def f(timestamp, n=32):
return int(abs(timestamp - int(timestamp)) * 2**n)
assert f(123456789.00) == 0 |
benchmark_functions_edited/f1909.py | def f(text, pos):
return text.count('\n', 0, pos) + 1
assert f('\n\n', 3) == 3 |
benchmark_functions_edited/f4990.py | def f(arr, t):
for i, x in enumerate(arr):
if x >= t:
return i
return len(arr)
assert f([], -1) == 0 |
benchmark_functions_edited/f11009.py | def f(array):
if type(array) is list:
return len(array)
else:
return array.shape[0]
assert f(list([1])) == 1 |
benchmark_functions_edited/f5591.py | def f(int_type):
length = 0
while int_type:
int_type >>= 1
length += 1
return length
assert f(5) == 3 |
benchmark_functions_edited/f7496.py | def f(f, y0, dt):
k1 = f(y0)
k2 = f(y0 + 0.5 * dt * k1)
k3 = f(y0 + 0.5 * dt * k2)
k4 = f(y0 + dt * k3)
y1 = y0 + dt / 6 * (k1 + 2 * (k2 + k3) + k4)
return y1
assert f(lambda y: 0 * y, 1, 0.5) == 1 |
benchmark_functions_edited/f552.py | def f(a, b):
c = a + b
print("{} + {} = {}".format(a, b, c))
return c
assert f(2, 2) == 4 |
benchmark_functions_edited/f13754.py | def f(time):
hour = int(time.split(":")[0])
minute = int(time.split(":")[1])
return hour/24 + minute/1440
assert f("00:00") == 0 |
benchmark_functions_edited/f7096.py | def f(num1, num2=0):
return (num1+num2)
assert f(0) == 0 |
benchmark_functions_edited/f12884.py | def f(draw, a, b):
return sum(1 for d in draw if a < d < b)
assert f(
[1, 1.2, 1.4, 1.5, 1.7],
2,
3,
) == 0 |
benchmark_functions_edited/f2903.py | def f(poly, poly1):
return not (poly-poly1)
assert f(set([1, 2]), set([2, 3])) == 0 |
benchmark_functions_edited/f7699.py | def f(wrappers, multi_env):
if wrappers is None:
wrappers = []
for wrap in wrappers:
multi_env = wrap(multi_env)
return multi_env
assert f([lambda e: e], 1) == 1 |
benchmark_functions_edited/f10564.py | def f(A):
def prod(a, b):
n = b - a
if n < 24:
p = 1
for k in range(a, b + 1):
p *= A[k]
return p
m = (a + b) // 2
return prod(a, m) * prod(m + 1, b)
return prod(0, len(A) - 1)
assert f(range(0, 5)) == 0 |
benchmark_functions_edited/f2835.py | def f(sc_len,edit_frac):
return(float(sc_len*edit_frac))
assert f(10,0.2) == 2 |
benchmark_functions_edited/f13850.py | def f(sentence_aligned_corpus):
max_m = 0
for aligned_sentence in sentence_aligned_corpus:
m = len(aligned_sentence.words)
max_m = max(m, max_m)
return max_m
assert f([]) == 0 |
benchmark_functions_edited/f1161.py | def f(mass: int) -> int:
return (mass // 3) - 2
assert f(12) == 2 |
benchmark_functions_edited/f6651.py | def f(R_c, I):
R_min, R_max = R_c
Ihi = (I - R_max) * (I > R_max)
Ilo = (R_min - I) * (R_min > I)
return Ihi + Ilo
assert f((1,2), 1) == 0 |
benchmark_functions_edited/f6506.py | def f(vals):
return sum(val**2 for val in vals)
assert f([1, 2]) == 5 |
benchmark_functions_edited/f14493.py | def f(points, marker):
for index, point in enumerate(points):
if (
point["x"] == marker["x"]
and point["y"] == marker["y"]
and point["z"] == marker["z"]
):
return index
return None
assert f(
[{"x": 1, "y": 1, "z": 1}, {"x": 1, "y": 1, "z": 1}],
{"x": 1, "y": 1, "z": 1},
) == 0 |
benchmark_functions_edited/f4722.py | def f(t, Tf, dt_frames=0.25):
return int(t // Tf) // dt_frames
assert f(0.1, 1.0) == 0 |
benchmark_functions_edited/f10079.py | def f(n, r):
memo = {}
def recur(n, r):
if n == r or r == 0:
return 1
if (n, r) not in memo:
memo[(n, r)] = recur(n - 1, r - 1) + recur(n - 1, r)
return memo[(n, r)]
return recur(n, r)
assert f(4, 3) == 4 |
benchmark_functions_edited/f7910.py | def f(section, y):
best_i=-1
dist=1e5
for i in range(len(section)):
d=min(abs(section[i][0]-y), abs(section[i][1]-y))
if d < dist:
best_i=i
dist=d
return best_i
assert f( [[0,1], [2,3], [4,5]], -0.5) == 0 |
benchmark_functions_edited/f11168.py | def f(iterable, what, test='equality'):
if test=='equality':
for index, item in enumerate(iterable):
if item == what:
break
else:
index = None
else:
raise NotImplementedError
return index
assert f( [1,2,3], 3) == 2 |
benchmark_functions_edited/f9649.py | def f(pitches: list) -> int:
return max(pitches) - min(pitches)
assert f(
[60, 62, 64, 65, 60]
) == 5 |
benchmark_functions_edited/f7390.py | def f(vals):
max_val = -float("inf")
for val in vals:
if isinstance(val, int) and val > max_val:
max_val = val
return max_val
assert f( [5, 4, 3, 2, 1] ) == 5 |
benchmark_functions_edited/f10060.py | def f(period1:int, start1:int, period2:int, start2:int)->int:
val = start1
while (val - start2) % period2:
val += period1
return val
assert f(1, 0, 10, 5) == 5 |
benchmark_functions_edited/f12657.py | def f(value):
value = abs(value)
result = 0
while value > 0:
result += value % 10
value //= 10
return result
assert f(0) == 0 |
benchmark_functions_edited/f4325.py | def f(data, num):
base = int(num // 8)
shift = 7 - int(num % 8)
return (data[base] & (1 << shift)) >> shift
assert f(bytes([0b00000001]), 1) == 0 |
benchmark_functions_edited/f1908.py | def f(n):
if n <= 1:
return n
return f(n - 1) + f(n - 2)
assert f(4) == 3 |
benchmark_functions_edited/f4053.py | def f(word, histogram):
return histogram.get(word) / sum(histogram.values())
assert f(0, {0: 1}) == 1 |
benchmark_functions_edited/f1304.py | def f(a, b):
result = a + b
return result
assert f(10, -2) == 8 |
benchmark_functions_edited/f14267.py | def f(cigarOps, currOffset):
if not cigarOps:
return currOffset
off = 0
# recompute the current substring position in the read
for cig in cigarOps:
if cig.op != 'D':
off += cig.size
# and return the amount needed to be consumed...
return currOffset - off
assert f([], 0) == 0 |
benchmark_functions_edited/f7510.py | def f(x, amplitude=1, center=0., sigma=1, beta=1.):
return amplitude / (((x - center)/sigma)**2 + 1)**beta
assert f(1, 1, 1) == 1 |
benchmark_functions_edited/f2968.py | def f(number):
print("Inside f()")
return number * 2
assert f(1) == 2 |
benchmark_functions_edited/f6588.py | def f(*nums: int or float) -> float:
return sum(nums) / len(nums)
assert f(3, 2, 1) == 2 |
benchmark_functions_edited/f9914.py | def f(val, parse_func, vtype):
if val is None:
return None
if isinstance(val, str):
val = parse_func(val)
if not isinstance(val, vtype):
raise TypeError("expect %s for %s" % (vtype, type(val)))
return val
assert f(1, int, int) == 1 |
benchmark_functions_edited/f2315.py | def f(data):
return max(data[0][1], data[1][1], data[2][1], data[3][1])
assert f(
[(0, 0), (1, 1), (2, 1), (2, 0)]
) == 1 |
benchmark_functions_edited/f2086.py | def f(a, b):
return abs(a[0] - b[0]) + abs(a[1] - b[1])
assert f( (0, 0), (3, 4) ) == 7 |
benchmark_functions_edited/f4826.py | def f(x: float) -> int:
retVal = 0
if x > 0:
retVal = 1
elif x < 0:
retVal = -1
return retVal
assert f(10000) == 1 |
benchmark_functions_edited/f1443.py | def f(graph):
return 1 + max((max(edge) for edge in graph))
assert f(set([frozenset((1, 2))])) == 3 |
benchmark_functions_edited/f3050.py | def f(numerator: float, denominator: float) -> float:
return (denominator / numerator) * 12
assert f(12, 1) == 1 |
benchmark_functions_edited/f7411.py | def f(a,b,c,d):
if a > b: ab = a*(a+1)/2 + b
else: ab = b*(b+1)/2 + a
if c > d: cd = c*(c+1)/2 + d
else: cd = d*(d+1)/2 + c
if ab > cd: abcd = ab*(ab+1)/2 + cd
else: abcd = cd*(cd+1)/2 + ab
return int(abcd)
assert f(2,0,0,0) == 6 |
benchmark_functions_edited/f14032.py | def f(number):
if number < 1:
raise ValueError("Provided number is less than 1.")
steps = 0
while number != 1:
steps += 1
# Even
if number % 2 == 0:
number = number / 2
else:
number = number * 3 + 1
return steps
assert f(2) == 1 |
benchmark_functions_edited/f10829.py | def f(blk, p0, p1, bsf):
if blk[p0:p0+bsf+1] != blk[p1:p1+bsf+1]:
return 0
for i in range(bsf + 1, len(blk) - p1):
if blk[p0:p0+i] != blk[p1:p1+i]:
return i - 1
return len(blk) - p1 - 1
assert f(b'x', 0, 0, 5) == 0 |
benchmark_functions_edited/f1284.py | def f(byte_array: bytes) -> int:
return int.from_bytes(byte_array, byteorder='big')
assert f(b'\x00\x01') == 1 |
benchmark_functions_edited/f8367.py | def f(arr: list):
if arr == []:
return 0
else:
head = arr[0]
smallerList = arr[1:]
return head + f(smallerList)
assert f([1]) == 1 |
benchmark_functions_edited/f1158.py | def f(ew):
return (((ew - 40) + 52) % 52) // 4 + 1
assert f(201046) == 7 |
benchmark_functions_edited/f1373.py | def f(x, y):
return (1 - x[0]) * y[0]
assert f( [1, 1, 0], [1, 0, 1] ) == 0 |
benchmark_functions_edited/f4946.py | def f(obj):
if not isinstance(obj, (list, tuple)):
return 1
else:
return sum([f(x) for x in obj])
assert f([1, [2, 3], 4, [5, [6, 7], 8]]) == 8 |
benchmark_functions_edited/f6238.py | def f(word):
if '+' in word:
return 1
return 0
assert f('+x+y+') == 1 |
benchmark_functions_edited/f1801.py | def f(x, y):
if x is None or y is None:
return None
return round(x / y)
assert f(1, 1) == 1 |
benchmark_functions_edited/f4038.py | def f(x, n):
return ((x << n) & 0xffffffff) + (x >> (32 - n))
assert f(0, 11) == 0 |
benchmark_functions_edited/f5719.py | def f(predicate, iterable):
for item in iterable:
if predicate(item):
return item
assert f(lambda x: x == 2, [2, 3, 4]) == 2 |
benchmark_functions_edited/f569.py | def f(v1, v2):
return v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2]
assert f( [0,0,0], [1,2,3] ) == 0 |
benchmark_functions_edited/f4189.py | def f(lst):
if not type(lst) == list:
return 0
return len(lst) + f(lst[0])
assert f(False) == 0 |
benchmark_functions_edited/f2848.py | def f(x, wave):
y = ((-wave[1] / wave[2]) * x) - (wave[0] / wave[2])
return y
assert f(1, (0, -1, 1)) == 1 |
benchmark_functions_edited/f3768.py | def f(a, b):
best = 0
for d in range(2, a + b):
if not a % d and not b % d:
best = d
return best
assert f(4, 6) == 2 |
benchmark_functions_edited/f1805.py | def f(n):
if n < 10:
return n
else:
return n % 10 + f(n // 10)
assert f(100) == 1 |
benchmark_functions_edited/f7266.py | def f(document, search_term):
words = document.split()
answer = 0
for word in words:
if word == search_term:
answer += 1
return answer
assert f(
"My name is Bob.", "is"
) == 1 |
benchmark_functions_edited/f8251.py | def f(str_name_id):
import re
numbers = re.findall(r'[0-9]+', str_name_id)
if len(numbers) > 0:
return float(numbers[-1])
return -1
assert f(u"Frame 3") == 3 |
benchmark_functions_edited/f8881.py | def f(references, candidates):
exact_match = 0
for img in references:
candidate_smi = ''
if img in candidates and references[img] == candidates[img]:
exact_match += 1
return exact_match
assert f(
{'0': 'C1=CC=C(C(=C1)C#N)O', '1': 'C1=CC=C(C(=C1)O)O'},
{'0': 'C1=CC=C(C(=C1)C#N)O'}
) == 1 |
benchmark_functions_edited/f13134.py | def f(values, ratio=0.95):
values.sort(reverse=True)
weight = 1
heat = 0
for i in range(len(values)):
heat += values[i]*weight
weight *= ratio
return heat
assert f( [] ) == 0 |
benchmark_functions_edited/f8812.py | def f(nm):
return int(nm.split("/")[-1].split("-")[3][3:5])
assert f(
"/path/to/data/ABI-L1b-RadM/2019/05/31/OR_ABI-L1b-RadM1-M6C08_G16_s20193003539244_e20193003539259_c20193003539311.nc"
) == 8 |
benchmark_functions_edited/f1626.py | def f(x):
return 3 * x ** 2 - 4 * x
assert f(0) == 0 |
benchmark_functions_edited/f11898.py | def f(count, t, total_number_of_paths):
total_number_of_paths += count[t][2]
# Calculate ratio of positive and negative paths
count[t][0] = 0 if not count[t][2] else round(count[t][0] / count[t][2], 2)
count[t][1] = 0 if not count[t][2] else round(count[t][1] / count[t][2], 2)
return total_number_of_paths
assert f(
{"pos_neg": [0, 0, 0]},
"pos_neg",
0) == 0 |
benchmark_functions_edited/f5488.py | def f(word, sep):
return len(word.split(sep))
assert f(u"a", u"a") == 2 |
benchmark_functions_edited/f10365.py | def f(guess, answer, turns):
if guess > answer:
print("Too high.")
return turns - 1
elif guess < answer:
print("Too low.")
return turns - 1
else:
print(f"You got it! The answer was {guess}.")
assert f(1, 5, 1) == 0 |
benchmark_functions_edited/f5021.py | def f(n, m):
if(n < m):##swaps n and m
n ^= m
m ^= n
n ^= m
while(m!=0):
k = n%m
n = m
m = k
return n
assert f(1, 13) == 1 |
benchmark_functions_edited/f5349.py | def f(s):
return len(s) - len(s.lstrip(' '))
assert f(u' a') == 2 |
benchmark_functions_edited/f2555.py | def f(bit):
if bit != -1:
return 1 - bit
return bit
assert f(1) == 0 |
benchmark_functions_edited/f6767.py | def f(search_input: str, post: str) -> int:
elem_length = 2 ** len(search_input)
elem = 0
for char in search_input:
elem_length //= 2
if char == post:
elem += elem_length
return elem
assert f(
'abcd',
'd'
) == 1 |
benchmark_functions_edited/f4337.py | def f(n, base):
return n - int(n / base) * base
assert f(4, 2) == 0 |
benchmark_functions_edited/f12354.py | def f(target_list, compared_list):
intersection = [e for e in target_list if e in compared_list]
return len(intersection)/len(target_list)
assert f(list('cat'), list('cat')) == 1 |
benchmark_functions_edited/f8301.py | def f(num, a, b):
return max(min(num, max(a, b)), min(a, b))
assert f(1.1, 2, 3) == 2 |
benchmark_functions_edited/f7013.py | def f(n):
if n == 0:
return 0
if n == 1:
return 1
return f(n-1) + f(n-2)
assert f(1) == 1 |
benchmark_functions_edited/f8496.py | def f(L):
result = L[0]
for x in L:
if x < result:
result = x
return result
assert f([0, 0.3, 0.3, 0.3, 0.3]) == 0 |
benchmark_functions_edited/f57.py | def f(b):
return 0 if b == 0 else 1
assert f(1+1j) == 1 |
benchmark_functions_edited/f1111.py | def f(val: int, bitNo: int) -> int:
return val | (1 << bitNo)
assert f(2, 2) == 6 |
benchmark_functions_edited/f8437.py | def f(value, min, max, reverse=False):
values = range(min, max + 1)
if reverse:
index = values.index(value) - 1
else:
index = values.index(value) + 1
return values[index % len(values)]
assert f(0, 0, 10) == 1 |
benchmark_functions_edited/f7164.py | def f(s1,s2) -> float:
return 2*len(s1&s2)/(len(s1)+len(s2))
assert f({1,2},{1,2}) == 1 |
benchmark_functions_edited/f11142.py | def f(new, original, lowerize=True):
if lowerize:
new = new.lower()
original = original.lower()
len_diff = abs(len(new) - len(original))
length = min(len(new), len(original))
for i in range(length):
len_diff += not(new[i] == original[i])
return len_diff
assert f('abc', 'abc', False) == 0 |
benchmark_functions_edited/f11369.py | def f(m, n):
if m == 0:
return n + 1
if (m > 0) and (n == 0):
return f(m - 1, 1)
if (m > 0) and (n > 0):
return f((m - 1), f(m, (n - 1)))
return None
assert f(0, 1) == 2 |
benchmark_functions_edited/f823.py | def f(value, lsb, width):
return (value >> lsb) & ((1 << width) - 1)
assert f(0x00000010, 0, 1) == 0 |
benchmark_functions_edited/f8899.py | def f(sdb, propcode, blocks):
for b in blocks:
if propcode == b[2]:
record = sdb.select('BlockRejectedReason_Id', 'BlockVisit', 'BlockVisit_Id=%i' % b[0])[0][0]
return record
return 0
assert f(None, 1, [(1, 2, 2)]) == 0 |
benchmark_functions_edited/f121.py | def f(e):
return e(lambda x: x + 1)(0)
assert f(lambda x: x) == 1 |
benchmark_functions_edited/f2699.py | def f(num1: float, num2: float) -> float:
result = num1 + num2
print(f"{num1} + {num2} = {result}")
return result
assert f(3, 4) == 7 |
benchmark_functions_edited/f11642.py | def f(readfn):
b = ord(readfn(1))
i = b & 0x7F
shift = 7
while b & 0x80 != 0:
b = ord(readfn(1))
i |= (b & 0x7F) << shift
shift += 7
return i
assert f(lambda n: b"\x00") == 0 |
benchmark_functions_edited/f8482.py | def f(ls, dict):
ls_len = len(ls)
if ls_len % 2 != 0:
return -1
i = 0
while i < ls_len:
dict[ls[i]] = ls[i+1]
i = i + 2
return 0
assert f(
["apple", "pear", "apple", "banana", "pear", "orange", "banana", "apple"],
{"apple": "fruit", "banana": "fruit", "pear": "fruit", "orange": "fruit"}
) == 0 |
benchmark_functions_edited/f14551.py | def f(v, divisible_by, min_value=None):
if min_value is None:
min_value = divisible_by
new_v = max(min_value, int(v + divisible_by / 2) // divisible_by * divisible_by)
# Make sure that round down does not go down by more than 10%.
if new_v < 0.9 * v:
new_v += divisible_by
return new_v
assert f(5, 4) == 8 |
benchmark_functions_edited/f3162.py | def f(cm, vi):
vf = cm * vi
return vf
assert f(0, 0) == 0 |
benchmark_functions_edited/f10850.py | def f(data, *, default=None):
if data:
try:
return int(data)
except (ValueError, TypeError):
return default
else:
return default
assert f(1.111) == 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.