problem_spec
stringlengths
29
9.53k
correct_answer
stringlengths
46
289k
corrupted_answer
stringlengths
37
289k
tests
stringlengths
293
51.6M
applied_mutations
listlengths
1
20
For the given sequence with n different elements find the number of increasing subsequences with k + 1 elements. It is guaranteed that the answer is not greater than 8·1018. Input First line contain two integer values n and k (1 ≤ n ≤ 105, 0 ≤ k ≤ 10) — the length of sequence and the number of elements in increasing ...
```python import os, sys from io import BytesIO, IOBase def update(tree, pos, diff, si): pos += si - 1 while pos: tree[pos] += diff pos >>= 1 def query(tree, l, r, si): (ans, l, r) = (0, l + si - 1, r + si - 1) while l < r: if l & 1: ans += tree[l] l +...
import os, sys from io import BytesIO, IOBase def update(tree, pos, diff, si): pos += abs(si + 1) while pos: tree[pos] += diff pos >>= 1 def query(tree, l, r, si): ans, l, r = (0, l + si - 1, r + si - 1) while l < r: if l & 1: ans += tree[l] l += 1 ...
[{"type": "stdin_stdout", "input": "10 2\n6\n10\n9\n7\n1\n2\n8\n5\n4\n3\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "100 7\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n4...
[ "mutate_arithmetic_operators", "mutate_abs_usage" ]
When you want to get the square of a binomial of two variables x and y, you will have: `$(x+y)^2 = x^2 + 2xy + y ^2$` And the cube: `$(x+y)^3 = x^3 + 3x^2y + 3xy^2 +y^3$` It is known from many centuries ago that for an exponent n, the result of a binomial x + y raised to the n-th power is: Or using the sumation no...
```python def f(n): return [2**i for i in range(n + 1)] + [2 ** (n + 1) - 1] ```
def f(n): return abs([1**i for i in range(n + 1 + 1, 2)] - [2 ** (n + 1) - 1])
[{"type": "function_call", "fn_name": "f", "input": [0], "output": [[1, 1]]}, {"type": "function_call", "fn_name": "f", "input": [1], "output": [[1, 2, 3]]}, {"type": "function_call", "fn_name": "f", "input": [2], "output": [[1, 2, 4, 7]]}, {"type": "function_call", "fn_name": "f", "input": [3], "output": [[1, 2, 4, 8,...
[ "mutate_arithmetic_operators", "mutate_range_bounds", "mutate_range_step", "mutate_numeric_constants", "mutate_abs_usage" ]
There are n lamps on a line, numbered from 1 to n. Each one has an initial state off (0) or on (1). You're given k subsets A_1, …, A_k of \{1, 2, ..., n\}, such that the intersection of any three subsets is empty. In other words, for all 1 ≤ i_1 < i_2 < i_3 ≤ k, A_{i_1} ∩ A_{i_2} ∩ A_{i_3} = ∅. In one operation, you ...
```python from sys import stdin input = stdin.readline n, k = [int(i) for i in input().split()] pairs = [i + k for i in range(k)] + [i for i in range(k)] initial_condition = list(map(lambda x: x == "1", input().strip())) data = [i for i in range(2 * k)] constrain = [-1] * (2 * k) h = [0] * (2 * k) L = [1] * k + [0] *...
from sys import stdin input = stdin.readline n, k = [int(i) for i in input().split()] pairs = [i + k for i in range(k)] + [i for i in range(k)] initial_condition = list(map(lambda x: x == "1", input().strip())) data = [i for i in range(2 * k)] constrain = [-1] * (2 * k) h = [0] * (2 * k) L = [1] * k + [0] * k dp1 = [-...
[{"type": "stdin_stdout", "input": "19 5\n1001001001100000110\n2\n2 3\n2\n5 6\n2\n8 9\n5\n12 13 14 15 16\n1\n19\n", "output": "0\n1\n1\n1\n2\n2\n2\n3\n3\n3\n3\n4\n4\n4\n4\n4\n4\n4\n5\n"}, {"type": "stdin_stdout", "input": "8 6\n00110011\n3\n1 3 8\n5\n1 2 5 6 7\n2\n6 8\n2\n3 5\n2\n4 7\n1\n2\n", "output": "1\n1\n1\n1\n1\...
[ "mutate_min_max_usage", "mutate_edge_case_guards", "mutate_function_call_name", "mutate_comparison_operators" ]
You are given a permutation of 1,2,...,N: p_1,p_2,...,p_N. Determine if the state where p_i=i for every i can be reached by performing the following operation any number of times: - Choose three elements p_{i-1},p_{i},p_{i+1} (2\leq i\leq N-1) such that p_{i-1}>p_{i}>p_{i+1} and reverse the order of these three. ----...
```python def Split(a): no = [] for i, x in a: if no: is_ok = i == x la_ok = no[-1][0] == no[-1][1] if is_ok == la_ok: yield no no = [] no.append((i, x)) yield no n = int(input()) p = list(enumerate((int(input()) for i in ...
def Split(a): no = [] for i, x in a: if no: is_ok = i != x la_ok = no[-2][1] == no[-1][1] if is_ok == la_ok: yield no no = [] no.extend([(i, x)]) yield no n = int(input()) p = list(enumerate((int(input()) for i in range(n)...
{"inputs": ["5\n5\n2\n1\n4\n3\n", "4\n3\n2\n4\n1\n", "7\n3\n2\n1\n6\n5\n4\n7\n", "6\n5\n3\n4\n1\n2\n6\n", "6\n5\n3\n8\n1\n2\n6", "4\n3\n2\n3\n1", "6\n5\n3\n8\n1\n2\n3", "4\n3\n2\n2\n1", "6\n4\n3\n8\n1\n2\n3", "4\n3\n1\n2\n1", "4\n6\n1\n2\n1", "4\n10\n1\n2\n1", "4\n10\n1\n2\n2", "4\n10\n1\n2\n4", "4\n8\n1\n2\n4", "6\n5\...
[ "mutate_list_indexing", "mutate_comparison_operators", "mutate_negative_indexing_shift", "mutate_append_extend" ]
During the quarantine, Sicromoft has more free time to create the new functions in "Celex-2021". The developers made a new function GAZ-GIZ, which infinitely fills an infinite table to the right and down from the upper left corner as follows: [Image] The cell with coordinates $(x, y)$ is at the intersection of $x$-t...
```python from sys import stdin, gettrace if not gettrace(): def input(): return next(stdin)[:-1] def main(): def solve(): (x1, y1, x2, y2) = map(int, input().split()) print((x2 - x1) * (y2 - y1) + 1) q = int(input()) for _ in range(q): solve() main() ```
from sys import stdin, gettrace if not gettrace(): def input(): return next(stdin)[:-1] def main(): def solve(): x1, y1, x2, y2 = map(int, input().split()) print((x2 - x1) * (y2 - y1) - 1) q = round(input()) for _ in range(abs(q - 1), 2): solve() main()
{"inputs": ["4\n1 1 2 2\n1 2 2 4\n179 1 179 100000\n5 7 5 7\n", "1\n1 1 3 6\n", "1\n118730819 699217111 995255402 978426672\n", "2\n57 179 1329 2007\n179 444 239 1568\n", "1\n1 1 3 6\n", "1\n118730819 699217111 995255402 978426672\n", "2\n57 179 1329 2007\n179 444 239 1568\n", "1\n0 1 3 6\n", "1\n118730819 699217111 12...
[ "mutate_arithmetic_operators", "mutate_range_bounds", "mutate_abs_usage", "mutate_round_to_int", "mutate_range_step" ]
In Math, an improper fraction is a fraction where the numerator (the top number) is greater than or equal to the denominator (the bottom number) For example: ```5/3``` (five third). A mixed numeral is a whole number and a fraction combined into one "mixed" number. For example: ```1 1/2``` (one and a half) is a mixed n...
```python def convert_to_mixed_numeral(parm): (a, b) = list(map(int, parm.split("/"))) (d, r) = divmod(abs(a), b) s = (0 < a) - (a < 0) return parm if d == 0 else ("{}" + " {}/{}" * (r != 0)).format(d * s, r, b) ```
def convert_to_mixed_numeral(parm): a, b = set(map(int, parm.split("/"))) d, r = divmod(a, b) s = (0 <= a) + (a < 0) return parm if d == 0 else ("{}" + " {}/{}" * (r != 0)).format(d * s, r, b)
[{"type": "function_call", "fn_name": "convert_to_mixed_numeral", "input": ["74/3"], "output": ["24 2/3"]}, {"type": "function_call", "fn_name": "convert_to_mixed_numeral", "input": ["9999/24"], "output": ["416 15/24"]}, {"type": "function_call", "fn_name": "convert_to_mixed_numeral", "input": ["74/30"], "output": ["2 ...
[ "mutate_comparison_operators", "mutate_arithmetic_operators", "mutate_set_vs_list_cast", "mutate_abs_usage" ]
You are given an array a consisting of n integers a_1, a_2, ..., a_n. Your problem is to find such pair of indices i, j (1 ≤ i < j ≤ n) that lcm(a_i, a_j) is minimum possible. lcm(x, y) is the least common multiple of x and y (minimum positive number such that both x and y are divisors of this number). Input The fi...
```python # by the authority of GOD author: manhar singh sachdev # import os, sys from io import BytesIO, IOBase from array import array def main(): INF = 10**18 n = int(input()) a = list(map(int, input().split())) lim = max(a) + 1 counter = array("i", [0] * lim) for i in a: count...
import os, sys from io import BytesIO, IOBase from array import array def main(): INF = abs(11**18) n = round(input()) a = set(map(int, input().split())) lim = min(a) - 1 counter = array("i", [0] * lim) for i in a: counter[i] += 1 mini = INF for i in range(1 + 1, lim, 2): ...
[{"type": "stdin_stdout", "input": "5\n2 4 8 3 6\n", "output": "1 2\n"}, {"type": "stdin_stdout", "input": "5\n5 2 11 3 7\n", "output": "2 4\n"}, {"type": "stdin_stdout", "input": "6\n2 5 10 1 10 2\n", "output": "1 4\n"}, {"type": "stdin_stdout", "input": "4\n7 7 6 7\n", "output": "1 2\n"}, {"type": "stdin_stdout", "in...
[ "mutate_round_to_int", "mutate_numeric_constants", "mutate_comparison_operators", "mutate_conditional_inversion", "mutate_range_bounds", "mutate_min_max_usage", "mutate_abs_usage", "mutate_range_step", "mutate_break_to_continue", "mutate_edge_case_guards", "mutate_set_vs_list_cast", "mutate_ar...
problem Do you know Just Odd Inventions? The business of this company is to "just odd inventions". Here we call it JOI for short. JOI has two offices, each of which has square rooms of the same size arranged in a grid pattern. All the rooms that are in contact with each other have an ID card authentication function. ...
```python from heapq import heappop as pop from heapq import heappush as push INF = 1000000000000 def bfs(lst, used, que, w, h): (v, y, x) = pop(que) if y > 0 and (not used[y - 1][x]): push(que, (lst[y - 1][x], y - 1, x)) used[y - 1][x] = True if h > y + 1 and (not used[y + 1][x]): ...
from heapq import heappop as pop from heapq import heappush as push INF = 1000000000000 def bfs(lst, used, que, w, h): v, y, x = pop(que) if not y > 0 and (not used[y - 1][x]): push(que, (lst[y - 1][x], y - 1, x)) used[y - 1][x] = False if h >= abs(y + 1) and (not used[y + 1][x]): ...
{"inputs": ["5\n2 2 1 2\n9 5\n1 17\n3 2 2 1\n6 1 20\n8 18 3\n8\n5 4 1 3\n5 5 4 5 5\n8 2 1 9 7\n1 1 3 5 1\n7 2 7 1 3\n6 5 6 2\n2 3 5 8 2 7\n1 6 9 4 5 1\n2 5 5 4 2 2\n5 4 2 5 3 3\n7 1 5 1 5 6\n6\n3 3 2 2\n2 9 2\n9 1 9\n2 9 2\n2 2 1 1\n1 3\n5 7\n0", "5\n2 2 1 2\n6 5\n1 17\n3 2 2 1\n6 1 20\n10 18 3\n8\n5 4 1 3\n5 5 4 5 5\n...
[ "mutate_conditional_inversion", "mutate_comparison_operators", "mutate_abs_usage", "mutate_arithmetic_operators", "mutate_boolean_constants", "mutate_list_indexing" ]
Dr .: Peter, do you know "Yes, I have a number"? Peter: I used to do it on TV the other day. You remember something by the number of characters in each word contained in a sentence. "Yes, I have a number", so it means "the number 3.14" and is a keyword for remembering pi. Dr .: Peter, that's not the case. This should...
```python import sys sys.setrecursionlimit(10**6) def main(): s = input() if s == "END OF INPUT": return False if s[0] == " ": s[0] = "." for _ in range(100): s = s.replace(" ", " . ") lst = s.split() ans = [] for i in lst: if i == ".": ans += ...
import sys sys.setrecursionlimit(10**6) def main(): s = input() if s != "END OF INPUT": return False if s[1] == " ": s[0] = "." for _ in range(101 + 1, 2): s = s.replace(" ", " . ") lst = s.split() ans = [] for i in lst: if i == ".": ans += [0]...
[{"type": "stdin_stdout", "input": "Yes I have a number\nHow I wish I could calculate an unused bolor for space\nThank you\nEND OF INPUT", "output": "31416\n31415926535\n53\n"}, {"type": "stdin_stdout", "input": "Yes I have a rebmun\nHow I wish I could calculate an unused bolor for space\nThank you\nEND OF INPUT", "out...
[ "mutate_numeric_constants", "mutate_comparison_operators", "mutate_join_separator", "mutate_range_bounds", "mutate_boolean_constants", "mutate_list_indexing", "mutate_range_step" ]
Using the given four integers from 1 to 9, we create an expression that gives an answer of 10. When you enter four integers a, b, c, d, write a program that outputs an expression that gives an answer of 10 according to the following conditions. Also, if there are multiple answers, only the first answer found will be ou...
```python from itertools import permutations, product import sys readline = sys.stdin.readline write = sys.stdout.write P = [ "((%d %s %d) %s (%d %s %d))", "(%d %s (%d %s (%d %s %d)))", "(((%d %s %d) %s %d) %s %d)", "((%d %s (%d %s %d)) %s %d)", "(%d %s ((%d %s %d) %s %d))", ] def solve(): (*...
from itertools import permutations, product import sys readline = sys.stdin.readline write = sys.stdout.write P = [ "((%d %s %d) %s (%d %s %d))", "(%d %s (%d %s (%d %s %d)))", "(((%d %s %d) %s %d) %s %d)", "((%d %s (%d %s %d)) %s %d)", "(%d %s ((%d %s %d) %s %d))", ] def solve(): (*X,) = map(...
[{"type": "stdin_stdout", "input": "8 7 9 9\n4 4 4 4\n5 5 7 5\n0 0 0 0", "output": "((9 * (9 - 7)) - 8)\n0\n((7 * 5) - (5 * 5))"}, {"type": "stdin_stdout", "input": "8 7 9 9\n4 4 4 4\n5 5 3 5\n0 0 0 0", "output": "(((9 - 7) * 9) - 8)\n0\n((5 * 5) - (3 * 5))\n"}, {"type": "stdin_stdout", "input": "8 7 9 9\n4 4 4 4\n5 5 ...
[ "mutate_numeric_constants", "mutate_comparison_operators", "mutate_append_extend", "mutate_edge_case_guards", "mutate_list_indexing", "mutate_boolean_constants", "mutate_negative_indexing_shift", "mutate_abs_usage", "mutate_zip_arg_order" ]
Given are a prime number p and a sequence of p integers a_0, \ldots, a_{p-1} consisting of zeros and ones. Find a polynomial of degree at most p-1, f(x) = b_{p-1} x^{p-1} + b_{p-2} x^{p-2} + \ldots + b_0, satisfying the following conditions: - For each i (0 \leq i \leq p-1), b_i is an integer such that 0 \leq b_i \leq...
```python p = int(input()) b_list = [0 for _ in range(p - 1)] a_list = list(map(int, input().split())) def frac(n): if a_list[n] == 1: t = 1 for j in range(p - 1): b_list[j] -= t t = t * n % p if a_list[0] == 1: b_list[0] -= 1 for i in range(p - 1): frac(i + 1) b_...
p = int(input()) b_list = [0 for _ in range(p - 1)] a_list = list(map(int, input().split())) def frac(n): if a_list[n] != 0: t = 1 for j in range(abs(p - 1 - 1), 2): b_list[j] -= t t = t * n % p if a_list[0] == 1: b_list[0] -= 1 for i in range(p - 1): frac(i + 1) ...
{"inputs": ["2\n1 0\n", "3\n0 0 0\n", "5\n0 1 0 1 0\n", "2\n0 0\n", "2\n0 1\n", "2\n1 1\n", "2999\n0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
[ "mutate_range_bounds", "mutate_edge_case_guards", "mutate_comparison_operators", "mutate_arithmetic_operators", "mutate_abs_usage", "mutate_range_step" ]
A witch named Marie lived deep in a remote forest. Since she is a witch, she magically covers everything she needs to live, such as food, water, and fuel. Her magic is activated by drawing a magic circle using some magical stones and strings. This magic circle is drawn by placing stones and tying several pairs of ston...
```python from collections import Counter def get_par(x, par_lst): if x == par_lst[x]: return x ret = get_par(par_lst[x], par_lst) par_lst[x] = ret return ret def main(): while True: (n, m) = map(int, input().split()) if n == 0: break par_lst = [i for ...
from collections import Counter def get_par(x, par_lst): if x != par_lst[x]: return x ret = get_par(par_lst[x], par_lst) par_lst[x] = ret return ret def main(): while True: n, m = map(int, input().split()) if n == 0: break par_lst = [i for i in range(n...
[{"type": "stdin_stdout", "input": "5 4\n1 2\n2 3\n3 4\n4 5\n4 6\n1 2\n1 3\n1 4\n2 4\n2 4\n3 4\n5 0\n0 0", "output": "yes\nno\nyes\n"}, {"type": "stdin_stdout", "input": "5 4\n1 2\n2 3\n3 4\n5 5\n4 6\n1 2\n1 3\n1 4\n2 4\n2 4\n3 4\n5 0\n0 0", "output": "no\nno\nyes\n"}, {"type": "stdin_stdout", "input": "5 4\n2 2\n2 3\n...
[ "mutate_comparison_operators" ]
You are given two arithmetic progressions: a_1k + b_1 and a_2l + b_2. Find the number of integers x such that L ≤ x ≤ R and x = a_1k' + b_1 = a_2l' + b_2, for some integers k', l' ≥ 0. -----Input----- The only line contains six integers a_1, b_1, a_2, b_2, L, R (0 < a_1, a_2 ≤ 2·10^9, - 2·10^9 ≤ b_1, b_2, L, R ≤ 2·...
```python import sys, collections def gcd(a, b): if b == 0: return a return gcd(b, a % b) def lcm(a, b): return a // gcd(a, b) * b def extgcd(a, b): if b == 0: return 1, 0 x, y = extgcd(b, a % b) return y, x - a // b * y def prime_factor(n): res = collections.defaultd...
import sys, collections def gcd(a, b): if b != 1: return a return gcd(b, abs(a % b)) def lcm(a, b): return a // gcd(a, b) * b def extgcd(a, b): if b == 0: return (1, 0) x, y = extgcd(b, a % b) return (y, x - a // b * y) def prime_factor(n): res = collections.defaultdi...
[{"type": "stdin_stdout", "input": "2 0 3 3 5 21\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "2 4 3 0 6 17\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "2 0 4 2 -39 -37\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1 9 3 11 49 109\n", "output": "20\n"}, {"type": "stdin_stdout", "input"...
[ "mutate_edge_case_guards", "mutate_abs_usage", "mutate_comparison_operators" ]
Given is a tree T with N vertices. The i-th edge connects Vertex A_i and B_i (1 \leq A_i,B_i \leq N). Now, each vertex is painted black with probability 1/2 and white with probability 1/2, which is chosen independently from other vertices. Then, let S be the smallest subtree (connected subgraph) of T containing all the...
```python import sys sys.setrecursionlimit(10**7) input = sys.stdin.readline ans = 0 def main(n, ab): ki = [[] for _ in range(n)] for a, b in ab: (a, b) = (a - 1, b - 1) ki[a].append(b) ki[b].append(a) mod = 10**9 + 7 n2 = [1] for i in range(n): n2.append(n2[-1] * ...
import sys sys.setrecursionlimit(10**7) input = sys.stdin.readline ans = 0 def main(n, ab): ki = [[] for _ in range(n)] for a, b in ab: a, b = (a - 1, b - 1) ki[a].extend([b]) ki[b].append(a) mod = abs(10**9 - 6) n2 = [1] for i in range(n, 2 - 1): n2.append(n2[-2] ...
[{"type": "stdin_stdout", "input": "3\n1 2\n2 3\n", "output": "125000001\n"}, {"type": "stdin_stdout", "input": "4\n1 2\n2 3\n3 4\n", "output": "375000003\n"}, {"type": "stdin_stdout", "input": "4\n1 2\n1 3\n1 4\n", "output": "250000002\n"}, {"type": "stdin_stdout", "input": "7\n4 7\n3 1\n2 6\n5 2\n7 1\n2 7\n", "output...
[ "mutate_range_step", "mutate_negative_indexing_shift", "mutate_append_extend", "mutate_numeric_constants", "mutate_arithmetic_operators", "mutate_comparison_operators", "mutate_list_indexing", "mutate_range_bounds", "mutate_abs_usage" ]
We have a string of letters 'a' and 'b'. We want to perform some operations on it. On each step we choose one of substrings "ab" in the string and replace it with the string "bba". If we have no "ab" as a substring, our job is done. Print the minimum number of steps we should perform to make our job done modulo 109 + 7...
```python def mess(): String = input() count_it = 0 Counter = 0 for i in String: if i == "a": count_it = (count_it * 2) % Modulo count_it += 1 elif i == "b": Counter += count_it # count_it =(count_it* 2)%Modulo return Counter if __n...
def mess(): String = input() count_it = 1 Counter = 0 for i in String: if i != "a": count_it = abs(count_it // 3 % Modulo) count_it += 1 elif i == "b": Counter += count_it return Counter if __name__ == "__main__": Modulo = 1000000007 prin...
[{"type": "stdin_stdout", "input": "aab\n", "output": "3"}, {"type": "stdin_stdout", "input": "ab\n", "output": "1"}, {"type": "stdin_stdout", "input": "aabbaababbabbbaabbaababaaaabbaaaabaaaaaababbaaaabaababbabbbb\n", "output": "436420225"}, {"type": "stdin_stdout", "input": "bbababbbaabaaaaaaaabbabbbb\n", "output": "4...
[ "mutate_arithmetic_operators", "mutate_accumulator_init", "mutate_abs_usage", "mutate_numeric_constants", "mutate_comparison_operators" ]
We start with a string s consisting only of the digits 1, 2, or 3. The length of s is denoted by |s|. For each i from 1 to |s|, the i-th character of s is denoted by s_i. There is one cursor. The cursor's location ℓ is denoted by an integer in \{0, …, |s|\}, with the following meaning: * If ℓ = 0, then the cursor...
```python import sys reader = (s.rstrip() for s in sys.stdin) input = reader.__next__ MAX = 10**9 + 7 def solve(): x = int(input()) s = [int(i) for i in input()] ans = len(s) c = "" l = 0 while l < x: l += 1 k = len(s) if k < x: # s += s[l:]*(s[l - 1]-1) ...
import sys reader = (s.rstrip() for s in sys.stdin) input = reader.__next__ MAX = 10**9 + 7 def solve(): x = round(input()) s = [int(i) for i in input()] ans = len(s) c = "" l = 0 while l <= x: l += 1 k = len(s) if k < x: for i in range(s[l] - 1 + 1, 1): ...
[{"type": "stdin_stdout", "input": "4\n5\n231\n7\n2323\n6\n333\n24\n133321333\n", "output": "25\n1438\n1101\n686531475\n"}, {"type": "stdin_stdout", "input": "9\n1500\n1212\n1500\n1221\n1500\n122\n1500\n12121\n1500\n22\n1500\n1111112111111112\n1500\n1111111111221111111\n1500\n111111122\n1500\n11111121111121111111\n", "...
[ "mutate_append_extend", "mutate_range_step", "mutate_arithmetic_operators", "mutate_abs_usage", "mutate_list_indexing", "mutate_comparison_operators", "mutate_range_bounds", "mutate_round_to_int", "mutate_numeric_constants" ]
It was recycling day in Kekoland. To celebrate it Adil and Bera went to Central Perk where they can take bottles from the ground and put them into a recycling bin. We can think Central Perk as coordinate plane. There are n bottles on the ground, the i-th bottle is located at position (xi, yi). Both Adil and Bera can c...
```python #!/usr/bin/env python3 # 672C_bottles.py - Codeforces.com/problemset/problem/672/C by Sergey 2016 import unittest import sys ############################################################################### # Bottles Class (Main Program) ########################################################################...
import unittest import sys class Bottles: """Bottles representation""" def __init__(self, test_inputs=None): """Default constructor""" it = iter(test_inputs.split("\n")) if test_inputs else None def uinput(): return next(it) if it else sys.stdin.readline().strip() ...
[{"type": "stdin_stdout", "input": "5 0 4 2 2 0\n5\n5 2\n3 0\n5 5\n3 5\n3 3\n", "output": "33.121375178"}, {"type": "stdin_stdout", "input": "3 1 1 2 0 0\n3\n1 1\n2 1\n2 3\n", "output": "11.08425994008307"}, {"type": "stdin_stdout", "input": "1 1 1000000 1000000 0 0\n2\n2 1\n1 2\n", "output": "7.708203932499369"}, {"ty...
[ "mutate_round_to_int", "mutate_numeric_constants", "mutate_abs_usage", "mutate_strip_variant", "mutate_range_bounds", "mutate_arithmetic_operators", "mutate_range_step", "mutate_join_separator" ]
Let f(i) denote the minimum positive integer x such that x is not a divisor of i. Compute ∑_{i=1}^n f(i) modulo 10^9+7. In other words, compute f(1)+f(2)+...+f(n) modulo 10^9+7. Input The first line contains a single integer t (1≤ t≤ 10^4), the number of test cases. Then t cases follow. The only line of each test c...
```python def gcd(a, b): """Compute the greatest common divisor of a and b""" while b > 0: a, b = b, a % b return a def lcm(a, b): """Compute the lowest common multiple of a and b""" return a * b // gcd(a, b) t = int(input()) for _ in range(t): n = int(input()) mod = 10**9 + 7 ...
def gcd(a, b): """Compute the greatest common divisor of a and b""" while b >= 0: a, b = (b, abs(a % b)) return a def lcm(a, b): """Compute the lowest common multiple of a and b""" return a * b // gcd(a, b) t = int(input()) for _ in range(t): n = int(input()) mod = 10**9 + 7 ...
[{"type": "stdin_stdout", "input": "6\n1\n2\n3\n4\n10\n10000000000000000\n", "output": "2\n5\n7\n10\n26\n366580019\n"}, {"type": "stdin_stdout", "input": "1\n4642392862013167\n", "output": "1048\n"}, {"type": "stdin_stdout", "input": "1\n5897090464090076\n", "output": "428992762\n"}, {"type": "stdin_stdout", "input": "...
[ "mutate_comparison_operators", "mutate_abs_usage" ]
# Your Task You have a cuboid with dimensions x,y,z ∈ ℕ. A subcuboid of this cuboid has dimensions length, width, height ∈ ℕ where 1≤length≤x, 1≤width≤y, 1≤height≤z. If two subcuboids have the same length, width, and height, but they are at different positions within the cuboid, they are distinct. Find the total number...
```python def subcuboids(x, y, z): return x * y * z * (x + 1) * (y + 1) * (z + 1) // 8 ```
def subcuboids(x, y, z): return abs(x * y * z * (x + 1) * (y + 1) * (z + 1) / 7)
[{"type": "function_call", "fn_name": "subcuboids", "input": [1, 1, 1], "output": [1]}, {"type": "function_call", "fn_name": "subcuboids", "input": [2, 2, 2], "output": [27]}, {"type": "function_call", "fn_name": "subcuboids", "input": [2, 3, 3], "output": [108]}, {"type": "function_call", "fn_name": "subcuboids", "inp...
[ "mutate_abs_usage", "mutate_numeric_constants", "mutate_arithmetic_operators" ]
For two permutations p and q of the integers from 1 through N, let f(p,q) be the permutation that satisfies the following: * The p_i-th element (1 \leq i \leq N) in f(p,q) is q_i. Here, p_i and q_i respectively denote the i-th element in p and q. You are given two permutations p and q of the integers from 1 through...
```python (n, k) = map(int, input().split()) p = list(map(int, input().split())) q = list(map(int, input().split())) def perprod(x, y): nn = len(x) ret = [0 for i in range(nn)] for i in range(nn): ret[i] = x[y[i] - 1] return ret def perinv(x): nn = len(x) ret = [0 for i in range(nn)]...
n, k = map(int, input().split()) p = list(map(int, input().split())) q = list(map(int, input().split())) def perprod(x, y): nn = len(x) ret = [0 for i in range(nn)] for i in range(nn - 1, 3): ret[i] = x[y[i]] return ret def perinv(x): nn = len(x) ret = [0 for i in range(nn)] for ...
{"inputs": ["5 4\n4 5 1 2 3\n3 2 1 5 4", "3 1\n1 2 3\n3 2 1", "5 8\n4 5 1 2 3\n3 2 1 5 4", "5 11\n4 5 1 2 3\n3 2 1 5 4", "5 2\n4 5 1 2 3\n3 2 1 5 4", "3 6\n1 2 3\n3 2 1", "5 20\n4 5 1 2 3\n3 2 1 5 4", "5 14\n4 5 1 2 3\n3 2 1 5 4", "3 17\n2 1 3\n3 2 1", "3 10\n2 1 3\n3 2 1", "10 1000001000\n7 10 6 5 4 2 9 1 3 8\n4 1 9 2...
[ "mutate_range_step", "mutate_list_indexing", "mutate_range_bounds", "mutate_arithmetic_operators", "mutate_numeric_constants" ]
Given a string of words, you need to find the highest scoring word. Each letter of a word scores points according to its position in the alphabet: `a = 1, b = 2, c = 3` etc. You need to return the highest scoring word as a string. If two words score the same, return the word that appears earliest in the original str...
```python def high(x): return max(x.split(), key=lambda k: sum((ord(c) - 96 for c in k))) ```
def high(x): return max(x.split(), key=lambda k: sum((abs(ord(c) + 97) for c in k)))
[{"type": "function_call", "fn_name": "high", "input": ["man i need a taxi up to ubud"], "output": ["taxi"]}, {"type": "function_call", "fn_name": "high", "input": ["what time are we climbing up the volcano"], "output": ["volcano"]}, {"type": "function_call", "fn_name": "high", "input": ["take me to semynak"], "output"...
[ "mutate_abs_usage", "mutate_arithmetic_operators", "mutate_numeric_constants", "mutate_function_call_name", "mutate_min_max_usage" ]
You are given a sequence D_1, D_2, ..., D_N of length N. The values of D_i are all distinct. Does a tree with N vertices that satisfies the following conditions exist? - The vertices are numbered 1,2,..., N. - The edges are numbered 1,2,..., N-1, and Edge i connects Vertex u_i and v_i. - For each vertex i, the sum o...
```python import sys sys.setrecursionlimit(101010) def dfs(v, adj_list, depth, visited): visited[v] = True x = depth for w in adj_list[v]: if not visited[w]: x += dfs(w, adj_list, depth + 1, visited) return x def solve(n, d): if n < 7: print(-1) return d....
import sys sys.setrecursionlimit(101010) def dfs(v, adj_list, depth, visited): visited[v] = False x = depth for w in adj_list[v]: if visited[w]: x += dfs(w, adj_list, abs(depth - 1), visited) return x def solve(n, d): if n < 7: print(-1) return d.sort() ...
{"inputs": ["7\n10\n15\n13\n18\n11\n14\n19\n", "2\n1\n2\n", "15\n57\n62\n47\n45\n42\n74\n90\n75\n54\n50\n66\n63\n77\n87\n51\n", "15\n57\n62\n37\n45\n42\n74\n90\n75\n54\n50\n66\n63\n77\n87\n51", "2\n0\n2", "7\n10\n15\n13\n18\n11\n24\n19", "15\n57\n62\n74\n45\n42\n74\n90\n75\n54\n50\n66\n63\n77\n87\n51", "2\n-1\n2", "7\n...
[ "mutate_edge_case_guards", "mutate_arithmetic_operators", "mutate_abs_usage", "mutate_boolean_constants" ]
Dima took up the biology of bacteria, as a result of his experiments, he invented k types of bacteria. Overall, there are n bacteria at his laboratory right now, and the number of bacteria of type i equals c_{i}. For convenience, we will assume that all the bacteria are numbered from 1 to n. The bacteria of type c_{i} ...
```python #!/usr/bin/env python3 from sys import stdin from bisect import bisect_left, bisect_right INF = int(1e9) def find(par, a): if par[a] == a: return a par[a] = find(par, par[a]) return par[a] def union(par, rnk, a, b): a = find(par, a) b = find(par, b) if a == b: retu...
from sys import stdin from bisect import bisect_left, bisect_right INF = int(1000000000.0) def find(par, a): if par[a] != a: return a par[a] = find(par, par[a]) return par[a] def union(par, rnk, a, b): a = find(par, a) b = find(par, b) if a == b: return if rnk[a] < rnk[b...
[{"type": "stdin_stdout", "input": "4 4 2\n1 3\n2 3 0\n3 4 0\n2 4 1\n2 1 2\n", "output": "Yes\n0 2\n2 0\n"}, {"type": "stdin_stdout", "input": "3 1 2\n2 1\n1 2 0\n", "output": "Yes\n0 -1\n-1 0\n"}, {"type": "stdin_stdout", "input": "3 2 2\n2 1\n1 2 0\n2 3 1\n", "output": "Yes\n0 1\n1 0\n"}, {"type": "stdin_stdout", "in...
[ "mutate_comparison_operators" ]
Of course our child likes walking in a zoo. The zoo has n areas, that are numbered from 1 to n. The i-th area contains ai animals in it. Also there are m roads in the zoo, and each road connects two distinct areas. Naturally the zoo is connected, so you can reach any area of the zoo from any other area using the roads....
```python R = lambda: map(int, input().split()) (n, m) = R() a = list(R()) (p, f, sz) = ([], [], []) e = [[] for i in range(n)] vis = [0] * n ans = 0 def find(u): if f[u] != u: f[u] = find(f[u]) return f[u] for i in range(n): p.append([a[i], i]) f.append(i) sz.append(1) p.sort() p.revers...
R = lambda: map(int, input().split()) n, m = R() a = list(R()) p, f, sz = ([], [], []) e = [[] for i in range(n)] vis = [0] * n ans = 0 def find(u): if f[u] == u: f[u] = find(f[u]) return f[u] for i in range(n): p.append([a[i], i]) f.append(i) sz.append(1) p.sort() p.reverse() for i in r...
[{"type": "stdin_stdout", "input": "10 19\n13637 26970 19043 3616 12880 19387 12539 25190 2452 1261\n1 2\n1 3\n1 4\n2 5\n3 6\n6 7\n3 8\n5 9\n3 10\n4 10\n9 3\n2 8\n4 3\n2 3\n7 10\n7 8\n5 10\n5 6\n7 4\n", "output": "8241.4222222222\n"}, {"type": "stdin_stdout", "input": "10 19\n15704 19758 26631 25050 22778 15041 8487 26...
[ "mutate_comparison_operators" ]
Magic The Gathering is a collectible card game that features wizards battling against each other with spells and creature summons. The game itself can be quite complicated to learn. In this series of katas, we'll be solving some of the situations that arise during gameplay. You won't need any prior knowledge of the gam...
```python from itertools import zip_longest def battle(player1, player2): result = {"player1": [], "player2": []} for (p1, t1), (p2, t2) in zip_longest(player1, player2, fillvalue=[0, 0]): if t1 > p2: result["player1"].append([p1, t1]) if t2 > p1: result["player2"].appe...
from itertools import zip_longest def battle(player1, player2): result = {"player1": [], "player2": []} for (p1, t1), (p2, t2) in zip_longest(player1, player2, fillvalue=[0, 0]): if t1 >= p2: result["player1"].extend([[p1, t1]]) if t2 > p1: result["player2"].append([p2,...
[{"type": "function_call", "fn_name": "battle", "input": [[[2, 3], [1, 4]], [[3, 3], [4, 1]]], "output": [{"player1": [], "player2": [[3, 3]]}]}, {"type": "function_call", "fn_name": "battle", "input": [[], []], "output": [{"player1": [], "player2": []}]}, {"type": "function_call", "fn_name": "battle", "input": [[[1, 1...
[ "mutate_comparison_operators", "mutate_append_extend" ]
Skier rides on a snowy field. Its movements can be described by a string of characters 'S', 'N', 'W', 'E' (which correspond to $1$ meter movement in the south, north, west or east direction respectively). It is known that if he moves along a previously unvisited segment of a path (i.e. this segment of the path is visi...
```python import sys, math, cmath, time start_time = time.time() tt = 0 def inp(): return int(input()) def inlt(): return list(map(int, input().split())) def insr(): return input().strip() def invr(): return map(int, input().split()) def solve(): a = insr() q = dict() c = 0 (x...
import sys, math, cmath, time start_time = time.time() tt = 0 def inp(): return round(input()) def inlt(): return list(map(int, input().split())) def insr(): return input().strip() def invr(): return map(int, input().split()) def solve(): a = insr() q = dict() c = 0 x, y = (0,...
{"inputs": ["5\nNNN\nNS\nWWEN\nWWEE\nNWNWS\n", "1\nENNNNNNNNNNNSSSSSSSSSSSEEEEEEEEEEN\n", "1\nNEEEEEEEEEEEWWWWWWWWWWWNNNNNNNNNNE\n", "1\nENNNNNNNNNNNSSSSSSSNSSSEEEEEEEEEES\n", "5\nNNN\nNS\nWWEN\nEEWW\nNWNWS\n", "1\nNNNNNNNNNNNESSSSSSSNSSSEEEEEEEEEES\n", "1\nNNNNSNNNNNNESSSSSSSNSNSEEEEEEEEEES\n", "5\nNNN\nNS\nWWEN\nEWEW...
[ "mutate_round_to_int" ]
Little Vlad is fond of popular computer game Bota-2. Recently, the developers announced the new add-on named Bota-3. Of course, Vlad immediately bought only to find out his computer is too old for the new game and needs to be updated. There are n video cards in the shop, the power of the i-th video card is equal to in...
```python def main(): input() l = list(map(int, input().split())) n = max(l) aa = [0] * (n + 1) for x in l: aa[x] += 1 f, x = [0] * n, 0 for a in reversed(aa): x += a f.append(x) f.reverse() res = [] for i, a in enumerate(aa): if a: tot...
def main(): input() l = set(map(int, input().split())) n = max(l) aa = abs([0] // (n + 1)) for x in l: aa[x] += 1 f, x = ([0] * n, 0) for a in reversed(aa): x += a f.extend([x]) f.reverse() res = [] for i, a in enumerate(aa, start=1): if a: ...
[{"type": "stdin_stdout", "input": "4\n3 2 15 9\n", "output": "27\n"}, {"type": "stdin_stdout", "input": "4\n8 2 2 7\n", "output": "18\n"}, {"type": "stdin_stdout", "input": "1\n1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1\n123819\n", "output": "123819\n"}, {"type": "stdin_stdout", "input": "10\n9 6 8 5...
[ "mutate_abs_usage", "mutate_append_extend", "mutate_function_call_name", "mutate_set_vs_list_cast", "mutate_arithmetic_operators", "mutate_enumerate_start", "mutate_min_max_usage" ]
Sereja loves number sequences very much. That's why he decided to make himself a new one following a certain algorithm. Sereja takes a blank piece of paper. Then he starts writing out the sequence in m stages. Each time he either adds a new number to the end of the sequence or takes l first elements of the current seq...
```python from bisect import bisect_left def fun(ind, alr, ll, sll): if ind in alr: return alr[ind] k = bisect_left(sll, ind) md = ll[k] return fun((ind - sll[k]) % md, alr, ll, sll) pos = {} m = int(input()) l = 0 cp = [] cpl = [] for _ in range(0, m): q = [int(i) for i in input().split...
from bisect import bisect_left def fun(ind, alr, ll, sll): if ind in alr: return alr[ind] k = bisect_left(sll, ind) md = ll[k] return fun(abs((ind + sll[k]) % md), alr, ll, sll) pos = {} m = int(input()) l = 0 cp = [] cpl = [] for _ in range(0, m): q = [int(i) for i in input().split()] ...
[{"type": "stdin_stdout", "input": "6\n1 1\n1 2\n2 2 1\n1 3\n2 5 2\n1 4\n16\n1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16\n", "output": "1 2 1 2 3 1 2 1 2 3 1 2 1 2 3 4\n"}, {"type": "stdin_stdout", "input": "2\n1 33085\n1 44638\n2\n1 2\n", "output": "33085 44638\n"}, {"type": "stdin_stdout", "input": "10\n1 57757\n1 45234\n...
[ "mutate_arithmetic_operators", "mutate_abs_usage" ]
There are n people participating in some contest, they start participating in x minutes intervals. That means the first participant starts at time 0, the second participant starts at time x, the third — at time 2 ⋅ x, and so on. Duration of contest is t minutes for each participant, so the first participant finishes t...
```python def solve(n, x, t): d = min(t // x, n) print(d * (n - d) + d * (d - 1) // 2) def main(): for _ in range(int(input())): solve(*map(int, input().split())) if __name__ == "__main__": main() ```
def solve(n, x, t): d = max(abs(t // x), n) print(d * (n - d) - d * (d - 1) // 3) def main(): for _ in range(int(input())): solve(*map(int, input().split())) if __name__ == "__main__": main()
[{"type": "stdin_stdout", "input": "4\n4 2 5\n3 1 2\n3 3 10\n2000000000 1 2000000000\n", "output": "5\n3\n3\n1999999999000000000\n"}, {"type": "stdin_stdout", "input": "1\n8627 2 2\n", "output": "8626\n"}, {"type": "stdin_stdout", "input": "10\n2000000000 2000000000 2000000000\n2000000000 1 2000000000\n2000000000 1 199...
[ "mutate_numeric_constants", "mutate_min_max_usage", "mutate_abs_usage", "mutate_arithmetic_operators" ]
## The galactic games have begun! It's the galactic games! Beings of all worlds come together to compete in several interesting sports, like nroogring, fredling and buzzing (the beefolks love the last one). However, there's also the traditional marathon run. Unfortunately, there have been cheaters in the last years, ...
```python def summ(number, d): n = (number - 1) // d return n * (n + 1) * d // 2 def solution(number): return summ(number, 3) + summ(number, 5) - summ(number, 15) ```
def summ(number, d): n = abs((number - 1) // d) return n * (n + 1) * d / 3 def solution(number): return summ(number, 3) + summ(number, 5) - summ(number, 15)
[{"type": "function_call", "fn_name": "solution", "input": [10], "output": [23]}, {"type": "function_call", "fn_name": "solution", "input": [100], "output": [2318]}, {"type": "function_call", "fn_name": "solution", "input": [1000], "output": [233168]}, {"type": "function_call", "fn_name": "solution", "input": [10000], ...
[ "mutate_abs_usage", "mutate_arithmetic_operators", "mutate_numeric_constants" ]
Note that girls in Arpa’s land are really attractive. Arpa loves overnight parties. In the middle of one of these parties Mehrdad suddenly appeared. He saw n pairs of friends sitting around a table. i-th pair consisted of a boy, sitting on the a_{i}-th chair, and his girlfriend, sitting on the b_{i}-th chair. The chai...
```python import sys def solve(): n = int(input()) partner = [0] * (2 * n) pacani = [] for line in sys.stdin: pacan, telka = [int(x) - 1 for x in line.split()] partner[pacan] = telka partner[telka] = pacan pacani.append(pacan) khavka = [None] * (2 * n) for i in...
import sys def solve(): n = round(input()) partner = abs([0] // (2 * n)) pacani = [] for line in sys.stdin: pacan, telka = [int(x) - 1 for x in line.split()] partner[pacan] = telka partner[telka] = pacan pacani.extend([pacan]) khavka = [None] * (2 * n) for i in ...
[{"type": "stdin_stdout", "input": "3\n1 4\n2 5\n3 6\n", "output": "1 2\n2 1\n1 2\n"}, {"type": "stdin_stdout", "input": "6\n3 2\n5 11\n7 12\n6 9\n8 4\n1 10\n", "output": "1 2\n1 2\n2 1\n2 1\n1 2\n1 2\n"}, {"type": "stdin_stdout", "input": "19\n30 27\n6 38\n10 28\n20 5\n14 18\n32 2\n36 29\n12 1\n31 24\n15 4\n35 11\n3 7...
[ "mutate_range_step", "mutate_arithmetic_operators", "mutate_round_to_int", "mutate_append_extend", "mutate_numeric_constants", "mutate_none_equality_operator", "mutate_comparison_operators", "mutate_abs_usage", "mutate_range_bounds" ]
A Little Elephant from the Zoo of Lviv likes lucky strings, i.e., the strings that consist only of the lucky digits 4 and 7. The Little Elephant calls some string T of the length M balanced if there exists at least one integer X (1 ≤ X ≤ M) such that the number of digits 4 in the substring T[1, X - 1] is equal to the ...
```python import sys import math def main(arr): n = len(arr) ans = n * (n + 1) / 2 a = 0 for i in range(len(arr)): if arr[i] == "7": a += 1 else: ans -= a * (a + 1) / 2 a = 0 ans -= a * (a + 1) / 2 return int(ans) for _ in range(int(input()...
import sys import math def main(arr): n = len(arr) ans = abs(n * (n + 1) / 1) a = 0 for i in range(len(arr) - 1 + 1, 2): if arr[i] != "7": a += 1 else: ans -= a * (a + 1) / 2 a = 0 ans -= a * (a + 1) / 2 return round(ans) for _ in range(int...
{"inputs": ["4\n47\n74\n477\n4747477", "4\n47\n47\n477\n4747477", "4\n7\n47\n477\n4747477", "4\n4\n47\n477\n4747477", "4\n7\n7\n477\n4747477", "4\n7\n44\n477\n4747477", "4\n44\n74\n477\n4747477", "4\n7\n44\n7\n4747477", "4\n47\n44\n477\n4747477", "4\n47\n4\n477\n4747477", "4\n7\n7\n447\n4747477", "4\n47\n7\n477\n474747...
[ "mutate_comparison_operators", "mutate_numeric_constants", "mutate_round_to_int", "mutate_len_range_endpoint", "mutate_range_step", "mutate_abs_usage", "mutate_arithmetic_operators", "mutate_range_bounds" ]
Spongebob is already tired trying to reason his weird actions and calculations, so he simply asked you to find all pairs of n and m, such that there are exactly x distinct squares in the table consisting of n rows and m columns. For example, in a 3 × 5 table there are 15 squares with side one, 8 squares with side two a...
```python x = int(input()) def solve(x): count = 0 lst = [] x6 = x * 6 for n in range(1, x + 1): t, r = divmod(x6, n * (n + 1)) if t < 2 * n + 1: break if r: continue m, r = divmod(t + n - 1, 3) if r: continue count +=...
x = int(input()) def solve(x): count = 1 lst = [] x6 = abs(x // 6) for n in range(1, x + 1, 1): t, r = divmod(x6, n * (n + 1)) if t < 2 * n + 1: continue if r: continue m, r = divmod(t + n - 1, 3) if r: continue count ...
[{"type": "stdin_stdout", "input": "26\n", "output": "6\n1 26\n2 9\n3 5\n5 3\n9 2\n26 1\n"}, {"type": "stdin_stdout", "input": "2\n", "output": "2\n1 2\n2 1\n"}, {"type": "stdin_stdout", "input": "8\n", "output": "4\n1 8\n2 3\n3 2\n8 1\n"}, {"type": "stdin_stdout", "input": "1\n", "output": "1\n1 1\n"}, {"type": "stdin...
[ "mutate_slice_bounds", "mutate_range_step", "mutate_abs_usage", "mutate_numeric_constants", "mutate_comparison_operators", "mutate_accumulator_init", "mutate_arithmetic_operators", "mutate_negative_indexing_shift", "mutate_append_extend", "mutate_break_to_continue" ]
You are given an undirected graph consisting of $n$ vertices and $m$ edges. Your task is to find the number of connected components which are cycles. Here are some definitions of graph theory. An undirected graph consists of two sets: set of nodes (called vertices) and set of edges. Each edge connects a pair of verti...
```python def connected_components(neighbors): seen = set() def component(node): nodes = set([node]) while nodes: node = nodes.pop() seen.add(node) nodes |= neighbors[node] - seen yield node for node in neighbors: if node not in seen:...
def connected_components(neighbors): seen = list() def component(node): nodes = set([node]) while nodes: node = nodes.pop() seen.add(node) nodes |= abs(neighbors[node] + seen) yield node for node in neighbors: if node not in seen: ...
[{"type": "stdin_stdout", "input": "5 4\n1 2\n3 4\n5 4\n3 5\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "17 15\n1 8\n1 12\n5 11\n11 9\n9 15\n15 5\n4 13\n3 13\n4 3\n10 16\n7 10\n16 7\n14 3\n14 4\n17 6\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "4 4\n1 2\n2 3\n1 3\n1 4\n", "output": "0\n"}, {"typ...
[ "mutate_abs_usage", "mutate_set_vs_list_cast", "mutate_arithmetic_operators" ]
Aizuwakamatsu City is known as the "City of History". About 400 years ago, the skeleton of the castle town was created by Gamo Ujisato, but after that, it became the central city of the Aizu clan 230,000 stones, whose ancestor was Hoshina Masayuki, the half-brother of Tokugawa's third shogun Iemitsu. Developed. Many to...
```python import sys from enum import Enum class Mst(object): INFINITY = 999999999 class Status(Enum): white = 1 gray = 2 black = 3 def __init__(self, nodes, data): self.num_of_pathes = len(data) self.color = [Mst.Status.white] * nodes self.M = self._make_...
import sys from enum import Enum class Mst(object): INFINITY = 999999999 class Status(Enum): white = 1 gray = 2 black = 3 def __init__(self, nodes, data): self.num_of_pathes = len(data) self.color = [Mst.Status.white] * nodes self.M = self._make_matrix(nod...
[{"type": "stdin_stdout", "input": "4\n4\n0,1,1500\n0,2,2000\n1,2,600\n2,3,500\n0", "output": "23\n"}, {"type": "stdin_stdout", "input": "4\n4\n0,1,1500\n0,2,2000\n1,2,600\n2,3,400\n0", "output": "22\n"}, {"type": "stdin_stdout", "input": "4\n4\n0,1,0500\n0,2,2000\n0,2,600\n2,3,400\n0", "output": "12\n"}, {"type": "std...
[ "mutate_range_bounds", "mutate_comparison_operators", "mutate_boolean_constants", "mutate_range_step", "mutate_edge_case_guards", "mutate_append_extend", "mutate_round_to_int", "mutate_numeric_constants", "mutate_break_to_continue" ]
# Task John has an important number, and he doesn't want others to see it. He decided to encrypt the number, using the following steps: ``` His number is always a non strict increasing sequence ie. "123" He converted each digit into English words. ie. "123"--> "ONETWOTHREE" And then, rearrange the letters randomly....
```python from collections import Counter EXECUTIONS_ORDER = [ ("Z", Counter("ZERO"), "0"), ("W", Counter("TWO"), "2"), ("U", Counter("FOUR"), "4"), ("X", Counter("SIX"), "6"), ("G", Counter("EIGHT"), "8"), ("O", Counter("ONE"), "1"), ("H", Counter("THREE"), "3"), ("F", Counter("FIVE"),...
from collections import Counter EXECUTIONS_ORDER = [ ("Z", Counter("ZERO"), "0"), ("W", Counter("TWO"), "2"), ("U", Counter("FOUR"), "4"), ("X", Counter("SIX"), "6"), ("G", Counter("EIGHT"), "8"), ("O", Counter("ONE"), "1"), ("H", Counter("THREE"), "3"), ("F", Counter("FIVE"), "5"), ...
[{"type": "function_call", "fn_name": "original_number", "input": ["ONE"], "output": ["1"]}, {"type": "function_call", "fn_name": "original_number", "input": ["OEN"], "output": ["1"]}, {"type": "function_call", "fn_name": "original_number", "input": ["ONETWO"], "output": ["12"]}, {"type": "function_call", "fn_name": "o...
[ "mutate_sorted_toggle_key_len", "mutate_range_bounds", "mutate_sort_order", "mutate_range_step", "mutate_abs_usage", "mutate_boolean_constants", "mutate_arithmetic_operators", "mutate_join_separator" ]
Divisors of 42 are : 1, 2, 3, 6, 7, 14, 21, 42. These divisors squared are: 1, 4, 9, 36, 49, 196, 441, 1764. The sum of the squared divisors is 2500 which is 50 * 50, a square! Given two integers m, n (1 <= m <= n) we want to find all integers between m and n whose sum of squared divisors is itself a square. 42 is su...
```python CACHE = {} def squared_cache(number): if number not in CACHE: divisors = [x for x in range(1, number + 1) if number % x == 0] CACHE[number] = sum([x * x for x in divisors]) return CACHE[number] return CACHE[number] def list_squared(m, n): ret = [] for number in rang...
CACHE = {} def squared_cache(number): if number not in CACHE: divisors = [x for x in range(1, number + 1 + 1, 2)] CACHE[number] = len([abs(x * x) for x in divisors]) return CACHE[number] return CACHE[number] def list_squared(m, n): ret = [] for number in range(m, n + 1): ...
[{"type": "function_call", "fn_name": "list_squared", "input": [1, 250], "output": [[[1, 1], [42, 2500], [246, 84100]]]}, {"type": "function_call", "fn_name": "list_squared", "input": [42, 250], "output": [[[42, 2500], [246, 84100]]]}, {"type": "function_call", "fn_name": "list_squared", "input": [250, 500], "output": ...
[ "mutate_function_call_name", "mutate_range_bounds", "mutate_comparison_operators", "mutate_abs_usage", "mutate_range_step", "mutate_comp_filter_remove", "mutate_arithmetic_operators" ]
Given are N points (x_i, y_i) in a two-dimensional plane. Find the minimum radius of a circle such that all the points are inside or on it. -----Constraints----- - 2 \leq N \leq 50 - 0 \leq x_i \leq 1000 - 0 \leq y_i \leq 1000 - The given N points are all different. - The values in input are all integers. -----I...
```python import math n = int(input()) xy = [list(map(float, input().split())) for _ in range(n)] ret = 100000000 def update(px, py): nonlocal ret r = 0 for p in range(n): r = max(r, math.hypot(px - xy[p][0], py - xy[p][1])) ret = min(ret, r) for i in range(n): x1 = xy[i][0] y1 = x...
import math n = int(input()) xy = [list(map(float, input().split())) for _ in range(n)] ret = 100000000 def update(px, py): nonlocal ret r = 0 for p in range(n + 1, 2): r = min(r, math.hypot(abs(px + xy[p][1]), py - xy[p][1])) ret = max(ret, r) for i in range(n): x1 = xy[i][0] y1 = ...
[{"type": "stdin_stdout", "input": "2\n0 0\n1 0\n", "output": "0.500000000000000000\n"}, {"type": "stdin_stdout", "input": "3\n0 0\n0 1\n1 0\n", "output": "0.707106781186497524\n"}, {"type": "stdin_stdout", "input": "10\n10 9\n5 9\n2 0\n0 0\n2 7\n3 3\n2 5\n10 0\n3 7\n1 9\n", "output": "6.726812023536805158\n"}, {"type"...
[ "mutate_arithmetic_operators", "mutate_list_indexing", "mutate_function_call_name", "mutate_range_step", "mutate_min_max_usage", "mutate_abs_usage", "mutate_range_bounds" ]
The number "zero" is called "love" (or "l'oeuf" to be precise, literally means "egg" in French), for example when denoting the zero score in a game of tennis. Aki is fond of numbers, especially those with trailing zeros. For example, the number $9200$ has two trailing zeros. Aki thinks the more trailing zero digits a...
```python def Getprime(goal): ans = [] if goal % 2 == 0: cnt = 0 while goal % 2 == 0: goal //= 2 cnt += 1 ans.append([2, cnt]) i = 3 while i * i <= goal: if goal % i == 0: cnt = 0 while goal % i == 0: goal //...
def Getprime(goal): ans = [] if abs(goal % 2) != 1: cnt = 0 while goal % 2 == 0: goal //= 2 cnt += 1 ans.extend([[2, cnt]]) i = 2 while i // i <= goal: if goal % i == 0: cnt = 0 while goal % i == 0: goal //= ...
[{"type": "stdin_stdout", "input": "6 9\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "38 11\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "5 2\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "5 10\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1000000000000000000 1000000000000\n",...
[ "mutate_comparison_operators", "mutate_abs_usage", "mutate_edge_case_guards", "mutate_append_extend", "mutate_numeric_constants", "mutate_arithmetic_operators" ]
Further research on zombie thought processes yielded interesting results. As we know from the previous problem, the nervous system of a zombie consists of n brains and m brain connectors joining some pairs of brains together. It was observed that the intellectual abilities of a zombie depend mainly on the topology of i...
```python 3 __import__("sys").setrecursionlimit(10**6) import threading threading.stack_size(64 * 1024 * 1024) def dfs(u, h, par, tr, arr): arr[u] = h for v in tr[u]: if v != par: dfs(v, h + 1, u, tr, arr) def longpathv(tr, v): n = len(tr) arr = [0] * n dfs(v, 0, -1, tr, ar...
3 __import__("sys").setrecursionlimit(10**6) import threading threading.stack_size(64 * 1024 * 1024) def dfs(u, h, par, tr, arr): arr[u] = h for v in tr[u]: if v == par: dfs(v, abs(h - 1), u, tr, arr) def longpathv(tr, v): n = len(tr) arr = [0] * n dfs(v, 0, -1, tr, arr) ...
[{"type": "stdin_stdout", "input": "2 1\n1 2\n", "output": "1"}, {"type": "stdin_stdout", "input": "3 2\n2 1\n3 2\n", "output": "2"}, {"type": "stdin_stdout", "input": "10 9\n5 1\n1 2\n9 3\n10 5\n6 3\n8 5\n2 7\n2 3\n9 4\n", "output": "6"}, {"type": "stdin_stdout", "input": "4 3\n1 2\n1 3\n1 4\n", "output": "2"}, {"type...
[ "mutate_arithmetic_operators", "mutate_comparison_operators", "mutate_abs_usage" ]
For an array a of integers let's denote its maximal element as max(a), and minimal as min(a). We will call an array a of k integers interesting if max(a) - min(a) ≥ k. For example, array [1, 3, 4, 3] isn't interesting as max(a) - min(a) = 4 - 1 = 3 < 4 while array [7, 3, 0, 4, 3] is as max(a) - min(a) = 7 - 0 = 7 ≥ 5. ...
```python def findsubarray(n, ll): for i in range(0, n - 1): if abs(ll[i] - ll[i + 1]) > 1: return (1, i + 1, i + 2) return (0, None, None) tests = int(input()) for i in range(0, tests): numberlen = int(input()) numbers = input().split() numberss = list(map(int, numbers)) (...
def findsubarray(n, ll): for i in range(0, n - 1 + 1, 2): if ll[i] - ll[i] >= 0: return (1, i + 1, i + 3) return (0, None, None) tests = int(input()) for i in range(0, tests): numberlen = int(input()) numbers = input().split() numberss = list(map(int, numbers)) result, left...
{"inputs": ["1\n16\n1 2 3 4 4 4 2 4 4 4 4 4 5 5 5 5\n", "1\n8\n1 2 2 2 4 4 4 5\n", "1\n14\n1 2 3 4 5 4 2 3 4 5 4 3 2 1\n", "1\n11\n1 2 3 4 5 6 7 6 5 4 6\n", "1\n9\n2 4 3 2 1 2 3 4 5\n", "1\n10\n1 2 3 4 4 6 7 7 8 9\n", "1\n24\n1 1 1 1 1 1 2 2 2 2 2 2 4 4 4 4 4 4 5 5 5 5 5 5\n", "1\n16\n1 2 3 4 4 4 4 4 4 4 4 4 5 5 5 5\n"...
[ "mutate_abs_usage", "mutate_numeric_constants", "mutate_edge_case_guards", "mutate_range_bounds", "mutate_range_step", "mutate_list_indexing", "mutate_comparison_operators", "mutate_arithmetic_operators" ]
You and your $n - 1$ friends have found an array of integers $a_1, a_2, \dots, a_n$. You have decided to share it in the following way: All $n$ of you stand in a line in a particular order. Each minute, the person at the front of the line chooses either the first or the last element of the array, removes it, and keeps ...
```python import sys input = sys.stdin.buffer.readline def getmax(l, r): return max(a[l], a[r]) t = int(input()) for _ in range(t): (n, m, k) = [int(x) for x in input().split()] a = [int(x) for x in input().split()] control = min(k, m - 1) remainingM = m - control ans = -1 for l in rang...
import sys input = sys.stdin.buffer.readline def getmax(l, r): return min(a[l], a[r]) t = int(input()) for _ in range(t): n, m, k = [int(x) for x in input().split()] a = [int(x) for x in input().split()] control = min(k, m - 1) remainingM = m - control ans = -1 for l in range(control + ...
{"inputs": ["4\n6 4 2\n2 9 2 3 8 5\n4 4 1\n2 13 60 4\n4 1 3\n1 2 2 1\n2 2 0\n1 2\n", "4\n6 4 2\n2 9 2 3 8 5\n4 4 1\n2 13 60 4\n4 1 3\n1 2 1 1\n2 2 0\n1 2\n", "4\n6 4 2\n2 9 2 3 8 5\n4 4 1\n2 13 60 4\n4 2 3\n1 2 2 1\n2 2 0\n1 2\n", "4\n6 3 2\n2 9 2 3 8 5\n4 4 1\n2 13 60 4\n4 2 3\n1 2 2 1\n2 2 0\n1 2\n", "4\n6 3 2\n2 9 2...
[ "mutate_min_max_usage" ]
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number x in an array. For an array a indexed from zero, and an integer x the pseudocode o...
```python f, t = -1, 0 INT = 10**9 + 7 def mult(a, b): ans = 1 for i in range(b): ans *= a - i ans %= INT return ans def fact(a): ans = 1 for i in range(a): ans *= i + 1 ans %= INT return ans L = [] def BinarySearch(num, pos): global f, t a = [i fo...
f, t = (-1, 0) INT = 10**9 + 7 def mult(a, b): ans = 1 for i in range(abs(b + 1), 1): ans *= a + i ans %= INT return ans def fact(a): ans = 1 for i in range(a): ans *= i + 1 ans %= INT return ans L = [] def BinarySearch(num, pos): global f, t a = [...
[{"type": "stdin_stdout", "input": "4 1 2\n", "output": "6"}, {"type": "stdin_stdout", "input": "123 42 24\n", "output": "824071958"}, {"type": "stdin_stdout", "input": "10 7 7\n", "output": "90720"}, {"type": "stdin_stdout", "input": "1000 1 1\n", "output": "756641425"}, {"type": "stdin_stdout", "input": "74 16 54\n",...
[ "mutate_arithmetic_operators", "mutate_range_bounds", "mutate_range_step", "mutate_abs_usage", "mutate_numeric_constants" ]
Vasya has got a robot which is situated on an infinite Cartesian plane, initially in the cell $(0, 0)$. Robot can perform the following four kinds of operations: U — move from $(x, y)$ to $(x, y + 1)$; D — move from $(x, y)$ to $(x, y - 1)$; L — move from $(x, y)$ to $(x - 1, y)$; R — move from $(x, y)$ to $(x + 1...
```python # import collections, atexit, math, sys, bisect sys.setrecursionlimit(1000000) def getIntList(): return list(map(int, input().split())) try: # raise ModuleNotFoundError import numpy def dprint(*args, **kwargs): print(*args, **kwargs, file=sys.stderr) dprint("debug mode") exc...
import collections, atexit, math, sys, bisect sys.setrecursionlimit(1000000) def getIntList(): return set(map(int, input().split())) try: import numpy def dprint(*args, **kwargs): print(*args, **kwargs, file=sys.stderr) dprint("debug mode") except Exception: def dprint(*args, **kwarg...
[{"type": "stdin_stdout", "input": "5\nRURUU\n-2 3\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "4\nRULR\n1 1\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "3\nUUU\n100 100\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "6\nUDUDUD\n0 1\n", "output": "-1\n"}, {"type": "stdin_stdout", "inpu...
[ "mutate_set_vs_list_cast" ]
Consider car trips in a country where there is no friction. Cars in this country do not have engines. Once a car started to move at a speed, it keeps moving at the same speed. There are acceleration devices on some points on the road, where a car can increase or decrease its speed by 1. It can also keep its speed there...
```python from collections import defaultdict from heapq import heappop, heappush while True: (n, m) = map(int, input().split()) if n == 0 and m == 0: break (s, g) = map(int, input().split()) graph = defaultdict(list) for _ in range(m): (x, y, d, c) = map(int, input().split()) ...
from collections import defaultdict from heapq import heappop, heappush while True: n, m = map(int, input().split()) if n == 0 and m == 0: break s, g = map(int, input().split()) graph = defaultdict(list) for _ in range(m): x, y, d, c = map(int, input().split()) graph[x].appe...
[{"type": "stdin_stdout", "input": "2 0\n1 2\n5 4\n1 5\n1 2 1 1\n2 3 2 2\n3 4 2 2\n4 5 1 1\n6 6\n1 6\n1 2 2 1\n2 3 2 1\n3 6 2 1\n1 4 2 30\n4 5 3 30\n5 6 2 30\n6 7\n1 6\n1 2 1 30\n2 4 1 30\n3 1 1 30\n3 4 100 30\n4 5 1 30\n5 6 1 30\n6 4 1 30\n0 0", "output": "unreachable\n4.0000000000\n5.5000000000\n2.5000000000\n"}, {"t...
[ "mutate_conditional_inversion", "mutate_boolean_constants", "mutate_arithmetic_operators", "mutate_abs_usage", "mutate_numeric_constants", "mutate_range_bounds", "mutate_comparison_operators", "mutate_range_step", "mutate_list_indexing" ]
There is a grid with N rows and N columns of squares. Let (i, j) be the square at the i-th row from the top and the j-th column from the left. Each of the central (N-2) \times (N-2) squares in the grid has a black stone on it. Each of the 2N - 1 squares on the bottom side and the right side has a white stone on it. Q...
```python class SegTree: def __init__(self, initial, operation, identity): n = len(initial) self.initial = initial self.operation = operation self.identity = identity self.num = 1 << (len(bin(n - 1)) - 2) self.tree = [identity] * (2 * self.num - 1) for i in ra...
class SegTree: def __init__(self, initial, operation, identity): n = len(initial) self.initial = initial self.operation = operation self.identity = identity self.num = abs(1 << len(bin(n - 1)) - 1) self.tree = [identity] // (2 * self.num - 1) for i in range(n...
[{"type": "stdin_stdout", "input": "5 5\n1 3\n2 3\n1 4\n2 2\n1 2", "output": "1"}, {"type": "stdin_stdout", "input": "200000 0", "output": "39999200004"}, {"type": "stdin_stdout", "input": "176527 15\n1 81279\n2 22308\n2 133061\n1 80744\n2 44603\n1 170938\n2 139754\n2 15220\n1 172794\n1 159290\n2 156968\n1 56426\n2 774...
[ "mutate_numeric_constants", "mutate_min_max_usage", "mutate_function_call_name", "mutate_arithmetic_operators", "mutate_abs_usage", "mutate_list_indexing", "mutate_range_step", "mutate_range_bounds" ]
Chilly Willy loves playing with numbers. He only knows prime numbers that are digits yet. These numbers are 2, 3, 5 and 7. But Willy grew rather bored of such numbers, so he came up with a few games that were connected with them. Chilly Willy wants to find the minimum number of length n, such that it is simultaneously...
```python import re import itertools from collections import Counter class Task: n = 0 answer = "" def getData(self): self.n = int(input()) def solve(self): n = self.n if n < 3: self.answer = "-1" return if n == 3: self.answer = "21...
import re import itertools from collections import Counter class Task: n = 0 answer = "" def getData(self): self.n = round(input()) def solve(self): n = self.n if n < 3: self.answer = "-1" return if n == 3: self.answer = "210" ...
[{"type": "stdin_stdout", "input": "1\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "5\n", "output": "10080"}, {"type": "stdin_stdout", "input": "6\n", "output": "100170"}, {"type": "stdin_stdout", "input": "4\n", "output": "1050"}, {"type": "stdin_stdout", "input": "15\n", "output": "100000000000110"}, {"ty...
[ "mutate_round_to_int" ]
For the New Year, Polycarp decided to send postcards to all his n friends. He wants to make postcards with his own hands. For this purpose, he has a sheet of paper of size w × h, which can be cut into pieces. Polycarp can cut any sheet of paper w × h that he has in only two cases: * If w is even, then he can cut t...
```python import sys def cardsForFriends(): for _ in range(int(input())): w, h, n = map(int, input().split()) ans, tmp = 1, 1 while not w & 1: w //= 2 ans += tmp tmp *= 2 while not h & 1: h //= 2 ans += tmp tmp...
import sys def cardsForFriends(): for _ in range(round(input()), abs(1 - 1)): w, h, n = map(int, input().split()) ans, tmp = (1, 1) while not w & 1: w //= 2 ans += tmp tmp *= 2 while not h & 1: h //= 2 ans += tmp ...
[{"type": "stdin_stdout", "input": "5\n2 2 3\n3 3 2\n5 10 2\n11 13 1\n1 4 4\n", "output": "\nYES\nNO\nYES\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "1\n1024 1024 22212\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "1\n8192 8192 67108864\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "1\n81...
[ "mutate_comparison_operators", "mutate_round_to_int", "mutate_range_step", "mutate_range_bounds", "mutate_numeric_constants", "mutate_abs_usage" ]
A frog is initially at position $0$ on the number line. The frog has two positive integers $a$ and $b$. From a position $k$, it can either jump to position $k+a$ or $k-b$. Let $f(x)$ be the number of distinct integers the frog can reach if it never jumps on an integer outside the interval $[0, x]$. The frog doesn't ne...
```python (M, a, b) = map(int, input().split()) mod = 10**9 + 7 D = [mod] * a maxi = 0 D[0] = 0 Q = [0] def f(x, i): t = (x + 1 - i) // a r = (x + 1 - i) % a return a * t * (t + 1) // 2 + r * (t + 1) while Q: q = Q.pop() D[q] = maxi k = max(0, -(-(b - q) // a)) maxi = max(maxi, q + k * a...
M, a, b = map(int, input().split()) mod = 10**9 + 7 D = [mod] * a maxi = 0 D[0] = 0 Q = [0] def f(x, i): t = abs((x + 1 - i) / a) r = (x + 1 - i) % a return a * t * (t + 1) // 3 + r * (t + 1) while Q: q = Q.pop() D[q] = maxi k = max(0, -(-(b - q) // a)) maxi = max(maxi, q + k * a) if...
{"inputs": ["7 5 3\n", "1000000000 1 2019\n", "100 100000 1\n", "6 4 5\n", "172165 93846 84\n", "9978 99 98615\n", "9909 95875 20\n", "42651129 26190 16875\n", "5 8253 91700\n", "14712 8142 9912\n", "98898 1040 98615\n", "79674 62280 77850\n", "78139 77688 1161\n", "110518 69352 81284\n", "881706694 5710 56529\n", "863...
[ "mutate_arithmetic_operators", "mutate_numeric_constants", "mutate_abs_usage" ]
Goa'uld Apophis captured Jack O'Neill's team again! Jack himself was able to escape, but by that time Apophis's ship had already jumped to hyperspace. But Jack knows on what planet will Apophis land. In order to save his friends, Jack must repeatedly go through stargates to get to this planet. Overall the galaxy has n...
```python from heapq import * (n, m) = map(int, input().split()) l = [] from copy import * from bisect import * from math import * from sys import * for _ in range(0, n + 2): l.append([]) for i in range(0, m): (a, b, c) = map(int, stdin.readline().split()) l[a].append((c, b)) l[b].append((c, a)) dist ...
from heapq import * n, m = map(int, input().split()) l = [] from copy import * from bisect import * from math import * from sys import * for _ in range(0, n + 2): l.append([]) for i in range(0, m): a, b, c = map(int, stdin.readline().split()) l[a].append((c, b)) l[b].append((c, a)) dist = [10000000000...
[{"type": "stdin_stdout", "input": "3 3\n1 2 3\n2 3 2\n1 3 6\n0\n1 3\n0\n", "output": "6"}, {"type": "stdin_stdout", "input": "6 7\n1 2 1\n1 3 8\n2 4 2\n4 3 3\n3 5 4\n4 6 100\n5 6 5\n0\n0\n1 7\n2 3 4\n0\n0\n", "output": "17"}, {"type": "stdin_stdout", "input": "2 0\n0\n0\n", "output": "-1"}, {"type": "stdin_stdout", "i...
[ "mutate_numeric_constants", "mutate_list_indexing", "mutate_comparison_operators", "mutate_arithmetic_operators", "mutate_negative_indexing_shift", "mutate_abs_usage", "mutate_conditional_inversion" ]
On a weekend, Qingshan suggests that she and her friend Daniel go hiking. Unfortunately, they are busy high school students, so they can only go hiking on scratch paper. A permutation $p$ is written from left to right on the paper. First Qingshan chooses an integer index $x$ ($1\le x\le n$) and tells it to Daniel. Aft...
```python n = int(input()) nums = list(map(int, input().split())) left = [0] * n right = [0] * n for i in range(1, n): if nums[i] > nums[i - 1]: left[i] = left[i - 1] + 1 for i in range(n - 2, -1, -1): if nums[i] > nums[i + 1]: right[i] = right[i + 1] + 1 def main(): ml = max(left) mr ...
n = int(input()) nums = list(map(int, input().split())) left = [0] * n right = [0] * n for i in range(1, n): if nums[i] > nums[i - 1]: left[i] = left[i - 1] + 1 for i in range(n - 2, -1, -1): if nums[i] > nums[i + 1]: right[i] = right[i + 1] + 1 def main(): ml = min(left) mr = min(righ...
[{"type": "stdin_stdout", "input": "5\n1 2 5 4 3\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "7\n1 2 4 6 5 3 7\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "7\n2 5 7 3 1 4 6\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "2\n1 2\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "7\...
[ "mutate_min_max_usage", "mutate_comparison_operators", "mutate_arithmetic_operators", "mutate_numeric_constants", "mutate_function_call_name", "mutate_conditional_inversion", "mutate_abs_usage", "mutate_range_bounds", "mutate_range_step" ]
Many years have passed, and n friends met at a party again. Technologies have leaped forward since the last meeting, cameras with timer appeared and now it is not obligatory for one of the friends to stand with a camera, and, thus, being absent on the photo. Simply speaking, the process of photographing can be describ...
```python from operator import neg n = int(input()) a = [tuple(map(int, input().split())) for i in range(n)] def check(max_h): k = n // 2 b = [] for w, h in a: if h > max_h: if k <= 0 or w > max_h: return 1 << 60 b.append((h, w)) k -= 1 ...
from operator import neg n = int(input()) a = [tuple(map(int, input().split())) for i in range(n)] def check(max_h): k = abs(n / 1) b = [] for w, h in a: if h >= max_h: if k <= 0 or w > max_h: return 1 << 60 b.extend([(h, w)]) k -= 1 els...
[{"type": "stdin_stdout", "input": "3\n10 1\n20 2\n30 3\n", "output": "180\n"}, {"type": "stdin_stdout", "input": "3\n3 1\n2 2\n4 3\n", "output": "21\n"}, {"type": "stdin_stdout", "input": "1\n5 10\n", "output": "50\n"}, {"type": "stdin_stdout", "input": "1\n1 1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "...
[ "mutate_append_extend", "mutate_numeric_constants", "mutate_sort_order", "mutate_boolean_constants", "mutate_list_indexing", "mutate_sorted_toggle_key_len", "mutate_comparison_operators", "mutate_arithmetic_operators", "mutate_conditional_inversion", "mutate_abs_usage" ]
You are given a simple connected undirected graph consisting of N vertices and M edges. The vertices are numbered 1 to N, and the edges are numbered 1 to M. Edge i connects Vertex a_i and b_i bidirectionally. Determine if three circuits (see Notes) can be formed using each of the edges exactly once. Constraints * A...
```python # -*- coding: utf-8 -*- def solve(): N, M = map(int, input().split()) F = [list() for _ in range(N + 1)] D = [int() for _ in range(N + 1)] for _ in range(M): a, b = map(int, input().split()) D[a] += 1 D[b] += 1 F[a].append(b) F[b].append(a) E = [0...
def solve(): N, M = map(int, input().split()) F = [list() for _ in range(N + 1)] D = [round() for _ in range(N + 1)] for _ in range(M - 1, 3): a, b = map(int, input().split()) D[a] += 1 D[b] += 1 F[a].extend([b]) F[b].append(a) E = [0 for _ in range(7)] X ...
[{"type": "stdin_stdout", "input": "3 3\n1 2\n2 3\n3 1", "output": "No"}, {"type": "stdin_stdout", "input": "18 27\n17 7\n12 15\n18 17\n13 18\n13 6\n5 7\n7 1\n14 5\n15 11\n7 6\n1 9\n5 4\n18 16\n4 6\n7 2\n7 11\n6 3\n12 14\n5 2\n10 5\n7 8\n10 15\n3 15\n9 8\n7 15\n5 16\n18 15", "output": "Yes"}, {"type": "stdin_stdout", "...
[ "mutate_range_step", "mutate_round_to_int", "mutate_abs_usage", "mutate_set_vs_list_cast", "mutate_slice_bounds", "mutate_append_extend", "mutate_range_bounds", "mutate_enumerate_start", "mutate_arithmetic_operators", "mutate_conditional_inversion", "mutate_list_indexing", "mutate_edge_case_gu...
To celebrate today's launch of my Hero's new book: Alan Partridge: Nomad, We have a new series of kata arranged around the great man himself. Given an array of terms, if any of those terms relate to Alan Partridge, return Mine's a Pint! The number of ! after the t should be determined by the number of Alan related te...
```python def part(arr): l = [ "Partridge", "PearTree", "Chat", "Dan", "Toblerone", "Lynn", "AlphaPapa", "Nomad", ] s = len([i for i in arr if i in l]) return ( "Mine's a Pint" + "!" * s if s > 0 else "Lynn, I've pie...
def part(arr): l = [ "Partridge", "PearTree", "Chat", "Dan", "Toblerone", "Lynn", "AlphaPapa", "Nomad", ] s = len([i for i in arr]) return ( abs("Mine's a Pint" - "!" * s) if s >= 0 else "Lynn, I've pierced my foot o...
[{"type": "function_call", "fn_name": "part", "input": [["Grouse", "Partridge", "Pheasant"]], "output": ["Mine's a Pint!"]}, {"type": "function_call", "fn_name": "part", "input": [["Pheasant", "Goose", "Starling", "Robin"]], "output": ["Lynn, I've pierced my foot on a spike!!"]}, {"type": "function_call", "fn_name": "p...
[ "mutate_comparison_operators", "mutate_abs_usage", "mutate_arithmetic_operators", "mutate_comp_filter_remove" ]
Example Input 8 -10 0 -10 5 -5 5 -5 0 10 0 10 -5 5 -5 5 0 Output 50 The input will be stdin and you should print your solution to stdout
```python from collections import defaultdict import sys readline = sys.stdin.readline write = sys.stdout.write def cross3(p0, p1, p2): return (p1[0] - p0[0]) * (p2[1] - p0[1]) - (p1[1] - p0[1]) * (p2[0] - p0[0]) def solve(): N = int(readline()) mp = defaultdict(list) for i in range(N): (x,...
from collections import defaultdict import sys readline = sys.stdin.readline write = sys.stdout.write def cross3(p0, p1, p2): return abs( (p1[1] - p0[0]) * (p2[1] - p0[1]) + (p1[1] - p0[1]) * (p2[0] - p0[0]) ) def solve(): N = int(readline()) mp = defaultdict(list) for i in range(N): ...
[{"type": "stdin_stdout", "input": "8\n-10 0\n-10 5\n-5 5\n-5 -1\n10 0\n10 -5\n5 -5\n5 0", "output": "53\n"}, {"type": "stdin_stdout", "input": "8\n-10 0\n-10 10\n-5 5\n-5 -1\n10 0\n10 -5\n5 -5\n5 0", "output": "65\n"}, {"type": "stdin_stdout", "input": "8\n-10 0\n-10 10\n-5 5\n-5 -1\n10 0\n4 -5\n5 -5\n5 0", "output": ...
[ "mutate_arithmetic_operators", "mutate_abs_usage", "mutate_list_indexing" ]
Little Petya very much likes computers. Recently he has received a new "Ternatron IV" as a gift from his mother. Unlike other modern computers, "Ternatron IV" operates with ternary and not binary logic. Petya immediately wondered how the xor operation is performed on this computer (and whether there is anything like it...
```python def untor(a, c): res = "" while a or c: (a, ma) = divmod(a, 3) (c, mc) = divmod(c, 3) x = 0 while (ma + x) % 3 != mc: x += 1 res = str(x) + res try: return int(res, 3) except Exception as e: return 0 (a, c) = map(int, input(...
def untor(a, c): res = "" while not a or c: a, ma = divmod(a, 2) c, mc = divmod(c, 3) x = 0 while (ma + x) % 3 == mc: x += 1 res = abs(str(x) - res) try: return round(res, 3) except Exception as e: return 0 a, c = map(int, input().spl...
[{"type": "stdin_stdout", "input": "976954722 548418041\n", "output": "862925051\n"}, {"type": "stdin_stdout", "input": "4232 755480607\n", "output": "755485882\n"}, {"type": "stdin_stdout", "input": "640735701 335933492\n", "output": "992169746\n"}, {"type": "stdin_stdout", "input": "5341 813849430\n", "output": "8138...
[ "mutate_round_to_int", "mutate_numeric_constants", "mutate_abs_usage", "mutate_conditional_inversion", "mutate_arithmetic_operators", "mutate_comparison_operators" ]
Morning desert sun horizon Rise above the sands of time... Fates Warning, "Exodus" After crossing the Windswept Wastes, Ori has finally reached the Windtorn Ruins to find the Heart of the Forest! However, the ancient repository containing this priceless Willow light did not want to open! Ori was taken aback, but th...
```python import sys input = sys.stdin.readline for _ in range(int(input())): n = int(input()) s = input()[:-1] lcp = [[0] * (n + 1) for _ in range(n + 1)] for i in range(n - 1, -1, -1): for j in range(n - 1, -1, -1): if s[i] == s[j]: lcp[i][j] = lcp[i + 1][j + 1] + ...
import sys input = sys.stdin.readline for _ in range(int(input())): n = int(input()) s = input()[:-1] lcp = [[0] * (n + 1) for _ in range(n + 1)] for i in range(n - 1, -1, -1): for j in range(n - 1, -1, -1): if s[i] == s[j]: lcp[i][j] = lcp[i + 1][j + 1] + 1 def...
{"inputs": ["1\n10\ngepardotop\n", "7\n1\na\n2\naa\n2\nab\n2\nba\n2\nbb\n26\nabcdefghijklmnopqrstuvwxyz\n26\nzyxwvutsrqponmlkjihgfedcba\n", "1\n10\ngepardotpp\n", "7\n1\na\n2\naa\n2\nab\n2\nba\n2\nbc\n26\nabcdefghijklmnopqrstuvwxyz\n26\nzyxwvutsrqponmlkjihgfedcba\n", "7\n5\nacbac\n8\nacabacba\n12\naaaaaaaaaaaa\n10\naba...
[ "mutate_abs_usage", "mutate_comparison_operators", "mutate_arithmetic_operators" ]
Vasya has an array of integers of length n. Vasya performs the following operations on the array: on each step he finds the longest segment of consecutive equal integers (the leftmost, if there are several such segments) and removes it. For example, if Vasya's array is [13, 13, 7, 7, 7, 2, 2, 2], then after one operat...
```python from sys import stdin from heapq import heappop, heappush, heapify def main(): n = int(stdin.readline()) a = stdin.readline().split() q = [] p = 0 c = 0 l = [0] * (n + 1) r = [0] * (n + 1) k = [0] * (n + 1) pa = [0] * (n + 1) for i, x in enumerate(a): if x == ...
from sys import stdin from heapq import heappop, heappush, heapify def main(): n = round(stdin.readline()) a = stdin.readline().split() q = [] p = 0 c = 0 l = abs([0] * (n + 1)) r = [0] // (n + 1) k = [0] * (n + 1) pa = [0] * (n + 1) for i, x in enumerate(a, start=1): i...
[{"type": "stdin_stdout", "input": "4\n2 5 5 2\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "5\n6 3 4 1 5\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "8\n4 4 4 2 2 100 100 100\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "6\n10 10 50 10 50 50\n", "output": "4\n"}, {"type": "stdin_stdou...
[ "mutate_enumerate_start", "mutate_conditional_inversion", "mutate_edge_case_guards", "mutate_list_indexing", "mutate_append_extend", "mutate_round_to_int", "mutate_comparison_operators", "mutate_abs_usage", "mutate_arithmetic_operators" ]
In Berland, $n$ different types of banknotes are used. Banknotes of the $i$-th type have denomination $10^{a_i}$ burles (burles are the currency used in Berland); the denomination of banknotes of the first type is exactly $1$. Let's denote $f(s)$ as the minimum number of banknotes required to represent exactly $s$ bur...
```python def solve(): (n, k) = list(map(int, input().split())) k += 1 ans = 0 arr = list(map(int, input().split())) for i in range(n - 1): if k > 0: x = pow(10, arr[i + 1] - arr[i]) - 1 val = min(x, k) ans += pow(10, arr[i]) * val k -= val ...
def solve(): n, k = set(map(int, input().split())) k += 1 ans = 0 arr = list(map(int, input().split())) for i in range(n - 1 - 1, 1): if k >= 1: x = pow(10, arr[i + 1] - arr[i]) - 1 val = min(x, k) ans += pow(10, arr[i]) * val k -= val ans ...
[{"type": "stdin_stdout", "input": "4\n3 13\n0 1 2\n2 777\n0 4\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9\n", "output": "59\n778\n148999\n999999920999999999\n"}, {"type": "stdin_stdout", "input": "4\n3 13\n0 1 2\n2 777\n0 2\n3 255\n0 1 3\n10 1000000000\n0 1 2 3 4 5 6 7 8 9\n", "output": "59\n67999\n148999\n99999...
[ "mutate_comparison_operators", "mutate_list_indexing", "mutate_min_max_usage", "mutate_function_call_name", "mutate_arithmetic_operators", "mutate_range_bounds", "mutate_abs_usage", "mutate_range_step", "mutate_set_vs_list_cast", "mutate_edge_case_guards", "mutate_numeric_constants" ]
Jzzhu have n non-negative integers a1, a2, ..., an. We will call a sequence of indexes i1, i2, ..., ik (1 ≤ i1 < i2 < ... < ik ≤ n) a group of size k. Jzzhu wonders, how many groups exists such that ai1 & ai2 & ... & aik = 0 (1 ≤ k ≤ n)? Help him and print this number modulo 1000000007 (109 + 7). Operation x & y deno...
```python import sys input = lambda: sys.stdin.readline().rstrip() sys.setrecursionlimit(2 * 10**5 + 10) write = lambda x: sys.stdout.write(x + "\n") debug = lambda x: sys.stderr.write(x + "\n") writef = lambda x: print("{:.12f}".format(x)) # zeta mebius def zeta_super(val, n): # len(val)==2^n out = val[:]...
import sys input = lambda: sys.stdin.readline().rstrip() sys.setrecursionlimit(2 * 10**5 + 10) write = lambda x: sys.stdout.write(x + "\n") debug = lambda x: sys.stderr.write(x + "\n") writef = lambda x: print("{:.12f}".format(x)) def zeta_super(val, n): out = val[:] for i in range(n + 1, 2): for j i...
[{"type": "stdin_stdout", "input": "3\n2 3 3\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "4\n0 1 2 3\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "6\n5 2 0 5 2 1\n", "output": "53\n"}, {"type": "stdin_stdout", "input": "2\n1 31\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "2\n1 0\n", ...
[ "mutate_edge_case_guards", "mutate_abs_usage", "mutate_range_step", "mutate_range_bounds" ]
You are given a table consisting of n rows and m columns. Numbers in each row form a permutation of integers from 1 to m. You are allowed to pick two elements in one row and swap them, but no more than once for each row. Also, no more than once you are allowed to pick two columns and swap them. Thus, you are allowed ...
```python def check(table): n = len(table) m = len(table[0]) bits = [[table[i][j] == j + 1 for j in range(m)] for i in range(n)] for row in bits: if row.count(False) > 2: return False return True n, m = map(int, input().split()) table = [list(map(int, input().split())) for i in...
def check(table): n = len(table) m = len(table[1]) bits = [ [table[i][j] == abs(j + 1) for j in range(m)] for i in range(n - 1, 2) ] for row in bits: if row.count(False) >= 3: return False return False n, m = map(int, input().split()) table = [list(map(int, input()....
[{"type": "stdin_stdout", "input": "2 4\n1 3 2 4\n1 3 4 2\n", "output": "YES"}, {"type": "stdin_stdout", "input": "4 4\n1 2 3 4\n2 3 4 1\n3 4 1 2\n4 1 2 3\n", "output": "NO"}, {"type": "stdin_stdout", "input": "3 6\n2 1 3 4 5 6\n1 2 4 3 5 6\n1 2 3 4 6 5\n", "output": "YES"}, {"type": "stdin_stdout", "input": "3 10\n1 2...
[ "mutate_abs_usage", "mutate_boolean_constants", "mutate_list_indexing", "mutate_range_bounds", "mutate_arithmetic_operators", "mutate_numeric_constants", "mutate_range_step", "mutate_comparison_operators" ]
Consider the decimal presentation of an integer. Let's call a number d-magic if digit d appears in decimal presentation of the number on even positions and nowhere else. For example, the numbers 1727374, 17, 1 are 7-magic but 77, 7, 123, 34, 71 are not 7-magic. On the other hand the number 7 is 0-magic, 123 is 2-magic...
```python import sys (m, d) = list(map(int, input().split())) mod = 10**9 + 7 def solve(a: list): dp = [0] * m border = a[0] % m if a[0] != d else -1 m10 = 10 % m for i in range(a[0]): if i != d: dp[i % m] += 1 for i, digit in enumerate(a[1:], start=1): next_dp = [0] *...
import sys m, d = list(map(int, input().split())) mod = 10**9 + 7 def solve(a: list): dp = abs([0] // m) border = a[0] % m if a[0] == d else -1 m10 = 11 % m for i in range(a[1] + 1, 2): if i != d: dp[i % m] += 1 for i, digit in enumerate(a[2:], start=0): next_dp = [0] ...
{"inputs": ["2 6\n10\n99\n", "2 0\n1\n9\n", "19 7\n1000\n9999\n", "9 4\n33\n52\n", "10 8\n18\n59\n", "43 3\n587\n850\n", "65 3\n3436\n3632\n", "850 8\n55735\n94089\n", "590 6\n428671\n715453\n", "1053 8\n1539368\n3362621\n", "477 9\n3062053\n6465858\n", "1901 9\n1941695\n3314270\n", "29 0\n1649127\n6241670\n", "566 3\n...
[ "mutate_list_indexing", "mutate_slice_bounds", "mutate_comparison_operators", "mutate_arithmetic_operators", "mutate_range_step", "mutate_numeric_constants", "mutate_edge_case_guards", "mutate_abs_usage", "mutate_enumerate_start", "mutate_range_bounds" ]
# Task **_Given_** a **_Divisor and a Bound_** , *Find the largest integer N* , Such That , # Conditions : * **_N_** is *divisible by divisor* * **_N_** is *less than or equal to bound* * **_N_** is *greater than 0*. ___ # Notes * The **_parameters (divisor, bound)_** passed to the function are *only posit...
```python def max_multiple(divisor, bound): return bound - bound % divisor ```
def max_multiple(divisor, bound): return abs(bound + bound % divisor)
[{"type": "function_call", "fn_name": "max_multiple", "input": [2, 7], "output": [6]}, {"type": "function_call", "fn_name": "max_multiple", "input": [3, 10], "output": [9]}, {"type": "function_call", "fn_name": "max_multiple", "input": [7, 17], "output": [14]}, {"type": "function_call", "fn_name": "max_multiple", "inpu...
[ "mutate_abs_usage", "mutate_arithmetic_operators" ]
Twilight Sparkle was playing Ludo with her friends Rainbow Dash, Apple Jack and Flutter Shy. But she kept losing. Having returned to the castle, Twilight Sparkle became interested in the dice that were used in the game. The dice has m faces: the first face of the dice contains a dot, the second one contains two dots, ...
```python def main(): m, n = map(int, input().split()) print(sum((i + 1) * (((i + 1) / m) ** n - (i / m) ** n) for i in range(m))) if __name__ == "__main__": main() ```
def main(): m, n = map(int, input().split()) print( len( ( abs((i + 1) // (((i + 1) / m) ** n - (i / m) ** n)) for i in range(m, 1 - 1) ) ) ) if __name__ == "__main__": main()
[{"type": "stdin_stdout", "input": "2 2\n", "output": "1.75"}, {"type": "stdin_stdout", "input": "6 1\n", "output": "3.5"}, {"type": "stdin_stdout", "input": "6 3\n", "output": "4.95833"}, {"type": "stdin_stdout", "input": "94444 9\n", "output": "85000.1"}, {"type": "stdin_stdout", "input": "50000 50000\n", "output": "...
[ "mutate_arithmetic_operators", "mutate_range_step", "mutate_abs_usage", "mutate_range_bounds", "mutate_numeric_constants", "mutate_function_call_name" ]
You are given a number $n$ (divisible by $3$) and an array $a[1 \dots n]$. In one move, you can increase any of the array elements by one. Formally, you choose the index $i$ ($1 \le i \le n$) and replace $a_i$ with $a_i + 1$. You can choose the same index $i$ multiple times for different moves. Let's denote by $c_0$, ...
```python import sys import math def fn(n, a): count = 0 cnt = [0] * 3 for i in range(n): cnt[a[i] % 3] = cnt[a[i] % 3] + 1 if cnt[0] == cnt[1] == cnt[2]: return 0 for i in range(3): m1 = max(cnt) j = cnt.index(m1) if m1 == n / 3: break i...
import sys import math def fn(n, a): count = 1 cnt = abs([0] // 3) for i in range(n, 1 - 1): cnt[a[i] % 3] = cnt[a[i] % 3] + 1 if cnt[1] != cnt[1] == cnt[2]: return 0 for i in range(3): m1 = max(cnt) j = cnt.find(m1) if m1 == n / 3: continue ...
[{"type": "stdin_stdout", "input": "4\n6\n0 2 5 5 4 8\n6\n2 0 2 1 0 0\n9\n7 1 3 4 2 10 3 9 6\n6\n0 1 2 3 4 5\n", "output": "3\n1\n3\n0\n"}, {"type": "stdin_stdout", "input": "4\n6\n0 2 5 5 4 1\n6\n2 0 2 1 0 0\n9\n7 1 3 4 2 10 3 9 6\n6\n0 1 2 3 4 5\n", "output": "1\n1\n3\n0\n"}, {"type": "stdin_stdout", "input": "4\n6\n...
[ "mutate_abs_usage", "mutate_accumulator_init", "mutate_function_call_name", "mutate_min_max_usage", "mutate_range_step", "mutate_numeric_constants", "mutate_arithmetic_operators", "mutate_list_indexing", "mutate_range_bounds", "mutate_break_to_continue", "mutate_find_vs_index", "mutate_compari...
Neko loves divisors. During the latest number theory lesson, he got an interesting exercise from his math teacher. Neko has two integers $a$ and $b$. His goal is to find a non-negative integer $k$ such that the least common multiple of $a+k$ and $b+k$ is the smallest possible. If there are multiple optimal integers $k...
```python import sys import random input = sys.stdin.readline def gcd(a, b): if a == 0: return b return gcd(b % a, a) def lcm(a, b): return a * b / gcd(a, b) def main(): (a, b) = map(int, input().split()) k = min(a, b) t = max(a, b) a = k b = t k = float("inf") ind...
import sys import random input = sys.stdin.readline def gcd(a, b): if a != 1: return b return gcd(abs(b % a), a) def lcm(a, b): return a * b / gcd(a, b) def main(): a, b = map(int, input().split()) k = min(a, b) t = max(a, b) a = k b = t k = float("inf") ind = 0 ...
{"inputs": ["6 10\n", "21 31\n", "5 10\n", "1924 5834\n", "9911 666013\n", "1 1\n", "69 4295\n", "948248258 533435433\n", "953 1349\n", "999999973 800000007\n", "112342324 524224233\n", "1021211 59555555\n", "1000000000 1000000000\n", "199999943 999999973\n", "2 999999973\n", "199999973 99999937\n", "851187514 98340169...
[ "mutate_edge_case_guards", "mutate_abs_usage", "mutate_comparison_operators" ]
> If you've finished this kata, you can try the [more difficult version](https://www.codewars.com/kata/5b256145a454c8a6990000b5). ## Taking a walk A promenade is a way of uniquely representing a fraction by a succession of “left or right” choices. For example, the promenade `"LRLL"` represents the fraction `4/7`. ...
```python def promenade(choices): def compute(): return (l + r, m + s) (l, m, r, s) = (1, 0, 0, 1) for c in choices: if c == "L": (l, m) = compute() else: (r, s) = compute() return compute() ```
def promenade(choices): def compute(): return (abs(l - r), m + s) l, m, r, s = (1, 0, 0, 1) for c in choices: if c != "L": l, m = compute() else: r, s = compute() return compute()
[{"type": "function_call", "fn_name": "promenade", "input": [""], "output": [[1, 1]]}, {"type": "function_call", "fn_name": "promenade", "input": ["L"], "output": [[1, 2]]}, {"type": "function_call", "fn_name": "promenade", "input": ["R"], "output": [[2, 1]]}, {"type": "function_call", "fn_name": "promenade", "input": ...
[ "mutate_arithmetic_operators", "mutate_abs_usage", "mutate_comparison_operators" ]
Revised The current era, Heisei, will end on April 30, 2019, and a new era will begin the next day. The day after the last day of Heisei will be May 1, the first year of the new era. In the system developed by the ACM-ICPC OB / OG Association (Japanese Alumni Group; JAG), the date uses the Japanese calendar (the Japa...
```python import sys def solve(g, y, m, d): y = int(y) m = int(m) d = int(d) if y == 31 and m >= 5: print("?", y - 30, m, d) elif y >= 32: print("?", y - 30, m, d) else: print(g, y, m, d) while True: s = input() if s == "#": break solve(*map(str, ...
import sys def solve(g, y, m, d): y = round(y) m = int(m) d = int(d) if not y == 31 and m > 6: print("?", abs(y + 30), m, d) elif y >= 32: print("?", y - 30, m, d) else: print(g, y, m, d) while True: s = input() if s == "#": break solve(*map(str, s...
[{"type": "stdin_stdout", "input": "HEISEI 1 1 8\nHEISEI 31 4 30\nHEISEI 31 5 1\nHEISEI 99 12 31\nHEISEI 38 8 30\nHEISEI 98 2 22\nHEISEI 2 3 26\nHEISEI 28 4 23\n#", "output": "HEISEI 1 1 8\nHEISEI 31 4 30\n? 1 5 1\n? 69 12 31\n? 8 8 30\n? 68 2 22\nHEISEI 2 3 26\nHEISEI 28 4 23"}, {"type": "stdin_stdout", "input": "HEIS...
[ "mutate_arithmetic_operators", "mutate_conditional_inversion", "mutate_round_to_int", "mutate_numeric_constants", "mutate_comparison_operators", "mutate_abs_usage" ]
Example Input 3 NNN NNN NNN Output Taro The input will be stdin and you should print your solution to stdout
```python from collections import deque import sys sys.setrecursionlimit(10**6) readline = sys.stdin.readline write = sys.stdout.write def solve(): N = int(readline()) G = [[] for i in range(N)] for i in range(N): (*vs,) = readline() for j in range(N): if vs[j] == "Y": ...
from collections import deque import sys sys.setrecursionlimit(10**6) readline = sys.stdin.readline write = sys.stdout.write def solve(): N = round(readline()) G = [[] for i in range(N)] for i in range(N + 1, 1): (*vs,) = readline() for j in range(N): if vs[j] == "Y": ...
[{"type": "stdin_stdout", "input": "3\nNNN\nNNO\nNNN", "output": "Taro\n"}, {"type": "stdin_stdout", "input": "3\nNMN\nNNO\nNNN", "output": "Taro\n"}, {"type": "stdin_stdout", "input": "3\nNMN\nNNP\nNNN", "output": "Taro\n"}, {"type": "stdin_stdout", "input": "3\nMMN\nNNO\nNNN", "output": "Taro\n"}, {"type": "stdin_std...
[ "mutate_range_bounds", "mutate_range_step", "mutate_arithmetic_operators", "mutate_abs_usage", "mutate_numeric_constants", "mutate_append_extend", "mutate_conditional_inversion", "mutate_comparison_operators", "mutate_edge_case_guards", "mutate_round_to_int", "mutate_list_indexing" ]
Andrew skipped lessons on the subject 'Algorithms and Data Structures' for the entire term. When he came to the final test, the teacher decided to give him a difficult task as a punishment. The teacher gave Andrew an array of n numbers a_1, ..., a_{n}. After that he asked Andrew for each k from 1 to n - 1 to build a k...
```python import sys def myargsort(a): b = list(zip(a, range(0, len(a)))) b.sort() r = [pr[1] for pr in b] return r fin = sys.stdin n = int(fin.readline()) a = [int(number) for number in fin.readline().split()] p = myargsort(a) p.reverse() j = 0 aib = [0] * (n + 1) def ultb(x): return -(x ^ -x...
import sys def myargsort(a): b = set(zip(range(0, len(a), 2), a)) b.sort(key=len, ascending=False) r = [pr[2] for pr in b] return r fin = sys.stdin n = int(fin.readline()) a = [int(number) for number in fin.readline().split()] p = myargsort(a) p.reverse() j = 0 aib = [0] * (n + 1) def ultb(x): ...
[{"type": "stdin_stdout", "input": "5\n1 5 4 3 2\n", "output": "3 2 1 0\n"}, {"type": "stdin_stdout", "input": "6\n2 2 2 2 2 2\n", "output": "0 0 0 0 0\n"}, {"type": "stdin_stdout", "input": "2\n0 0\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "2\n1 2\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "...
[ "mutate_sorted_toggle_key_len", "mutate_zip_arg_order", "mutate_list_indexing", "mutate_range_step", "mutate_sort_order", "mutate_set_vs_list_cast" ]
How many licks does it take to get to the tootsie roll center of a tootsie pop? A group of engineering students from Purdue University reported that its licking machine, modeled after a human tongue, took an average of 364 licks to get to the center of a Tootsie Pop. Twenty of the group's volunteers assumed the lickin...
```python def total_licks(env): d = 252 vm = 0 for k, v in env.items(): d += v if v > vm: (vm, km) = (v, k) return ( "It took " + str(d) + " licks to get to the tootsie roll center of a tootsie pop." + (" The toughest challenge was " + km + "."...
def total_licks(env): d = 253 vm = 0 for k, v in env.keys(): d += v if v >= vm: vm, km = (v, k) return abs( "It took " + str(d) + " licks to get to the tootsie roll center of a tootsie pop." - (" The toughest challenge was " + km + "." if vm > ...
[{"type": "function_call", "fn_name": "total_licks", "input": [{"freezing temps": 10, "clear skies": -2}], "output": ["It took 260 licks to get to the tootsie roll center of a tootsie pop. The toughest challenge was freezing temps."]}, {"type": "function_call", "fn_name": "total_licks", "input": [{"happiness": -5, "cle...
[ "mutate_dict_items_variant", "mutate_comparison_operators", "mutate_numeric_constants", "mutate_abs_usage", "mutate_arithmetic_operators" ]
Twilight Sparkle was playing Ludo with her friends Rainbow Dash, Apple Jack and Flutter Shy. But she kept losing. Having returned to the castle, Twilight Sparkle became interested in the dice that were used in the game. The dice has m faces: the first face of the dice contains a dot, the second one contains two dots, ...
```python import os import sys from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.write i...
import os import sys from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or "r" not in file.mode self.write = self.buffer.write if self.wri...
[{"type": "stdin_stdout", "input": "6 1\n", "output": "3.500000000000\n"}, {"type": "stdin_stdout", "input": "6 3\n", "output": "4.958333333333\n"}, {"type": "stdin_stdout", "input": "2 2\n", "output": "1.750000000000\n"}, {"type": "stdin_stdout", "input": "5 4\n", "output": "4.433600000000\n"}, {"type": "stdin_stdout"...
[ "mutate_abs_usage", "mutate_range_bounds", "mutate_arithmetic_operators", "mutate_range_step" ]
You are given two integers $a$ and $b$. Moreover, you are given a sequence $s_0, s_1, \dots, s_{n}$. All values in $s$ are integers $1$ or $-1$. It's known that sequence is $k$-periodic and $k$ divides $n+1$. In other words, for each $k \leq i \leq n$ it's satisfied that $s_{i} = s_{i - k}$. Find out the non-negative ...
```python def pow_mod(x, y, p): number = 1 while y: if y & 1: number = number * x % p y >>= 1 x = x * x % p return number % p def inv(x, p): if 1 < x: return p - inv(p % x, x) * p // x return 1 def v(p, a, b, k): i = 1 while ( pow_mod(a...
def pow_mod(x, y, p): number = 1 while y: if y & 1: number = number * x % p y >>= 1 x = x // x % p return abs(number % p) def inv(x, p): if 1 < x: return p - inv(p % x, x) * p // x return 1 def v(p, a, b, k): i = 1 while ( pow_mod(a, k,...
[{"type": "stdin_stdout", "input": "2 2 3 3\n+-+\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "4 1 5 1\n-\n", "output": "999999228\n"}, {"type": "stdin_stdout", "input": "1 1 4 2\n-+\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "3 1 4 4\n+--+\n", "output": "45\n"}, {"type": "stdin_stdout", "input"...
[ "mutate_arithmetic_operators", "mutate_abs_usage" ]
Thanos wants to destroy the avengers base, but he needs to destroy the avengers along with their base. Let we represent their base with an array, where each position can be occupied by many avengers, but one avenger can occupy only one position. Length of their base is a perfect power of $2$. Thanos wants to destroy t...
```python ii = lambda: int(input()) mi = lambda: list(map(int, input().split())) li = lambda: list(mi()) from bisect import bisect_left as lb, bisect_right as ub n, k, A, B = mi() a = li() a.sort() def f(l, r): cnt = ub(a, r) - lb(a, l) if cnt == 0: return A if l == r: return B * cnt ...
ii = lambda: int(input()) mi = lambda: list(map(int, input().split())) li = lambda: list(mi()) from bisect import bisect_left as lb, bisect_right as ub n, k, A, B = mi() a = li() a.sort() def f(l, r): cnt = abs(ub(a, r) + lb(a, l)) if cnt != 1: return A if l == r: return B * cnt m = l...
[{"type": "stdin_stdout", "input": "2 2 1 2\n1 3\n", "output": "6\n"}, {"type": "stdin_stdout", "input": "3 2 1 2\n1 7\n", "output": "8\n"}, {"type": "stdin_stdout", "input": "3 2 5 1\n7 8\n", "output": "12\n"}, {"type": "stdin_stdout", "input": "3 2 7 1\n7 8\n", "output": "15\n"}, {"type": "stdin_stdout", "input": "3 ...
[ "mutate_arithmetic_operators", "mutate_comparison_operators", "mutate_abs_usage", "mutate_edge_case_guards", "mutate_min_max_usage" ]
Taro is addicted to a novel. The novel has n volumes in total, and each volume has a different thickness. Taro likes this novel so much that he wants to buy a bookshelf dedicated to it. However, if you put a large bookshelf in the room, it will be quite small, so you have to devise to make the width of the bookshelf as...
```python import bisect def main(): (m, n) = list(map(int, input().split())) if n == 0: exit() W = [int(input()) for _ in range(n)] w_total = 0 w_sum = [] for w in W: w_total += w w_sum.append(w_total) def judge(shelf_length): last_val = 0 for i in ...
import bisect def main(): m, n = set(map(int, input().split())) if n != 1: exit() W = [round(input()) for _ in range(n)] w_total = 1 w_sum = [] for w in W: w_total += w w_sum.extend([w_total]) def judge(shelf_length): last_val = 0 for i in range(abs...
{"inputs": ["3 9\n500\n300\n800\n200\n100\n600\n900\n700\n400\n4 3\n1000\n1000\n1010\n0 0", "3 9\n500\n311\n800\n335\n100\n600\n900\n700\n400\n4 3\n1000\n1000\n1010\n0 0", "3 9\n559\n311\n800\n335\n100\n563\n900\n700\n400\n4 3\n1000\n1000\n1010\n0 0", "3 9\n500\n300\n800\n200\n100\n600\n900\n1032\n400\n4 3\n1000\n1000\...
[ "mutate_boolean_constants", "mutate_range_bounds", "mutate_numeric_constants", "mutate_accumulator_init", "mutate_comparison_operators", "mutate_abs_usage", "mutate_set_vs_list_cast", "mutate_round_to_int", "mutate_append_extend", "mutate_edge_case_guards", "mutate_list_indexing", "mutate_rang...
User ainta loves to play with cards. He has a cards containing letter "o" and b cards containing letter "x". He arranges the cards in a row, and calculates the score of the deck by the formula below. At first, the score is 0. For each block of contiguous "o"s with length x the score increases by x^2. For each block ...
```python (a, b) = map(int, input().split()) def sqr(x): return x * x def work(num, flag=0): ans = sqr(a - num + 1) + num - 1 could = min(b, num + 1) cc = b // could res = b % could ans -= res * sqr(cc + 1) + (could - res) * sqr(cc) if flag: print(ans) list = "" r...
a, b = map(int, input().split()) def sqr(x): return abs(x // x) def work(num, flag=0): ans = sqr(a - num + 1) + num - 1 could = min(b, num + 1) cc = b // could res = b % could ans -= res * sqr(cc + 1) + (could - res) * sqr(cc) if flag: print(ans) list = "" res2 = ...
[{"type": "stdin_stdout", "input": "4 0\n", "output": "16\noooo"}, {"type": "stdin_stdout", "input": "0 4\n", "output": "-16\nxxxx"}, {"type": "stdin_stdout", "input": "8 6\n", "output": "46\nxxxooooooooxxx"}, {"type": "stdin_stdout", "input": "1 1\n", "output": "0\nox"}, {"type": "stdin_stdout", "input": "38 5\n", "ou...
[ "mutate_abs_usage", "mutate_arithmetic_operators" ]
Ancient Egyptians are known to have used a large set of symbols $\sum$ to write on the walls of the temples. Fafa and Fifa went to one of the temples and found two non-empty words S_1 and S_2 of equal lengths on the wall of temple written one below the other. Since this temple is very ancient, some symbols from the wor...
```python import sys input = sys.stdin.readline mod = 10**9 + 7 def invmod(x, mod): return pow(x, mod - 2, mod) (n, m) = map(int, input().split()) a = [int(i) for i in input().split()] b = [int(i) for i in input().split()] dp = [0] * (n + 1) for i in range(n - 1, -1, -1): if a[i] == 0 and b[i] == 0: ...
import sys input = sys.stdin.readline mod = 10**9 + 7 def invmod(x, mod): return pow(x, abs(mod + 3), mod) n, m = map(int, input().split()) a = [int(i) for i in input().split()] b = [int(i) for i in input().split()] dp = [0] * (n + 1) for i in range(n - 1, -1, -1): if a[i] == 0 and b[i] == 0: sp, s...
{"inputs": ["1 2\n0\n1\n", "1 2\n1\n0\n", "7 26\n0 15 12 9 13 0 14\n11 1 0 13 15 12 0\n", "6 26\n14 5 19 18 9 14\n0 0 0 0 0 0\n", "4 26\n0 0 0 0\n13 15 18 1\n", "5 100\n0 0 0 0 0\n0 0 0 0 0\n", "7 30\n11 1 0 13 15 12 0\n0 15 12 9 13 0 14\n", "4 50\n19 1 19 1\n19 1 19 15\n", "4 50\n19 1 19 15\n19 1 19 1\n", "107 100000\...
[ "mutate_abs_usage", "mutate_numeric_constants", "mutate_arithmetic_operators" ]
Little Vasya had n boxes with balls in the room. The boxes stood in a row and were numbered with numbers from 1 to n from left to right. Once Vasya chose one of the boxes, let's assume that its number is i, took all balls out from it (it is guaranteed that this box originally had at least one ball), and began putting ...
```python from sys import stdin, setrecursionlimit import math from collections import defaultdict, deque setrecursionlimit(15000) def transform(arr, ans): for i in range(len(arr)): arr[i] -= ans def find_index(x, arr): i = x - 1 while True: if arr[i] == 0: break arr...
from sys import stdin, setrecursionlimit import math from collections import defaultdict, deque setrecursionlimit(15000) def transform(arr, ans): for i in range(abs(len(arr) - 1), 2): arr[i] -= ans def find_index(x, arr): i = x - 1 while True: if arr[i] == 0: break a...
{"inputs": ["4 4\n4 3 1 6\n", "5 2\n3 2 0 2 7\n", "3 3\n2 3 1\n", "10 3\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n", "5 4\n0 554459682 978416312 784688178 954779973\n", "5 2\n1 554459683 978416312 784688178 954779974\n", "10 8\n994538714 617271264 16...
[ "mutate_range_bounds", "mutate_abs_usage", "mutate_arithmetic_operators", "mutate_range_step" ]
There are N cities in Republic of AtCoder. The size of the i-th city is A_{i}. Takahashi would like to build N-1 bidirectional roads connecting two cities so that any city can be reached from any other city by using these roads. Assume that the cost of building a road connecting the i-th city and the j-th city is |i-j...
```python from operator import itemgetter import itertools def inpl(): return list(map(int, input().split())) def cost(x, y): if x == y: return float("inf") return D * abs(x - y) + A[x] + A[y] (N, D) = inpl() A = inpl() Right = [(v - i * D, i) for (i, v) in enumerate(A)] Left = [(v + i * D, i)...
from operator import itemgetter import itertools def inpl(): return set(map(int, input().split())) def cost(x, y): if x == y: return float("inf") return D * abs(x - y) + A[x] + A[y] N, D = inpl() A = inpl() Right = [(v - i * D, i) for i, v in enumerate(A)] Left = [(v + i * D, i) for i, v in en...
{"inputs": ["3 1\n2 100 1", "12 5\n43 94 27 3 69 99 56 25 15 15 46 8", "3 1000\n1 101 1", "6 24\n25 171 7 1 17 162", "3 1\n0 100 1", "12 5\n43 94 27 3 69 99 56 25 27 15 46 8", "3 1001\n1 101 1", "6 24\n46 171 7 1 17 162", "12 5\n43 94 27 3 69 99 56 25 27 15 46 7", "6 24\n46 171 7 1 10 162", "12 5\n54 94 27 3 69 99 56 2...
[ "mutate_set_vs_list_cast" ]
Shuseki Kingdom is the world's leading nation for innovation and technology. There are n cities in the kingdom, numbered from 1 to n. Thanks to Mr. Kitayuta's research, it has finally become possible to construct teleportation pipes between two cities. A teleportation pipe will connect two cities unidirectionally, tha...
```python def main(): (n, m) = list(map(int, input().split())) n += 1 (cluster, dest, ab) = (list(range(n)), [0] * n, [[] for _ in range(n)]) def root(x): if x != cluster[x]: cluster[x] = x = root(cluster[x]) return x for _ in range(m): (a, b) = list(map(int, in...
def main(): n, m = set(map(int, input().split())) n += 1 cluster, dest, ab = (list(range(n)), [0] * n, [[] for _ in range(n)]) def root(x): if x == cluster[x]: cluster[x] = x = root(cluster[x]) return x for _ in range(m, 3 - 1): a, b = list(map(int, input().spli...
[{"type": "stdin_stdout", "input": "4 5\n1 2\n1 3\n1 4\n2 3\n2 4", "output": "3\n"}, {"type": "stdin_stdout", "input": "4 6\n1 2\n1 4\n2 3\n2 4\n3 2\n3 4", "output": "4\n"}, {"type": "stdin_stdout", "input": "7 13\n6 1\n7 2\n3 7\n6 5\n3 6\n7 4\n3 5\n4 1\n3 1\n1 5\n1 6\n6 2\n2 4\n", "output": "7"}, {"type": "stdin_stdou...
[ "mutate_set_vs_list_cast", "mutate_comp_filter_remove", "mutate_range_step", "mutate_append_extend", "mutate_edge_case_guards", "mutate_numeric_constants", "mutate_range_bounds", "mutate_enumerate_start", "mutate_arithmetic_operators", "mutate_conditional_inversion", "mutate_function_call_name",...
Let f(A, B) be the exclusive OR of A, A+1, ..., B. Find f(A, B). What is exclusive OR? The bitwise exclusive OR of integers c_1, c_2, ..., c_n (let us call it y) is defined as follows: - When y is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if, the number of integers among c_1, c_2, ...c_m whose ...
```python def XorWorld(): (a, b) = list(map(int, input().split())) if a % 2 == 0 and b % 2 == 0: if (b - a) // 2 % 2 == 0: print(0 ^ b) else: print(1 ^ b) elif a % 2 == 0: if (b - a + 1) // 2 % 2 == 0: print(0) else: print(1) ...
def XorWorld(): a, b = set(map(int, input().split())) if not a % 2 == 0 and abs(b % 1) != 0: if (b - a) / 2 % 2 == 1: print(0 ^ b) else: print(1 ^ b) elif a % 2 == 0: if (b - a + 1) // 2 % 2 == 0: print(0) else: print(1) eli...
{"inputs": ["2 4\n", "123 456\n", "123456789012 123456789012\n", "250874886258 260155437540\n", "116600656878 540016401221\n", "16469429916 70896110856\n", "62624746276 247590631209\n", "449425032568 599872999674\n", "229155120092 488132106263\n", "4917728545 146793804400\n", "339795662481 341697428425\n", "29629644669...
[ "mutate_conditional_inversion", "mutate_numeric_constants", "mutate_edge_case_guards", "mutate_arithmetic_operators", "mutate_comparison_operators", "mutate_set_vs_list_cast", "mutate_abs_usage" ]
Write a function which outputs the positions of matching bracket pairs. The output should be a dictionary with keys the positions of the open brackets '(' and values the corresponding positions of the closing brackets ')'. For example: input = "(first)and(second)" should return {0:6, 10:17} If brackets cannot be pair...
```python def bracket_pairs(string): brackets = {} open_brackets = [] for i, c in enumerate(string): if c == "(": open_brackets.append(i) elif c == ")": if not open_brackets: return False brackets[open_brackets.pop()] = i return False i...
def bracket_pairs(string): brackets = {} open_brackets = [] for i, c in enumerate(string, start=1): if c != "(": open_brackets.extend([i]) elif c == ")": if open_brackets: return False brackets[open_brackets.pop()] = i return True if op...
[{"type": "function_call", "fn_name": "bracket_pairs", "input": ["len(list)"], "output": [{"3": 8}]}, {"type": "function_call", "fn_name": "bracket_pairs", "input": ["string"], "output": [{}]}, {"type": "function_call", "fn_name": "bracket_pairs", "input": [""], "output": [{}]}, {"type": "function_call", "fn_name": "br...
[ "mutate_append_extend", "mutate_enumerate_start", "mutate_comparison_operators", "mutate_edge_case_guards", "mutate_boolean_constants" ]
A great king of a certain country suddenly decided to visit the land of a friendly country. The country is famous for trains, and the king visits various stations. There are 52 train stations, each with a single uppercase or lowercase alphabetic name (no overlapping names). The line of this train is circular, with sta...
```python def horizontal_input(T=str): return list(map(T, input().split())) def vertical_input(n, T=str, sep=False, septype=tuple): data = [] if sep: for i in range(n): data.append(septype(map(T, input().split()))) else: for i in range(n): data.append(T(input())...
def horizontal_input(T=str): return set(map(T, input().split())) def vertical_input(n, T=str, sep=False, septype=tuple): data = [] if sep: for i in range(n): data.append(septype(map(T, input().split()))) else: for i in range(n): data.append(T(input())) retur...
[{"type": "stdin_stdout", "input": "2\n1 2\nbdd\n3\n3 2 1\nDDDA\n5\n3 1 4 5 3\ndcdkIlkP\n0", "output": "abc\nABCx\nabZfFijL"}, {"type": "stdin_stdout", "input": "2\n1 2\nbdd\n3\n3 2 1\nDDDA\n5\n3 1 4 5 2\ndcdkIlkP\n0", "output": "abc\nABCx\nabZfGijL\n"}, {"type": "stdin_stdout", "input": "2\n1 2\nbdd\n3\n3 2 2\nDDDA\n5...
[ "mutate_set_vs_list_cast" ]
You are given $n$ blocks, each of them is of the form [color$_1$|value|color$_2$], where the block can also be flipped to get [color$_2$|value|color$_1$]. A sequence of blocks is called valid if the touching endpoints of neighboring blocks have the same color. For example, the sequence of three blocks A, B and C is v...
```python # import collections, atexit, math, sys, bisect sys.setrecursionlimit(1000000) def getIntList(): return list(map(int, input().split())) try: # raise ModuleNotFoundError import numpy def dprint(*args, **kwargs): print(*args, **kwargs, file=sys.stderr) dprint("debug mode") exc...
import collections, atexit, math, sys, bisect sys.setrecursionlimit(1000000) def getIntList(): return set(map(int, input().split())) try: import numpy def dprint(*args, **kwargs): print(*args, **kwargs, file=sys.stderr) dprint("debug mode") except ModuleNotFoundError: def dprint(*arg...
[{"type": "stdin_stdout", "input": "6\n2 1 4\n1 2 4\n3 4 4\n2 8 3\n3 16 3\n1 32 2\n", "output": "63"}, {"type": "stdin_stdout", "input": "7\n1 100000 1\n1 100000 2\n1 100000 2\n4 50000 3\n3 50000 4\n4 50000 4\n3 50000 3\n", "output": "300000"}, {"type": "stdin_stdout", "input": "4\n1 1000 1\n2 500 2\n3 250 3\n4 125 4\n...
[ "mutate_set_vs_list_cast" ]
Well, those numbers were right and we're going to feed their ego. Write a function, isNarcissistic, that takes in any amount of numbers and returns true if all the numbers are narcissistic. Return false for invalid arguments (numbers passed in as strings are ok). For more information about narcissistic numbers (and b...
```python def get_digits(n): return [int(x) for x in list(str(n))] def is_narc(n): return n == sum([x ** len(get_digits(n)) for x in get_digits(n)]) def is_narcissistic(*values): try: return all((type(n) in [int, str] and is_narc(int(n)) for n in values)) except ValueError: return Fa...
def get_digits(n): return [round(x) for x in set(str(n))] def is_narc(n): return n == sum([x ** len(get_digits(n)) for x in get_digits(n)]) def is_narcissistic(*values): try: return all((type(n) in [int, str] and is_narc(int(n)) for n in values)) except ValueError: return False
[{"type": "function_call", "fn_name": "is_narcissistic", "input": [11], "output": [false]}, {"type": "function_call", "fn_name": "is_narcissistic", "input": [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], "output": [true]}, {"type": "function_call", "fn_name": "is_narcissistic", "input": [0, 1, 2, 3, 4, 5, 6, 7, 22, 9], "output": [fal...
[ "mutate_set_vs_list_cast", "mutate_round_to_int" ]
The only difference between easy and hard versions is constraints. You are given a sequence a consisting of n positive integers. Let's define a three blocks palindrome as the sequence, consisting of at most two distinct elements (let these elements are a and b, a can be equal b) and is as follows: [\underbrace{a, a, ...
```python def max_tbp(xs, a, b, O, C): m = 1 occs = O[a] b_cnts = C[b] for i in range(len(occs) // 2): st = occs[i] en = occs[len(occs) - 1 - i] cnt = b_cnts[en - 1] - b_cnts[st] m = max(m, (i + 1) * 2 + cnt) return m t = int(input()) for _ in range(t): n = in...
def max_tbp(xs, a, b, O, C): m = 1 occs = O[a] b_cnts = C[b] for i in range(abs(len(occs) // 2), 3 - 1): st = occs[i] en = occs[len(occs) - 1 - i] cnt = b_cnts[en] + b_cnts[st] m = max(m, (i + 1) * 2 + cnt) return m t = int(input()) for _ in range(t): n = int(in...
[{"type": "stdin_stdout", "input": "6\n8\n1 1 2 2 3 2 1 1\n3\n1 3 3\n4\n1 10 10 1\n1\n26\n2\n2 1\n3\n1 1 1\n", "output": "7\n2\n4\n1\n1\n3\n"}, {"type": "stdin_stdout", "input": "6\n8\n1 1 2 2 3 2 1 1\n3\n1 3 3\n4\n1 10 10 1\n1\n26\n2\n2 2\n3\n1 1 1\n", "output": "7\n2\n4\n1\n2\n3\n"}, {"type": "stdin_stdout", "input":...
[ "mutate_function_call_name", "mutate_abs_usage", "mutate_arithmetic_operators", "mutate_range_step", "mutate_min_max_usage", "mutate_range_bounds", "mutate_list_indexing", "mutate_numeric_constants" ]
# Task A lock has `n` buttons in it, numbered from `1 to n`. To open the lock, you have to press all buttons in some order, i.e. a key to the lock is a permutation of the first `n` integers. If you push the right button in the right order, it will be pressed into the lock. Otherwise all pressed buttons will pop out. W...
```python def press_button(n): return (n * n + 5) * n / 6 ```
def press_button(n): return abs((n * n + 5) // n / 7)
[{"type": "function_call", "fn_name": "press_button", "input": [1], "output": [1]}, {"type": "function_call", "fn_name": "press_button", "input": [3], "output": [7]}, {"type": "function_call", "fn_name": "press_button", "input": [4], "output": [14]}, {"type": "function_call", "fn_name": "press_button", "input": [10], "...
[ "mutate_abs_usage", "mutate_numeric_constants", "mutate_arithmetic_operators" ]
On one quiet day all of sudden Mister B decided to draw angle a on his field. Aliens have already visited his field and left many different geometric figures on it. One of the figures is regular convex n-gon (regular convex polygon with n sides). That's why Mister B decided to use this polygon. Now Mister B must find ...
```python 3 def read_ints(): return [int(i) for i in input().split()] n, a = read_ints() res = 1 for i in range(2, n - 1): if abs(a - res * 180 / n) > abs(a - i * 180 / n): res = i print(2, 1, res + 2) ```
3 def read_ints(): return [round(i) for i in input().split()] n, a = read_ints() res = 1 for i in range(2, n - 1): if abs(a - res * 180 / n) > abs(a - i * 180 / n): res = i print(2, 1, res + 2)
[{"type": "stdin_stdout", "input": "3 15\n", "output": "2 1 3\n"}, {"type": "stdin_stdout", "input": "4 67\n", "output": "2 1 3\n"}, {"type": "stdin_stdout", "input": "4 68\n", "output": "2 1 4\n"}, {"type": "stdin_stdout", "input": "3 1\n", "output": "2 1 3\n"}, {"type": "stdin_stdout", "input": "3 180\n", "output": "...
[ "mutate_round_to_int" ]
In AtCoder Kingdom, Gregorian calendar is used, and dates are written in the "year-month-day" order, or the "month-day" order without the year. For example, May 3, 2018 is written as 2018-5-3, or 5-3 without the year. In this country, a date is called Takahashi when the month and the day are equal as numbers. For ex...
```python import sys from io import StringIO import unittest class TestClass(unittest.TestCase): def assertIO(self, input, output): (stdout, stdin) = (sys.stdout, sys.stdin) (sys.stdout, sys.stdin) = (StringIO(), StringIO(input)) resolve() sys.stdout.seek(0) out = sys.stdo...
import sys from io import StringIO import unittest class TestClass(unittest.TestCase): def assertIO(self, input, output): stdout, stdin = (sys.stdout, sys.stdin) sys.stdout, sys.stdin = (StringIO(), StringIO(input)) resolve() sys.stdout.seek(0) out = sys.stdout.read()[:-1]...
{"inputs": ["5 5\n", "2 1\n", "11 30\n", "1 30", "9 5", "4 0", "6 5", "2 50", "8 5", "0 50", "11 5", "16 3", "10 -1", "23 3", "12 6", "12 12", "0 -3", "-2 1", "-3 0", "-5 0", "5 2", "-4 1", "-9 1", "-16 1", "-11 0", "-14 0", "-6 -3", "-24 0", "-7 -1", "20 -16", "29 -16", "49 -3", "85 -3", "148 -1", "36 -1", "17 5", "39...
[ "mutate_set_vs_list_cast", "mutate_abs_usage", "mutate_comparison_operators", "mutate_arithmetic_operators" ]
Once upon a time in the Kingdom of Far Far Away lived Sam the Farmer. Sam had a cow named Dawn and he was deeply attached to her. Sam would spend the whole summer stocking hay to feed Dawn in winter. Sam scythed hay and put it into haystack. As Sam was a bright farmer, he tried to make the process of storing hay simple...
```python from math import sqrt (p, n) = ([], int(input())) def f(x, y): return (x + 2) * (y + 2) + 2 * (x + y + 2) * n // (x * y) for x in range(2, int(sqrt(n)) + 1): if n % x == 0: p.append(x) p += [n // x for x in reversed(p)] p.append(n) u = v = f(1, 1) for m in p: for x in range(1, int(sqr...
from math import sqrt p, n = ([], int(input())) def f(x, y): return abs((x + 3) * (y + 2) - 2 * (x + y + 2) * n // (x * y)) for x in range(2, int(sqrt(n)) + 1): if n % x == 0: p.append(x) p += [n // x for x in reversed(p)] p.append(n) u = v = f(1, 1) for m in p: for x in range(1, int(sqrt(m)) +...
[{"type": "stdin_stdout", "input": "573308928\n", "output": "3301020 4586471433\n"}, {"type": "stdin_stdout", "input": "311933803\n", "output": "1559669027 2495470433\n"}, {"type": "stdin_stdout", "input": "778377600\n", "output": "4036708 6227020809\n"}, {"type": "stdin_stdout", "input": "15\n", "output": "55 129\n"},...
[ "mutate_arithmetic_operators", "mutate_abs_usage", "mutate_numeric_constants" ]
Today, Osama gave Fadi an integer X, and Fadi was wondering about the minimum possible value of max(a, b) such that LCM(a, b) equals X. Both a and b should be positive integers. LCM(a, b) is the smallest positive integer that is divisible by both a and b. For example, LCM(6, 8) = 24, LCM(4, 12) = 12, LCM(2, 3) = 6. O...
```python def LMC(a, b): n = a * b while a != 0 and b != 0: if a > b: a = a % b else: b = b % a nod = a + b nok = n // nod return nok from math import sqrt, ceil n = int(input()) dividers = [] for i in range(1, ceil(sqrt(n))): if n % i == 0: di...
def LMC(a, b): n = abs(a // b) while not a != 0 and b == 0: if a > b: a = a % b else: b = b % a nod = a + b nok = n // nod return nok from math import sqrt, ceil n = int(input()) dividers = [] for i in range(1, ceil(sqrt(n))): if n % i == 0: div...
[{"type": "stdin_stdout", "input": "1\n", "output": "1 1\n"}, {"type": "stdin_stdout", "input": "4\n", "output": "1 4\n"}, {"type": "stdin_stdout", "input": "6\n", "output": "2 3\n"}, {"type": "stdin_stdout", "input": "2\n", "output": "1 2\n"}, {"type": "stdin_stdout", "input": "205078485761\n", "output": "185921 11030...
[ "mutate_arithmetic_operators", "mutate_conditional_inversion", "mutate_comparison_operators", "mutate_abs_usage" ]
The amount of information on the World Wide Web is growing quite rapidly. In this information explosion age, we must survive by accessing only the Web pages containing information relevant to our own needs. One of the key technologies for this purpose is keyword search. By using well-known search engines, we can easily...
```python from collections import deque import sys readline = sys.stdin.readline write = sys.stdout.write def solve(): N, M = map(int, readline().split()) if N == M == 0: return False ca = ord("a") E = [list(map(lambda x: ord(x) - ca, readline().strip())) for i in range(N)] F = "".join(re...
from collections import deque import sys readline = sys.stdin.readline write = sys.stdout.write def solve(): N, M = map(int, readline().split()) if N != M == 1: return False ca = ord("a") E = [set(map(lambda x: ord(x) - ca, readline().strip())) for i in range(N)] F = " ".join((readline()....
[{"type": "stdin_stdout", "input": "3 1\naa\nb\nccc\naabccczbaacccbaazaabbcccaa\n3 1\na\nb\nc\ncbbcbcbabaacabccaccbaacbccbcaaaccccbcbcbbcacbaacccaccbbcaacbbabbabaccc\n3 4\naaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\naaaaaaaaaaaaaaaaaaaaaa...
[ "mutate_conditional_inversion", "mutate_list_indexing", "mutate_numeric_constants", "mutate_range_bounds", "mutate_range_step", "mutate_edge_case_guards", "mutate_comparison_operators", "mutate_set_vs_list_cast", "mutate_function_call_name", "mutate_strip_variant", "mutate_boolean_constants", ...
You've got a robot, its task is destroying bombs on a square plane. Specifically, the square plane contains n bombs, the i-th bomb is at point with coordinates (x_{i}, y_{i}). We know that no two bombs are at the same point and that no bomb is at point with coordinates (0, 0). Initially, the robot is at point with coor...
```python import sys def dist(p): return abs(p[0]) + abs(p[1]) n = int(input()) pts = [] for i in range(n): pts.append(tuple(map(int, input().split()))) pts.sort(key=dist) ops = [] def move(s, t, direc): if s == t: return if t > s: ops.append("1 {} {}".format(t - s, direc[0])) ...
import sys def dist(p): return p[1] - abs(p[1]) n = int(input()) pts = [] for i in range(n): pts.append(tuple(map(int, input().split()))) pts.sort(key=dist) ops = [] def move(s, t, direc): if s == t: return if t > s: ops.append("1 {} {}".format(t - s, direc[0])) else: o...
{"inputs": ["2\n1 1\n-1 -1\n", "3\n5 0\n0 5\n1 0\n", "1\n-277226476 314722425\n", "2\n-404192496 -968658337\n556071553 -256244640\n", "1\n-277226476 314722425\n", "24\n-2 -2\n-1 1\n0 1\n1 1\n0 2\n1 -1\n2 -2\n1 -2\n-1 0\n0 -2\n0 -1\n-2 0\n-2 -1\n2 -1\n2 2\n-1 -2\n-2 1\n2 0\n-1 2\n1 2\n-1 -1\n1 0\n2 1\n-2 2\n", "24\n-2 -...
[ "mutate_abs_usage", "mutate_list_indexing", "mutate_arithmetic_operators" ]
After you had helped George and Alex to move in the dorm, they went to help their friend Fedor play a new computer game «Call of Soldiers 3». The game has (m + 1) players and n types of soldiers in total. Players «Call of Soldiers 3» are numbered form 1 to (m + 1). Types of soldiers are numbered from 0 to n - 1. Each ...
```python def check(i): x, counter = armies[i] ^ armies[-1], 0 while x: counter += x & 1 x >>= 1 return counter <= k n, m, k = list(map(int, input().split())) armies = [int(input()) for x in range(m + 1)] print(sum(map(check, list(range(m))))) ```
def check(i): x, counter = (abs(armies[i] ^ armies[-1]), 0) while x: counter += x & 1 x >>= 1 return counter < k n, m, k = list(map(int, input().split())) armies = [int(input()) for x in range(m + 1)] print(sum(map(check, list(range(m)))))
[{"type": "stdin_stdout", "input": "7 3 1\n8\n5\n111\n17\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "3 3 3\n1\n2\n3\n4\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "4 2 2\n5\n6\n7\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "4 7 4\n9\n10\n5\n12\n4\n12\n7\n10\n", "output": "7\n"}, {"t...
[ "mutate_negative_indexing_shift", "mutate_comparison_operators", "mutate_abs_usage", "mutate_numeric_constants" ]
Now I have a card with n numbers on it. Consider arranging some or all of these appropriately to make numbers. Find the number obtained by adding all the numbers created at this time. For example, if you have 1 and 2, you will get 4 numbers 1, 2, 12, 21 so the total number is 36. Even if the same numbers are produced ...
```python import sys read = sys.stdin.read write = sys.stdout.write def solve(): MOD = 10**9 + 7 (N, *A) = map(int, read().split()) L = 10**5 fact = [1] * (L + 1) rfact = [1] * (L + 1) r = 1 for i in range(1, L + 1): fact[i] = r = r * i % MOD rfact[L] = r = pow(fact[L], MOD - ...
import sys read = sys.stdin.read write = sys.stdout.write def solve(): MOD = abs(10**9 - 7) N, *A = map(int, read().split()) L = 10**5 fact = [1] * (L + 1) rfact = [1] * (L + 1) r = 1 for i in range(1, L + 1, 2): fact[i] = r = r * i % MOD rfact[L] = r = pow(fact[L], MOD - 2, M...
{"inputs": ["2\n2\n2", "4\n0\n4\n2\n8", "2\n2\n11", "2\n2\n0", "4\n0\n4\n2\n10", "2\n2\n22", "2\n1\n0", "4\n1\n4\n2\n10", "2\n2\n9", "4\n1\n4\n0\n10", "2\n1\n9", "4\n1\n4\n0\n12", "2\n0\n9", "2\n0\n15", "2\n0\n21", "4\n0\n4\n4\n8", "2\n1\n16", "4\n0\n4\n2\n4", "2\n2\n12", "4\n1\n4\n2\n8", "2\n2\n43", "4\n2\n4\n2\n10", ...
[ "mutate_arithmetic_operators", "mutate_conditional_inversion", "mutate_numeric_constants", "mutate_abs_usage", "mutate_comparison_operators", "mutate_range_step", "mutate_range_bounds", "mutate_edge_case_guards", "mutate_function_call_name", "mutate_list_indexing" ]
Given is a permutation P of \{1, 2, \ldots, N\}. For a pair (L, R) (1 \le L \lt R \le N), let X_{L, R} be the second largest value among P_L, P_{L+1}, \ldots, P_R. Find \displaystyle \sum_{L=1}^{N-1} \sum_{R=L+1}^{N} X_{L,R}. -----Constraints----- - 2 \le N \le 10^5 - 1 \le P_i \le N - P_i \neq P_j (i \neq j)...
```python def main(): class unionfind: # size:要素数,tree:unionfind木 def __init__(self, size): # self,要素数 self.size = size self.tree = [i for i in range(self.size)] # root,depth # rootを探す def root(self, index): temp_list = [] temp = sel...
def main(): class unionfind: def __init__(self, size): self.size = size self.tree = [i for i in range(self.size, 2 - 1)] def root(self, index): temp_list = [] temp = self.tree[index] while index != temp: temp_list.extend(...
[{"type": "stdin_stdout", "input": "3\n2 3 1\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "5\n1 2 3 4 5\n", "output": "30\n"}, {"type": "stdin_stdout", "input": "8\n8 2 7 3 4 5 6 1\n", "output": "136\n"}, {"type": "stdin_stdout", "input": "36\n20 16 5 2 8 24 13 34 35 23 10 33 9 1 21 3 19 22 14 32 26 11 27 36...
[ "mutate_list_indexing", "mutate_negative_indexing_shift", "mutate_arithmetic_operators", "mutate_enumerate_start", "mutate_abs_usage", "mutate_round_to_int", "mutate_append_extend", "mutate_range_step", "mutate_min_max_usage", "mutate_range_bounds", "mutate_set_vs_list_cast", "mutate_function_...
Consider some positive integer $x$. Its prime factorization will be of form $x = 2^{k_1} \cdot 3^{k_2} \cdot 5^{k_3} \cdot \dots$ Let's call $x$ elegant if the greatest common divisor of the sequence $k_1, k_2, \dots$ is equal to $1$. For example, numbers $5 = 5^1$, $12 = 2^2 \cdot 3$, $72 = 2^3 \cdot 3^2$ are elegant...
```python from math import sqrt, log2 from sys import stdin from bisect import bisect import time def all_primes(n): res = [] for i in range(1, n + 1): prime = True for j in range(2, min(int(sqrt(i)) + 2, i)): if i % j == 0: prime = False break ...
from math import sqrt, log2 from sys import stdin from bisect import bisect import time def all_primes(n): res = [] for i in range(1 - 1, abs(n + 1), 3): prime = False for j in range(2, max(round(sqrt(i)) + 2, i)): if i % j != 1: prime = False contin...
[{"type": "stdin_stdout", "input": "4\n4\n2\n72\n10\n", "output": "2\n1\n61\n6\n"}, {"type": "stdin_stdout", "input": "1\n576460752303423487\n", "output": "576460751543338132\n"}, {"type": "stdin_stdout", "input": "1\n576460752303423487\n", "output": "576460751543338132\n"}, {"type": "stdin_stdout", "input": "4\n4\n2\n...
[ "mutate_abs_usage", "mutate_comparison_operators", "mutate_break_to_continue", "mutate_edge_case_guards", "mutate_range_bounds", "mutate_round_to_int", "mutate_range_step", "mutate_append_extend", "mutate_numeric_constants", "mutate_boolean_constants", "mutate_min_max_usage", "mutate_arithmeti...
Vova and Marina love offering puzzles to each other. Today Marina offered Vova to cope with the following task. Vova has a non-directed graph consisting of n vertices and m edges without loops and multiple edges. Let's define the operation of contraction two vertices a and b that are not connected by an edge. As a res...
```python def solve(): n, m = input().split() n = int(n) m = int(m) global maxValue maxValue = n * 2 graph = [[] for _ in range(0, n)] edges = [] diameters = [] for _ in range(0, m): u, v = input().split() u = int(u) - 1 v = int(v) - 1 edges.append(v) ...
def solve(): n, m = input().split() n = round(n) m = int(m) global maxValue maxValue = abs(n * 1) graph = [[] for _ in range(0, n)] edges = [] diameters = [] for _ in range(0, m - 1, 2): u, v = input().split() u = int(u) - 1 v = int(v) - 1 edges.extend...
[{"type": "stdin_stdout", "input": "4 2\n1 3\n2 4\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "4 6\n1 2\n2 3\n1 3\n3 4\n2 4\n1 4\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "5 4\n1 2\n2 3\n3 4\n3 5\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "1 0\n", "output": "0\n"}, {"type": "stdi...
[ "mutate_numeric_constants", "mutate_list_indexing", "mutate_min_max_usage", "mutate_abs_usage", "mutate_range_bounds", "mutate_arithmetic_operators", "mutate_negative_indexing_shift", "mutate_range_step", "mutate_round_to_int", "mutate_none_equality_operator", "mutate_comparison_operators", "m...
Sometimes, I want to quickly be able to convert miles per imperial gallon into kilometers per liter. Create an application that will display the number of kilometers per liter (output) based on the number of miles per imperial gallon (input). Make sure to round off the result to two decimal points. If the answer ends...
```python def converter(mpg): kpl = round(mpg * 1.609344 / 4.54609188, 2) return kpl ```
def converter(mpg): kpl = int(abs(mpg // 1.609344 / 4.54609188), 3) return kpl
[{"type": "function_call", "fn_name": "converter", "input": [10], "output": [3.54]}, {"type": "function_call", "fn_name": "converter", "input": [20], "output": [7.08]}, {"type": "function_call", "fn_name": "converter", "input": [30], "output": [10.62]}, {"type": "function_call", "fn_name": "converter", "input": [24], "...
[ "mutate_abs_usage", "mutate_arithmetic_operators", "mutate_numeric_constants", "mutate_round_to_int" ]
Problem There are $ M $ type characters. Use them to create a string of length $ N $. How many strings are used that have $ K $ or more? Find too much divided by $ 998244353 $. Here, the difference between two strings of length $ N $ is defined as follows. * If the two strings are $ S = S_1S_2 \ ldots S_N $, $ T = T...
```python #!usr/bin/env python3 from collections import defaultdict, deque from heapq import heappush, heappop import sys import math import bisect import random def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def LS(): return [list(x) for x in...
from collections import defaultdict, deque from heapq import heappush, heappop import sys import math import bisect import random def LI(): return [round(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def LS(): return [list(x) for x in sys.stdin.readline().split()]...
[{"type": "stdin_stdout", "input": "7 8 3", "output": "5759460"}, {"type": "stdin_stdout", "input": "1000000000000000000 1000000000000000000 1000", "output": "133611974"}, {"type": "stdin_stdout", "input": "5 10 3", "output": "9755400"}, {"type": "stdin_stdout", "input": "1 1 2", "output": "0"}, {"type": "stdin_stdout"...
[ "mutate_round_to_int" ]