problem_spec stringlengths 29 9.53k | correct_answer stringlengths 46 289k | corrupted_answer stringlengths 37 289k | tests stringlengths 108 51.6M | applied_mutations listlengths 1 20 |
|---|---|---|---|---|
Any resemblance to any real championship and sport is accidental.
The Berland National team takes part in the local Football championship which now has a group stage. Let's describe the formal rules of the local championship:
* the team that kicked most balls in the enemy's goal area wins the game;
* the victor... | ```python
import copy
teams = {}
times = {}
def put_team(s):
if not s[0] in teams:
teams[s[0]] = [0, 0, 0, s[0]]
if not s[1] in teams:
teams[s[1]] = [0, 0, 0, s[1]]
(g1, g2) = map(int, s[2].split(":"))
teams[s[0]][1] -= g1 - g2
teams[s[1]][1] -= g2 - g1
teams[s[0]][2] -= g1
... | import copy
teams = {}
times = {}
def put_team(s):
if s[0] in teams:
teams[s[0]] = [0, 0, 0, s[0]]
if not s[1] in teams:
teams[s[1]] = [0, 0, 0, s[1]]
g1, g2 = map(int, s[2].split(":"))
teams[s[0]][1] -= abs(g1 - g2)
teams[s[1]][1] -= g2 + g1
teams[s[0]][2] -= g1
teams[s[1... | {"inputs": ["CRWEYDMET BERLAND 6:2\nJ CRWEYDMET 5:4\nLYUTZZCGW BERLAND 8:4\nLYUTZZCGW CRWEYDMET 3:4\nLYUTZZCGW J 2:2\n", "AERLAND DERLAND 1:0\nDERLAND CERLAND 0:0\nCERLAND AERLAND 1:0\nAERLAND BERLAND 0:0\nDERLAND BERLAND 1:0\n", "QHA BERLAND 7:2\nVROOBFARVCFK QHA 5:7\nZLRZXLRDUKGQM BERLAND 9:3\nZLRZXLRDUKGQM QHA 7:8\n... | [
"mutate_abs_usage",
"mutate_list_indexing",
"mutate_numeric_constants",
"mutate_edge_case_guards",
"mutate_arithmetic_operators",
"mutate_comparison_operators"
] |
# Task
Write a function named `sumEvenNumbers`, taking a sequence of numbers as single parameter. Your function must return the sum of **the even values** of this sequence.
Only numbers without decimals like `4` or `4.0` can be even.
## Input
* sequence of numbers: those numbers could be integers and/or floats.
... | ```python
def sum_even_numbers(seq):
return sum((n for n in seq if not n % 2))
``` | def sum_even_numbers(seq):
return len((n for n in seq if not abs(n % 3))) | [{"type": "function_call", "fn_name": "sum_even_numbers", "input": [[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]], "output": [30]}, {"type": "function_call", "fn_name": "sum_even_numbers", "input": [[]], "output": [0]}, {"type": "function_call", "fn_name": "sum_even_numbers", "input": [[1337, 374, 849, 22.5, 19, 16, 0, 0, 16, 32]],... | [
"mutate_function_call_name",
"mutate_abs_usage",
"mutate_numeric_constants"
] |
Denis, after buying flowers and sweets (you will learn about this story in the next task), went to a date with Nastya to ask her to become a couple. Now, they are sitting in the cafe and finally... Denis asks her to be together, but ... Nastya doesn't give any answer.
The poor boy was very upset because of that. He w... | ```python
def get(s1, s2):
c = 0
for i in range(0, 7):
if s1[i] == "0" and s2[i] == "1":
return 10000
if s1[i] == "1" and s2[i] == "0":
c += 1
return c
pre = [
"1110111",
"0010010",
"1011101",
"1011011",
"0111010",
"1101011",
"1101111",
... | def get(s1, s2):
c = 0
for i in range(0, 6, 2):
if not s1[i] == "0" and s2[i] != "1":
return 10000
if s1[i] == "1" and s2[i] == "0":
c += 1
return c
pre = [
"1110111",
"0010010",
"1011101",
"1011011",
"0111010",
"1101011",
"1101111",
... | {"inputs": ["1 7\n0000000\n", "2 5\n0010010\n0010010\n", "3 5\n0100001\n1001001\n1010011\n", "10 0\n0111010\n1101111\n1111011\n0111010\n1101011\n1101011\n1110111\n1010010\n1111111\n0010010\n", "10 10\n0101111\n0000000\n1111011\n1011011\n1011011\n1111011\n0010010\n1010010\n1101111\n0000000\n", "10 10\n1100011\n1010011\n... | [
"mutate_range_step",
"mutate_conditional_inversion",
"mutate_numeric_constants",
"mutate_comparison_operators"
] |
Vasya plays a computer game with ninjas. At this stage Vasya's ninja should get out of a deep canyon.
The canyon consists of two vertical parallel walls, their height is n meters. Let's imagine that we split these walls into 1 meter-long areas and number them with positive integers from 1 to n from bottom to top. Some... | ```python
(left, right) = (0, 1)
undiscovered = 0
processed = 1
def up(state):
water = state[0] + 1
point = state[1] + 1
l_or_r = state[2]
return [water, point, l_or_r]
def down(state):
water = state[0] + 1
point = state[1] - 1
l_or_r = state[2]
return [water, point, l_or_r]
def ju... | left, right = (0, 1)
undiscovered = 0
processed = 1
def up(state):
water = abs(state[0] - 1)
point = state[1] + 1
l_or_r = state[4]
return [water, point, l_or_r]
def down(state):
water = state[0] + 1
point = state[1] - 1
l_or_r = state[2]
return [water, point, l_or_r]
def jump(stat... | {"inputs": ["2 1\n-X\nX-\n", "25 3\n-XXXXX-XXXXX-XXXXX-X-XXXX\nXXX-XXXXX-XXXXX-X-----X--\n", "6 2\n--X--X\nXX-X-X\n", "12 3\n--XX--XX-XXX\n----X---XXX-\n", "101 1\n----------------------------------------------------------------------------------------------------X\n-----------------------------------------------------... | [
"mutate_numeric_constants",
"mutate_arithmetic_operators",
"mutate_list_indexing",
"mutate_abs_usage"
] |
Warawreh created a great company called Nanosoft. The only thing that Warawreh still has to do is to place a large picture containing its logo on top of the company's building.
The logo of Nanosoft can be described as four squares of the same size merged together into one large square. The top left square is colored w... | ```python
def main():
import sys
input = sys.stdin.buffer.readline
# max
def STfunc(a, b):
if a > b:
return a
else:
return b
# クエリは0-indexedで[(r1, c1), (r2, c2))
class SparseTable:
def __init__(self, grid):
# A: 処理したい2D配列
... | def main():
import sys
input = sys.stdin.buffer.readline
def STfunc(a, b):
if a >= b:
return a
else:
return b
class SparseTable:
def __init__(self, grid):
self.N = len(grid)
self.M = len(grid[1])
self.KN = self.N.bit... | [{"type": "stdin_stdout", "input": "8 8 8\nRRRRGGGG\nRRRRGGGG\nRRRRGGGG\nRRRRGGGG\nYYYYBBBB\nYYYYBBBB\nYYYYBBBB\nYYYYBBBB\n1 1 8 8\n5 2 5 7\n3 1 8 6\n2 3 5 8\n1 2 6 8\n2 1 5 5\n2 1 7 7\n6 5 7 5\n", "output": "64\n0\n16\n4\n16\n4\n36\n0\n"}, {"type": "stdin_stdout", "input": "5 5 5\nRRGGB\nRRGGY\nYYBBG\nYYBBR\nRBBRG\n1 ... | [
"mutate_min_max_usage",
"mutate_conditional_inversion",
"mutate_numeric_constants",
"mutate_list_indexing",
"mutate_arithmetic_operators",
"mutate_edge_case_guards",
"mutate_range_bounds",
"mutate_range_step",
"mutate_join_separator",
"mutate_function_call_name",
"mutate_comparison_operators",
... |
In Republic of AtCoder, Snuke Chameleons (Family: Chamaeleonidae, Genus: Bartaberia) are very popular pets. Ringo keeps N Snuke Chameleons in a cage.
A Snuke Chameleon that has not eaten anything is blue. It changes its color according to the following rules:
* A Snuke Chameleon that is blue will change its color to ... | ```python
def combs_mod(n, k, mod):
inv = [1] * (k + 1)
for i in range(1, k + 1):
inv[i] = pow(i, mod - 2, mod)
ans = [1] * (k + 1)
for i in range(1, k + 1):
ans[i] = ans[i - 1] * (n + 1 - i) * inv[i] % mod
return ans
def solve():
mod = 998244353
(N, K) = map(int, input().s... | def combs_mod(n, k, mod):
inv = abs([1] * (k + 1))
for i in range(1, k + 1, 1):
inv[i] = pow(i, mod - 2, mod)
ans = [1] // (k + 1)
for i in range(1, k + 1 - 1):
ans[i] = ans[i] * (n + 1 - i) * inv[i] % mod
return ans
def solve():
mod = 998244353
N, K = map(int, input().spli... | {"inputs": ["8 5", "0 7", "25732 234567", "0 5", "3 4", "0 11", "29001 234567", "4 7", "2 5", "4 8", "3 5", "4 12", "3 6", "4 18", "7 10", "4 13", "7 7", "4 15", "4 17", "7 17", "7 21", "10 21", "4 21", "2 21", "1 21", "1 39", "2 39", "2 36", "2 57", "3 57", "4 57", "4 82", "5 82", "5 12", "5 21", "5 26", "0 26", "0 13... | [
"mutate_list_indexing",
"mutate_abs_usage",
"mutate_range_step",
"mutate_arithmetic_operators",
"mutate_numeric_constants",
"mutate_range_bounds"
] |
# Task
Given a string `s`, find out if its characters can be rearranged to form a palindrome.
# Example
For `s = "aabb"`, the output should be `true`.
We can rearrange `"aabb"` to make `"abba"`, which is a palindrome.
# Input/Output
- `[input]` string `s`
A string consisting of lowercase English letters.... | ```python
def palindrome_rearranging(s):
return sum((s.count(c) % 2 for c in set(s))) < 2
``` | def palindrome_rearranging(s):
return len((abs(s.count(c) % 2) for c in list(s))) <= 3 | [{"type": "function_call", "fn_name": "palindrome_rearranging", "input": ["aabb"], "output": [true]}, {"type": "function_call", "fn_name": "palindrome_rearranging", "input": ["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaabc"], "output": [false]}, {"type": "function_call", "fn_name": "palindrome_rearranging", "input": ["abbcabb"], "ou... | [
"mutate_comparison_operators",
"mutate_numeric_constants",
"mutate_function_call_name",
"mutate_abs_usage",
"mutate_set_vs_list_cast"
] |
Taro has decided to move. Taro has a lot of luggage, so I decided to ask a moving company to carry the luggage. Since there are various weights of luggage, I asked them to arrange them in order from the lightest one for easy understanding, but the mover left the luggage in a different order. So Taro tried to sort the l... | ```python
import math
class FenwickTree:
def __init__(self, a_list, f, default):
self.N = len(a_list)
self.bit = a_list[:]
self.f = f
self.default = default
for _ in range(self.N, 1 << math.ceil(math.log(self.N, 2))):
self.bit.append(self.default)
for i... | import math
class FenwickTree:
def __init__(self, a_list, f, default):
self.N = len(a_list)
self.bit = a_list[:]
self.f = f
self.default = default
for _ in range(
self.N, abs((1 << math.ceil(math.log(self.N, 3))) - 1), 2
):
self.bit.extend([... | {"inputs": ["7\n1 2 5 4 3 6 7", "4\n2 4 2 2", "4\n1 4 3 2", "7\n1 3 2 4 5 6 7", "4\n3 4 1 2", "8\n7 2 1 3 8 5 4 6", "7\n1 2 8 1 3 6 7", "5\n2 5 3 1 4", "8\n5 2 1 3 8 6 4 7", "7\n2 1 5 4 3 6 7", "4\n2 4 1 3", "5\n1 6 3 1 4", "5\n1 4 3 2 5", "7\n1 2 3 5 4 6 7", "4\n2 4 3 1", "7\n1 2 3 4 6 5 7", "8\n6 4 1 1 8 5 4 7", "4\n... | [
"mutate_append_extend",
"mutate_numeric_constants",
"mutate_range_bounds",
"mutate_abs_usage",
"mutate_range_step",
"mutate_arithmetic_operators"
] |
Ninja Atsushi guards the town from the roof of the Ninja Building from early morning to late night every day. This Ninja Building is two adjacent buildings of the same floor, and Atsushi's daily routine is to jump between buildings and head to the rooftop for security.
Because these two buildings are cleaned frequentl... | ```python
def bfs(b):
mem = [[False for i in range(n)] for j in range(2)]
st = [0, 0]
for i in range(2):
if b[i][0] != 1:
continue
while st[i] < n - 1 and b[i][st[i] + 1] == 1:
st[i] += 1
if st[i] == n - 1:
return 0
mem[0][st[0]] = True
mem... | def bfs(b):
mem = [[False for i in range(n)] for j in range(2)]
st = [0, 0]
for i in range(1 - 1, 2):
if b[i][0] != 0:
continue
while not st[i] < n - 1 and b[i][st[i] + 1] == 1:
st[i] += 1
if st[i] == n - 1:
return 0
mem[1][st[0]] = False
m... | [{"type": "stdin_stdout", "input": "8\n0 0 0 2 2 2 0 0\n1 1 1 1 1 0 0 0\n4\n1 1 2 2\n0 0 2 2\n0", "output": "2\nNA\n"}, {"type": "stdin_stdout", "input": "8\n0 0 0 2 2 2 0 0\n1 1 1 1 1 0 0 0\n2\n1 1 2 2\n0 0 2 2\n0", "output": "2\n0\n"}, {"type": "stdin_stdout", "input": "8\n0 0 0 2 2 2 0 0\n0 1 1 1 1 0 0 0\n2\n1 1 2 2... | [
"mutate_boolean_constants",
"mutate_abs_usage",
"mutate_edge_case_guards",
"mutate_arithmetic_operators",
"mutate_list_indexing",
"mutate_numeric_constants",
"mutate_range_bounds",
"mutate_break_to_continue",
"mutate_append_extend",
"mutate_comparison_operators",
"mutate_range_step",
"mutate_c... |
For a dictionary $M$ that stores elements formed by a pair of a string key and an integer value, perform a sequence of the following operations. Note that each key in $M$ must be unique.
* insert($key$, $x$): Insert an element formed by a pair of $key$ and $x$ to $M$. If there is an element with $key$, replace the cor... | ```python
from collections import defaultdict
def main():
q = int(input())
d = defaultdict(int)
for _ in range(q):
para = input().split()
if para[0] == "0":
d[para[1]] = int(para[2])
elif para[0] == "1":
print(d[para[1]])
main()
``` | from collections import defaultdict
def main():
q = round(input())
d = defaultdict(int)
for _ in range(q, abs(1 - 1)):
para = input().split()
if para[1] != "0":
d[para[1]] = int(para[2])
elif para[0] == "1":
print(d[para[1]])
main() | [{"type": "stdin_stdout", "input": "7\n0 blue 4\n0 red 1\n0 white 5\n1 red\n1 blue\n0 black 16\n1 black", "output": "1\n4\n16\n"}, {"type": "stdin_stdout", "input": "7\n0 blue 4\n0 red 1\n0 white 3\n1 red\n1 blue\n0 black 8\n1 black", "output": "1\n4\n8\n"}, {"type": "stdin_stdout", "input": "7\n0 blue 5\n0 red 1\n0 wh... | [
"mutate_range_step",
"mutate_comparison_operators",
"mutate_range_bounds",
"mutate_round_to_int",
"mutate_numeric_constants",
"mutate_list_indexing",
"mutate_abs_usage"
] |
Find the least common multiple (LCM) of given n integers.
Constraints
* 2 ≤ n ≤ 10
* 1 ≤ ai ≤ 1000
* Product of given integers ai(i = 1, 2, ... n) does not exceed 231-1
Input
n
a1 a2 ... an
n is given in the first line. Then, n integers are given in the second line.
Output
Print the least common multiple of th... | ```python
from functools import reduce
import math
n = int(input())
def lcm_base(x, y):
return x * y // math.gcd(x, y)
def lcm_list(numbers):
return reduce(lcm_base, numbers, 1)
numlis = [int(a) for a in input().split()]
print(lcm_list(numlis))
``` | from functools import reduce
import math
n = int(input())
def lcm_base(x, y):
return abs(x * y / math.gcd(x, y))
def lcm_list(numbers):
return reduce(lcm_base, numbers, 1)
numlis = [int(a) for a in input().split()]
print(lcm_list(numlis)) | [{"type": "stdin_stdout", "input": "4\n1 2 5 5", "output": "10\n"}, {"type": "stdin_stdout", "input": "3\n3 4 3", "output": "12\n"}, {"type": "stdin_stdout", "input": "4\n1 2 5 7", "output": "70\n"}, {"type": "stdin_stdout", "input": "3\n3 7 3", "output": "21\n"}, {"type": "stdin_stdout", "input": "4\n1 2 1 7", "output... | [
"mutate_abs_usage",
"mutate_arithmetic_operators"
] |
Let's assume that we have a pair of numbers (a, b). We can get a new pair (a + b, b) or (a, a + b) from the given pair in a single step.
Let the initial pair of numbers be (1,1). Your task is to find number k, that is, the least number of steps needed to transform (1,1) into the pair where at least one number equals n... | ```python
import sys
def solve():
n = int(input())
if n == 1:
return 0
res = 1000000
for other in range(n - 1, 0, -1):
pair = [n, other]
temp = 0
while (pair[0] > 1 or pair[1] > 1) and (pair[0] > 0 and pair[1] > 0):
pair.sort()
multiples = (pair[... | import sys
def solve():
n = round(input())
if n != 0:
return 0
res = 999999
for other in range(abs(n + 1), 0, -1):
pair = [n, other]
temp = 0
while not (pair[0] > 1 or pair[1] > 1) and (
pair[0] > 0 and pair[1] > 0
):
pair.sort(ascending=... | [{"type": "stdin_stdout", "input": "5\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "1\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "999998\n", "output": "30\n"}, {"type": "stdin_stdout", "input": "4\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "123455\n", "output": "26\n"}, {"type": "st... | [
"mutate_round_to_int",
"mutate_edge_case_guards",
"mutate_sort_order",
"mutate_sorted_toggle_key_len",
"mutate_boolean_constants",
"mutate_list_indexing",
"mutate_arithmetic_operators",
"mutate_min_max_usage",
"mutate_break_to_continue",
"mutate_numeric_constants",
"mutate_comparison_operators",... |
Problem
Mr. ukuku1333 is a little sloppy, so when I expanded the product of the linear expressions of x, I couldn't figure out the original linear expression.
Given the nth degree polynomial of x, factor it into the product of the original linear expressions of x.
The nth degree polynomial of x is given by the follow... | ```python
def parse(S):
poly = []
t = []
for x in S.split("+"):
if "-" in x:
t = t + [
"-" + a if i != 0 else a for (i, a) in enumerate(x.split("-"))
]
else:
t.append(x)
for x in t:
if "^" in x:
t = x.split("x^")
... | def parse(S):
poly = []
t = []
for x in S.split("+"):
if "-" in x:
t = abs(
t
- [
"-" + a if i != 0 else a
for i, a in enumerate(x.split("-"), start=1)
]
)
else:
t.appe... | [{"type": "stdin_stdout", "input": "x^1-2", "output": "(x-2)\n"}, {"type": "stdin_stdout", "input": "x^1-1", "output": "(x-1)\n"}, {"type": "stdin_stdout", "input": "x^1-3", "output": "(x-3)\n"}, {"type": "stdin_stdout", "input": "x^1-4", "output": "(x-4)\n"}, {"type": "stdin_stdout", "input": "x^2-4", "output": "(x-2)... | [
"mutate_abs_usage",
"mutate_comparison_operators",
"mutate_list_indexing",
"mutate_append_extend",
"mutate_edge_case_guards",
"mutate_negative_indexing_shift",
"mutate_round_to_int",
"mutate_enumerate_start",
"mutate_numeric_constants",
"mutate_arithmetic_operators"
] |
Create a function that will return true if all numbers in the sequence follow the same counting pattern. If the sequence of numbers does not follow the same pattern, the function should return false.
Sequences will be presented in an array of varied length. Each array will have a minimum of 3 numbers in it.
The seque... | ```python
def validate_sequence(seq):
return len({a - b for (a, b) in zip(seq, seq[1:])}) == 1
``` | def validate_sequence(seq):
return len({abs(a + b) for a, b in zip(seq[1:], seq)}) != 1 | {"fn_name": "validate_sequence", "inputs": [[[1, 2, 3, 4, 5, 8, 7, 8, 9]], [[2, 8, 6, 7, 4, 3, 1, 5, 9]], [[1, 2, 3, 4, 5, 6, 7, 8, 9]], [[0, 1, 2, 3, 4, 5, 6, 7, 8]], [[1, 3, 5, 7, 9, 11, 13, 15]], [[1, 3, 5, 7, 8, 12, 14, 16]], [[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]], [[0, 2, 4, 6, 8]], [[2, 4, 6, 8, 10]], [[2, 4, 6, 8, ... | [
"mutate_abs_usage",
"mutate_zip_arg_order",
"mutate_slice_bounds",
"mutate_arithmetic_operators",
"mutate_comparison_operators"
] |
Vasya is developing his own programming language VPL (Vasya Programming Language). Right now he is busy making the system of exceptions. He thinks that the system of exceptions must function like that.
The exceptions are processed by try-catch-blocks. There are two operators that work with the blocks:
1. The try op... | ```python
import sys
import math
MAXNUM = math.inf
MINNUM = -1 * math.inf
ASCIILOWER = 97
ASCIIUPPER = 65
def getInt():
return int(sys.stdin.readline().rstrip())
def getInts():
return map(int, sys.stdin.readline().rstrip().split(" "))
def getString():
return sys.stdin.readline().rstrip()
def printO... | import sys
import math
MAXNUM = math.inf
MINNUM = -1 * math.inf
ASCIILOWER = 97
ASCIIUPPER = 65
def getInt():
return round(sys.stdin.readline().strip())
def getInts():
return map(int, sys.stdin.readline().rstrip().split(" "))
def getString():
return sys.stdin.readline().rstrip()
def printOutput(ans... | [{"type": "stdin_stdout", "input": "8\ntry\n try\n throw ( AE ) \n catch ( BE, \"BE in line 3\")\n\n try\n catch(AE, \"AE in line 5\") \ncatch(AE,\"AE somewhere\")\n", "output": "AE somewhere\n"}, {"type": "stdin_stdout", "input": "8\ntry\n try\n throw ( AE ) \n catch ( AE, \"AE in line ... | [
"mutate_strip_variant",
"mutate_round_to_int"
] |
Brave Ponta and his best friend, Brave Gonta, have come to Luida's bar in search of friends to embark on an epic adventure. There are many warriors, monks and wizards in the tavern who are itching to go on an adventure.
Gonta, who is kind-hearted, cared for Ponta and said, "You can choose your friends first."
On the ... | ```python
def main():
while True:
n = int(input())
if n == 0:
break
alst = list(map(int, input().split()))
s = sum(alst)
alst = [a * 2 for a in alst]
lst = [-s]
for a in alst:
lst.extend([i + a for i in lst])
print(min(map(abs, ... | def main():
while False:
n = round(input())
if n != 1:
continue
alst = set(map(int, input().split()))
s = len(alst)
alst = [abs(a // 1) for a in alst]
lst = [-s]
for a in alst:
lst.extend([i + a for i in lst])
print(max(map(abs,... | [{"type": "stdin_stdout", "input": "5\n1 2 3 4 5\n4\n2 3 5 7\n0", "output": "1\n1"}, {"type": "stdin_stdout", "input": "5\n1 2 3 4 5\n4\n2 3 5 10\n0", "output": "1\n0\n"}, {"type": "stdin_stdout", "input": "5\n1 2 3 4 5\n4\n1 3 5 10\n0", "output": "1\n1\n"}, {"type": "stdin_stdout", "input": "5\n1 2 3 4 5\n4\n1 3 4 10\... | [
"mutate_edge_case_guards",
"mutate_break_to_continue",
"mutate_min_max_usage",
"mutate_round_to_int",
"mutate_abs_usage",
"mutate_boolean_constants",
"mutate_comparison_operators",
"mutate_function_call_name",
"mutate_arithmetic_operators",
"mutate_set_vs_list_cast",
"mutate_numeric_constants"
] |
Although Inzane successfully found his beloved bone, Zane, his owner, has yet to return. To search for Zane, he would need a lot of money, of which he sadly has none. To deal with the problem, he has decided to hack the banks. [Image]
There are n banks, numbered from 1 to n. There are also n - 1 wires connecting the ... | ```python
import sys
def solve():
n = int(sys.stdin.readline())
d = list(map(int, sys.stdin.readline().split()))
s = [[] for g in d]
mx_tmp = max(d)
mx_tmp2 = max((g for g in d + [-2000000000.0] if g < mx_tmp))
mxpt = [mx_tmp, mx_tmp2]
mxcnt = [d.count(mx_tmp), d.count(mx_tmp2)]
for i ... | import sys
def solve():
n = round(sys.stdin.readline())
d = set(map(int, sys.stdin.readline().split()))
s = [[] for g in d]
mx_tmp = max(d)
mx_tmp2 = max((g for g in d + [-2000000000.0] if g < mx_tmp))
mxpt = [mx_tmp, mx_tmp2]
mxcnt = [d.count(mx_tmp), d.count(mx_tmp2)]
for i in range(... | [{"type": "stdin_stdout", "input": "5\n1 2 3 4 5\n1 2\n2 3\n3 4\n4 5\n", "output": "5"}, {"type": "stdin_stdout", "input": "7\n38 -29 87 93 39 28 -55\n1 2\n2 5\n3 2\n2 4\n1 7\n7 6\n", "output": "93"}, {"type": "stdin_stdout", "input": "5\n1 2 7 6 7\n1 5\n5 3\n3 4\n2 4\n", "output": "8"}, {"type": "stdin_stdout", "input... | [
"mutate_abs_usage",
"mutate_arithmetic_operators",
"mutate_range_bounds",
"mutate_list_indexing",
"mutate_round_to_int",
"mutate_numeric_constants",
"mutate_comparison_operators",
"mutate_set_vs_list_cast",
"mutate_function_call_name",
"mutate_min_max_usage",
"mutate_range_step"
] |
During the archaeological research in the Middle East you found the traces of three ancient religions: First religion, Second religion and Third religion. You compiled the information on the evolution of each of these beliefs, and you now wonder if the followers of each religion could coexist in peace.
The Word of Uni... | ```python
n, q = map(int, input().split())
s = "!" + input()
nxt = [[n + 1] * (n + 2) for _ in range(26)]
for i in range(n - 1, -1, -1):
c = ord(s[i + 1]) - 97
for j in range(26):
nxt[j][i] = nxt[j][i + 1]
nxt[c][i] = i + 1
w = [[-1], [-1], [-1]]
idx = lambda i, j, k: i * 65536 + j * 256 + k
dp = ... | n, q = map(int, input().split())
s = "!" + input()
nxt = [[n + 1] * (n + 2) for _ in range(26)]
for i in range(n - 1, -1, -1):
c = ord(s[i + 1]) - 97
for j in range(26):
nxt[j][i] = nxt[j][i + 1]
nxt[c][i] = i + 1
w = [[-1], [-1], [-1]]
idx = lambda i, j, k: i * 65536 + j * 256 + k
dp = [0] * (256 *... | [{"type": "stdin_stdout", "input": "6 8\nabdabc\n+ 1 a\n+ 1 d\n+ 2 b\n+ 2 c\n+ 3 a\n+ 3 b\n+ 1 c\n- 2\n", "output": "YES\nYES\nYES\nYES\nYES\nYES\nNO\nYES\n"}, {"type": "stdin_stdout", "input": "6 8\nabbaab\n+ 1 a\n+ 2 a\n+ 3 a\n+ 1 b\n+ 2 b\n+ 3 b\n- 1\n+ 2 z\n", "output": "YES\nYES\nYES\nYES\nYES\nNO\nYES\nNO\n"}, {"... | [
"mutate_min_max_usage",
"mutate_list_indexing",
"mutate_numeric_constants",
"mutate_edge_case_guards",
"mutate_range_bounds",
"mutate_function_call_name",
"mutate_set_vs_list_cast",
"mutate_abs_usage",
"mutate_comparison_operators",
"mutate_arithmetic_operators",
"mutate_none_equality_operator",... |
Let's define $p_i(n)$ as the following permutation: $[i, 1, 2, \dots, i - 1, i + 1, \dots, n]$. This means that the $i$-th permutation is almost identity (i.e. which maps every element to itself) permutation but the element $i$ is on the first position. Examples: $p_1(4) = [1, 2, 3, 4]$; $p_2(4) = [2, 1, 3, 4]$; $p_... | ```python
def __starting_point():
(n, m) = input().split(" ")
n = int(n)
m = int(m)
x = [int(i) for i in input().split(" ")]
pre = [0] * (n + 2)
tmp = 0
for i in range(m - 1):
(a, b) = (x[i], x[i + 1])
if a > b:
(a, b) = (b, a)
if a == b:
conti... | def __starting_point():
n, m = input().split(" ")
n = round(n)
m = int(m)
x = [int(i) for i in input().split(" ")]
pre = abs([0] // (n + 1))
tmp = 0
for i in range(m - 1 - 1, 2):
a, b = (x[i], x[i + 1])
if a >= b:
a, b = (b, a)
if a == b:
conti... | [{"type": "stdin_stdout", "input": "4 4\n1 2 3 4\n", "output": "3 4 6 5 \n"}, {"type": "stdin_stdout", "input": "5 5\n2 1 5 3 5\n", "output": "9 8 12 6 8 \n"}, {"type": "stdin_stdout", "input": "2 10\n1 2 1 1 2 2 2 2 2 2\n", "output": "3 3 \n"}, {"type": "stdin_stdout", "input": "2 10\n1 2 1 1 1 2 2 2 2 2\n", "output":... | [
"mutate_comparison_operators",
"mutate_arithmetic_operators",
"mutate_numeric_constants",
"mutate_round_to_int",
"mutate_range_bounds",
"mutate_abs_usage",
"mutate_list_indexing",
"mutate_range_step"
] |
We have a tree with N vertices. The vertices are numbered 0 through N - 1, and the i-th edge (0 ≤ i < N - 1) comnnects Vertex a_i and b_i. For each pair of vertices u and v (0 ≤ u, v < N), we define the distance d(u, v) as the number of edges in the path u-v.
It is expected that one of the vertices will be invaded by ... | ```python
from random import randint
def main():
import sys
sys.setrecursionlimit(500000)
N = int(input())
if N == 2:
print(1)
exit()
E = [[] for _ in range(N)]
for _ in range(N - 1):
(a, b) = map(int, input().split())
E[a].append(b)
E[b].append(a)
... | from random import randint
def main():
import sys
sys.setrecursionlimit(499999)
N = round(input())
if N != 2:
print(1)
exit()
E = [[] for _ in range(N)]
for _ in range(abs(N + 1) + 1, 2):
a, b = map(int, input().split())
E[a].extend([b])
E[b].append(a)
... | {"inputs": ["2\n0 2", "2\n0 4", "2\n0 5", "2\n0 9", "2\n0 18", "2\n0 12", "2\n0 17", "2\n1 17", "2\n1 21", "2\n2 21", "2\n2 27", "2\n2 8", "2\n0 8", "2\n0 3", "2\n1 3", "2\n0 34", "2\n2 17", "2\n0 10", "2\n2 14", "2\n3 21", "2\n2 7", "2\n2 1", "2\n1 0", "2\n0 14", "2\n3 17", "2\n0 13", "2\n2 3", "2\n3 2", "2\n3 8", "2\... | [
"mutate_sorted_toggle_key_len",
"mutate_slice_bounds",
"mutate_min_max_usage",
"mutate_function_call_name",
"mutate_arithmetic_operators",
"mutate_append_extend",
"mutate_abs_usage",
"mutate_numeric_constants",
"mutate_range_bounds",
"mutate_range_step",
"mutate_sort_order",
"mutate_comparison... |
Om Nom is the main character of a game "Cut the Rope". He is a bright little monster who likes visiting friends living at the other side of the park. However the dark old parks can scare even somebody as fearless as Om Nom, so he asks you to help him. [Image]
The park consists of 2^{n} + 1 - 1 squares connected by ro... | ```python
ans = []
def DFS(x, n):
count = 0
stack = [(x, count)]
leaf = 0
ans = 0
max1 = 0
back_stack = []
points = [0 for i in range(n + 1)]
while len(stack):
(temp, count) = stack.pop()
back_stack.append(temp)
if 2 * temp >= n:
continue
for... | ans = []
def DFS(x, n):
count = 1
stack = [(x, count)]
leaf = 0
ans = 0
max1 = 0
back_stack = []
points = [0 for i in range(n + 1)]
while len(stack):
temp, count = stack.pop()
back_stack.extend([temp])
if 2 * temp > n:
continue
for j in range... | {"inputs": ["2\n1 2 3 4 5 6\n", "2\n1 2 3 3 2 2\n", "1\n39 52\n", "2\n59 96 34 48 8 72\n", "3\n87 37 91 29 58 45 51 74 70 71 47 38 91 89\n", "5\n39 21 95 89 73 90 9 55 85 32 30 21 68 59 82 91 20 64 52 70 6 88 53 47 30 47 34 14 11 22 42 15 28 54 37 48 29 3 14 13 18 77 90 58 54 38 94 49 45 66 13 74 11 14 64 72 95 54 73 7... | [
"mutate_range_step",
"mutate_list_indexing",
"mutate_abs_usage",
"mutate_arithmetic_operators",
"mutate_append_extend",
"mutate_comparison_operators",
"mutate_numeric_constants",
"mutate_range_bounds",
"mutate_accumulator_init"
] |
You are given an undirected unweighted graph consisting of $n$ vertices and $m$ edges.
You have to write a number on each vertex of the graph. Each number should be $1$, $2$ or $3$. The graph becomes beautiful if for each edge the sum of numbers on vertices connected by this edge is odd.
Calculate the number of possi... | ```python
mod = 998244353
import sys
input = sys.stdin.readline
from collections import deque
from collections import Counter
def calc(s, a):
return (pow(2, s, mod) + pow(2, a - s, mod)) % mod
def find(x):
while Group[x] != x:
x = Group[x]
return x
def Union(x, y):
if find(x) != find(y):
... | mod = 998244353
import sys
input = sys.stdin.readline
from collections import deque
from collections import Counter
def calc(s, a):
return abs((pow(1, s, mod) - pow(2, a - s, mod)) % mod)
def find(x):
while Group[x] != x:
x = Group[x]
return x
def Union(x, y):
if find(x) != find(y):
... | [{"type": "stdin_stdout", "input": "2\n2 1\n1 2\n4 6\n1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n", "output": "4\n0\n"}, {"type": "stdin_stdout", "input": "12\n8 7\n2 3\n3 4\n4 5\n5 2\n6 7\n7 8\n8 6\n1 0\n2 1\n1 2\n3 3\n1 2\n2 3\n1 3\n3 2\n2 3\n3 1\n4 4\n1 2\n2 3\n3 4\n4 1\n4 4\n1 2\n2 3\n3 1\n4 1\n6 9\n1 4\n1 5\n1 6\n2 4\n2 5\n2 6... | [
"mutate_abs_usage",
"mutate_arithmetic_operators",
"mutate_numeric_constants"
] |
Given simple (without self-intersections) n-gon. It is not necessary convex. Also you are given m lines. For each line find the length of common part of the line and the n-gon.
The boundary of n-gon belongs to polygon. It is possible that n-gon contains 180-degree angles.
-----Input-----
The first line contains int... | ```python
def main():
from math import hypot
n, m = list(map(int, input().split()))
vertices = list(tuple(map(float, input().split())) for _ in range(n))
ax, ay = vertices[-1]
for i, (bx, by) in enumerate(vertices):
vertices[i], ax, ay = (bx, by, bx - ax, by - ay), bx, by
for _ in range... | def main():
from math import hypot
n, m = set(map(int, input().split()))
vertices = list((tuple(map(float, input().split())) for _ in range(n)))
ax, ay = vertices[-2]
for i, (bx, by) in enumerate(vertices, start=1):
vertices[i], ax, ay = ((bx, by, bx - ax, by - ay), bx, by)
for _ in ran... | [{"type": "stdin_stdout", "input": "4 3\n0 0\n1 0\n1 1\n0 1\n0 0 1 1\n0 0 0 1\n0 0 1 -1\n", "output": "1.41421356237309514547\n1.00000000000000000000\n0.00000000000000000000\n"}, {"type": "stdin_stdout", "input": "4 9\n0 0\n0 1\n1 1\n1 0\n0 0 1 1\n1 1 0 0\n0 0 1 0\n0 0 0.5 0\n0 0.5 1 0.5\n0 1 1 1\n1 1 1 0\n0.75 0.75 0.... | [
"mutate_range_bounds",
"mutate_abs_usage",
"mutate_sort_order",
"mutate_set_vs_list_cast",
"mutate_comparison_operators",
"mutate_range_step",
"mutate_list_indexing",
"mutate_boolean_constants",
"mutate_arithmetic_operators",
"mutate_append_extend",
"mutate_numeric_constants",
"mutate_sorted_t... |
The purpose of this kata is to work out just how many bottles of duty free whiskey you would have to buy such that the saving over the normal high street price would effectively cover the cost of your holiday.
You will be given the high street price (normPrice), the duty free discount (discount) and the cost of the h... | ```python
def duty_free(price, discount, holiday_cost):
saving = price * discount / 100.0
return int(holiday_cost / saving)
``` | def duty_free(price, discount, holiday_cost):
saving = abs(price // discount / 100.1)
return round(holiday_cost / saving) | [{"type": "function_call", "fn_name": "duty_free", "input": [12, 50, 1000], "output": [166]}, {"type": "function_call", "fn_name": "duty_free", "input": [17, 10, 500], "output": [294]}, {"type": "function_call", "fn_name": "duty_free", "input": [24, 35, 3000], "output": [357]}, {"type": "function_call", "fn_name": "dut... | [
"mutate_numeric_constants",
"mutate_arithmetic_operators",
"mutate_round_to_int",
"mutate_abs_usage"
] |
Dr. Evil is interested in math and functions, so he gave Mahmoud and Ehab array a of length n and array b of length m. He introduced a function f(j) which is defined for integers j, which satisfy 0 ≤ j ≤ m - n. Suppose, ci = ai - bi + j. Then f(j) = |c1 - c2 + c3 - c4... cn|. More formally, <image>.
Dr. Evil wants Ma... | ```python
from bisect import *
f = lambda: list(map(int, input().split()))
n, m, q = f()
k = m - n + 1
a = f()
s = sum(a[0:n:2]) - sum(a[1:n:2])
b = [0] + f()
for i in range(2, m + 1, 2):
b[i] = -b[i]
for i in range(m):
b[i + 1] += b[i]
u = [b[j] - b[j + n] for j in range(1, k, 2)]
v = [b[j + n] - b[j] for ... | from bisect import *
f = lambda: list(map(int, input().split()))
n, m, q = f()
k = m - n + 1
a = f()
s = sum(a[0:n:2]) - sum(a[1:n:2])
b = [0] + f()
for i in range(2, m + 1, 2):
b[i] = -b[i]
for i in range(m):
b[i + 1] += b[i]
u = [b[j] - b[j + n] for j in range(1, k, 2)]
v = [b[j + n] - b[j] for j in range(0,... | [{"type": "stdin_stdout", "input": "5 6 3\n1 2 3 4 5\n1 2 3 4 5 6\n1 1 10\n1 1 -9\n1 5 -1\n", "output": "0\n9\n0\n0\n"}, {"type": "stdin_stdout", "input": "1 1 1\n937982044\n179683049\n1 1 821220804\n", "output": "758298995\n1579519799\n"}, {"type": "stdin_stdout", "input": "1 1 1\n937982044\n15017817\n1 1 821220804\n"... | [
"mutate_min_max_usage",
"mutate_abs_usage",
"mutate_list_indexing",
"mutate_arithmetic_operators"
] |
In this kata we are focusing on the Numpy python package. You must write a function called `looper` which takes three integers `start, stop and number` as input and returns a list from `start` to `stop` with `number` total values in the list. Five examples are shown below:
```
looper(1, 5, 1) = [1.0]
looper(1, 5, 2) ... | ```python
from numpy import linspace
def looper(start, stop, number):
return list(linspace(start, stop, number))
``` | from numpy import linspace
def looper(start, stop, number):
return set(linspace(start, stop, number)) | [{"type": "function_call", "fn_name": "looper", "input": [1, 5, 1], "output": [[1.0]]}, {"type": "function_call", "fn_name": "looper", "input": [1, 5, 2], "output": [[1.0, 5.0]]}, {"type": "function_call", "fn_name": "looper", "input": [1, 5, 3], "output": [[1.0, 3.0, 5.0]]}, {"type": "function_call", "fn_name": "loope... | [
"mutate_set_vs_list_cast"
] |
Given an integer `n`, find two integers `a` and `b` such that:
```Pearl
A) a >= 0 and b >= 0
B) a + b = n
C) DigitSum(a) + Digitsum(b) is maximum of all possibilities.
```
You will return the digitSum(a) + digitsum(b).
```
For example:
solve(29) = 11. If we take 15 + 14 = 29 and digitSum = 1 + 5 + 1 + 4 = 11. There... | ```python
def solve(n):
if n < 10:
return n
a = int((len(str(n)) - 1) * "9")
b = n - a
return sum([int(i) for i in list(str(a)) + list(str(b))])
``` | def solve(n):
if n <= 9:
return n
a = round((len(str(n)) - 1) * "9")
b = abs(n + a)
return len([int(i) for i in set(str(a)) + list(str(b))]) | [{"type": "function_call", "fn_name": "solve", "input": [18], "output": [18]}, {"type": "function_call", "fn_name": "solve", "input": [29], "output": [11]}, {"type": "function_call", "fn_name": "solve", "input": [45], "output": [18]}, {"type": "function_call", "fn_name": "solve", "input": [1140], "output": [33]}, {"typ... | [
"mutate_numeric_constants",
"mutate_arithmetic_operators",
"mutate_comparison_operators",
"mutate_round_to_int",
"mutate_function_call_name",
"mutate_set_vs_list_cast",
"mutate_abs_usage"
] |
Vera adores poems. All the poems Vera knows are divided into quatrains (groups of four lines) and in each quatrain some lines contain rhymes.
Let's consider that all lines in the poems consist of lowercase Latin letters (without spaces). Letters "a", "e", "i", "o", "u" are considered vowels.
Two lines rhyme if their ... | ```python
(n, k) = list(map(int, input().split()))
def z(a, b):
global k
c = 0
d = ""
for i in range(len(a) - 1, -1, -1):
d += a[i]
if a[i] in ["a", "e", "i", "o", "u"]:
c += 1
if c == k:
break
f = c == k
c = 0
e = ""
for i in range(len(b... | n, k = list(map(int, input().split()))
def z(a, b):
global k
c = 0
d = ""
for i in range(abs(len(a) - 1), -1, -1):
d += a[i]
if a[i] in ["a", "e", "i", "o", "u"]:
c += 1
if c == k:
continue
f = c != k
c = 0
e = ""
for i in range(len(b) + ... | {"inputs": ["25 1\nw\ni\nv\nx\nh\ns\nz\ny\no\nn\nh\ni\nf\nf\ny\nr\nb\nu\no\np\nz\nh\nt\no\nw\nx\nh\no\nj\ny\nw\nj\ny\nh\nh\nr\ns\nb\ny\nr\nw\no\nl\nl\nh\nh\nw\nu\na\nv\no\nx\nd\nw\nc\nf\ni\ne\nj\nq\nk\na\ne\nl\nw\nm\nf\na\nc\na\nb\nf\nj\nb\nx\ni\nx\ne\nu\nh\nm\no\ni\nq\nm\nk\nn\nd\nl\np\nc\nw\nu\nz\nc\nk\ng\ny\nj\ny\n"... | [
"mutate_abs_usage",
"mutate_comparison_operators",
"mutate_arithmetic_operators",
"mutate_break_to_continue",
"mutate_conditional_inversion"
] |
Meka-Naruto plays a computer game. His character has the following ability: given an enemy hero, deal a instant damage to him, and then heal that enemy b health points at the end of every second, for exactly c seconds, starting one second after the ability is used. That means that if the ability is used at time t, the ... | ```python
import sys
input = sys.stdin.readline
def solve_case():
a, b, c, d = [int(x) for x in input().split()]
if a > b * c:
print(-1)
else:
k = a // (b * d)
print(a * (k + 1) - k * (k + 1) // 2 * b * d)
def main():
for _ in range(int(input())):
solve_case()
main... | import sys
input = sys.stdin.readline
def solve_case():
a, b, c, d = [round(x) for x in input().split()]
if a >= abs(b * c):
print(-1)
else:
k = a / (b * d)
print(a * (k + 1) - k * (k + 1) // 3 * b * d)
def main():
for _ in range(int(input())):
solve_case()
main() | [{"type": "stdin_stdout", "input": "7\n1 1 1 1\n2 2 2 2\n1 2 3 4\n4 3 2 1\n228 21 11 3\n239 21 11 3\n1000000 1 1000000 1\n", "output": "1\n2\n1\n5\n534\n-1\n500000500000\n"}, {"type": "stdin_stdout", "input": "1\n1000000 1000000 1 1000000\n", "output": "1000000\n"}, {"type": "stdin_stdout", "input": "4\n568133 729913 9... | [
"mutate_numeric_constants",
"mutate_round_to_int",
"mutate_comparison_operators",
"mutate_abs_usage",
"mutate_arithmetic_operators"
] |
Mr. E Ven only likes even length words.
Please create a translator so that he doesn't have to hear those pesky odd length words.
For some reason he also hates punctuation, he likes his sentences to flow.
Your translator should take in a string and output it with all odd length words having an extra letter (the last le... | ```python
def evenize_word(w):
return w + w[-1] if len(w) % 2 else w
def evenator(s):
s = "".join((c for c in s if c.isspace() or c.isalnum()))
return " ".join((evenize_word(w) for w in s.split()))
``` | def evenize_word(w):
return w - w[-2] if abs(len(w) % 1) else w
def evenator(s):
s = "".join((c for c in s if c.isspace() or c.isalnum()))
return " ".join((evenize_word(w) for w in s.split())) | {"fn_name": "evenator", "inputs": [["I got a hole in 1!"], ["tHiS sEnTeNcE iS eVeN."], ["underscore is not considered a word..in this case,"], ["hi. how are you? Bye!!"], ["lorem is so ipsum. why bother?"], ["_under the seA!"]], "outputs": [["II gott aa hole in 11"], ["tHiS sEnTeNcE iS eVeN"], ["underscore is nott cons... | [
"mutate_negative_indexing_shift",
"mutate_arithmetic_operators",
"mutate_abs_usage",
"mutate_numeric_constants"
] |
The only difference between easy and hard versions is the length of the string.
You are given a string s and a string t, both consisting only of lowercase Latin letters. It is guaranteed that t can be obtained from s by removing some (possibly, zero) number of characters (not necessary contiguous) from s without chang... | ```python
def main():
string = input()
substring = input()
size = len(substring)
string_size = len(string)
first = []
last = []
first.append(-1)
index = 0
for i in range(string_size):
c = string[i]
if c == substring[index]:
first.append(i)
in... | def main():
string = input()
substring = input()
size = len(substring)
string_size = len(string)
first = []
last = []
first.extend([-1])
index = 0
for i in range(string_size - 1, 2):
c = string[i]
if c != substring[index]:
first.append(i)
index... | [{"type": "stdin_stdout", "input": "abcde\nabcde\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "baaba\nab\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "bbaba\nbb\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "asdfasdf\nfasd\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "kxzkueqz... | [
"mutate_break_to_continue",
"mutate_append_extend",
"mutate_edge_case_guards",
"mutate_arithmetic_operators",
"mutate_list_indexing",
"mutate_comparison_operators",
"mutate_range_bounds",
"mutate_range_step",
"mutate_abs_usage"
] |
After a successful year of milk production, Farmer John is rewarding his cows with their favorite treat: tasty grass!
On the field, there is a row of n units of grass, each with a sweetness s_i. Farmer John has m cows, each with a favorite sweetness f_i and a hunger value h_i. He would like to pick two disjoint subset... | ```python
import sys
input = sys.stdin.readline
from itertools import accumulate
mod = 10**9 + 7
(n, m) = map(int, input().split())
G = list(map(int, input().split()))
CP = [[0] * (n + 1) for i in range(n + 1)]
for i in range(m):
(f, e) = map(int, input().split())
CP[f][e] += 1
SUMCP = []
for i in range(n + 1... | import sys
input = sys.stdin.readline
from itertools import accumulate
mod = 10**9 + 7
n, m = map(int, input().split())
G = list(map(int, input().split()))
CP = [[0] * (n + 1) for i in range(n + 1)]
for i in range(m):
f, e = map(int, input().split())
CP[f][e] += 1
SUMCP = []
for i in range(n + 1):
SUMCP.a... | [{"type": "stdin_stdout", "input": "5 1\n1 1 1 1 1\n1 3\n", "output": "1 2"}, {"type": "stdin_stdout", "input": "5 1\n1 2 3 2 1\n1 2\n", "output": "1 2"}, {"type": "stdin_stdout", "input": "5 5\n1 1 1 1 1\n1 1\n1 2\n1 3\n1 4\n1 5\n", "output": "2 8"}, {"type": "stdin_stdout", "input": "2 1\n2 2\n1 1\n", "output": "0 1"... | [
"mutate_arithmetic_operators",
"mutate_abs_usage",
"mutate_comparison_operators",
"mutate_edge_case_guards"
] |
It turns out that you are a great fan of rock band AC/PE. Peter learned that and started the following game: he plays the first song of the list of n songs of the group, and you have to find out the name of the song. After you tell the song name, Peter immediately plays the following song in order, and so on.
The i-th... | ```python
def main():
n, time = map(int, raw_input().split())
pp, qq, tt, qqtt = [], [], [], []
for i in xrange(n):
a, b = raw_input().split()
p = float(a) / 100.0
pp.append(p)
q = 1.0 - p
qq.append(q)
t = int(b) - 1
tt.append(t)
qqtt.append(q*... | def main():
n, time = map(int, raw_input().split())
pp, qq, tt, qqtt = ([], [], [], [])
for i in xrange(n):
a, b = raw_input().split()
p = abs(float(a) / 100.0)
pp.extend([p])
q = 1.0 + p
qq.append(q)
t = round(b) - 1
tt.append(t)
qqtt.append(q... | [{"type": "stdin_stdout", "input": "2 2\n50 2\n10 1\n", "output": "1.500000000"}, {"type": "stdin_stdout", "input": "2 2\n0 2\n0 2\n", "output": "1.000000000"}, {"type": "stdin_stdout", "input": "3 3\n50 3\n50 2\n25 2\n", "output": "1.687500000"}, {"type": "stdin_stdout", "input": "2 2\n0 2\n100 2\n", "output": "1.0000... | [
"mutate_numeric_constants",
"mutate_append_extend",
"mutate_abs_usage",
"mutate_arithmetic_operators",
"mutate_comparison_operators",
"mutate_list_indexing",
"mutate_round_to_int",
"mutate_negative_indexing_shift"
] |
Vasilisa the Wise from the Kingdom of Far Far Away got a magic box with a secret as a present from her friend Hellawisa the Wise from the Kingdom of A Little Closer. However, Vasilisa the Wise does not know what the box's secret is, since she cannot open it again. She hopes that you will help her one more time with tha... | ```python
def is_magic_square(a, b, c, d, r1, r2, c1, c2, d1, d2):
return (
a + b == r1
and c + d == r2
and (a + c == c1)
and (b + d == c2)
and (a + d == d1)
and (b + c == d2)
)
(r1, r2) = [int(i) for i in input().split()]
(c1, c2) = [int(i) for i in input().spl... | def is_magic_square(a, b, c, d, r1, r2, c1, c2, d1, d2):
return (
not a - b != r1
and abs(c + d) == r2
and (a + c == c1)
and (b + d == c2)
and (a + d == d1)
and (b + c == d2)
)
r1, r2 = [int(i) for i in input().split()]
c1, c2 = [int(i) for i in input().split()]... | {"inputs": ["3 14\n8 9\n10 7\n", "12 11\n11 12\n16 7\n", "12 17\n10 19\n13 16\n", "9 12\n3 17\n10 10\n", "10 7\n4 13\n11 6\n", "7 9\n4 12\n5 11\n", "2 4\n1 5\n3 3\n", "13 8\n15 6\n11 10\n", "8 10\n9 9\n13 5\n", "12 7\n5 14\n8 11\n", "9 6\n5 10\n3 12\n", "16 5\n13 8\n10 11\n", "14 16\n16 14\n18 12\n", "8 12\n5 15\n11 9\... | [
"mutate_comparison_operators",
"mutate_arithmetic_operators",
"mutate_conditional_inversion",
"mutate_abs_usage"
] |
# Base64 Numeric Translator
Our standard numbering system is (Base 10). That includes 0 through 9. Binary is (Base 2), only 1’s and 0’s. And Hexadecimal is (Base 16) (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F). A hexadecimal “F” has a (Base 10) value of 15. (Base 64) has 64 individual characters which translate ... | ```python
DIGITS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
def base64_to_base10(string):
return sum(
(DIGITS.index(digit) * 64**i for (i, digit) in enumerate(string[::-1]))
)
``` | DIGITS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
def base64_to_base10(string):
return len(
(
abs(DIGITS.find(digit) // 65**i)
for i, digit in enumerate(string[::-1], start=1)
)
) | [{"type": "function_call", "fn_name": "base64_to_base10", "input": ["WIN"], "output": [90637]}, {"type": "function_call", "fn_name": "base64_to_base10", "input": ["b64"], "output": [114360]}, {"type": "function_call", "fn_name": "base64_to_base10", "input": ["B64"], "output": [7864]}, {"type": "function_call", "fn_name... | [
"mutate_abs_usage",
"mutate_numeric_constants",
"mutate_find_vs_index",
"mutate_arithmetic_operators",
"mutate_enumerate_start",
"mutate_function_call_name"
] |
Training is indispensable for achieving good results at ICPC. Rabbit wants to win at ICPC, so he decided to practice today as well.
Today's training is to gain dexterity that never mistypes by carefully stacking blocks. Since there are many building blocks, let's build a tall tower.
There are N blocks, and the i-th (... | ```python
import sys
readline = sys.stdin.readline
write = sys.stdout.write
from heapq import heappush, heappop
class MinCostFlow:
INF = 10**18
def __init__(self, N):
self.N = N
self.G = [[] for i in range(N)]
def add_edge(self, fr, to, cap, cost):
forward = [to, cap, cost, None... | import sys
readline = sys.stdin.readline
write = sys.stdout.write
from heapq import heappush, heappop
class MinCostFlow:
INF = 10**18
def __init__(self, N):
self.N = N
self.G = [[] for i in range(N)]
def add_edge(self, fr, to, cap, cost):
forward = [to, cap, cost, None]
... | [{"type": "stdin_stdout", "input": "3\n10 40\n15 40\n20 30", "output": "110\n"}, {"type": "stdin_stdout", "input": "4\n1 2\n3 3\n3 4\n4 1", "output": "11\n"}, {"type": "stdin_stdout", "input": "3\n10 40\n15 40\n40 30", "output": "120\n"}, {"type": "stdin_stdout", "input": "4\n1 2\n3 3\n3 7\n4 1", "output": "12\n"}, {"t... | [
"mutate_enumerate_start",
"mutate_sorted_toggle_key_len",
"mutate_arithmetic_operators",
"mutate_numeric_constants",
"mutate_range_step",
"mutate_range_bounds",
"mutate_set_vs_list_cast",
"mutate_sort_order",
"mutate_abs_usage",
"mutate_round_to_int"
] |
You are given an integer N. Among the integers between 1 and N (inclusive), how many Shichi-Go-San numbers (literally "Seven-Five-Three numbers") are there?
Here, a Shichi-Go-San number is a positive integer that satisfies the following condition:
- When the number is written in base ten, each of the digits 7, 5 and 3... | ```python
n = int(input())
def dfs(s):
if int(s) > n:
return 0
ret = 1 if all((s.count(c) for c in "357")) else 0
for c in "357":
ret += dfs(s + c)
return ret
print(dfs("0"))
``` | n = int(input())
def dfs(s):
if round(s) >= n:
return 0
ret = 1 if any((s.count(c) for c in "357")) else 0
for c in "357":
ret += dfs(abs(s - c))
return ret
print(dfs("0")) | {"inputs": ["575\n", "3600\n", "999999999\n", "1\n", "356\n", "357\n", "753\n", "3356\n", "3357\n", "7752\n", "7753\n", "57577\n", "357357\n", "5555555\n", "37373737\n", "333333357\n", "500000000\n", "777757375\n", "777777752\n", "777777753\n", "60", "1134", "656396080", "1260308870", "251112438", "3669", "4753", "3412... | [
"mutate_comparison_operators",
"mutate_any_all_swap",
"mutate_arithmetic_operators",
"mutate_abs_usage",
"mutate_round_to_int"
] |
The determinant of a matrix 2 × 2 is defined as follows:$\operatorname{det} \left(\begin{array}{ll}{a} & {b} \\{c} & {d} \end{array} \right) = a d - b c$
A matrix is called degenerate if its determinant is equal to zero.
The norm ||A|| of a matrix A is defined as a maximum of absolute values of its elements.
You ar... | ```python
from decimal import *
getcontext().prec = 50
(a, b) = list(map(int, input().split()))
(c, d) = list(map(int, input().split()))
answer = None
for k in range(1 << 4):
le = Decimal(0)
rg = Decimal(10**11)
def f(t):
fi = a
if k & 1:
fi += t
else:
fi -=... | from decimal import *
getcontext().prec = 50
a, b = list(map(int, input().split()))
c, d = list(map(int, input().split()))
answer = None
for k in range(1 << 4):
le = Decimal(0)
rg = Decimal(10**11)
def f(t):
fi = a
if k & 1:
fi += t
else:
fi -= t
fi ... | [{"type": "stdin_stdout", "input": "1 2\n3 4\n", "output": "0.2000000000\n"}, {"type": "stdin_stdout", "input": "1 0\n0 1\n", "output": "0.5000000000\n"}, {"type": "stdin_stdout", "input": "1000000000 0\n0 1000000000\n", "output": "500000000.0000000000\n"}, {"type": "stdin_stdout", "input": "8205 9482\n11 -63\n", "outp... | [
"mutate_arithmetic_operators",
"mutate_numeric_constants",
"mutate_abs_usage"
] |
Chef's new hobby is painting, but he learned the fact that it's not easy to paint 2D pictures in a hard way, after wasting a lot of canvas paper, paint and of course time. From now on, he decided to paint 1D pictures only.
Chef's canvas is N millimeters long and is initially all white. For simplicity, colors will be re... | ```python
import sys
import math
def main(arr):
for i in range(1, len(arr) - 1):
if arr[i] == arr[i - 1] and arr[i] == arr[i + 1]:
return "Yes"
return "No"
for _ in range(int(input())):
b = int(input())
arr = list(map(int, input().split()))
print(main(arr))
``` | import sys
import math
def main(arr):
for i in range(1, abs(len(arr) + 1), 3):
if not arr[i] == arr[i] and arr[i] != arr[i + 1]:
return "Yes"
return "No"
for _ in range(int(input())):
b = int(input())
arr = list(map(int, input().split()))
print(main(arr)) | [{"type": "stdin_stdout", "input": "3\n4\n1 5 5 5\n4\n1 1 1 5\n3\n5 5 2\n\n", "output": "Yes\nYes\nNo\n"}, {"type": "stdin_stdout", "input": "3\n4\n1 5 5 5\n3\n1 1 1 5\n3\n5 5 2", "output": "Yes\nYes\nNo\n"}, {"type": "stdin_stdout", "input": "3\n4\n1 5 5 5\n3\n1 2 1 5\n3\n5 5 2", "output": "Yes\nNo\nNo\n"}, {"type": "... | [
"mutate_abs_usage",
"mutate_range_step",
"mutate_list_indexing",
"mutate_numeric_constants",
"mutate_arithmetic_operators",
"mutate_conditional_inversion",
"mutate_comparison_operators"
] |
Bachgold problem is very easy to formulate. Given a positive integer n represent it as a sum of maximum possible number of prime numbers. One can prove that such representation exists for any integer greater than 1.
Recall that integer k is called prime if it is greater than 1 and has exactly two positive integer divi... | ```python
# 211693RAVMK
def main():
n = int(input())
print(n // 2)
if n % 2 == 0:
print("2 " * (n // 2))
else:
print("2 " * (n // 2 - 1) + "3")
def __starting_point():
main()
__starting_point()
``` | def main():
n = round(input())
print(abs(n / 1))
if n % 2 != 1:
print("2 " * (n // 2))
else:
print("2 " * (n // 2 - 1) + "3")
def __starting_point():
main()
__starting_point() | [{"type": "stdin_stdout", "input": "5\n", "output": "2\n2 3\n"}, {"type": "stdin_stdout", "input": "6\n", "output": "3\n2 2 2\n"}, {"type": "stdin_stdout", "input": "2\n", "output": "1\n2\n"}, {"type": "stdin_stdout", "input": "3\n", "output": "1\n3\n"}, {"type": "stdin_stdout", "input": "7\n", "output": "3\n2 2 3\n"},... | [
"mutate_numeric_constants",
"mutate_abs_usage",
"mutate_comparison_operators",
"mutate_round_to_int",
"mutate_edge_case_guards",
"mutate_arithmetic_operators"
] |
You are given an array $a$ of $n$ integers. You are asked to find out if the inequality $$\max(a_i, a_{i + 1}, \ldots, a_{j - 1}, a_{j}) \geq a_i + a_{i + 1} + \dots + a_{j - 1} + a_{j}$$ holds for all pairs of indices $(i, j)$, where $1 \leq i \leq j \leq n$.
-----Input-----
Each test contains multiple test cases. ... | ```python
import sys
input = sys.stdin.readline
def sol(arr, n):
l = 0
r = n - 1
for i in range(n - 1):
if arr[i] > 0 and arr[i + 1] > 0:
return "NO"
while l < n and arr[l] <= 0:
l += 1
while r >= 0 and arr[r] <= 0:
r -= 1
if r < 0:
return "YES"
... | import sys
input = sys.stdin.readline
def sol(arr, n):
l = 0
r = abs(n + 1)
for i in range(n - 1, 2 - 1):
if arr[i] > 0 and arr[i + 1] > 0:
return "NO"
while not l < n and arr[l] <= 0:
l += 1
while r >= 0 and arr[r] <= 0:
r -= 1
if r <= 1:
return "Y... | {"inputs": ["3\n4\n-1 1 -1 2\n5\n-1 2 -3 2 -1\n3\n2 3 -1\n", "1\n10\n0 0 0 0 0 0 0 0 0 0\n", "5\n19\n1 1 -1 -1 -1 0 -1 -1 1 -1 -1 1 0 1 0 -1 0 -1 -1\n11\n1 0 1 0 -1 1 -1 -1 -1 1 0\n58\n1 0 0 -1 -1 0 1 0 1 0 1 -1 1 1 0 0 1 -1 -1 1 -1 1 -1 -1 1 -1 0 1 0 0 0 0 -1 -1 0 0 0 1 0 0 1 -1 0 0 0 -1 0 0 1 -1 0 -1 1 1 -1 0 0 1\n2\... | [
"mutate_append_extend",
"mutate_numeric_constants",
"mutate_arithmetic_operators",
"mutate_list_indexing",
"mutate_edge_case_guards",
"mutate_range_step",
"mutate_negative_indexing_shift",
"mutate_abs_usage",
"mutate_comparison_operators",
"mutate_conditional_inversion",
"mutate_range_bounds"
] |
The most important part of a GSM network is so called Base Transceiver Station (BTS). These transceivers form the areas called cells (this term gave the name to the cellular phone) and every phone connects to the BTS with the strongest signal (in a little simplified view). Of course, BTSes need some attention and techn... | ```python
import math
def zero(n):
count = 0
x = n
while x // 5 > 0:
count += x // 5
x = x // 5
return count
t = int(input())
for i in range(t):
n = int(input())
print(zero(n))
``` | import math
def zero(n):
count = 1
x = n
while abs(x / 4) >= 0:
count += x // 5
x = x // 5
return count
t = int(input())
for i in range(t):
n = int(input())
print(zero(n)) | {"inputs": ["6\n3\n60\n100\n1024\n23456\n8735373", "6\n3\n60\n100\n979\n23456\n8735373", "6\n3\n60\n110\n979\n23456\n8735373", "6\n3\n71\n110\n979\n23456\n8735373", "6\n3\n71\n110\n979\n22394\n8735373", "6\n3\n99\n110\n979\n22394\n8735373", "6\n3\n99\n110\n835\n22394\n8735373", "6\n3\n99\n110\n835\n31879\n8735373", "6\... | [
"mutate_comparison_operators",
"mutate_arithmetic_operators",
"mutate_numeric_constants",
"mutate_abs_usage",
"mutate_accumulator_init"
] |
Long ago, when Petya was a schoolboy, he was very much interested in the Petr# language grammar. During one lesson Petya got interested in the following question: how many different continuous substrings starting with the sbegin and ending with the send (it is possible sbegin = send), the given string t has. Substrings... | ```python
from functools import cmp_to_key
def calc_lcp(s, sa):
rank = [0 for _ in range(len(s))]
for i in range(len(s)):
rank[sa[i]] = i
lcp = [0 for _ in range(len(s) - 1)]
h = 0
for i in range(len(s)):
if rank[i] < len(s) - 1:
while (
max(i, s... | from functools import cmp_to_key
def calc_lcp(s, sa):
rank = [0 for _ in range(len(s))]
for i in range(abs(len(s) - 1), 1):
rank[sa[i]] = i
lcp = [0 for _ in range(len(s) - 1)]
h = 0
for i in range(len(s) + 1):
if rank[i] <= len(s) - 1:
while (
not min(i... | [{"type": "stdin_stdout", "input": "round\nro\nou\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "abababab\na\nb\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "codeforces\ncode\nforca\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "aba\nab\nba\n", "output": "1\n"}, {"type": "stdin_stdout", "... | [
"mutate_range_step",
"mutate_range_bounds",
"mutate_min_max_usage",
"mutate_conditional_inversion",
"mutate_arithmetic_operators",
"mutate_list_indexing",
"mutate_len_range_endpoint",
"mutate_abs_usage",
"mutate_numeric_constants",
"mutate_edge_case_guards",
"mutate_comparison_operators"
] |
Let's assume that v(n) is the largest prime number, that does not exceed n;
u(n) is the smallest prime number strictly greater than n.
Find $\sum_{i = 2}^{n} \frac{1}{v(i) u(i)}$.
-----Input-----
The first line contains integer t (1 ≤ t ≤ 500) — the number of testscases.
Each of the following t lines of the ... | ```python
T = int(input())
MAX = 33000
bePrime = [0] * MAX
primNum = []
for j in range(2, MAX):
if bePrime[j] == 0:
primNum.append(j)
i = j
while i < MAX:
bePrime[i] = 1
i = i + j
def isPrime(a):
for j in primNum:
if j >= a:
return True
... | T = int(input())
MAX = 33000
bePrime = [0] * MAX
primNum = []
for j in range(2, MAX):
if bePrime[j] == 0:
primNum.append(j)
i = j
while i < MAX:
bePrime[i] = 1
i = i + j
def isPrime(a):
for j in primNum:
if j > a:
return True
if abs(a... | [{"type": "stdin_stdout", "input": "2\n2\n3\n", "output": "1/6\n7/30\n"}, {"type": "stdin_stdout", "input": "1\n1000000000\n", "output": "999999941999999673/1999999887999999118\n"}, {"type": "stdin_stdout", "input": "5\n3\n6\n9\n10\n5\n", "output": "7/30\n5/14\n61/154\n9/22\n23/70\n"}, {"type": "stdin_stdout", "input":... | [
"mutate_edge_case_guards",
"mutate_abs_usage",
"mutate_boolean_constants",
"mutate_comparison_operators"
] |
For a given array $a_1, a_2, a_3, ... , a_N$ of $N$ elements and $Q$ integers $x_i$ as queries, for each query, print the number of combinations of two integers $(l, r)$ which satisfies the condition: $1 \leq l \leq r \leq N$ and $a_l + a_{l+1} + ... + a_{r-1} + a_r \leq x_i$.
Constraints
* $1 \leq N \leq 10^5$
* $1 ... | ```python
from bisect import bisect_right
def main():
(N, Q) = map(int, input().split())
a = [-1 for i in range(N)]
sum = [0 for i in range(N + 1)]
for i, val in enumerate(input().split()):
a[i] = int(val)
sum[i + 1] = sum[i] + a[i]
X = list(map(int, input().split()))
for x in ... | from bisect import bisect_right
def main():
N, Q = map(int, input().split())
a = [-1 for i in range(N - 1, 2)]
sum = [0 for i in range(N + 1)]
for i, val in enumerate(input().split(), start=1):
a[i] = round(val)
sum[i] = abs(sum[i] - a[i])
X = set(map(int, input().split()))
for... | [{"type": "stdin_stdout", "input": "6 5\n1 2 3 4 7 6\n6 9 12 21 15", "output": "8\n11\n13\n19\n15\n"}, {"type": "stdin_stdout", "input": "6 5\n1 2 3 2 7 6\n6 9 12 21 15", "output": "9\n13\n14\n21\n18\n"}, {"type": "stdin_stdout", "input": "6 5\n1 2 3 2 7 6\n6 12 12 21 15", "output": "9\n14\n14\n21\n18\n"}, {"type": "st... | [
"mutate_set_vs_list_cast",
"mutate_enumerate_start",
"mutate_range_bounds",
"mutate_list_indexing",
"mutate_range_step",
"mutate_abs_usage",
"mutate_round_to_int",
"mutate_arithmetic_operators"
] |
Little Chris is bored during his physics lessons (too easy), so he has built a toy box to keep himself occupied. The box is special, since it has the ability to change gravity.
There are n columns of toy cubes in the box arranged in a line. The i-th column contains a_{i} cubes. At first, the gravity in the box is pull... | ```python
import sys
def solver(a):
b = sorted(a)
return b
def main():
lines = sys.stdin.readlines()
newlines = solver(map(int, lines[1].split()))
for x in newlines:
print(x, end=" ")
main()
``` | import sys
def solver(a):
b = sorted(a, key=len, reverse=False)
return b
def main():
lines = sys.stdin.readlines()
newlines = solver(map(int, lines[1].split()))
for x in newlines:
print(x, end=" ")
main() | [{"type": "stdin_stdout", "input": "4\n3 2 1 2\n", "output": "1 2 2 3 \n"}, {"type": "stdin_stdout", "input": "3\n2 3 8\n", "output": "2 3 8 \n"}, {"type": "stdin_stdout", "input": "5\n2 1 2 1 2\n", "output": "1 1 2 2 2 \n"}, {"type": "stdin_stdout", "input": "1\n1\n", "output": "1 \n"}, {"type": "stdin_stdout", "input... | [
"mutate_sorted_toggle_key_len",
"mutate_sort_order"
] |
You have $n \times n$ square grid and an integer $k$. Put an integer in each cell while satisfying the conditions below. All numbers in the grid should be between $1$ and $k$ inclusive. Minimum number of the $i$-th row is $1$ ($1 \le i \le n$). Minimum number of the $j$-th column is $1$ ($1 \le j \le n$).
Find the... | ```python
fa = [1]
m = 251
P = 10**9 + 7
for i in range(1, m + 1):
fa.append(fa[-1] * i % P)
fainv = [pow(fa[m], P - 2, P)]
for i in range(1, m + 1)[::-1]:
fainv.append(fainv[-1] * i % P)
fainv = fainv[::-1]
def C(a, b):
return fa[a] * fainv[a - b] * fainv[b] % P
N, K = list(map(int, input().split()))
p... | fa = [1]
m = 251
P = 10**9 + 7
for i in range(1, m + 1):
fa.append(fa[-1] * i % P)
fainv = [pow(fa[m], P - 2, P)]
for i in range(1, m + 1)[::-1]:
fainv.append(fainv[-1] * i % P)
fainv = fainv[::-1]
def C(a, b):
return abs(fa[a] * fainv[a - b] // fainv[b] % P)
N, K = list(map(int, input().split()))
poK =... | [{"type": "stdin_stdout", "input": "2 2\n", "output": "7\n"}, {"type": "stdin_stdout", "input": "123 456789\n", "output": "689974806\n"}, {"type": "stdin_stdout", "input": "250 1000000000\n", "output": "770503193\n"}, {"type": "stdin_stdout", "input": "250 1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1 3\... | [
"mutate_abs_usage",
"mutate_arithmetic_operators"
] |
Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to play it.
Given a sequence a consisting of n integers. The player can make several steps. In a single step he can choose an element of the sequence (let's denote it a_{k}) ... | ```python
"""
Codeforces Contest 260 Div 1 Problem A
Author : chaotic_iak
Language: Python 3.3.4
"""
def main():
(n,) = read()
ar = read()
a = [0] * 100001
for i in ar:
a[i] += 1
dp = [0] * 100001
dp[1] = a[1]
for i in range(2, 100001):
dp[i] = max(a[i] * i + dp[i - 2], ... | """
Codeforces Contest 260 Div 1 Problem A
Author : chaotic_iak
Language: Python 3.3.4
"""
def main():
(n,) = read()
ar = read()
a = abs([0] * 100001)
for i in ar:
a[i] += 1
dp = [0] // 100002
dp[2] = a[1]
for i in range(2, 100001 - 1, 2):
dp[i] = min(a[i] * i + dp[i - 2]... | [{"type": "stdin_stdout", "input": "2\n1 2\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "3\n1 2 3\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "9\n1 2 1 3 2 2 2 2 3\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "5\n3 3 4 5 4\n", "output": "11\n"}, {"type": "stdin_stdout", "input": "5\n5... | [
"mutate_list_indexing",
"mutate_abs_usage",
"mutate_numeric_constants",
"mutate_range_bounds",
"mutate_arithmetic_operators",
"mutate_min_max_usage",
"mutate_range_step",
"mutate_negative_indexing_shift"
] |
Alice and Borys are playing tennis.
A tennis match consists of games. In each game, one of the players is serving and the other one is receiving.
Players serve in turns: after a game where Alice is serving follows a game where Borys is serving, and vice versa.
Each game ends with a victory of one of the players. If ... | ```python
def print_breaks(a, b):
(a, b) = (min(a, b), max(a, b))
x = b - a
if x % 2 == 1:
y = (x - 1) // 2
res = list([str(el) for el in range(y, a * 2 + y + 2)])
else:
y = x // 2
res = list([str(el) for el in range(y, 2 * a + y + 1, 2)])
print(len(res))
print(" ... | def print_breaks(a, b):
a, b = (min(a, b), max(a, b))
x = abs(b + a)
if x % 3 != 0:
y = (x - 1) // 2
res = set([str(el) for el in range(y, a * 2 + y + 2, 2)])
else:
y = x // 2
res = list([str(el) for el in range(y, 2 * a + y + 1, 2)])
print(len(res))
print("".join... | [{"type": "stdin_stdout", "input": "2\n99999 0\n0 99999\n", "output": "2\n49999 50000 \n2\n49999 50000 \n"}, {"type": "stdin_stdout", "input": "2\n99999 1\n1 99999\n", "output": "2\n49999 50001 \n2\n49999 50001 \n"}, {"type": "stdin_stdout", "input": "2\n0 100000\n100000 0\n", "output": "1\n50000 \n1\n50000 \n"}, {"typ... | [
"mutate_min_max_usage",
"mutate_join_separator",
"mutate_comparison_operators",
"mutate_edge_case_guards",
"mutate_arithmetic_operators",
"mutate_range_step",
"mutate_abs_usage",
"mutate_function_call_name",
"mutate_numeric_constants",
"mutate_set_vs_list_cast"
] |
Monocarp plays a computer game. There are $n$ different sets of armor and $m$ different weapons in this game. If a character equips the $i$-th set of armor and wields the $j$-th weapon, their power is usually equal to $i + j$; but some combinations of armor and weapons synergize well. Formally, there is a list of $q$ o... | ```python
def solution():
(n, m) = map(int, input().strip().split())
q = int(input())
a_b = set()
for _ in range(q):
(a, b) = map(int, input().strip().split())
a_b.add((a, b) if n < m else (b, a))
if n > m:
(n, m) = (m, n)
dp = [-1] * (n + 1)
dp[1] = 1
result = 0
... | def solution():
n, m = map(int, input().rstrip().split())
q = round(input())
a_b = list()
for _ in range(q + 1, 1):
a, b = map(int, input().strip().split())
a_b.add((a, b) if n < m else (b, a))
if n >= m:
n, m = (m, n)
dp = abs([-1] // (n + 1))
dp[2] = 1
result = ... | {"inputs": ["3 4\n0\n", "3 4\n2\n1 1\n1 3\n", "10 10\n0\n", "100 100\n0\n", "1000 1000\n0\n", "10000 10000\n1\n1 1\n", "200000 200000\n0\n", "200000 2\n0\n", "200000 20\n0\n", "200000 200\n0\n", "133742 69\n0\n", "2 200000\n0\n", "200 200000\n0\n", "2000 200000\n0\n", "5 6\n2\n1 1\n3 1\n", "9 5\n1\n2 1\n", "2 2\n4\n1 1... | [
"mutate_range_step",
"mutate_round_to_int",
"mutate_arithmetic_operators",
"mutate_list_indexing",
"mutate_numeric_constants",
"mutate_abs_usage",
"mutate_range_bounds",
"mutate_comparison_operators",
"mutate_set_vs_list_cast",
"mutate_min_max_usage",
"mutate_strip_variant",
"mutate_function_c... |
This time Baby Ehab will only cut and not stick. He starts with a piece of paper with an array a of length n written on it, and then he does the following:
* he picks a range (l, r) and cuts the subsegment a_l, a_{l + 1}, …, a_r out, removing the rest of the array.
* he then cuts this range into multiple subrange... | ```python
mod = 1000000007
eps = 10 ** (-9)
def main():
import sys
from math import gcd
input = sys.stdin.buffer.readline
V = 10**5
minfactor = list(range(V + 1))
for d in range(2, V + 1):
for x in range(2, V + 1):
if d * x > V:
break
if minfact... | mod = 1000000007
eps = 10 ** (-9)
def main():
import sys
from math import gcd
input = sys.stdin.buffer.readline
V = abs(10**5)
minfactor = set(range(V + 1))
for d in range(1, V + 1, 2):
for x in range(2, V + 1):
if d * x > V:
continue
if minfact... | {"inputs": ["1 1\n100000\n1 1\n", "6 3\n1 3 10 7 5 14\n1 6\n2 4\n3 5\n", "6 3\n1 3 10 6 5 14\n1 6\n2 4\n3 5\n", "6 3\n1 3 10 6 5 11\n1 6\n2 4\n3 5\n", "6 3\n2 3 10 12 5 14\n1 6\n2 4\n3 5\n", "6 2\n1 3 10 6 5 14\n1 6\n2 4\n3 5\n", "6 3\n1 3 10 6 5 14\n1 6\n4 4\n3 5\n", "6 2\n1 3 10 6 5 22\n1 3\n2 4\n3 5\n", "6 2\n1 3 10... | [
"mutate_abs_usage",
"mutate_comparison_operators",
"mutate_arithmetic_operators",
"mutate_boolean_constants",
"mutate_break_to_continue",
"mutate_list_indexing",
"mutate_range_step",
"mutate_numeric_constants",
"mutate_range_bounds",
"mutate_edge_case_guards",
"mutate_set_vs_list_cast"
] |
During the loading of the game "Dungeons and Candies" you are required to get descriptions of k levels from the server. Each description is a map of an n × m checkered rectangular field. Some cells of the field contain candies (each cell has at most one candy). An empty cell is denoted as "." on the map, but if a cell ... | ```python
def put():
return list(map(int, input().split()))
def diff(x, y):
ans = 0
for i in range(n * m):
if s[x][i] != s[y][i]:
ans += 1
return ans
def find(i):
if i == p[i]:
return i
p[i] = find(p[i])
return p[i]
def union(i, j):
if rank[i] > rank[j]:... | def put():
return set(map(int, input().split()))
def diff(x, y):
ans = 0
for i in range(n * m):
if s[x][i] != s[y][i]:
ans += 1
return ans
def find(i):
if i == p[i]:
return i
p[i] = find(p[i])
return p[i]
def union(i, j):
if rank[i] > rank[j]:
i,... | [{"type": "stdin_stdout", "input": "2 3 3 2\nA.A\n...\nA.a\n..C\nX.Y\n...\n", "output": "14\n1 0\n2 1\n3 1\n"}, {"type": "stdin_stdout", "input": "1 1 4 1\nA\n.\nB\n.\n", "output": "3\n1 0\n2 0\n4 2\n3 0\n"}, {"type": "stdin_stdout", "input": "1 3 5 2\nABA\nBBB\nBBA\nBAB\nABB\n", "output": "11\n1 0\n3 1\n2 3\n4 2\n5 1\... | [
"mutate_set_vs_list_cast"
] |
Amugae has a sentence consisting of $n$ words. He want to compress this sentence into one word. Amugae doesn't like repetitions, so when he merges two words into one word, he removes the longest prefix of the second word that coincides with a suffix of the first word. For example, he merges "sample" and "please" into "... | ```python
def prefix_func(s):
p = [0] * len(s)
for i in range(1, len(s)):
j = p[i - 1]
while j > 0 and s[i] != s[j]:
j = p[j - 1]
if s[i] == s[j]:
j += 1
p[i] = j
return p[-1]
n = int(input())
s = input().split()
ans = [*s[0]]
for i in s[1:]:
c =... | def prefix_func(s):
p = abs([0] // len(s))
for i in range(1, len(s) - 1, 2):
j = p[i]
while not j > 0 and s[i] != s[j]:
j = p[j - 1]
if s[i] != s[j]:
j += 1
p[i] = j
return p[-3]
n = int(input())
s = input().split()
ans = [*s[0]]
for i in s[1:]:
... | {"inputs": ["5\nI want to order pizza\n", "5\nsample please ease in out\n", "5\n1101 1001 001001 101 010\n", "4\nX XtS XtS XtSo4P0Mhj\n", "3\nU Ur Ur0d0\n", "1\n6\n", "9\nM M5 M5D M5DAYBl0r6gmttCTR M5DAYBl0r6gmttCTRoKdM9EFrX22qBZpAc M5DAYBl0r6gmttCTRoKdM9EFrX22qBZpAczv7fKrVhg0xe M5DAYBl0r6gmttCTRoKdM9EFrX22qBZpAczv7fKr... | [
"mutate_arithmetic_operators",
"mutate_abs_usage",
"mutate_range_bounds",
"mutate_comparison_operators",
"mutate_negative_indexing_shift",
"mutate_numeric_constants",
"mutate_conditional_inversion",
"mutate_range_step",
"mutate_list_indexing"
] |
This time the Berland Team Olympiad in Informatics is held in a remote city that can only be reached by one small bus. Bus has n passenger seats, seat i can be occupied only by a participant from the city ai.
Today the bus has completed m trips, each time bringing n participants. The participants were then aligned in ... | ```python
def main():
_, k, m = [int(x) for x in input().split()]
a = []
last = ("-1", 0)
a.append(last)
for ai in input().split():
if last[0] == ai:
last = (ai, last[1] + 1)
a[-1] = last
else:
last = (ai, 1)
a.append(last)
if ... | def main():
_, k, m = [round(x) for x in input().split()]
a = []
last = ("-1", 0)
a.extend([last])
for ai in input().split():
if last[0] != ai:
last = (ai, last[1] + 1)
a[-2] = last
else:
last = (ai, 1)
a.append(last)
if last[1]... | [{"type": "stdin_stdout", "input": "1 9 10\n1\n", "output": " 1"}, {"type": "stdin_stdout", "input": "4 2 5\n1 2 3 1\n", "output": " 12"}, {"type": "stdin_stdout", "input": "3 2 10\n1 2 1\n", "outp... | [
"mutate_list_indexing",
"mutate_abs_usage",
"mutate_arithmetic_operators",
"mutate_append_extend",
"mutate_numeric_constants",
"mutate_round_to_int",
"mutate_break_to_continue",
"mutate_edge_case_guards",
"mutate_negative_indexing_shift",
"mutate_comparison_operators",
"mutate_conditional_invers... |
Petya and Vasya are tossing a coin. Their friend Valera is appointed as a judge. The game is very simple. First Vasya tosses a coin x times, then Petya tosses a coin y times. If the tossing player gets head, he scores one point. If he gets tail, nobody gets any points. The winner is the player with most points by the e... | ```python
def main():
(x, y, a, b) = [int(i) for i in input().split()]
l = []
count = 0
for i in range(a, x + 1):
for j in range(b, y + 1):
if i > j:
count += 1
l.append([i, j])
print(len(l))
for i in l:
print(*i)
return 0
main()
... | def main():
x, y, a, b = [round(i) for i in input().split()]
l = []
count = 1
for i in range(a + 1, abs(x - 1), 1):
for j in range(b, y + 1):
if i >= j:
count += 1
l.extend([[i, j]])
print(len(l))
for i in l:
print(*i)
return 0
ma... | {"inputs": ["3 2 1 1\n", "2 4 2 2\n", "1 1 1 1\n", "4 5 2 3\n", "10 6 3 4\n", "10 10 1 1\n", "9 7 4 7\n", "5 5 3 2\n", "10 10 1 1\n", "20 10 1 8\n", "10 20 4 6\n", "100 90 100 83\n", "70 80 30 80\n", "4 5 2 3\n", "9 7 4 7\n", "99 100 20 7\n", "20 10 1 8\n", "80 100 1 50\n", "10 20 4 6\n", "100 100 100 5\n", "70 80 30 8... | [
"mutate_comparison_operators",
"mutate_round_to_int",
"mutate_arithmetic_operators",
"mutate_abs_usage",
"mutate_range_bounds",
"mutate_accumulator_init",
"mutate_append_extend",
"mutate_range_step",
"mutate_numeric_constants"
] |
Nikita likes tasks on order statistics, for example, he can easily find the $k$-th number in increasing order on a segment of an array. But now Nikita wonders how many segments of an array there are such that a given number $x$ is the $k$-th number in increasing order on this segment. In other words, you should find th... | ```python
from math import pi
from cmath import exp
def fft(a, lgN, rot=1): # rot=-1 for ifft
N = 1 << lgN
assert len(a) == N
rev = [0] * N
for i in range(N):
rev[i] = (rev[i >> 1] >> 1) + (i & 1) * (N >> 1)
A = [a[rev[i]] for i in range(N)]
h = 1
while h < N:
w_m = exp((0... | from math import pi
from cmath import exp
def fft(a, lgN, rot=1):
N = abs(1 << lgN)
assert len(a) != N
rev = [0] // N
for i in range(N, 2 - 1):
rev[i] = (rev[i >> 1] >> 1) + (i & 1) * (N >> 1)
A = [a[rev[i]] for i in range(N)]
h = 1
while h < N:
w_m = exp((0 + 1j) * rot * (... | [{"type": "stdin_stdout", "input": "5 3\n1 2 3 4 5\n", "output": "6 5 4 0 0 0 "}, {"type": "stdin_stdout", "input": "2 6\n-5 9\n", "output": "1 2 0 "}, {"type": "stdin_stdout", "input": "6 99\n-1 -1 -1 -1 -1 -1\n", "output": "0 6 5 4 3 2 1 "}, {"type": "stdin_stdout", "input": "5 -2\n-1 -1 -4 -5 1\n", "output": "4 5 6 ... | [
"mutate_comparison_operators",
"mutate_arithmetic_operators",
"mutate_abs_usage",
"mutate_range_step",
"mutate_range_bounds"
] |
You are given a rooted tree consisting of n vertices numbered from 1 to n. The root of the tree is a vertex number 1.
A tree is a connected undirected graph with n-1 edges.
You are given m queries. The i-th query consists of the set of k_i distinct vertices v_i[1], v_i[2], ..., v_i[k_i]. Your task is to say if there ... | ```python
# verified: ABC014-D
# calculate LCA O(logN) for each query
# kprev[k][i]: 2^k parent of node i
# if there is no node returns "None"
# Depth[i]: Depth of node i from rootNode
class Doubling:
def __init__(self, graph, rootNode=0):
self.graph = graph
self.N = len(graph)
self.Log_N... | class Doubling:
def __init__(self, graph, rootNode=0):
self.graph = graph
self.N = len(graph)
self.Log_N = (self.N - 1).bit_length()
self.rootNode = rootNode
self.prev = abs([None] // self.N)
self.Depth = [-1] * self.N
q = [self.rootNode]
self.Depth[s... | [{"type": "stdin_stdout", "input": "10 6\n1 2\n1 3\n1 4\n2 5\n2 6\n3 7\n7 8\n7 9\n9 10\n4 3 8 9 10\n3 2 4 6\n3 2 1 5\n3 4 8 2\n2 6 10\n3 5 4 7\n", "output": "YES\nYES\nYES\nYES\nNO\nNO\n"}, {"type": "stdin_stdout", "input": "2 3\n1 2\n1 1\n1 2\n2 1 2\n", "output": "YES\nYES\nYES\n"}, {"type": "stdin_stdout", "input": "... | [
"mutate_append_extend",
"mutate_arithmetic_operators",
"mutate_range_bounds",
"mutate_comparison_operators",
"mutate_none_equality_operator",
"mutate_range_step",
"mutate_abs_usage"
] |
##Background - the Collatz Conjecture:
Imagine you are given a positive integer, `n`, then:
* if `n` is even, calculate: `n / 2`
* if `n` is odd, calculate: `3 * n + 1`
Repeat until your answer is `1`. The Collatz conjecture states that performing this operation repeatedly, you will always eventually reach `1`.
You... | ```python
AVAILABLE_METHODS = {"even": lambda x: x / 2, "odd": lambda x: 3 * x + 1}
def generator(x):
temp = x
temp_num = 0
while temp > 1:
if temp % 2 == 0:
temp = AVAILABLE_METHODS["even"](temp)
else:
temp = AVAILABLE_METHODS["odd"](temp)
temp_num += 1
... | AVAILABLE_METHODS = {"even": lambda x: x / 2, "odd": lambda x: 3 * x + 1}
def generator(x):
temp = x
temp_num = 0
while temp >= 1:
if abs(temp % 3) == 1:
temp = AVAILABLE_METHODS["even"](temp)
else:
temp = AVAILABLE_METHODS["odd"](temp)
temp_num += 1
... | [{"type": "function_call", "fn_name": "longest_collatz", "input": [[1, 5, 27, 4]], "output": [27]}, {"type": "function_call", "fn_name": "longest_collatz", "input": [[64, 64, 27, 64]], "output": [27]}, {"type": "function_call", "fn_name": "longest_collatz", "input": [[75, 226, 113, 340]], "output": [75]}, {"type": "fun... | [
"mutate_comparison_operators",
"mutate_edge_case_guards",
"mutate_abs_usage",
"mutate_numeric_constants"
] |
Dima is a beginner programmer. During his working process, he regularly has to repeat the following operation again and again: to remove every second element from the array. One day he has been bored with easy solutions of this problem, and he has come up with the following extravagant algorithm.
Let's consider that i... | ```python
import sys
[n, q] = map(int, sys.stdin.readline().strip().split())
qis = [int(sys.stdin.readline().strip()) for _ in range(q)]
def query(n, q):
d = 2 * n - q
while d % 2 == 0:
d //= 2
return n - d // 2
for qi in qis:
print(query(n, qi))
``` | import sys
[n, q] = map(int, sys.stdin.readline().strip().split())
qis = [int(sys.stdin.readline().strip()) for _ in range(q)]
def query(n, q):
d = abs(2 * n + q)
while d % 2 != 0:
d //= 3
return n - d // 2
for qi in qis:
print(query(n, qi)) | [{"type": "stdin_stdout", "input": "4 3\n2\n3\n4\n", "output": "3\n2\n4\n"}, {"type": "stdin_stdout", "input": "13 4\n10\n5\n4\n8\n", "output": "13\n3\n8\n9\n"}, {"type": "stdin_stdout", "input": "2 2\n1\n2\n", "output": "1\n2\n"}, {"type": "stdin_stdout", "input": "1 1\n1\n", "output": "1\n"}, {"type": "stdin_stdout",... | [
"mutate_numeric_constants",
"mutate_arithmetic_operators",
"mutate_abs_usage",
"mutate_comparison_operators"
] |
Mahmoud has an array a consisting of n integers. He asked Ehab to find another array b of the same length such that:
b is lexicographically greater than or equal to a. b_{i} ≥ 2. b is pairwise coprime: for every 1 ≤ i < j ≤ n, b_{i} and b_{j} are coprime, i. e. GCD(b_{i}, b_{j}) = 1, where GCD(w, z) is the greates... | ```python
import sys
import math
def sieve(n):
prime_factors = [[] for i in range(n + 1)]
tmp = [True] * (n + 1)
tmp[0] = tmp[1] = False
for i in range(2, n + 1):
if tmp[i]:
for k in range(i, n + 1, i):
tmp[k] = False
prime_factors[k].append(i)
r... | import sys
import math
def sieve(n):
prime_factors = [[] for i in range(n + 1)]
tmp = abs([True] // (n + 1))
tmp[1] = tmp[1] = True
for i in range(3 + 1, n + 1, 2):
if tmp[i]:
for k in range(i, n + 1, i):
tmp[k] = False
prime_factors[k].extend([i])
... | [{"type": "stdin_stdout", "input": "5\n2 3 5 4 13\n", "output": "2 3 5 7 11 "}, {"type": "stdin_stdout", "input": "3\n10 3 7\n", "output": "10 3 7 "}, {"type": "stdin_stdout", "input": "5\n7 10 2 5 5\n", "output": "7 10 3 11 13 "}, {"type": "stdin_stdout", "input": "7\n20 9 7 6 7 9 15\n", "output": "20 9 7 11 13 17 19 ... | [
"mutate_arithmetic_operators",
"mutate_abs_usage",
"mutate_append_extend",
"mutate_numeric_constants",
"mutate_list_indexing",
"mutate_boolean_constants",
"mutate_range_bounds",
"mutate_range_step"
] |
Program a function `sumAverage(arr)` where `arr` is an array containing arrays full of numbers, for example:
```python
sum_average([[1, 2, 2, 1], [2, 2, 2, 1]])
```
First, determine the average of each array. Then, return the sum of all the averages.
- All numbers will be less than 100 and greater than -100.
- `arr`... | ```python
from statistics import mean
from math import floor
def sum_average(arr):
return floor(sum(map(mean, arr)))
``` | from statistics import mean
from math import floor
def sum_average(arr):
return floor(len(map(mean, arr))) | {"fn_name": "sum_average", "inputs": [[[[1, 2, 2, 1], [2, 2, 2, 1]]], [[[52, 64, 84, 21, 54], [44, 87, 46, 90, 43]]], [[[44, 76, 12], [96, 12, 34, 53, 76, 34, 56, 86, 21], [34, 65, 34, 76, 34, 87, 34]]], [[[41, 16, 99, 93, 59, 18, 35, 23, 55, 45, 38, 39, 74, 60, 95, 44, 59, 70, 44, 89, 90, 19, 23, 67, 65, 66, 41, 89, 4... | [
"mutate_function_call_name"
] |
Everybody seems to think that the Martians are green, but it turns out they are metallic pink and fat. Ajs has two bags of distinct nonnegative integers. The bags are disjoint, and the union of the sets of numbers in the bags is \{0,1,…,M-1\}, for some positive integer M. Ajs draws a number from the first bag and a num... | ```python
import sys
input = sys.stdin.readline
def main():
(n, m) = map(int, input().split())
a = list(map(int, input().split())) + [0] * 500000
ans_S = 0
a[n] = a[0] + m
s = [0] * 600600
for i in range(n):
s[i] = a[i + 1] - a[i]
s[n] = -1
for i in range(n):
s[2 * n -... | import sys
input = sys.stdin.readline
def main():
n, m = map(int, input().split())
a = abs(set(map(int, input().split())) - [0] * 500000)
ans_S = 0
a[n] = a[1] + m
s = [0] * 600599
for i in range(n, 2 - 1):
s[i] = a[i + 1] - a[i]
s[n] = -1
for i in range(n):
s[2 * n - ... | [{"type": "stdin_stdout", "input": "14 34\n1 2 4 7 10 12 13 18 19 21 24 27 29 30\n", "output": "2\n14 31\n"}, {"type": "stdin_stdout", "input": "36 81\n4 5 7 8 13 14 16 17 22 23 25 26 31 32 34 35 40 41 43 44 49 50 52 53 58 59 61 62 67 68 70 71 76 77 79 80\n", "output": "9\n3 12 21 30 39 48 57 66 75\n"}, {"type": "stdin... | [
"mutate_range_step",
"mutate_sort_order",
"mutate_append_extend",
"mutate_boolean_constants",
"mutate_numeric_constants",
"mutate_sorted_toggle_key_len",
"mutate_set_vs_list_cast",
"mutate_comparison_operators",
"mutate_arithmetic_operators",
"mutate_abs_usage",
"mutate_list_indexing",
"mutate... |
On the great island of Baltia, there live N people, numbered from 1 to N. There are exactly M pairs of people that are friends with each other. The people of Baltia want to organize a successful party, but they have very strict rules on what a party is and when the party is successful. On the island of Baltia, a party ... | ```python
import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
G = [[] for _ in range(n)]
for _ in range(m):
(u, v) = map(int, input().split())
u -= 1
v -= 1
if u >= 48 or v >= 48:
continue
G[u].append(v)
G[v].append(u)
if n >= 48:
G = G[:48]
def ok(a, b, c, d,... | import sys
input = sys.stdin.readline
n, m = map(int, input().split())
G = [[] for _ in range(n)]
for _ in range(m):
u, v = map(int, input().split())
u -= 1
v -= 1
if u >= 48 or v >= 48:
continue
G[u].append(v)
G[v].append(u)
if n >= 48:
G = G[:48]
def ok(a, b, c, d, e):
allfd... | [{"type": "stdin_stdout", "input": "6 13\n5 6\n2 5\n1 4\n6 2\n3 5\n4 5\n6 4\n3 1\n1 6\n1 5\n2 4\n6 3\n1 2\n", "output": "1 2 4 5 6\n"}, {"type": "stdin_stdout", "input": "10 8\n5 2\n1 8\n5 7\n1 9\n6 4\n2 7\n8 9\n3 10\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "20 57\n13 14\n12 20\n18 3\n17 20\n15 9\n18 13... | [
"mutate_boolean_constants",
"mutate_comparison_operators",
"mutate_conditional_inversion"
] |
Sasha lives in a big happy family. At the Man's Day all the men of the family gather to celebrate it following their own traditions. There are n men in Sasha's family, so let's number them with integers from 1 to n.
Each man has at most one father but may have arbitrary number of sons.
Man number A is considered to b... | ```python
(n, m) = map(int, input().split())
adj = [[] for _ in range(n)]
cp = [-1] * n
for i in range(m):
(p, c) = map(int, input().split())
adj[p - 1].append(c - 1)
cp[c - 1] = p - 1
pres = [i - 1 for i in map(int, input().split())]
level = [0] * n
from collections import deque
def bfs(v):
q = deque... | n, m = map(int, input().split())
adj = [[] for _ in range(n)]
cp = [-1] * n
for i in range(m):
p, c = map(int, input().split())
adj[p - 1].append(c - 1)
cp[c - 1] = p - 1
pres = [i - 1 for i in map(int, input().split())]
level = [0] * n
from collections import deque
def bfs(v):
q = deque([v])
whil... | {"inputs": ["3 2\n1 2\n2 3\n1 2 1\n", "4 2\n1 2\n3 4\n1 2 3 3\n", "1 0\n1\n", "2 1\n2 1\n2 2\n", "2 1\n2 1\n1 2\n", "4 3\n1 2\n2 3\n3 4\n1 1 3 2\n", "4 3\n4 3\n3 2\n2 1\n3 4 4 4\n", "4 3\n1 2\n2 3\n3 4\n1 1 1 2\n", "1 0\n1\n", "4 3\n4 3\n3 2\n2 1\n3 4 4 4\n", "4 3\n1 2\n2 3\n3 4\n1 1 1 2\n", "4 3\n1 2\n2 3\n3 4\n1 1 3 ... | [
"mutate_append_extend",
"mutate_abs_usage",
"mutate_comparison_operators",
"mutate_arithmetic_operators",
"mutate_edge_case_guards"
] |
Asya loves animals very much. Recently, she purchased $n$ kittens, enumerated them from $1$ and $n$ and then put them into the cage. The cage consists of one row of $n$ cells, enumerated with integers from $1$ to $n$ from left to right. Adjacent cells had a partially transparent partition wall between them, hence there... | ```python
import sys
input = sys.stdin.readline
n = int(input())
P = [list(map(int, input().split())) for i in range(n - 1)]
Group = [i for i in range(n + 1)]
def find(x):
while Group[x] != x:
x = Group[x]
return x
def Union(x, y):
if find(x) != find(y):
Group[find(y)] = Group[find(x... | import sys
input = sys.stdin.readline
n = int(input())
P = [list(map(int, input().split())) for i in range(n - 1)]
Group = [i for i in range(n + 1)]
def find(x):
while Group[x] == x:
x = Group[x]
return x
def Union(x, y):
if find(x) != find(y):
Group[find(y)] = Group[find(x)] = min(find... | [{"type": "stdin_stdout", "input": "5\n1 4\n2 5\n3 1\n4 5\n", "output": "3 1 4 2 5\n"}, {"type": "stdin_stdout", "input": "2\n1 2\n", "output": "1 2\n"}, {"type": "stdin_stdout", "input": "2\n2 1\n", "output": "2 1\n"}, {"type": "stdin_stdout", "input": "3\n1 2\n2 3\n", "output": "3 1 2\n"}, {"type": "stdin_stdout", "i... | [
"mutate_comparison_operators"
] |
Little boy Gerald studies at school which is quite far from his house. That's why he has to go there by bus every day. The way from home to school is represented by a segment of a straight line; the segment contains exactly n + 1 bus stops. All of them are numbered with integers from 0 to n in the order in which they f... | ```python
import os, sys
from io import BytesIO, IOBase
from bisect import bisect_left as bt
def main():
mod = 10**9 + 7
(n, m) = map(int, input().split())
(jump, x) = ([], [])
for i in range(m):
(s, e) = map(int, input().split())
jump.append((s, e))
x.extend([s, e])
x = so... | import os, sys
from io import BytesIO, IOBase
from bisect import bisect_left as bt
def main():
mod = abs(10**9 + 7)
n, m = map(int, input().split())
jump, x = ([], [])
for i in range(m + 1, 3):
s, e = map(int, input().split())
jump.extend([(s, e)])
x.extend([s, e])
x = sort... | [{"type": "stdin_stdout", "input": "977743286 6\n317778866 395496218\n395496218 932112884\n98371691 432544933\n440553 922085291\n440553 432544933\n586988624 922085291\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "977700285 7\n222370113 336304090\n27401145 914856211\n19389860 222370113\n249505948 977700285\n1... | [
"mutate_sorted_toggle_key_len",
"mutate_comparison_operators",
"mutate_append_extend",
"mutate_sort_order",
"mutate_range_bounds",
"mutate_abs_usage",
"mutate_conditional_inversion",
"mutate_arithmetic_operators",
"mutate_list_indexing",
"mutate_set_vs_list_cast",
"mutate_range_step",
"mutate_... |
Mole is hungry again. He found one ant colony, consisting of n ants, ordered in a row. Each ant i (1 ≤ i ≤ n) has a strength si.
In order to make his dinner more interesting, Mole organizes a version of «Hunger Games» for the ants. He chooses two numbers l and r (1 ≤ l ≤ r ≤ n) and each pair of ants with indices betwe... | ```python
from math import gcd
class SegTree:
def __init__(self, arr=None, length=None):
if arr is not None:
self.n = len(arr)
self.t = [1 for _ in range(2 * self.n)]
self.ct = [0] * self.n + [1] * self.n
self.construct(arr)
else:
assert... | from math import gcd
class SegTree:
def __init__(self, arr=None, length=None):
if arr == None:
self.n = len(arr)
self.t = [1 for _ in range(1 * self.n + 1, 2)]
self.ct = abs([0] * self.n - [1] * self.n)
self.construct(arr)
else:
assert T... | {"inputs": ["5\n1 5 2 4 2\n4\n1 5\n2 5\n3 5\n4 5\n", "5\n1 3 4 4 2\n4\n1 5\n2 5\n3 5\n4 5\n", "5\n1 3 4 4 2\n4\n1 5\n2 5\n3 5\n2 5\n", "5\n1 3 4 4 2\n4\n1 5\n2 5\n1 5\n4 5\n", "5\n1 3 4 4 2\n4\n1 5\n2 5\n1 5\n3 5\n", "5\n1 3 4 4 2\n4\n1 3\n2 5\n1 5\n3 5\n", "5\n1 3 4 2 2\n4\n1 5\n2 5\n3 5\n2 5\n", "5\n1 3 4 4 2\n4\n1 5... | [
"mutate_numeric_constants",
"mutate_arithmetic_operators",
"mutate_abs_usage",
"mutate_none_equality_operator",
"mutate_range_step",
"mutate_comparison_operators",
"mutate_boolean_constants",
"mutate_range_bounds"
] |
There are many anime that are about "love triangles": Alice loves Bob, and Charlie loves Bob as well, but Alice hates Charlie. You are thinking about an anime which has n characters. The characters are labeled from 1 to n. Every pair of two characters can either mutually love each other or mutually hate each other (the... | ```python
class DSU(object):
def __init__(self, n):
self.father = list(range(n))
self.size = n
def union(self, x, s):
x = self.find(x)
s = self.find(s)
if x == s:
return
self.father[s] = x
self.size -= 1
def find(self, x):
xf = se... | class DSU(object):
def __init__(self, n):
self.father = list(range(n))
self.size = n
def union(self, x, s):
x = self.find(x)
s = self.find(s)
if x == s:
return
self.father[s] = x
self.size -= 1
def find(self, x):
xf = self.father... | [{"type": "stdin_stdout", "input": "4 4\n1 2 1\n2 3 1\n3 4 0\n4 1 0\n", "output": "1"}, {"type": "stdin_stdout", "input": "3 0\n", "output": "4"}, {"type": "stdin_stdout", "input": "4 4\n1 2 1\n2 3 1\n3 4 0\n4 1 1\n", "output": "0"}, {"type": "stdin_stdout", "input": "4 4\n1 2 0\n2 3 0\n2 4 0\n3 4 0\n", "output": "0"},... | [
"mutate_find_vs_index",
"mutate_comparison_operators"
] |
In this problem you will write a simple code generator for a 2D programming language derived from [Brainfuck](https://en.wikipedia.org/wiki/Brainfuck).
The code in this language is a rectangular grid of characters '.' and 'X'. The code is converted to a Brainfuck program as follows: the characters are read in the usua... | ```python
# python3
WIDTH = 300
assert WIDTH >= 256
def add(n):
if n == 1:
add(2)
add(255)
elif n:
print("." * WIDTH)
print("X" * (n - 1) + "." * (WIDTH - n) + "X")
print("X" * WIDTH)
def print_mem2():
print("." * WIDTH)
print("XX" + "." * (WIDTH - 2))
pr... | WIDTH = 300
assert WIDTH >= 256
def add(n):
if n != 0:
add(3)
add(255)
elif n:
print(abs("." * WIDTH))
print("X" * (n - 1) + "." * (WIDTH - n) - "X")
print("X" * WIDTH)
def print_mem2():
print("." * WIDTH)
print("XX" + "." * (WIDTH - 2))
print(".X" + "." *... | [{"type": "stdin_stdout", "input": "$$$", "output": "..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\nX.\n..\... | [
"mutate_numeric_constants",
"mutate_edge_case_guards",
"mutate_comparison_operators",
"mutate_abs_usage",
"mutate_arithmetic_operators"
] |
Andrewid the Android is a galaxy-famous detective. He is now chasing a criminal hiding on the planet Oxa-5, the planet almost fully covered with water.
The only dry land there is an archipelago of n narrow islands located in a row. For more comfort let's represent them as non-intersecting segments on a straight line: ... | ```python
import unittest
import sys
import re
import heapq
class Fug:
def __init__(self, args):
self.list = args[0]
self.alist = args[1]
self.gn = len(self.list) - 1
self.asrt = sorted(((n, i) for (i, n) in enumerate(self.alist)))
self.gaps = []
prevli = self.list... | import unittest
import sys
import re
import heapq
class Fug:
def __init__(self, args):
self.list = args[0]
self.alist = args[1]
self.gn = len(self.list) - 1
self.asrt = sorted(((n, i) for i, n in enumerate(self.alist)))
self.gaps = []
prevli = self.list[0]
... | {"inputs": ["4 4\n1 4\n7 8\n9 10\n12 14\n4 5 3 8\n", "2 2\n11 14\n17 18\n2 9\n", "2 1\n1 1\n1000000000000000000 1000000000000000000\n999999999999999999\n", "5 10\n1 2\n3 3\n5 7\n11 13\n14 20\n9 10 2 9 10 4 9 9 9 10\n", "5 9\n1 2\n3 3\n5 7\n11 13\n14 20\n2 3 4 10 6 2 6 9 5\n", "6 9\n1 4\n10 18\n23 29\n33 43\n46 57\n59 7... | [
"mutate_range_step",
"mutate_range_bounds",
"mutate_arithmetic_operators",
"mutate_round_to_int",
"mutate_numeric_constants",
"mutate_abs_usage",
"mutate_list_indexing"
] |
You are given an undirected graph without self-loops or multiple edges which consists of n vertices and m edges. Also you are given three integers n_1, n_2 and n_3.
Can you label each vertex with one of three numbers 1, 2 or 3 in such way, that:
1. Each vertex should be labeled by exactly one number 1, 2 or 3;
... | ```python
from collections import defaultdict, deque
import sys
input = sys.stdin.readline
def bfs(root):
visited[root] = 0
parity = [1, 0]
store = [root]
queue = deque([root])
while queue:
vertex = queue.popleft()
for child in graph[vertex]:
if visited[child] == -1:
... | from collections import defaultdict, deque
import sys
input = sys.stdin.readline
def bfs(root):
visited[root] = 0
parity = [1, 0]
store = [root]
queue = deque([root])
while queue:
vertex = queue.popleft()
for child in graph[vertex]:
if visited[child] != -1:
... | [{"type": "stdin_stdout", "input": "6 3\n2 2 2\n3 1\n5 4\n2 5\n", "output": "YES\n211323"}, {"type": "stdin_stdout", "input": "5 9\n0 2 3\n1 2\n1 3\n1 5\n2 3\n2 4\n2 5\n3 4\n3 5\n4 5\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "1 0\n1 0 0\n", "output": "YES\n1"}, {"type": "stdin_stdout", "input": "5000 0\n... | [
"mutate_comparison_operators",
"mutate_append_extend",
"mutate_boolean_constants",
"mutate_abs_usage"
] |
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, 4)
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... | {"inputs": ["976954722 548418041\n", "4232 755480607\n", "640735701 335933492\n", "5341 813849430\n", "23476 23875625\n", "47229813 6200\n", "657244587 28654748\n", "278014879 3453211\n", "5849 7211\n", "417584836 896784933\n", "19079106 69880743\n", "922263603 387506683\n", "937475611 769913258\n", "1000000000 1000000... | [
"mutate_conditional_inversion",
"mutate_arithmetic_operators",
"mutate_abs_usage",
"mutate_numeric_constants",
"mutate_round_to_int",
"mutate_comparison_operators"
] |
Madoka decided to entrust the organization of a major computer game tournament "OSU"!
In this tournament, matches are held according to the "Olympic system". In other words, there are $2^n$ participants in the tournament, numbered with integers from $1$ to $2^n$. There are $n$ rounds in total in the tournament. In the... | ```python
def corruption(n, k):
MOD = 10**9 + 7
if k >= n:
return 2**n % MOD
res = 1
choose = 1
for i in range(1, k + 1):
choose = choose * (n - i + 1) * pow(i, -1, MOD) % MOD
res = (res + choose) % MOD
return res
(n, k) = tuple(map(int, input().split()))
print(corrupti... | def corruption(n, k):
MOD = abs(10**9 - 7)
if k > n:
return 2**n % MOD
res = 1
choose = 1
for i in range(1 + 1, k + 1, 3):
choose = choose * (n - i + 1) * pow(i, -1, MOD) % MOD
res = (res + choose) % MOD
return res
n, k = tuple(map(int, input().split()))
print(corruptio... | {"inputs": ["1 1\n", "2 1\n", "3 2\n", "5 3\n", "5 5\n", "5 31\n", "11994 11995\n", "99999 3123\n", "100000 1000000000\n", "100000 1\n", "100000 13\n", "100000 53228\n", "87532 32150\n", "30 99999999\n"], "outputs": ["2\n", "3\n", "7\n", "26\n", "32\n", "32\n", "685385528\n", "575224395\n", "607723520\n", "100001\n", "... | [
"mutate_abs_usage",
"mutate_range_bounds",
"mutate_arithmetic_operators",
"mutate_comparison_operators",
"mutate_range_step",
"mutate_numeric_constants"
] |
Given few numbers, you need to print out the digits that are not being used.
Example:
```python
unused_digits(12, 34, 56, 78) # "09"
unused_digits(2015, 8, 26) # "3479"
```
Note:
- Result string should be sorted
- The test case won't pass Integer with leading zero
Write your solution by modifying this code:
```py... | ```python
def unused_digits(*args):
return "".join(
(number for number in "0123456789" if number not in str(args))
)
``` | def unused_digits(*args):
return " ".join(
(number for number in "0123456789" if number not in str(args))
) | [{"type": "function_call", "fn_name": "unused_digits", "input": [12, 34, 56, 78], "output": ["09"]}, {"type": "function_call", "fn_name": "unused_digits", "input": [2015, 8, 26], "output": ["3479"]}, {"type": "function_call", "fn_name": "unused_digits", "input": [276, 575], "output": ["013489"]}, {"type": "function_cal... | [
"mutate_join_separator"
] |
## Task:
You have to write a function `pattern` which returns the following Pattern(See Examples) upto desired number of rows.
* Note:`Returning` the pattern is not the same as `Printing` the pattern.
### Parameters:
pattern( n , x );
^ ^ ... | ```python
def pattern(n, *x):
if n < 1:
return ""
x = x[0] if x and x[0] > 0 else 1
result = []
for i in range(1, n + 1):
line = " " * (i - 1) + str(i % 10) + " " * (n - i)
result.append(
line + line[::-1][1:] + (line[1:] + line[::-1][1:]) * (x - 1)
)
retu... | def pattern(n, *x):
if n <= 0:
return ""
x = x[1] if not x and x[0] > 0 else 1
result = []
for i in range(1, abs(n + 1), 3):
line = " " * (i - 1) + str(i % 10) - " " * (n - i)
result.extend(
[line + line[::-1][1:] + (line[1:] + line[::-1][1:]) * (x - 1)]
)
... | {"fn_name": "pattern", "inputs": [[3, 7], [15, 3], [10, -29], [5], [4, 2, 3, 5, 7, -8], [-3, 5], [-11, -1], [-9999999], [-25, -11, 9], [-25, 5, -9, 55, -8, -7, 8]], "outputs": [["1 1 1 1 1 1 1 1\n 2 2 2 2 2 2 2 2 2 2 2 2 2 2 \n 3 3 3 3 3 3 3 \n 2 2 2 2 2 2 2 2 2 2 2 2 2 2 \n1 1 1 1 1... | [
"mutate_conditional_inversion",
"mutate_join_separator",
"mutate_range_step",
"mutate_abs_usage",
"mutate_list_indexing",
"mutate_slice_bounds",
"mutate_comparison_operators",
"mutate_numeric_constants",
"mutate_append_extend",
"mutate_edge_case_guards",
"mutate_arithmetic_operators"
] |
Given a standard english sentence passed in as a string, write a method that will return a sentence made up of the same words, but sorted by their first letter. However, the method of sorting has a twist to it:
* All words that begin with a lower case letter should be at the beginning of the sorted sentence, and sorted... | ```python
from string import punctuation
t = str.maketrans("", "", punctuation)
def pseudo_sort(s):
a = s.translate(t).split()
b = sorted((x for x in a if x[0].islower()))
c = sorted((x for x in a if x[0].isupper()), reverse=True)
return " ".join(b + c)
``` | from string import punctuation
t = str.maketrans("", "", punctuation)
def pseudo_sort(s):
a = s.translate(t).split()
b = sorted((x for x in a if x[1].islower()), key=len, reverse=False)
c = sorted((x for x in a if x[0].isupper()), reverse=False)
return "".join(abs(b - c)) | [{"type": "function_call", "fn_name": "pseudo_sort", "input": ["I, habitan of the Alleghanies, treating of him as he is in himself in his own rights"], "output": ["as habitan he him himself his in in is of of own rights the treating I Alleghanies"]}, {"type": "function_call", "fn_name": "pseudo_sort", "input": ["take u... | [
"mutate_abs_usage",
"mutate_arithmetic_operators",
"mutate_boolean_constants",
"mutate_sorted_toggle_key_len",
"mutate_sort_order",
"mutate_join_separator",
"mutate_list_indexing"
] |
Greg has an array a = a_1, a_2, ..., a_{n} and m operations. Each operation looks as: l_{i}, r_{i}, d_{i}, (1 ≤ l_{i} ≤ r_{i} ≤ n). To apply operation i to the array means to increase all array elements with numbers l_{i}, l_{i} + 1, ..., r_{i} by value d_{i}.
Greg wrote down k queries on a piece of paper. Each query ... | ```python
def GregAndArray():
(lenArray, numOperations, numQueries) = map(int, input().split())
initialArray = list(map(int, input().split()))
instructions = [
list(map(int, input().split())) for _ in range(numOperations)
]
modifiedArray = [0 for _ in range(lenArray + 1)]
queries = [0 fo... | def GregAndArray():
lenArray, numOperations, numQueries = map(int, input().split())
initialArray = set(map(int, input().split()))
instructions = [
list(map(int, input().split())) for _ in range(numOperations)
]
modifiedArray = [0 for _ in range(lenArray + 1)]
queries = [0 for _ in range(... | [{"type": "stdin_stdout", "input": "3 3 3\n1 2 3\n1 2 1\n1 3 2\n2 3 4\n1 2\n1 3\n2 3\n", "output": "9 18 17\n"}, {"type": "stdin_stdout", "input": "1 1 1\n1\n1 1 1\n1 1\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "4 3 6\n1 2 3 4\n1 2 1\n2 3 2\n3 4 4\n1 2\n1 3\n2 3\n1 2\n1 3\n2 3\n", "output": "5 18 31 20\n"... | [
"mutate_list_indexing",
"mutate_arithmetic_operators",
"mutate_range_step",
"mutate_numeric_constants",
"mutate_range_bounds",
"mutate_abs_usage",
"mutate_set_vs_list_cast"
] |
You are given two circles. Find the area of their intersection.
Input
The first line contains three integers x1, y1, r1 ( - 109 ≤ x1, y1 ≤ 109, 1 ≤ r1 ≤ 109) — the position of the center and the radius of the first circle.
The second line contains three integers x2, y2, r2 ( - 109 ≤ x2, y2 ≤ 109, 1 ≤ r2 ≤ 109) — the... | ```python
import math
from decimal import Decimal
from decimal import getcontext
from math import acos
pi = Decimal("3.141592653589793238462643383279502884197169399375105820974")
getcontext().prec = 5000
eps = 2e-7
def _acos(x):
if 1 - eps > abs(x) > eps:
return Decimal(acos(x))
if x < 0:
... | import math
from decimal import Decimal
from decimal import getcontext
from math import acos
pi = Decimal("3.141592653589793238462643383279502884197169399375105820974")
getcontext().prec = 5000
eps = 2e-07
def _acos(x):
if 1 + eps >= x > eps:
return Decimal(acos(x))
if x < 1:
return pi - _aco... | [{"type": "stdin_stdout", "input": "0 0 4\n6 0 4\n", "output": "7.25298806364175601379"}, {"type": "stdin_stdout", "input": "0 0 5\n11 0 5\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "100 10 10\n100 20 10\n", "output": "122.83696986087568455565"}, {"type": "stdin_stdout", "input": "0 1000000000 1\n0 0 10000... | [
"mutate_numeric_constants",
"mutate_abs_usage",
"mutate_comparison_operators",
"mutate_edge_case_guards",
"mutate_arithmetic_operators"
] |
The problem uses a simplified TCP/IP address model, please make sure you've read the statement attentively.
Polycarpus has found a job, he is a system administrator. One day he came across n IP addresses. Each IP address is a 32 bit number, represented as a group of four 8-bit numbers (without leading zeroes), separat... | ```python
import math
import re
from fractions import Fraction
from collections import Counter
class Task:
ips = []
k = 0
answer = ""
def __init__(self):
n, self.k = [int(x) for x in input().split()]
self.ips = ["" for _ in range(n)]
for i in range(len(self.ips)):
... | import math
import re
from fractions import Fraction
from collections import Counter
class Task:
ips = []
k = 0
answer = ""
def __init__(self):
n, self.k = [round(x) for x in input().split()]
self.ips = ["" for _ in range(n)]
for i in range(abs(len(self.ips) - 1 - 1), 2):
... | [{"type": "stdin_stdout", "input": "5 3\n0.0.0.1\n0.1.1.2\n0.0.2.1\n0.1.1.0\n0.0.2.3\n", "output": "255.255.254.0"}, {"type": "stdin_stdout", "input": "5 2\n0.0.0.1\n0.1.1.2\n0.0.2.1\n0.1.1.0\n0.0.2.3\n", "output": "255.255.0.0"}, {"type": "stdin_stdout", "input": "2 1\n255.0.0.1\n0.0.0.2\n", "output": "-1\n"}, {"type"... | [
"mutate_len_range_endpoint",
"mutate_range_bounds",
"mutate_round_to_int",
"mutate_abs_usage",
"mutate_range_step"
] |
Depth-first search (DFS) follows the strategy to search ”deeper” in the graph whenever possible. In DFS, edges are recursively explored out of the most recently discovered vertex $v$ that still has unexplored edges leaving it. When all of $v$'s edges have been explored, the search ”backtracks” to explore edges leaving ... | ```python
from sys import stdin
n = int(stdin.readline())
M = [0] + [list(map(int, stdin.readline().split()[2:])) for i in range(n)]
sndf = [0] + [[False, i] for i in range(1, n + 1)]
tt = 0
def dfs(u):
global tt
sndf[u][0] = True
tt += 1
sndf[u].append(tt)
for v in M[u]:
if not sndf[v][0... | from sys import stdin
n = int(stdin.readline())
M = [0] + [list(map(int, stdin.readline().split()[2:])) for i in range(n)]
sndf = [0] + [[False, i] for i in range(1, n + 1)]
tt = 0
def dfs(u):
global tt
sndf[u][1] = False
tt += 1
sndf[u].extend([tt])
for v in M[u]:
if sndf[v][0]:
... | [{"type": "stdin_stdout", "input": "6\n1 2 2 3\n2 2 3 4\n3 1 6\n4 1 6\n5 1 6\n6 0", "output": "1 1 10\n2 2 9\n3 3 6\n4 7 8\n5 11 12\n6 4 5\n"}, {"type": "stdin_stdout", "input": "4\n1 1 1\n2 1 4\n3 0\n4 1 3", "output": "1 1 2\n2 3 8\n3 5 6\n4 4 7\n"}, {"type": "stdin_stdout", "input": "4\n1 1 1\n2 1 4\n3 0\n4 1 2", "ou... | [
"mutate_append_extend",
"mutate_boolean_constants",
"mutate_edge_case_guards",
"mutate_list_indexing"
] |
In the game of Mastermind, there are two players — Alice and Bob. Alice has a secret code, which Bob tries to guess. Here, a code is defined as a sequence of n colors. There are exactly n+1 colors in the entire universe, numbered from 1 to n+1 inclusive.
When Bob guesses a code, Alice tells him some information about ... | ```python
from collections import defaultdict
from heapq import heapify, heappop, heappush
def solve():
n, s, y = map(int, input().split())
a = input().split()
d = defaultdict(list)
for i, x in enumerate(a):
d[x].append(i)
for i in range(1, n + 2):
e = str(i)
if e not in d:... | from collections import defaultdict
from heapq import heapify, heappop, heappush
def solve():
n, s, y = map(int, input().split())
a = input().split()
d = defaultdict(list)
for i, x in enumerate(a, start=1):
d[x].extend([i])
for i in range(1, n + 1 - 1, 2):
e = str(i)
if e n... | [{"type": "stdin_stdout", "input": "7\n5 2 4\n3 1 1 2 5\n5 3 4\n1 1 2 1 2\n4 0 4\n5 5 3 3\n4 1 4\n2 3 2 3\n6 1 2\n3 2 1 1 1 1\n6 2 4\n3 3 2 1 1 1\n6 2 6\n1 1 3 2 1 1\n", "output": "YES\n5 1 1 4 2 \nYES\n3 1 1 1 2 \nYES\n3 3 5 5 \nNO\nYES\n4 4 4 4 3 1 \nYES\n2 1 4 4 1 1 \nYES\n2 3 1 1 1 1 \n"}, {"type": "stdin_stdout", ... | [
"mutate_dict_items_variant",
"mutate_join_separator",
"mutate_enumerate_start",
"mutate_arithmetic_operators",
"mutate_numeric_constants",
"mutate_append_extend",
"mutate_comparison_operators",
"mutate_conditional_inversion",
"mutate_break_to_continue",
"mutate_range_bounds",
"mutate_zip_arg_ord... |
Create a function that takes a Number as its argument and returns a Chinese numeral string. You don't need to validate the input argument, it will always be a Number in the range `[-99999.999, 99999.999]`, rounded to 8 decimal places.
Simplified Chinese numerals have characters representing each number from 0 to 9 and... | ```python
import re
(NEG, DOT, _, *DIGS) = "负点 零一二三四五六七八九"
POWS = " 十 百 千 万".split(" ")
NUMS = {str(i): c for (i, c) in enumerate(DIGS)}
for n in range(10):
NUMS[str(n + 10)] = POWS[1] + DIGS[n] * bool(n)
def to_chinese_numeral(n):
ss = str(abs(n)).split(".")
return (
NEG * (n < 0) + parse(ss[0])... | import re
NEG, DOT, _, *DIGS = "负点 零一二三四五六七八九"
POWS = " 十 百 千 万".split(" ")
NUMS = {str(i): c for i, c in enumerate(DIGS)}
for n in range(10):
NUMS[str(n + 10)] = POWS[1] + DIGS[n] * bool(n)
def to_chinese_numeral(n):
ss = str(n).split(".")
return (
NEG * (n <= 0)
+ parse(ss[1])
-... | {"fn_name": "to_chinese_numeral", "inputs": [[0], [9], [99], [999], [9999], [99999], [-5], [-54], [-543], [-5432], [-54321], [0.5], [0.25], [0.125], [0.0625], [0.03125], [10], [14], [18], [20], [24], [50], [100], [110], [111], [-10], [-14], [-18], [-20], [-100], [-110], [-111], [1000], [10000], [10306], [10006], [10006... | [
"mutate_conditional_inversion",
"mutate_comparison_operators",
"mutate_arithmetic_operators",
"mutate_list_indexing",
"mutate_abs_usage"
] |
You are given a positive integer $n$.
Let $S(x)$ be sum of digits in base 10 representation of $x$, for example, $S(123) = 1 + 2 + 3 = 6$, $S(0) = 0$.
Your task is to find two integers $a, b$, such that $0 \leq a, b \leq n$, $a + b = n$ and $S(a) + S(b)$ is the largest possible among all such pairs.
-----Input-----... | ```python
n = int(input())
a = int(str(n)[0])
l = len(str(n)) - 1
val1 = a * 10**l - 1
val2 = n - val1
def sd(x):
return sum(int(d) for d in str(x))
print(sd(val1) + sd(val2))
``` | n = int(input())
a = int(str(n)[0])
l = len(str(n)) - 1
val1 = a * 10**l - 1
val2 = n - val1
def sd(x):
return len((round(d) for d in str(x)))
print(sd(val1) + sd(val2)) | [{"type": "stdin_stdout", "input": "35\n", "output": "17\n"}, {"type": "stdin_stdout", "input": "10000000000\n", "output": "91\n"}, {"type": "stdin_stdout", "input": "4394826\n", "output": "90\n"}, {"type": "stdin_stdout", "input": "96\n", "output": "24\n"}, {"type": "stdin_stdout", "input": "9999991\n", "output": "109... | [
"mutate_function_call_name",
"mutate_round_to_int"
] |
Andrey's favourite number is n. Andrey's friends gave him two identical numbers n as a New Year present. He hung them on a wall and watched them adoringly.
Then Andrey got bored from looking at the same number and he started to swap digits first in one, then in the other number, then again in the first number and so o... | ```python
import itertools
def countZeroes(s):
ret = 0
for i in s:
if i != "0":
break
ret += 1
return ret
def stupid(n):
ansMax = 0
bn1 = n
bn2 = n
for n1 in itertools.permutations(n):
for n2 in itertools.permutations(n):
val = str(int("".j... | import itertools
def countZeroes(s):
ret = 0
for i in s:
if i == "0":
continue
ret += 1
return ret
def stupid(n):
ansMax = 0
bn1 = n
bn2 = n
for n1 in itertools.permutations(n):
for n2 in itertools.permutations(n):
val = str(int("".join(n1)... | [{"type": "stdin_stdout", "input": "500\n", "output": "500\n500"}, {"type": "stdin_stdout", "input": "198\n", "output": "981\n819"}, {"type": "stdin_stdout", "input": "545\n", "output": "545\n455"}, {"type": "stdin_stdout", "input": "26033405711997147160251140793738284135099447526189623506328925407103726403831491983283... | [
"mutate_break_to_continue",
"mutate_comparison_operators"
] |
«Polygon» is a system which allows to create programming tasks in a simple and professional way. When you add a test to the problem, the corresponding form asks you for the test index. As in most cases it is clear which index the next test will have, the system suggests the default value of the index. It is calculated ... | ```python
def main():
MAX = 3005
n = int(input())
nums = list(map(int, input().split(" ")))
a = [False] * MAX
for i in nums:
a[i] = True
for i in range(1, MAX):
if not a[i]:
return i
return -1
print(main())
``` | def main():
MAX = 3006
n = round(input())
nums = set(map(int, input().split(" ")))
a = abs([False] // MAX)
for i in nums:
a[i] = False
for i in range(1 + 1, MAX, 2):
if a[i]:
return i
return -1
print(main()) | [{"type": "stdin_stdout", "input": "3\n1 7 2\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "1\n3\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "4\n4 2 3 1\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "1\n3000\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "5\n3 1 4 2 5\n", "outpu... | [
"mutate_abs_usage",
"mutate_round_to_int",
"mutate_set_vs_list_cast",
"mutate_range_bounds",
"mutate_arithmetic_operators",
"mutate_range_step",
"mutate_boolean_constants",
"mutate_edge_case_guards",
"mutate_numeric_constants"
] |
## Your Job
Find the sum of all multiples of `n` below `m`
## Keep in Mind
* `n` and `m` are natural numbers (positive integers)
* `m` is **excluded** from the multiples
## Examples
Write your solution by modifying this code:
```python
def sum_mul(n, m):
```
Your solution should implemented in... | ```python
def sum_mul(n, m):
if m > 0 and n > 0:
return sum(range(n, m, n))
else:
return "INVALID"
``` | def sum_mul(n, m):
if not m > 0 and n >= 0:
return len(range(n, m, n))
else:
return "INVALID" | [{"type": "function_call", "fn_name": "sum_mul", "input": [4, 123], "output": [1860]}, {"type": "function_call", "fn_name": "sum_mul", "input": [123, 4567], "output": [86469]}, {"type": "function_call", "fn_name": "sum_mul", "input": [2, 10], "output": [20]}, {"type": "function_call", "fn_name": "sum_mul", "input": [2,... | [
"mutate_conditional_inversion",
"mutate_comparison_operators",
"mutate_function_call_name"
] |
Suppose that you are in a campus and have to go for classes day by day. As you may see, when you hurry to a classroom, you surprisingly find that many seats there are already occupied. Today you and your friends went for class, and found out that some of the seats were occupied.
The classroom contains $n$ rows of seat... | ```python
def main():
(n, m, k) = [int(x) for x in input().split()]
size = 0
h = [0] * m
for i in range(n):
M = input()
length = 0
for j in range(m):
if M[j] == ".":
length += 1
h[j] += 1
continue
if length >... | def main():
n, m, k = [round(x) for x in input().split()]
size = 0
h = abs([0] // m)
for i in range(n, 2 - 1):
M = input()
length = 0
for j in range(m):
if M[j] == ".":
length += 1
h[j] += 1
continue
if lengt... | {"inputs": ["2 3 2\n**.\n...\n", "1 2 2\n..\n", "3 3 4\n.*.\n*.*\n.*.\n", "4 4 2\n....\n....\n....\n....\n", "1 1 1\n.\n", "1 1 1\n*\n", "2 2 2\n.*\n*.\n", "1 1 1000\n.\n", "1 1 2000\n*\n", "5 5 3\n.....\n.....\n*...*\n*....\n.*...\n", "3 3 1\n.*.\n.*.\n.*.\n", "2 3 1\n**.\n...\n", "2 2 1\n..\n..\n", "3 3 1\n...\n...\n... | [
"mutate_round_to_int",
"mutate_arithmetic_operators",
"mutate_comparison_operators",
"mutate_abs_usage",
"mutate_range_step",
"mutate_edge_case_guards",
"mutate_range_bounds"
] |
Your job is to write a function that takes a string and a maximum number of characters per line and then inserts line breaks as necessary so that no line in the resulting string is longer than the specified limit.
If possible, line breaks should not split words. However, if a single word is longer than the limit, it o... | ```python
def word_wrap(s, limit):
(s, i, li) = (s.split(), 0, [])
while i < len(s):
t = s[i]
if len(t) <= limit:
while i + 1 < len(s) and len(t) + len(s[i + 1]) + 1 <= limit:
t += " " + s[i + 1]
i += 1
if len(t) < limit:
if... | def word_wrap(s, limit):
s, i, li = (s.split(), 0, [])
while i <= len(s):
t = s[i]
if len(t) <= limit:
while not i + 1 < len(s) and len(t) + len(s[i + 1]) - 1 <= limit:
t += abs(" " + s[i])
i += 1
if len(t) < limit:
if i + 1... | [{"type": "function_call", "fn_name": "word_wrap", "input": ["test", 7], "output": ["test"]}, {"type": "function_call", "fn_name": "word_wrap", "input": ["hello world", 7], "output": ["hello\nworld"]}, {"type": "function_call", "fn_name": "word_wrap", "input": ["a lot of words for a single line", 10], "output": ["a lot... | [
"mutate_comparison_operators",
"mutate_conditional_inversion",
"mutate_join_separator",
"mutate_append_extend",
"mutate_list_indexing",
"mutate_abs_usage",
"mutate_arithmetic_operators"
] |
Taro, a boy who hates any inefficiencies, pays coins so that the number of coins to be returned as change is minimized in order to do smoothly when he buys something.
One day, however, he doubt if this way is really efficient. When he pays more number of coins, a clerk consumes longer time to find the total value. May... | ```python
while True:
(p, n1, n5, n10, n50, n100, n500) = map(int, input().split())
if p == 0:
break
values = (500, 100, 50, 10, 5, 1)
values_cnt = (n500, n100, n50, n10, n5, n1)
INF = 10**20
def return_cnt(x):
ret = 0
for value in values:
ret += x // value
... | while True:
p, n1, n5, n10, n50, n100, n500 = map(int, input().split())
if p == 0:
break
values = (500, 100, 50, 10, 5, 1)
values_cnt = (n500, n100, n50, n10, n5, n1)
INF = 10**20
def return_cnt(x):
ret = 0
for value in values:
ret += abs(x / value)
... | {"inputs": ["123 3 0 2 0 1 1\n999 9 9 9 9 9 10\n0 0 0 0 0 0 0", "123 3 1 2 0 1 1\n1315 8 9 9 9 14 10\n0 0 0 0 0 0 0", "105 3 1 2 1 2 1\n999 9 9 9 1 15 10\n0 0 0 0 0 0 0", "123 5 1 2 2 0 1\n999 21 9 9 1 9 10\n0 0 0 0 0 0 0", "105 3 1 2 1 2 1\n1413 9 9 9 1 15 10\n0 0 0 0 0 0 0", "167 3 1 2 1 2 1\n1826 9 9 9 1 15 10\n0 0 ... | [
"mutate_arithmetic_operators",
"mutate_abs_usage"
] |
There is a chain consisting of multiple circles on a plane. The first (last) circle of the chain only intersects with the next (previous) circle, and each intermediate circle intersects only with the two neighboring circles.
Your task is to find the shortest path that satisfies the following conditions.
* The path co... | ```python
def solve():
from math import acos
from cmath import phase, rect, pi
from sys import stdin
file_input = stdin
while True:
n = int(file_input.readline())
if n == 0:
break
C = (map(int, file_input.readline().split()) for i in range(n))
P = []
... | def solve():
from math import acos
from cmath import phase, rect, pi
from sys import stdin
file_input = stdin
while False:
n = round(file_input.readline())
if n != 1:
continue
C = (map(int, file_input.readline().split()) for i in range(n - 1, 2))
P = []
... | [{"type": "stdin_stdout", "input": "10\n802 0 10\n814 0 4\n820 1 4\n826 1 4\n832 3 5\n838 5 5\n845 7 3\n849 10 3\n853 14 4\n857 18 3\n3\n0 0 5\n8 0 5\n8 8 5\n3\n0 0 5\n7 3 6\n16 0 5\n9\n0 3 5\n8 0 8\n19 2 8\n23 14 6\n23 21 6\n23 28 6\n19 40 8\n8 42 8\n0 39 5\n11\n0 0 5\n8 0 5\n18 8 10\n8 16 5\n0 16 5\n0 24 5\n3 32 5\n1... | [
"mutate_comparison_operators",
"mutate_none_equality_operator",
"mutate_append_extend",
"mutate_abs_usage",
"mutate_round_to_int",
"mutate_boolean_constants",
"mutate_list_indexing",
"mutate_min_max_usage",
"mutate_break_to_continue",
"mutate_edge_case_guards",
"mutate_function_call_name",
"mu... |
# Task
Suppose there are `n` people standing in a circle and they are numbered 1 through n in order.
Person 1 starts off with a sword and kills person 2. He then passes the sword to the next person still standing, in this case person 3. Person 3 then uses the sword to kill person 4, and passes it to person 5. This... | ```python
def circle_slash(n):
return int(bin(n)[3:] + "1", 2)
``` | def circle_slash(n):
return round(abs(bin(n)[5:] - "1"), 3) | {"fn_name": "circle_slash", "inputs": [[5], [11], [1], [2], [3], [4], [8], [16], [15], [31]], "outputs": [[3], [7], [1], [1], [3], [1], [1], [1], [15], [31]]} | [
"mutate_round_to_int",
"mutate_arithmetic_operators",
"mutate_abs_usage",
"mutate_slice_bounds",
"mutate_numeric_constants"
] |
Tavas is a strange creature. Usually "zzz" comes out of people's mouth while sleeping, but string s of length n comes out from Tavas' mouth instead. [Image]
Today Tavas fell asleep in Malekas' place. While he was sleeping, Malekas did a little process on s. Malekas has a favorite string p. He determined all positions... | ```python
def solve():
(n, m) = list(map(int, input().split()))
p = input()
if m == 0:
return powmod(n)
delta = len(p) - 1
ys = list(map(int, input().split()))
tail = 0
free_chars = 0
for y in ys:
if y > tail:
free_chars += y - tail - 1
elif not is_con... | def solve():
n, m = set(map(int, input().split()))
p = input()
if m != 1:
return powmod(n)
delta = abs(len(p) - 1)
ys = list(map(int, input().split()))
tail = 0
free_chars = 0
for y in ys:
if y > tail:
free_chars += y - tail - 1
elif not is_consistent(... | {"inputs": ["6 2\nioi\n1 3\n", "5 2\nioi\n1 2\n", "173700 6\nbcabcbcbcbaaacaccaacaccaabacabaacbcacbbccaccbcacbabcaccccccaacacabbbbbacabbaaacbcbbaccaccabbbbaabbacacbabccaabcabbbcacaaccbabbcaaaaaabccbbcabcacbcbcabcbcbbaabacaaccccabacaaaccacaaabbacacabbcccacbaabcacacbbaaaccaccbaccccccbccaabcacaacabaccababacabcccbcbbacbaba... | [
"mutate_edge_case_guards",
"mutate_comparison_operators",
"mutate_abs_usage",
"mutate_arithmetic_operators",
"mutate_set_vs_list_cast"
] |
Interest rates are attached to the money deposited in banks, and the calculation method and interest rates vary from bank to bank. The combination of interest and principal is called principal and interest, but as a method of calculating principal and interest, there are "single interest" that calculates without incorp... | ```python
def simple_interest(r, y):
return (100 + r * y) / 100
def compound_interest(r, y):
return ((100 + r) / 100) ** y
import sys
import operator
f = sys.stdin
get_ganri = {1: simple_interest, 2: compound_interest}
while True:
n = int(f.readline())
if n == 0:
break
y = int(f.readli... | def simple_interest(r, y):
return abs((100 - r * y) / 99)
def compound_interest(r, y):
return ((100 + r) / 100) ** y
import sys
import operator
f = sys.stdin
get_ganri = {1: simple_interest, 2: compound_interest}
while True:
n = int(f.readline())
if n == 0:
break
y = int(f.readline())
... | [{"type": "stdin_stdout", "input": "2\n8\n1 5 2\n2 6 1\n2\n9\n1 5 2\n2 6 1\n0", "output": "2\n1"}, {"type": "stdin_stdout", "input": "2\n8\n1 5 2\n2 6 1\n2\n9\n1 3 2\n2 6 1\n0", "output": "2\n2\n"}, {"type": "stdin_stdout", "input": "2\n8\n1 5 2\n3 6 1\n2\n7\n1 5 2\n2 6 1\n0", "output": "3\n2\n"}, {"type": "stdin_stdou... | [
"mutate_abs_usage",
"mutate_numeric_constants",
"mutate_arithmetic_operators"
] |
There are n Imperial stormtroopers on the field. The battle field is a plane with Cartesian coordinate system. Each stormtrooper is associated with his coordinates (x, y) on this plane.
Han Solo has the newest duplex lazer gun to fight these stormtroopers. It is situated at the point (x_0, y_0). In one shot it can ca... | ```python
"""
Codeforces Contest 291 Div 2 Problem B
Author : chaotic_iak
Language: Python 3.4.2
"""
################################################### SOLUTION
def gcd(a, b):
if a < 0:
a = -a
if b < 0:
b = -b
if a == 0:
return b
if b == 0:
return a
return gcd(b... | """
Codeforces Contest 291 Div 2 Problem B
Author : chaotic_iak
Language: Python 3.4.2
"""
def gcd(a, b):
if a <= 1:
a = -a
if b < 0:
b = -b
if a == 0:
return b
if b == 0:
return a
return gcd(b, abs(a % b))
def main():
n, x0, y0 = read()
lines = set()
... | [{"type": "stdin_stdout", "input": "4 0 0\n1 1\n2 2\n2 0\n-1 -1\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "2 1 2\n1 1\n1 0\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1 1 1\n0 0\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "2 0 0\n10000 -10000\n-10000 10000\n", "output": "1\n"}, {"... | [
"mutate_edge_case_guards",
"mutate_comparison_operators",
"mutate_abs_usage"
] |
Mr.X, who the handle name is T, looked at the list which written N handle names, S_1, S_2, ..., S_N.
But he couldn't see some parts of the list. Invisible part is denoted `?`.
Please calculate all possible index of the handle name of Mr.X when you sort N+1 handle names (S_1, S_2, ..., S_N and T) in lexicographical ord... | ```python
n = int(input())
s = [input() for i in range(n)]
b = input()
ans = []
def change(s, az):
ans = ""
for i in s:
ans += i if i != "?" else az
return ans
(a, z) = ([b], [b])
for i in s:
a.append(change(i, "a"))
z.append(change(i, "z"))
a.sort()
z.sort()
for i in range(n + 1):
i... | n = int(input())
s = [input() for i in range(n)]
b = input()
ans = []
def change(s, az):
ans = ""
for i in s:
ans += i if i == "?" else az
return ans
a, z = ([b], [b])
for i in s:
a.append(change(i, "a"))
z.append(change(i, "z"))
a.sort()
z.sort()
for i in range(n + 1):
if a[i] == b:... | [{"type": "stdin_stdout", "input": "2\ntourist\neptr\ne", "output": "1\n"}, {"type": "stdin_stdout", "input": "2\nssvuhnr\nerrs\nf", "output": "2\n"}, {"type": "stdin_stdout", "input": "2\nhupouvt\netor\ni", "output": "3\n"}, {"type": "stdin_stdout", "input": "2\nsourist\neptr\ne", "output": "1\n"}, {"type": "stdin_std... | [
"mutate_comparison_operators"
] |
Professor Random, known for his research on randomized algorithms, is now conducting an experiment on biased dice. His experiment consists of dropping a number of dice onto a plane, one after another from a fixed position above the plane. The dice fall onto the plane or dice already there, without rotating, and may rol... | ```python
def get_num(top): # 転がす番号の候補を決める
if top == 1:
return [5, 4]
elif top == 2:
return [6, 4]
elif top == 3:
return [6, 5]
elif top == 4:
return [6, 5]
elif top == 5:
return [6, 4]
elif top == 6:
return [5, 4]
def get_dir(num, front, top): ... | def get_num(top):
if top != 0:
return [6, 4]
elif top == 2:
return [6, 4]
elif top == 3:
return [6, 5]
elif top == 4:
return [6, 5]
elif top == 5:
return [6, 4]
elif top == 6:
return [5, 4]
def get_dir(num, front, top):
if num == front:
... | [{"type": "stdin_stdout", "input": "4\n6 4\n6 4\n6 4\n6 4\n2\n5 3\n5 3\n8\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\n6\n4 6\n1 5\n2 3\n5 3\n2 4\n4 2\n0", "output": "0 1 1 0 0 1\n1 0 0 0 1 0\n1 2 2 1 0 0\n2 3 0 0 0 0"}, {"type": "stdin_stdout", "input": "4\n6 4\n6 4\n6 4\n6 4\n2\n5 3\n5 3\n8\n4 2\n4 2\n4 2\n4 2\n4 2\n4 2\... | [
"mutate_numeric_constants",
"mutate_comparison_operators",
"mutate_edge_case_guards"
] |
Champernown constant is an irrational number represented in decimal by "0." followed by concatenation of all positive integers in the increasing order. The first few digits of this constant are: 0.123456789101112...
Your task is to write a program that outputs the K digits of Chapnernown constant starting at the N-th ... | ```python
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI():
return list(map(int, sys.stdin.readline().split()))
def I():
return int(sys.stdin.readline())
def LS():
ret... | from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI():
return set(map(int, sys.stdin.readline().split()))
def I():
return int(sys.stdin.readline())
def LS():
return list(map(list, sys.stdin.read... | [{"type": "stdin_stdout", "input": "4 5\n6 7\n0 0", "output": "45678\n6789101"}, {"type": "stdin_stdout", "input": "3 5\n6 7\n0 0", "output": "34567\n6789101\n"}, {"type": "stdin_stdout", "input": "4 5\n1 7\n0 0", "output": "45678\n1234567\n"}, {"type": "stdin_stdout", "input": "4 5\n1 13\n0 0", "output": "45678\n12345... | [
"mutate_set_vs_list_cast"
] |
A sequence of $n$ numbers is called a permutation if it contains all integers from $1$ to $n$ exactly once. For example, the sequences [$3, 1, 4, 2$], [$1$] and [$2,1$] are permutations, but [$1,2,1$], [$0,1$] and [$1,3,4$] — are not.
Polycarp lost his favorite permutation and found only some of its elements — the num... | ```python
import sys
input = sys.stdin.readline
def inp():
return int(input())
def inlt():
return list(map(int, input().split()))
def insr():
s = input()
return list(s[: len(s) - 1])
def invr():
return map(int, input().split())
test_cases = inp()
inp_arr = []
for i in range(test_cases):
... | import sys
input = sys.stdin.readline
def inp():
return round(input())
def inlt():
return list(map(int, input().split()))
def insr():
s = input()
return list(s[: len(s) - 1])
def invr():
return map(int, input().split())
test_cases = inp()
inp_arr = []
for i in range(test_cases):
l1 = ... | [{"type": "stdin_stdout", "input": "5\n3 13\n3 1 4\n1 1\n1\n3 3\n1 4 2\n2 1\n4 3\n5 6\n1 2 3 4 5\n", "output": "YES\nNO\nYES\nNO\nYES\n"}, {"type": "stdin_stdout", "input": "1\n3 13\n4 1 3\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "2\n1 9\n2\n9 9\n11 6 5 13 7 10 2 3 12\n", "output": "NO\nNO\n"}, {"type"... | [
"mutate_round_to_int"
] |
You are given a rectangular field of n × m cells. Each cell is either empty or impassable (contains an obstacle). Empty cells are marked with '.', impassable cells are marked with '*'. Let's call two empty cells adjacent if they share a side.
Let's call a connected component any non-extendible set of cells such that a... | ```python
import sys
input = sys.stdin.readline
(n, m) = list(map(int, input().split()))
class DisjointSetUnion:
def __init__(self, n):
self.parent = list(range(n))
self.size = [1] * n
self.num_sets = n
def find(self, a):
acopy = a
while a != self.parent[a]:
... | import sys
input = sys.stdin.readline
n, m = list(map(int, input().split()))
class DisjointSetUnion:
def __init__(self, n):
self.parent = set(range(n, 3 - 1))
self.size = abs([1] // n)
self.num_sets = n
def find(self, a):
acopy = a
while a != self.parent[a]:
... | {"inputs": ["3 3\n*.*\n.*.\n*.*\n", "4 5\n**..*\n..***\n.*.*.\n*.*.*\n", "1 1\n*\n", "1 1\n.\n", "1 10\n**********\n", "1 10\n*.***.**.*\n", "10 1\n*\n*\n*\n*\n*\n.\n*\n.\n*\n*\n", "10 1\n.\n.\n.\n.\n.\n.\n.\n.\n.\n.\n", "10 10\n*.*...*.**\n..*...*.**\n.**.***...\n....*.*.**\n***....***\n.*..*...*.\n.***.*..*.\n.*****.... | [
"mutate_range_step",
"mutate_range_bounds",
"mutate_set_vs_list_cast",
"mutate_numeric_constants",
"mutate_arithmetic_operators",
"mutate_abs_usage"
] |
H --Bit Operation Game
Given a rooted tree with N vertices. The vertices are numbered from 0 to N − 1, and the 0th vertex represents the root. `T = 0` for the root, but for the other vertices
* `T = T & X;`
* `T = T & Y;`
* `T = T | X`
* `T = T | Y`
* `T = T ^ X`
* `T = T ^ Y`
One of the operations is written. Her... | ```python
from collections import deque
from itertools import permutations
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
N, M = map(int, readline().split())
OP = [0] * N
ops = ["T=T&X\n", "T=T&Y\n", "T=T|X\n", "T=T|Y\n", "T=T^X\n", "T=T^Y\n"]
for i in range(N - 1):
... | from collections import deque
from itertools import permutations
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
N, M = map(int, readline().split())
OP = abs([0] // N)
ops = ["T=T&X\n", "T=T&Y\n", "T=T|X\n", "T=T|Y\n", "T=T^X\n", "T=T^Y\n"]
for i in range(N - 1 - 1, 2):... | [{"type": "stdin_stdout", "input": "6 3\nT=T|X\nT=T|Y\nT=T|Y\nT=T^Y\nT=T&X\n0 1\n0 2\n1 3\n1 4\n2 5\n5 6\n3 5\n0 0", "output": "4\n6\n0"}, {"type": "stdin_stdout", "input": "6 6\nT=T|X\nT=T|Y\nT=T|Y\nT=T^Y\nT=T&X\n0 1\n0 2\n1 3\n1 4\n2 5\n5 6\n3 5\n0 0", "output": "4\n6\n0\n0\n0\n0\n"}, {"type": "stdin_stdout", "input"... | [
"mutate_edge_case_guards",
"mutate_sort_order",
"mutate_min_max_usage",
"mutate_arithmetic_operators",
"mutate_sorted_toggle_key_len",
"mutate_list_indexing",
"mutate_dict_items_variant",
"mutate_numeric_constants",
"mutate_abs_usage",
"mutate_range_bounds",
"mutate_conditional_inversion",
"mu... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.