file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f12046.py
def f(t, D_o, P_o, sig): return ((sig * 2 * t) / D_o) + P_o assert f(0.05, 0.01, 0, 0) == 0
benchmark_functions_edited/f2463.py
def f(num): s = bin(num) s = s.lstrip('-0b') return len(s) assert f(18) == 5
benchmark_functions_edited/f9142.py
def f(x): return max(x) - min(x) assert f(range(5)) == 4
benchmark_functions_edited/f14447.py
def f(k, arr): dictionary = {i : i for i in arr} total = 0 for num in arr: complement = num - k if complement < 0: continue if complement in dictionary: total += 1 return total assert f(7, [1, 2, 3, 4]) == 0
benchmark_functions_edited/f11711.py
def f(file_obj): return sum(1 for line in file_obj if line[:4] == b'$$$$') assert f(open('empty.sdf', 'r')) == 0
benchmark_functions_edited/f11582.py
def f(list1, list2): import itertools it = itertools.zip_longest(list1, list2, fillvalue='Missing!') for i, (s1, s2) in enumerate(it): if s1 != s2: return i return None assert f( ["Line 1", "Line 2", "Line 3"], ["Line 1", "Line 2", "Line 4"]) == 2
benchmark_functions_edited/f7418.py
def f(rating) -> int: rating = int(rating) if rating <= 2: return 0 elif rating == 3: return 1 else: return 2 assert f(5) == 2
benchmark_functions_edited/f9259.py
def f(a, b): diff = [key for key in a if a[key] != b[key]] return len(diff) assert f( {'a': 5, 'b': 6}, {'a': 5, 'b': 5}, ) == 1
benchmark_functions_edited/f8466.py
def f(*args): total = 0 for arg in args: if type(arg) is int: total += arg return total assert f(1, 2, 3) == 6
benchmark_functions_edited/f9866.py
def f(ar, n): if n == 0: return 1 if ar[n] is not None: return ar[n] else: print("call---" + str(n)) ar[n] = n * f(ar, n - 1) return ar[n] assert f(None, 0) == 1
benchmark_functions_edited/f3798.py
def f(a, D): return (a*1e-3) / (6*D) assert f(0, 1) == 0
benchmark_functions_edited/f1196.py
def f(a, b): return (a + b) & 0xFFFFFFFFFFFFFFFF assert f(0, 0) == 0
benchmark_functions_edited/f7577.py
def f(score, opponent_score): # BEGIN PROBLEM 11 "*** REPLACE THIS LINE ***" return 4 # Replace this statement # END PROBLEM 11 assert f(20, 10) == 4
benchmark_functions_edited/f11813.py
def f(passW,tags): connection=0 for i in tags: if(i.name.lower() in passW.lower()): print("[Found Connection]>",i.name.lower()) connection += i.priority/2 return connection assert f("Nicolas", []) == 0
benchmark_functions_edited/f14148.py
def f(config, n_iter): ranges = [i for i in range(len(config) - 1) if config[i][0] <= n_iter < config[i + 1][0]] if len(ranges) == 0: assert n_iter >= config[-1][0] return config[-1][1] assert len(ranges) == 1 i = ranges[0] x_a, y_a = config[i] x_b, y_b = config[i + 1] return y_a + (n_iter - x_a) * float(y_b - y_a) / float(x_b - x_a) assert f( [(0, 1), (10, 1), (20, 0.1), (30, 1)], 10) == 1
benchmark_functions_edited/f5647.py
def f(array): count = 0 for _ in array: count += 1 return count assert f((0, 1, 2)) == 3
benchmark_functions_edited/f5779.py
def f(thread): if not thread['children']: return 1 return 1 + max([f(reply) for reply in thread['children']]) assert f({"children": []}) == 1
benchmark_functions_edited/f9556.py
def f(baseSize, datasetSize, numTests): return min(max(int(baseSize / (numTests * datasetSize)), 5), 200) assert f(100, 10, 2) == 5
benchmark_functions_edited/f8892.py
def f(iterable): it = iter(iterable) return next(it) assert f(x for x in range(1, 1000000)) == 1
benchmark_functions_edited/f11622.py
def f(lst): Y_longest_run = count = 0 current = lst[0] for outcome in lst: if outcome == current: count += 1 else: count = 1 current = outcome Y_longest_run = max(count, Y_longest_run) return Y_longest_run assert f([0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1]) == 3
benchmark_functions_edited/f10266.py
def f(*args): args_without_none = [n for n in args if n is not None] if not args_without_none: return None return min(args_without_none) assert f(None, 0, 1) == 0
benchmark_functions_edited/f12530.py
def f(risk): _index = 0 if risk >= 0.9 and risk < 1.2: _index = 1 elif risk >= 1.2 and risk <= 1.5: _index = 2 elif risk > 1.5: _index = 3 return _index assert f(3.4) == 3
benchmark_functions_edited/f494.py
def f(Qi, Qe): Ql = 1/(1/Qi+1/Qe) return Ql assert f(2, 2) == 1
benchmark_functions_edited/f8970.py
def f(pl, ps): n = len(ps) are = 0 for i in range(n): j = (i + 1) % n if ps[i] in pl and ps[j] in pl: are += (pl[ps[i]][0] + pl[ps[j]][0]) * (pl[ps[i]][1] - pl[ps[j]][1]) return are / 2 assert f( {'a': (1, 2), 'b': (3, 1), 'c': (0, 2)}, [] ) == 0
benchmark_functions_edited/f612.py
def f(a,b): return a[0]*b[0] + a[1]*b[1] + a[2]*b[2]; assert f( [0,0,1], [0,1,0] ) == 0
benchmark_functions_edited/f10743.py
def f(p1, p2): distance = 0 for dim in range(len(p1)): distance += abs(p1[dim] - p2[dim]) return distance assert f( (1, 2), (1, 1) ) == 1
benchmark_functions_edited/f2000.py
def f( ndvi ): ndvimin = 0.05 ndvimax = 0.95 return ( ( ndvi - ndvimin ) / ( ndvimax - ndvimin ) ) assert f( 0.95 ) == 1
benchmark_functions_edited/f5324.py
def f(r, g, b): return ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3) assert f(0, 0, 0) == 0
benchmark_functions_edited/f7378.py
def f(n: int) -> int: total = 0 while n: n -= 1 if n % 2 == 1: total += n * n return total assert f(1) == 0
benchmark_functions_edited/f13490.py
def f(d, path): my_d = d for key in path: my_d = my_d[key] return my_d assert f( { "a": 1, "b": { "c": 2, "d": [ {"e": 3}, ], }, }, ["b", "d", 0, "e"] ) == 3
benchmark_functions_edited/f10273.py
def f(d): return max(d, key=lambda k: d[k]) assert f( {1: 1, 2: 2, 3: 3, 4: 1} ) == 3
benchmark_functions_edited/f6497.py
def f(start, stop, step=1): return (stop - start + step - 1 + 2 * (step < 0)) // step assert f(10, 2, -5) == 2
benchmark_functions_edited/f4380.py
def f(n1, v1): if v1 >= n1: return n1 while n1 % v1 != 0: v1 -= 1 return v1 assert f(2, 3) == 2
benchmark_functions_edited/f6746.py
def f(num_list): return_value = None for num in num_list: if return_value is None or num > return_value: return_value = num return return_value assert f([4, 3]) == 4
benchmark_functions_edited/f12164.py
def f(nCols, nRows, col, row): return (nRows - row) * (nCols - col + 1) assert f(1000, 1000, 1000, 1000) == 0
benchmark_functions_edited/f3095.py
def f(num_list): product = 1 for x in num_list: product *= x return product assert f(list(range(0))) == 1
benchmark_functions_edited/f3279.py
def f(val): return int(val.replace(',', '').replace('MW', '')) assert f('1MW') == 1
benchmark_functions_edited/f9380.py
def f(c): if ord(c) >= ord('a') and ord(c) <= ord('z'): return (ord(c) - ord('a')) + 6 if ord(c) >= ord('1') and ord(c) <= ord('5'): return (ord(c) - ord('1')) + 1 return 0 assert f( '5') == 5
benchmark_functions_edited/f6638.py
def f(rho, vel, dvisc, length=0.05): #put len as 0.05, for all typical meteorites return rho * vel * length / dvisc assert f(1, 1, 1, 1) == 1
benchmark_functions_edited/f4156.py
def f(n): assert isinstance(n, int), 'Argument to sum_squares must be an integer.' return int((n*(n+1)*(2*n+1))//6) assert f(2) == 5
benchmark_functions_edited/f5554.py
def f(meters: int) -> float: # meters * 360 / (2 * PI * 6400000) # multiply by (1/cos(lat) for longitude) return meters * 1 / 111701 assert f(0) == 0
benchmark_functions_edited/f12302.py
def f(cpf, position): # type: (str, int) -> int val = sum(int(digit) * weight for digit, weight in zip(cpf, range(position, 1, -1))) % 11 return 0 if val < 2 else 11 - val assert f(str(10), 0) == 0
benchmark_functions_edited/f4725.py
def f(x, y): ret = 0 for i in range(64): if (x & (1 << i)) != 0: ret ^= y << i return ret assert f(0, 1) == 0
benchmark_functions_edited/f3541.py
def f(x, y): x = abs(x) y = abs(y) while x > 0: x, y = y % x, x return y assert f(123, 1234) == 1
benchmark_functions_edited/f13014.py
def f(a, b): m = 0 # matches mm = 0 # mismatches for A, B in zip(list(a), list(b)): if A == '.' or B == '.': continue if A == '-' and B == '-': continue if A == B: m += 1 else: mm += 1 try: return float(float(m)/float((m + mm))) * 100 except: return 0 assert f(str(''), str('')) == 0
benchmark_functions_edited/f2498.py
def f(delta): if delta > 0: return 1 else: return 0 assert f(0.00000001) == 1
benchmark_functions_edited/f12733.py
def f(contact_form_id: int, type_id: int) -> int: if contact_form_id > 0: return contact_form_id return 1 if type_id in {4, 5} else 6 assert f(0, 12) == 6
benchmark_functions_edited/f2510.py
def f(effect_list): return sum(el.economic_loss for el in effect_list) assert f([]) == 0
benchmark_functions_edited/f4213.py
def f(coord1, coord2): return ((coord1[0] - coord2[0])**2 + (coord1[1] - coord2[1])**2 + (coord1[2] - coord2[2])**2)**(1./2) assert f( (0, 0, 0), (0, 0, 0) ) == 0
benchmark_functions_edited/f6183.py
def f(a, b): return sum(a) * sum(b) assert f([0,0,0], [1,1,1]) == 0
benchmark_functions_edited/f12879.py
def f(position): if position < 0: return -1 if position == 0 or position == 1: return position else: return f(position - 1) + f(position - 2) assert f(3) == 2
benchmark_functions_edited/f2412.py
def f(st, ave): return (st + ave) * (st + ave + 1) // 2 + ave assert f(0, 0) == 0
benchmark_functions_edited/f8763.py
def f(observation): return 0 if observation[0] >= 20 else 1 assert f([0, 20]) == 1
benchmark_functions_edited/f14200.py
def f( x_ring_size: int, y_ring_size: int, ) -> int: if x_ring_size != y_ring_size: raise ValueError( f"Expected the same ring size for x and y ({x_ring_size} vs {y_ring_size})" ) return x_ring_size assert f(2, 2) == 2
benchmark_functions_edited/f8487.py
def f(result_dict, settings_paral): num_workers = settings_paral["num_workers"] # sum_rewards = 0 for idx in range(num_workers): sum_curr = sum( result_dict[idx] ) sum_rewards += sum_curr # return sum_rewards assert f( {0: [1], 1: [1]}, {"num_workers": 2} ) == 2
benchmark_functions_edited/f9098.py
def f(factorization): from functools import reduce powers = list(factorization.values()) num_divisors = reduce(lambda x, y: x * y, [_p + 1 for _p in powers]) return num_divisors assert f({"1": 2}) == 3
benchmark_functions_edited/f1052.py
def f(i, n): if i >= n: return i+1 else: return i assert f(2, 1) == 3
benchmark_functions_edited/f6668.py
def f(iLUFS, goalLUFS=-16): gainLog = -(iLUFS - goalLUFS) return 10 ** (gainLog / 20) assert f(-16) == 1
benchmark_functions_edited/f9389.py
def f(b): if len(b) < 2: return 0 b1 = ord(b[0]) << 1 b2 = ord(b[1]) << 8 bc = b2 + b1 bc = bc >> 1 return bc assert f(bytearray([0])) == 0
benchmark_functions_edited/f766.py
def f(A): return A * (1 - A) assert f(1) == 0
benchmark_functions_edited/f6756.py
def f(x): try: return sum([s.isupper() for s in list(str(x))]) except Exception as e: print(f"Exception raised:\n{e}") return 0 assert f(123) == 0
benchmark_functions_edited/f7550.py
def f(a,b): keys = set(a.keys()).intersection(set(b.keys())) sum = 0 for i in keys: try: sum += a[i] * b[i]; except KeyError: pass return sum assert f(dict(), {1: 2}) == 0
benchmark_functions_edited/f2355.py
def f(v, a): try: return tuple(i / a for i in v) except TypeError: return v / a assert f(3, 1) == 3
benchmark_functions_edited/f8390.py
def get_Rprecision (phrase1, phrase2): c = 0.0 for w1 in phrase2.split(): if w1 in phrase1: c += 1 return c/max(len(phrase2.split()), len(phrase1.split())) assert f("aa", "a a") == 1
benchmark_functions_edited/f14052.py
def f(txt, pat): t, p = len(txt), len(pat) dp = [[0 for _ in range(t+1)] for _ in range(p+1)] for i in range(len(dp[0])): dp[0][i]=1 for ip in range(p): matches = 0 for it in range(ip, t): if txt[it] == pat[ip]: matches += dp[ip][it] dp[ip+1][it+1] = matches return max(dp[-1]) assert f("abcab", "ab") == 3
benchmark_functions_edited/f3468.py
def size (N): bits = 0 while N >> bits: bits += 1 return bits assert f(256) == 9
benchmark_functions_edited/f6955.py
def f(hhmmss): try: hh_mm_ss = hhmmss.split(":") secs = int(hh_mm_ss[0]) * 3600 + int(hh_mm_ss[1]) * 60 + int(hh_mm_ss[2]) except: secs = 0 return secs assert f("00:00:01") == 1
benchmark_functions_edited/f3653.py
def f(func, val, exc=Exception): try: return func() except exc: return val assert f(lambda: 1/0, 0, ZeroDivisionError) == 0
benchmark_functions_edited/f11575.py
def f(costs): dpr = dpb = dpg = 0 for r, b, g in costs: print("red", r) print('blue', b) print('green', g) dpr, dpb, dpg = min(dpb, dpg) + r, min(dpr, dpg) + b, min(dpr, dpb) + g return min(dpr, dpb, dpg) assert f( [[7,6,2]] ) == 2
benchmark_functions_edited/f10203.py
def f(raw_cost, current_cpi, cpi_time_variant): return raw_cost * current_cpi / cpi_time_variant assert f(0, 1, 1) == 0
benchmark_functions_edited/f14115.py
def f(arr, x): lo, hi = 0, len(arr) # detail 1: len(arr) vs len(arr) - 1 while lo < hi: # detail 2: lo < hi vs lo <= hi mid = lo + hi >> 1 # detail 3: lo + hi >> 1 vs lo + hi + 1 >> 1 if arr[mid] < x: lo = mid + 1 # detail 4: arr[mid] < x vs arr[mid] <= x else: hi = mid # detail 5: lo = mid + 1 & hi = mid vs lo = mid & hi = mid - 1 return lo assert f(list('abc'), 'd') == 3
benchmark_functions_edited/f9787.py
def f(array): s = sorted(array) return s[0] assert f([3, 5, 7, 9]) == 3
benchmark_functions_edited/f11186.py
def f(someset, n): assoc_seq = [k + 1 in someset for k in range(n)] bit = False rank = 0 for k, x in enumerate(assoc_seq): bit ^= x rank += bit * 2**(n - k - 1) return rank assert f({1, 2, 3, 4}, 3) == 5
benchmark_functions_edited/f4570.py
def f(diaglist, diagname): for i, d in enumerate(diaglist): if d["name"] == diagname: return i return None assert f( [ {"name": "name1", "type": "Type1"}, {"name": "name2", "type": "Type2"}, ], "name1", ) == 0
benchmark_functions_edited/f1088.py
def f(val): return float(val.replace('%', '')) / 100 assert f("100.0000%") == 1
benchmark_functions_edited/f8508.py
def f(list1: list, list2: list) -> float: L = list(list2) swaps = 0 for element in list(list1): ind = L.index(element) L.pop(ind) swaps += ind return swaps assert f(list(range(8)), list(range(8))) == 0
benchmark_functions_edited/f8971.py
def f(solution): length = len(solution) result = 0 for index, number1 in enumerate(solution): for nr_2_indx in range(index + 1, length): result += abs(number1 - solution[nr_2_indx]) return result assert f([1, 1, 1, 1]) == 0
benchmark_functions_edited/f684.py
def f(message): print(message) return 1 assert f(1) == 1
benchmark_functions_edited/f6726.py
def f(value): try: return int(value) except (ValueError, TypeError): return value assert f(3) == 3
benchmark_functions_edited/f2240.py
def f(a, b): c = a + b return c assert f(1, 3) == 4
benchmark_functions_edited/f11440.py
def f(n): if 0 <= n < 10: return n else: if n < 0: return f(-n) else: if (n % 10) <= ((n % 100 - n % 10)/10): return f((n-n % 10)//10) else: return f((n//10) - ((n//10) % 10) + (n % 10)) assert f(100) == 1
benchmark_functions_edited/f1792.py
def f(ind): if ind is None: return None return int(ind) assert f(0) == 0
benchmark_functions_edited/f8050.py
def f(n): return sum(x for x in range(n) if (x % 3 == 0 or x % 5 == 0)) assert f(2) == 0
benchmark_functions_edited/f11636.py
def f(image_len, crop_num, crop_size): return int((image_len - crop_size) / (crop_num - 1)) assert f(10, 3, 6) == 2
benchmark_functions_edited/f2158.py
def f(instruction, blank): return abs(instruction[0] - blank[0]) + abs(instruction[1] - blank[1]) assert f( (0, 0), (2, 3) ) == 5
benchmark_functions_edited/f13955.py
def f(ij, NiNj): return ij[0] * NiNj[0] + ij[1] assert f( [1, 0], [2, 2] ) == 2
benchmark_functions_edited/f4123.py
def f(a: float, b: float, c: float, d: float, x: float) -> float: return ((((a*x + b) * x) + c) * x) + d assert f(3, 2, 1, 1, 0) == 1
benchmark_functions_edited/f2008.py
def f(bits): byte=0 for i in range(8): if bits[i]: byte=byte+2**i return byte assert f(list([0, 0, 0, 0, 0, 0, 0, 0])) == 0
benchmark_functions_edited/f4210.py
def f(x_a, y_a, x_b, y_b): return max(abs(x_b-x_a),abs(y_b-y_a)) assert f(1,1,2,2) == 1
benchmark_functions_edited/f4807.py
def f(numbers): # Modify example to take argument that specifies threshold return sum( 1 for number in numbers if number > 5 ) assert f([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 11]) == 1
benchmark_functions_edited/f8672.py
def f( m, n ): if m == 0: return n + 1 elif m > 0 and n == 0: return f( m - 1, 1 ) elif m > 0 and n > 0: return f( m - 1, f( m, n - 1 ) ) assert f( 1, 0 ) == 2
benchmark_functions_edited/f767.py
def f(a,b): sum = a + b return sum assert f(-2, 11) == 9
benchmark_functions_edited/f10115.py
def f(A, B, kind="normal"): if kind == 'normal': return A * B - B * A elif kind == 'anti': return A * B + B * A else: raise TypeError("Unknown commutator kind '%s'" % kind) assert f(1, 1, 'normal') == 0
benchmark_functions_edited/f5509.py
def f(x: float, m_x: float, s_x: float) -> float: return (x - m_x) / s_x assert f(1, 1, 1) == 0
benchmark_functions_edited/f10019.py
def f(searched, the_list, index=0): for ikey, key in enumerate(reversed(the_list)): print(f"back_search ikey={ikey} key[index]={key[index]} searched={searched}") if key[index] == searched: return ikey return -1 assert f(1, [(1, 1), (1, 1)]) == 0
benchmark_functions_edited/f8099.py
def f(x, y): return int(x) + int(y) assert f(3, '5') == 8
benchmark_functions_edited/f6509.py
def f(indices, t): memlen, itemsize, ndim, shape, strides, offset = t p = offset for i in range(ndim): p += strides[i] * indices[i] return p assert f((0, 0), (5, 1, 2, (2, 3), (1, 2), 0)) == 0
benchmark_functions_edited/f8884.py
def f(longitude): return (int(1+(longitude+180.0)/6.0)) assert f(-175.000000) == 1
benchmark_functions_edited/f1462.py
def f(value): return int(float(float(value) / 1024.0) / 1024.0) assert f(1000) == 0
benchmark_functions_edited/f7438.py
def f(nir, red): return (nir-red) / (nir+red) assert f(10, 10) == 0