file_name
stringlengths
32
36
content
stringlengths
44
898
benchmark_functions_edited/f856.py
def f(a, b): return a[0] * b[0] + a[1] * b[1] assert f( (1, 1), (1, 1) ) == 2
benchmark_functions_edited/f10054.py
def f(tags_list1, tags_list2): tags_s2 = 0 for tag1 in tags_list2: for tag2 in tags_list1: if not (tag1 == tag2): tags_s2+=1 return tags_s2 assert f(list(''), list('abc')) == 0
benchmark_functions_edited/f5974.py
def f(rating1, rating2): distance = 0 for key in rating1: if key in rating2: distance += abs(rating1[key] - rating2[key]) return distance assert f( {'a': 100, 'b': 50, 'c': 75, 'd': 100, 'e': 100, 'f': 100}, {'a': 100, 'b': 50, 'c': 75, 'd': 100}) == 0
benchmark_functions_edited/f5788.py
def f(a, b): while a != b: if a > b: a = a - b else: b = b - a return a assert f(2, 15) == 1
benchmark_functions_edited/f3310.py
def f(blacklist): i = 1 while i in blacklist: i += 1 return i assert f({1, 2, 3}) == 4
benchmark_functions_edited/f7882.py
def f(num): level = 0 for i in range(4): # bitwise AND if (num&1): level += 1 # Right logical shift num = num >> 1 return level assert f(0b0010) == 1
benchmark_functions_edited/f9095.py
def f(file_list, index, amount): index += amount return index % len(file_list) assert f(list("abcde"), 4, 1) == 0
benchmark_functions_edited/f4864.py
def f(y1, y2): y1 -= 1 y2 -= 1 return (y2//4 - y1//4) - (y2//100 - y1//100) + (y2//400 - y1//400) assert f(2018, 2020) == 0
benchmark_functions_edited/f10275.py
def f(x, coef, N): ans = coef[0] for i in range(1, N+1): ans = ans * x + coef[i] return ans assert f(1, [1], 0) == 1
benchmark_functions_edited/f10942.py
def f(val, power, m_value): if power <= 100: return (val ** power) % m_value if power % 2 == 0: return (f(val, power // 2, m_value) ** 2) % m_value return (f(val, power // 2, m_value) * f(val, power // 2 + 1, m_value)) % m_value assert f(7, 5, 10) == 7
benchmark_functions_edited/f2150.py
def f(x): if x>0: return 1 else: return 0 assert f(-1) == 0
benchmark_functions_edited/f12192.py
def f(actual, expected): if actual < expected: print("Unsupported version {}.{}".format(actual[0], actual[1])) return 1 else: m = "OK: actual Python version {}.{} conforms to expected version {}.{}" print(m.format(actual[0], actual[1], expected[0], expected[1])) return 0 assert f((2, 5), (2, 5)) == 0
benchmark_functions_edited/f9833.py
def f(axis): if axis in [0, 1]: return (axis + 1) % 2 else: raise ValueError("Axis should be 0 or 1.") assert f(1) == 0
benchmark_functions_edited/f12651.py
def f(arr: list) -> int: smallest = arr[0] smallest_index = 0 for index in range(1, len(arr)): if arr[index] < smallest: smallest = arr[index] smallest_index = index return smallest_index assert f([0, 1, 2]) == 0
benchmark_functions_edited/f2184.py
def f(x): if x == 0: return 0 else: return x**x assert f(1) == 1
benchmark_functions_edited/f2131.py
def f(value): return min(360, round((value * 360) / 255, 3)) assert f(0) == 0
benchmark_functions_edited/f7662.py
def f(n,k): if n == k: return 1 if n == 0 and k == 0: return 1 if n == 0 or k == 0: return 0 return k*f(n-1,k) + f(n-1,k-1) assert f(3,0) == 0
benchmark_functions_edited/f5501.py
def f(i: int, length: int, ) -> int: return i + 1 if i + 1 < length else 0 assert f(5, 10) == 6
benchmark_functions_edited/f9461.py
def f(limit = 4000000): n1, n2 = 1, 2 even_sum = 0 while (n2 <= limit): if n2%2 == 0: even_sum += n2 temp = n2 + n1 n1 = n2 n2 = temp return even_sum assert f(0) == 0
benchmark_functions_edited/f8305.py
def f(x, b, data_format): if data_format == 'NHWC': return x * b elif data_format == 'NCHW': return x * b else: raise ValueError('invalid data_format: %s' % data_format) assert f(1, 1, 'NCHW') == 1
benchmark_functions_edited/f11108.py
def f(setmap, p1, p2): total = 0 for (pset, count) in setmap.items(): if (p1 in pset) or (p2 in pset): total += count d = 0 for (pset, count) in setmap.items(): if (p1 in pset) ^ (p2 in pset): d += count / float(total) return d assert f( {'A': 2, 'B': 1}, 'A', 'B' ) == 1
benchmark_functions_edited/f5168.py
def f(data, type_=None): if type_ is not None: if type_ == int: return int.from_bytes(data, byteorder='little') assert f(b'\x00\x00\x00\x00', int) == 0
benchmark_functions_edited/f11847.py
def f(name, dictionary): if ("templates_dict" in dictionary): dictionary = dictionary["templates_dict"] if (name in dictionary): return dictionary[name] raise KeyError("'{}' was not found in context.".format(name)) assert f(1, {1:1}) == 1
benchmark_functions_edited/f3434.py
def f(height, txcount): return (txcount + (1 << height) - 1) >> height assert f(100, 1) == 1
benchmark_functions_edited/f10107.py
def f(level, save_type): if save_type == "good": return int(round(level/2)) + 2 else: return int(round(level/3)) assert f(2, "good") == 3
benchmark_functions_edited/f12918.py
def f(lines): increase_counter = 0 for i in range(1, len(lines)): if lines[i] > lines[i - 1]: increase_counter += 1 return increase_counter assert f( [199, 200, 208, 210, 200, 207, 240, 269, 260, 263]) == 7
benchmark_functions_edited/f10338.py
def f(samples): return len(samples) - 1 assert f((1, 2, 3, 4, 5, 6, 7)) == 6
benchmark_functions_edited/f6682.py
def f(obj, name: str): attr_names = name.split(".") attr = obj for attr_name in attr_names: attr = getattr(attr, attr_name) return attr assert f(3, "real") == 3
benchmark_functions_edited/f12120.py
def f(thermal_diffusivity, density, specific_heat_capacity): conductivity = thermal_diffusivity * density * specific_heat_capacity return conductivity assert f(1, 1, 1) == 1
benchmark_functions_edited/f11784.py
def f(var_a, var_b, primes): counter = 0 for i in range(0, 1_000): temp = (i**2) + (i * var_a) + var_b if temp not in primes: break counter += 1 return counter assert f(2, 2, [3, 5]) == 0
benchmark_functions_edited/f9916.py
def f(x, y): return -x ** 2 - (y - 1) ** 2 + 1 assert f(0, 1) == 1
benchmark_functions_edited/f3510.py
def f(total_value, percent): return percent / 100 * total_value assert f(100, 0) == 0
benchmark_functions_edited/f5982.py
def f(factor): ret_val = int(round((float(factor) - 0.5) * 2)) if ret_val < 0: ret_val = 0 if ret_val > 3: ret_val = 3 return ret_val assert f(3.99999) == 3
benchmark_functions_edited/f6630.py
def f(value): if value > 1000: value = 1000 elif value < 300: value = 300 new_value = (value - 300.0) / 700.0 return round(new_value * 60.0) assert f(150) == 0
benchmark_functions_edited/f13429.py
def f(items, value, key): try: return [i[key] for i in items].index(value) except ValueError: return None assert f( [ {"id": 1, "name": "first", "description": "first item"}, {"id": 2, "name": "second", "description": "second item"}, {"id": 3, "name": "third", "description": "third item"}, ], "second", "name", ) == 1
benchmark_functions_edited/f12927.py
def f(filename="", text=""): with open(filename, "a", encoding="utf-8") as file: return file.write(text) assert f("test.txt", "d\n") == 2
benchmark_functions_edited/f2072.py
def f(text, newline): return max([len(line) for line in text.split(newline)]) assert f( "Hello,\nworld!", "\n" ) == 6
benchmark_functions_edited/f12314.py
def f(text, subtext, start=None, compare=None): assert compare is None, "Compare modes not allowed for InStrRev" if start is None: start = len(text) if subtext == "": return len(text) elif start > len(text): return 0 else: return text[:start].rfind(subtext)+1 assert f("abc", "ab") == 1
benchmark_functions_edited/f8780.py
def f(str): ok = 1 if not str: return 0 try: int(str) except ValueError: ok = 0 except TypeError: ok = 0 return ok assert f(1234) == 1
benchmark_functions_edited/f6774.py
def f(genome1, genome2): count = 0 for idx, item in enumerate(genome1): if genome1[idx] != genome2[idx]: count += 1 return count assert f( "0", "A" ) == 1
benchmark_functions_edited/f10174.py
def f(nums): slow,fast=nums[0],nums[0] while True: fast=nums[nums[fast]] slow=nums[slow] if fast==slow: break fast=nums[0] while fast!=slow: fast=nums[fast] slow=nums[slow] return slow assert f( [1, 1, 2]) == 1
benchmark_functions_edited/f1055.py
def f(a, b): print("Calculating the sum of %d, %d" % (a, b)) return a + b assert f(0, 0) == 0
benchmark_functions_edited/f9206.py
def f(tokens): # get Platzhalter "es" es = [t for t in tokens if t.lemma == 'es' and t.function == 'expl'] # color for e in es: e.pattern_color.append('Placeholder es') return len(es) assert f([]) == 0
benchmark_functions_edited/f11285.py
def f(c): # only positive polarity x = ord(c) if (x & 0x08) != 0: x = x & 0x07 else: x = 0 return x assert f(u'\x10') == 0
benchmark_functions_edited/f1567.py
def f(presjek_strugotine, brzina_rezanja): return 1e3*presjek_strugotine*brzina_rezanja assert f(4.7, 0) == 0
benchmark_functions_edited/f6715.py
def f(m, n): if m == 0: return n + 1 if n == 0: return f(m - 1, 1) return f(m - 1, f(m, n - 1)) assert f(1, 1) == 3
benchmark_functions_edited/f1623.py
def f(a, b): if b != 0: return a//b assert f(100000, 50000) == 2
benchmark_functions_edited/f11003.py
def f(text_input): total = 0 target = 'abcdefghijklmnopqrstuvwxyz' for group in text_input: for char in target: if char in group: total += 1 return total assert f( ["abc"]) == 3
benchmark_functions_edited/f11046.py
def f(text1, text2): intersection = set(text1).intersection(set(text2)) union = set(text1).union(set(text2)) return 1 - len(intersection) / len(union) assert f(list("abcd"), list("")) == 1
benchmark_functions_edited/f9876.py
def f(string: str) -> int: return sum(1 for char in string if char.lower() in 'bcdfghjklmnpqrstvwxyz') assert f("H3ll0 W0rld") == 7
benchmark_functions_edited/f13038.py
def f(box): return max(0, box[0][1] - box[0][0] + 1) * max(0, box[1][1] - box[1][0] + 1) assert f( ((0, 0), (1, 0)) ) == 0
benchmark_functions_edited/f10301.py
def f(a, b): return (b - a) / ((a + b) / 2) assert f(100.0, 100.0) == 0
benchmark_functions_edited/f11557.py
def f(name): num = -1 if name == "rock": num = 0 elif name == "Spock": num = 1 elif name == "paper": num = 2 elif name == "lizard": num = 3 elif name == "scissors": num = 4 return num assert f("rock") == 0
benchmark_functions_edited/f12969.py
def f(n, minn, maxn): if n < minn: return minn elif n > maxn: return maxn else: return n assert f(1, 0, 1) == 1
benchmark_functions_edited/f12861.py
def f(quadrant_dict, current_angle): if current_angle > 360: raise ValueError('You have left the circle, my fiend.') quadrant = 1 while not (current_angle >= quadrant_dict[quadrant][0] and current_angle <= quadrant_dict[quadrant][1]): quadrant += 1 return quadrant assert f( {1: (0, 90), 2: (90, 180), 3: (180, 270), 4: (270, 360)}, 181) == 3
benchmark_functions_edited/f6015.py
def f(dic): v = list(dic.values()) k = list(dic.keys()) return k[v.index(max(v))] assert f({0: 10, 1: 20, 2: 30}) == 2
benchmark_functions_edited/f3897.py
def f(vector): k = 2 return k assert f(None) == 2
benchmark_functions_edited/f9012.py
def f(l, m): return int((l * (l + 2) + m) / 2) assert f(1,0) == 1
benchmark_functions_edited/f10941.py
def f(word, bits, value): # Make sure that value is expressible with bits given assert 1 << len(bits) > value for i, bit in enumerate(bits): if value & 1 << i: word |= 1 << bit else: word &= ~(1 << bit) return word assert f(0, [3], 1) == 8
benchmark_functions_edited/f6695.py
def f(data, freq): return len(data)/freq assert f(b'', 8000) == 0
benchmark_functions_edited/f7198.py
def f(s): try: nr = int(s) except (ValueError, TypeError): nr = 0 return nr assert f('spam') == 0
benchmark_functions_edited/f6389.py
def f(number: int): return len(str(number)) assert f(10) == 2
benchmark_functions_edited/f6098.py
def f(data): data.sort() num_values = len(data) half = num_values // 2 if num_values % 2: return data[half] return 0.5 * (data[half-1] + data[half]) assert f([2]) == 2
benchmark_functions_edited/f12937.py
def f(a, b): table = {} l = 0 for i, ca in enumerate(a, 1): for j, cb in enumerate(b, 1): if ca == cb: table[i, j] = table.get((i - 1, j - 1), 0) + 1 if table[i, j] > l: l = table[i, j] return l assert f(list('abcde'), list('fgh')) == 0
benchmark_functions_edited/f12907.py
def f(rules): counter = 0 pos = 0 visited_pos = [] while pos not in visited_pos: rule = rules[pos] visited_pos.append(pos) if rule[0] == 'acc': counter += rule[1] pos += 1 elif rule[0] == 'jmp': pos += rule[1] else: pos += 1 return counter assert f( [ ('nop', 0), ('acc', 1), ('jmp', 4), ('acc', 3), ('jmp', -3), ('acc', -99), ('acc', 1), ('jmp', -4), ('acc', 6) ] ) == 5
benchmark_functions_edited/f10124.py
def potential_lrc ( density, r_cut ): import math # density, r_cut, and the results, are in LJ units where sigma = 1, epsilon = 1 sr3 = 1.0 / r_cut**3 return math.pi * ( (8.0/9.0) * sr3**3 - (8.0/3.0) * sr3 ) * density assert f(0, 0.5) == 0
benchmark_functions_edited/f929.py
def f(one, two, three): return one + two + three assert f(1, 2, 5) == 8
benchmark_functions_edited/f14521.py
def f(iterable, predicate): for item in iterable: if predicate(item): return item raise ValueError("No matching items") assert f(range(5), lambda x: x % 2 == 0) == 0
benchmark_functions_edited/f10717.py
def f(args=None): print("Hello World", args) return 0 assert f(None) == 0
benchmark_functions_edited/f1051.py
def f(a): return (a[2] - a[0]) + (a[3] - a[1]) assert f( (0, 0, 0, 0) ) == 0
benchmark_functions_edited/f128.py
def f(a, b): return a[1] + b[1] assert f( (1, -3), (2, 5), ) == 2
benchmark_functions_edited/f7432.py
def f(label): if(label == 'POSITIVE'): return 1 else: return 0 assert f(5) == 0
benchmark_functions_edited/f7110.py
def f(response): try: return len(response.query_result.parameters) except: return 0 assert f({}) == 0
benchmark_functions_edited/f8302.py
def f(x: int) -> int: i = 0 while i <= x: if x >= i * i and x < (i + 1) * (i + 1): return i i += 1 return -1 assert f(0) == 0
benchmark_functions_edited/f5978.py
def f(binary, pcp_size=36): return int((binary / (pcp_size / 12.0)) + 9) % 12 assert f(17) == 2
benchmark_functions_edited/f12647.py
def f(pattern, p1, p2): while max(p2,p1)<len(pattern) and pattern[p1] == pattern[p2]: p1+=1 p2+=1 return p1 assert f("aba", 2, 1) == 2
benchmark_functions_edited/f12681.py
def f(repositories): i = 0 if repositories: for r in repositories: plugins = r.get("plugins") if not plugins: continue i += len(plugins) return i assert f([{"a": "b", "plugins": [{"a": "b"}]}]) == 1
benchmark_functions_edited/f656.py
def f(a, b): if b == 0: return a return f(b, a % b) assert f(10, 5) == 5
benchmark_functions_edited/f13113.py
def f(num_lst): num = 0.0 for i in num_lst: num += i num = num / len(num_lst) return num assert f([1, 2, 3, 4, 5]) == 3
benchmark_functions_edited/f12356.py
def f(azote, phosphore, potassium): expected = 0.3, 0.2, 0.5 return ( 1 - ( (azote - expected[0]) ** 2 + (phosphore - expected[1]) ** 2 + (potassium - expected[2]) ** 2 ) ** 0.5 ) assert f(0.3, 0.2, 0.5) == 1
benchmark_functions_edited/f618.py
def f(u1,u2): return u1[0]*u2[0] + u1[1]*u2[1] + u1[2]*u2[2] assert f( (1,1,2), (0,0,1) ) == 2
benchmark_functions_edited/f1248.py
def f(x): return int(round(x * 2 ** 16)) assert f(-0.0) == 0
benchmark_functions_edited/f452.py
def f(v): return sum(vv**2 for vv in v) ** 0.5 assert f( () ) == 0
benchmark_functions_edited/f13629.py
def f(sequence): gaps = 0 for i, position in enumerate(sequence): if sequence[i:i+3] == 'ATG': break elif sequence[i] == '-': gaps += 1 else: pass return gaps assert f('') == 0
benchmark_functions_edited/f12817.py
def f(factors): acc = 1 for f,e in factors.items(): acc *= f**e return acc assert f(dict()) == 1
benchmark_functions_edited/f11356.py
def f(log_lik, n_samples, dof): return - 2 * log_lik + 2 * dof assert f(1, 1, 2) == 2
benchmark_functions_edited/f8745.py
def f(number: int) -> int: result = [0, 1, 1] for c in range(2, number): result.append(result[0] + result[1]) del result[0] return result[0] + result[1] assert f(**{'number': 5}) == 3
benchmark_functions_edited/f5153.py
def f(attrs, node): acc = 0 for i in range(len(attrs)): if attrs[i] in node.attrs: acc += 10**i return acc assert f((), {}) == 0
benchmark_functions_edited/f13845.py
def f(tau_1, rho_1, rho_2) -> float: return rho_1 + (tau_1 * tau_1 * rho_2) / (1 - rho_1 * rho_2) assert f(0, 0, 0) == 0
benchmark_functions_edited/f9813.py
def f(n: int = 2): return (1 << 2 * n) - (n << 1) - 1 assert f(1) == 1
benchmark_functions_edited/f4294.py
def f(istr): sum = 0 for i in istr: sum += int(i) return sum assert f(str(1)) == 1
benchmark_functions_edited/f2434.py
def f(n): x=1 while x<n: x=x*2 return x assert f(2) == 2
benchmark_functions_edited/f7090.py
def f(hexinput): return int(''.join('{0}'.format(x) for x in hexinput), 10) assert f(tuple((0,0))) == 0
benchmark_functions_edited/f9859.py
def f(base, power, mod): if power < 0: return -1 base %= mod result = 1 while power > 0: if power & 1: result = (result * base) % mod power = power >> 1 base = (base * base) % mod return result assert f(5, 0, 10) == 1
benchmark_functions_edited/f13392.py
def f(num, base, pos): return (num // base ** pos) % base assert f(123456, 10, -7) == 0
benchmark_functions_edited/f4653.py
def f(a: int, b: int): while a != 0: a, b = b % a, a return b assert f(7, 3) == 1
benchmark_functions_edited/f7155.py
def f(n): # height = 1 # for i in range(n): # height = height * 2 if i % 2 == 0 else height + 1 height = 2 ** ((n + 3) // 2) - 2 + (n + 1) % 2 return height assert f(0) == 1
benchmark_functions_edited/f2916.py
def f(x: int) -> int: if x < 0: return -1 else: return 1 assert f(1) == 1
benchmark_functions_edited/f8794.py
def f(floor: int, control: str) -> int: if control == '(': return floor + 1 if control == ')': return floor - 1 raise ValueError('Unexpected control input: {}'.format(control)) assert f(2, ')') == 1
benchmark_functions_edited/f8739.py
def f(guid): return int(guid.rstrip('L'), base=16) assert f(u'1L') == 1