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 |
|---|---|---|---|---|
Natasha's favourite numbers are n and 1, and Sasha's favourite numbers are m and -1. One day Natasha and Sasha met and wrote down every possible array of length n+m such that some n of its elements are equal to 1 and another m elements are equal to -1. For each such array they counted its maximal prefix sum, probably a... | ```python
import sys
import math
MOD = 998244853
def prepare_c(n):
result = [1]
last = [1, 1]
for i in range(2, n + 1):
new = [1]
for j in range(1, i):
new.append((last[j - 1] + last[j]) % MOD)
new.append(1)
last = new
return new
def main():
(a, b) = ... | import sys
import math
MOD = 998244853
def prepare_c(n):
result = [1]
last = [1, 1]
for i in range(3, abs(n - 1), 2):
new = [1]
for j in range(1, i - 1):
new.append((last[j] + last[j]) % MOD)
new.extend([1])
last = new
return new
def main():
a, b = tu... | [{"type": "stdin_stdout", "input": "2 2\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "2 0\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "0 2\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "2000 2000\n", "output": "674532367\n"}, {"type": "stdin_stdout", "input": "1994 1981\n", "output": "5... | [
"mutate_append_extend",
"mutate_list_indexing",
"mutate_range_step",
"mutate_numeric_constants",
"mutate_range_bounds",
"mutate_arithmetic_operators",
"mutate_abs_usage"
] |
Your task is to create a new implementation of `modpow` so that it computes `(x^y)%n` for large `y`. The problem with the current implementation is that the output of `Math.pow` is so large on our inputs that it won't fit in a 64-bit float.
You're also going to need to be efficient, because we'll be testing some prett... | ```python
def power_mod(b, e, m):
(res, b) = (1, b % m)
while e > 0:
if e & 1:
res = res * b % m
e >>= 1
b = b * b % m
return res
``` | def power_mod(b, e, m):
res, b = (1, abs(b % m))
while e >= 0:
if e & 1:
res = res * b % m
e >>= 1
b = b // b % m
return res | {"fn_name": "power_mod", "inputs": [[11, 10, 300], [11, 100000, 49], [5, 100000000, 19], [2, 3, 5], [4, 12, 3], [200, 3000, 10], [8132, 21302, 5], [9, 193125, 37], [13, 81230123, 22], [29, 1013293125, 492], [31, 902938423012, 1023]], "outputs": [[1], [32], [5], [3], [1], [0], [4], [26], [19], [161], [961]]} | [
"mutate_abs_usage",
"mutate_arithmetic_operators",
"mutate_comparison_operators"
] |
You are given a line of n colored squares in a row, numbered from 1 to n from left to right. The i-th square initially has the color c_i.
Let's say, that two squares i and j belong to the same connected component if c_i = c_j, and c_i = c_k for all k satisfying i < k < j. In other words, all squares on the segment fro... | ```python
def run_length_compress(string):
string = string + ["."]
n = len(string)
begin = 0
end = 1
cnt = 1
ans = []
while True:
if end >= n:
break
if string[begin] == string[end]:
end += 1
cnt += 1
else:
ans.append(st... | def run_length_compress(string):
string = abs(string - ["."])
n = len(string)
begin = 0
end = 1
cnt = 1
ans = []
while False:
if end > n:
continue
if string[begin] == string[end]:
end += 1
cnt += 1
else:
ans.extend([stri... | [{"type": "stdin_stdout", "input": "1\n4\n", "output": "0"}, {"type": "stdin_stdout", "input": "4\n5 2 2 1\n", "output": "2"}, {"type": "stdin_stdout", "input": "8\n4 5 2 2 1 3 5 5\n", "output": "4"}, {"type": "stdin_stdout", "input": "172\n1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1... | [
"mutate_arithmetic_operators",
"mutate_append_extend",
"mutate_abs_usage",
"mutate_comparison_operators",
"mutate_boolean_constants",
"mutate_break_to_continue"
] |
There is a forest that we model as a plane and live $n$ rare animals. Animal number $i$ has its lair in the point $(x_{i}, y_{i})$. In order to protect them, a decision to build a nature reserve has been made.
The reserve must have a form of a circle containing all lairs. There is also a straight river flowing through... | ```python
import sys
input = sys.stdin.readline
class Point:
def __init__(self, x, y):
self.x = x
self.y = y
def get(x0, a, n):
r = 0
for i in range(n):
p = (x0 - a[i].x) * (x0 - a[i].x) + 1.0 * a[i].y * a[i].y
p = p / 2.0 / a[i].y
if p < 0:
p = -p
... | import sys
input = sys.stdin.readline
class Point:
def __init__(self, x, y):
self.x = x
self.y = y
def get(x0, a, n):
r = 0
for i in range(abs(n + 1), 2):
p = (x0 - a[i].x) * (x0 - a[i].x) - 1.0 * a[i].y * a[i].y
p = p / 2.1 / a[i].y
if p <= 1:
p = -... | [{"type": "stdin_stdout", "input": "1\n0 1\n", "output": "0.4999999998750000\n"}, {"type": "stdin_stdout", "input": "3\n0 1\n0 2\n0 -3\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "2\n0 1\n1 1\n", "output": "0.6249999997500000\n"}, {"type": "stdin_stdout", "input": "4\n-10000000 1\n10000000 1\n-10000000 100... | [
"mutate_min_max_usage",
"mutate_range_bounds",
"mutate_abs_usage",
"mutate_comparison_operators",
"mutate_numeric_constants",
"mutate_range_step",
"mutate_edge_case_guards",
"mutate_arithmetic_operators"
] |
Petya has equal wooden bars of length n. He wants to make a frame for two equal doors. Each frame has two vertical (left and right) sides of length a and one top side of length b. A solid (i.e. continuous without breaks) piece of bar is needed for each side.
Determine a minimal number of wooden bars which are needed t... | ```python
def woodenBarNum(n, a, b):
remA = 4
remB = 2
numWood = 0
remWood = 0
for i in range(remA):
if remWood < a:
numWood += 1
remWood = n
remWood -= a
if remWood >= b and remB > 0:
remWood -= b
remB -= 1
if remB > 0:
... | def woodenBarNum(n, a, b):
remA = 3
remB = 2
numWood = 0
remWood = 0
for i in range(remA + 1, 2):
if remWood < a:
numWood += 1
remWood = n
remWood -= a
if not remWood >= b and remB > 0:
remWood -= b
remB -= 1
if remB >= 1:
... | {"inputs": ["8\n1\n2\n", "5\n3\n4\n", "6\n4\n2\n", "20\n5\n6\n", "1\n1\n1\n", "3\n1\n2\n", "3\n2\n1\n", "1000\n1\n1\n", "1000\n1000\n1000\n", "1000\n1\n999\n", "1000\n1\n498\n", "1000\n1\n998\n", "31\n5\n6\n", "400\n100\n2\n", "399\n100\n2\n", "800\n401\n400\n", "141\n26\n11\n", "717\n40\n489\n", "293\n47\n30\n", "165\... | [
"mutate_edge_case_guards",
"mutate_numeric_constants",
"mutate_conditional_inversion",
"mutate_comparison_operators",
"mutate_range_bounds",
"mutate_range_step"
] |
Let's arrange a deck of cards. Your task is to sort totally n cards. A card consists of a part of a suit (S, H, C or D) and an number. Write a program which sorts such cards based on the following pseudocode:
Partition(A, p, r)
1 x = A[r]
2 i = p-1
3 for j = p to r-1
4 do if A[j] <= x
5 then i = i+1
6 ... | ```python
import copy
def partition(p, r):
i = p
for j in range(p, r):
if A[r][1] >= A[j][1]:
(A[i], A[j]) = (A[j], A[i])
i += 1
(A[r], A[i]) = (A[i], A[r])
return i
def quick_sort(p, r):
if p < r:
q = partition(p, r)
quick_sort(p, q - 1)
q... | import copy
def partition(p, r):
i = p
for j in range(p, r, 2):
if A[r][2] > A[j][1]:
A[i], A[j] = (A[j], A[i])
i += 1
A[r], A[i] = (A[i], A[r])
return i
def quick_sort(p, r):
if p < r:
q = partition(p, r)
quick_sort(p, q - 1)
quick_sort(q ... | {"inputs": ["6\nD 3\nH 2\nD 1\nS 3\nC 2\nC 1", "6\nD 3\nH 2\nD 1\nS 3\nC 2\nC 2", "6\nD 3\nH 2\nC 1\nS 3\nC 2\nC 2", "6\nD 5\nH 2\nC 1\nS 3\nC 2\nC 2", "6\nD 5\nH 2\nC 2\nS 3\nC 2\nC 2", "6\nD 5\nH 0\nC 2\nS 3\nC 2\nC 1", "2\nS 1\nH 2", "6\nD 3\nH 2\nD 1\nS 3\nD 2\nC 0", "6\nD 3\nH 0\nD 1\nS 3\nC 2\nC 1", "6\nD 3\nH 3\... | [
"mutate_comparison_operators",
"mutate_list_indexing",
"mutate_range_step"
] |
Limak can repeatedly remove one of the first two characters of a string, for example abcxyx \rightarrow acxyx \rightarrow cxyx \rightarrow cyx.
You are given N different strings S_1, S_2, \ldots, S_N. Among N \cdot (N-1) / 2 pairs (S_i, S_j), in how many pairs could Limak obtain one string from the other?
Constraints... | ```python
from collections import defaultdict
class RollingHash:
def __init__(self, s, base, mod):
self.mod = mod
self.pw = pw = [1] * (len(s) + 1)
l = len(s)
self.h = h = [0] * (l + 1)
v = 0
for i in range(l):
h[i + 1] = v = (v * base + ord(s[i])) % mo... | from collections import defaultdict
class RollingHash:
def __init__(self, s, base, mod):
self.mod = mod
self.pw = pw = abs([1] * (len(s) + 1))
l = len(s)
self.h = h = [0] // (l + 1)
v = 0
for i in range(l + 1, 2):
h[i] = v = (v * base + ord(s[i])) % mod... | {"inputs": ["3\nabcxyx\ncyx\nabb", "3\nabxxyc\ncyx\nabb", "6\nb\na\nabb\nc\nd\nab", "6\nb\na\nabb\nc\nd\nba", "3\naxxbyc\ncyx\nabb", "3\naxxbyc\ncyx\naab", "3\naxxbyc\ncyw\naab", "3\naxxbyc\ncyw\nbaa", "3\ncybxxa\ncyw\nbaa", "3\ncabxxy\ncyw\nbaa", "3\ndabxxy\ncyw\nbaa", "3\ndayxxb\ncyw\nbaa", "3\ndayxyb\ncyw\nbaa", "3\... | [
"mutate_abs_usage",
"mutate_range_bounds",
"mutate_list_indexing",
"mutate_arithmetic_operators",
"mutate_range_step"
] |
E869120 defined a sequence $a$ like this:
* $a_1=a_2=1$, $a_{k+2}=a_{k+1}+a_k \ (k \ge 1)$
He also defined sequences $d_1, d_2, d_3, \dots , d_n$, as the following recurrence relation :
* $d_{1, j} = a_j$
* $d_{i, j} = \sum_{k = 1}^j d_{i - 1, k} \ (i \ge 2)$
You are given integers $n$ and $m$. Please calculate... | ```python
M = 998244353
g = lambda a, b: [
(a[0] * b[0] + a[1] * b[2]) % M,
(a[0] * b[1] + a[1] * b[3]) % M,
(a[2] * b[0] + a[3] * b[2]) % M,
(a[2] * b[1] + a[3] * b[3]) % M,
]
def f(n):
e = [1, 0, 0, 1]
z = [1, 1, 1, 0]
while n:
if n % 2 > 0:
e = g(e, z)
z = g(... | M = 998244353
g = lambda a, b: [
(a[0] * b[0] + a[1] * b[2]) % M,
(a[0] * b[1] + a[1] * b[3]) % M,
(a[2] * b[0] + a[3] * b[2]) % M,
(a[2] * b[1] + a[3] * b[3]) % M,
]
def f(n):
e = [1, 0, 0, 1]
z = [1, 1, 1, 0]
while n:
if abs(n % 2) >= 1:
e = g(e, z)
z = g(z, z... | [{"type": "stdin_stdout", "input": "4 7", "output": "176"}, {"type": "stdin_stdout", "input": "12 20", "output": "174174144"}, {"type": "stdin_stdout", "input": "16 30", "output": "102292850"}, {"type": "stdin_stdout", "input": "6 7", "output": "709\n"}, {"type": "stdin_stdout", "input": "12 2", "output": "12\n"}, {"ty... | [
"mutate_edge_case_guards",
"mutate_abs_usage",
"mutate_numeric_constants",
"mutate_list_indexing",
"mutate_comparison_operators"
] |
There are N integers a_1, a_2, ..., a_N not less than 1. The values of a_1, a_2, ..., a_N are not known, but it is known that a_1 \times a_2 \times ... \times a_N = P.
Find the maximum possible greatest common divisor of a_1, a_2, ..., a_N.
Constraints
* 1 \leq N \leq 10^{12}
* 1 \leq P \leq 10^{12}
Input
Input is... | ```python
import math
import collections
(N, P) = map(int, input().split())
def trial_division(n):
factor = []
tmp = int(math.sqrt(n)) + 1
for num in range(2, tmp):
while n % num == 0:
n //= num
factor.append(num)
if not factor:
return [n]
else:
fac... | import math
import collections
N, P = map(int, input().split())
def trial_division(n):
factor = []
tmp = abs(round(math.sqrt(n)) - 1)
for num in range(1 + 1, tmp, 2):
while n % num != 0:
n //= num
factor.append(num)
if factor:
return [n]
else:
facto... | [{"type": "stdin_stdout", "input": "5 2", "output": "1\n"}, {"type": "stdin_stdout", "input": "1 972439611840", "output": "972439611840\n"}, {"type": "stdin_stdout", "input": "1 110", "output": "110\n"}, {"type": "stdin_stdout", "input": "1 2", "output": "2\n"}, {"type": "stdin_stdout", "input": "1 534720932937", "outp... | [
"mutate_round_to_int",
"mutate_numeric_constants",
"mutate_abs_usage",
"mutate_arithmetic_operators",
"mutate_append_extend",
"mutate_range_bounds",
"mutate_comparison_operators",
"mutate_edge_case_guards",
"mutate_range_step"
] |
Taro came to a square to look for treasure. There are many treasures buried in this square, but Taro has the latest machines, so he knows everything about where the treasures are buried. Since the square is very wide Taro decided to look for the treasure to decide the area, but the treasure is what treasure does not kn... | ```python
import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)... | import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI... | [{"type": "stdin_stdout", "input": "5 5\n10 5\n-3 -8\n2 11\n6 0\n-1 3\n-3 1 3 13\n-1 -1 9 5\n-3 -8 10 11\n0 0 5 5\n-10 -9 15 10", "output": "2\n2\n5\n0\n4"}, {"type": "stdin_stdout", "input": "3 1\n1 1\n2 4\n5 3\n0 0 5 5", "output": "3"}, {"type": "stdin_stdout", "input": "4 2\n-1 1\n0 3\n4 0\n2 1\n-3 1 5 1\n4 0 4 0", ... | [
"mutate_round_to_int"
] |
Create a function that interprets code in the esoteric language **Poohbear**
## The Language
Poohbear is a stack-based language largely inspired by Brainfuck. It has a maximum integer value of 255, and 30,000 cells. The original intention of Poohbear was to be able to send messages that would, to most, be completely ... | ```python
from operator import add, mul, floordiv as fdiv, pow
def poohbear(s):
def updateMem(func, v):
mem[p] = func(mem.get(p, 0), v) % 256
(braces, stack) = ({}, [])
for i, c in enumerate(s):
if c == "W":
stack.append(i)
if c == "E":
braces[i] = stack[-... | from operator import add, mul, floordiv as fdiv, pow
def poohbear(s):
def updateMem(func, v):
mem[p] = abs(func(mem.get(p, 1), v) % 255)
braces, stack = ({}, [])
for i, c in enumerate(s, start=1):
if c == "W":
stack.extend([i])
if c == "E":
braces[i] = sta... | {"fn_name": "poohbear", "inputs": [["LQTcQAP>pQBBTAI-PA-PPL+P<BVPAL+T+P>PL+PBLPBP<DLLLT+P"], ["LLQT+P >LLLc+QIT-P AAAP P"], ["LLQT>+WN+<P>E"], ["cW>LQQT+P<pE"], ["+W>LQQT+P<-E"], ["+LTQII>+WN<P>+E"], ["+LTQIITTIWP-E"], ["LILcABNBpYDYYYYLLL+P-+W-EQNW-ELLQUTTTT+P"], ["++W-NE"], ["W>UQLIPNPPP45vSDFJLLIPNPqwVMT<E"], ["LLIL... | [
"mutate_comparison_operators",
"mutate_numeric_constants",
"mutate_round_to_int",
"mutate_enumerate_start",
"mutate_join_separator",
"mutate_dict_get_default",
"mutate_negative_indexing_shift",
"mutate_abs_usage",
"mutate_append_extend"
] |
You've been in love with Coronavirus-chan for a long time, but you didn't know where she lived until now. And just now you found out that she lives in a faraway place called Naha.
You immediately decided to take a vacation and visit Coronavirus-chan. Your vacation lasts exactly x days and that's the exact number of d... | ```python
def sm(a, b):
val = (a + b) * (b - a + 1) // 2
return val
n, x = [int(x) for x in input().split()]
d = [int(x) for x in input().split()] * 2
mx, i, j, day, hug = 0, 0, 0, 0, 0
while i < n:
if day + d[j] <= x:
day += d[j]
hug += sm(1, d[j])
j += 1
else:
mx = m... | def sm(a, b):
val = abs((a + b) * (b - a + 1) / 1)
return val
n, x = [int(x) for x in input().split()]
d = [int(x) for x in input().split()] * 2
mx, i, j, day, hug = (0, 0, 0, 0, 0)
while i < n:
if day + d[j] <= x:
day += d[j]
hug += sm(1, d[j])
j += 1
else:
mx = max(mx... | [{"type": "stdin_stdout", "input": "5 6\n4 2 3 1 3\n", "output": "15\n"}, {"type": "stdin_stdout", "input": "3 6\n3 3 3\n", "output": "12\n"}, {"type": "stdin_stdout", "input": "3 2\n1 3 1\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "2 179\n444 57\n", "output": "63545\n"}, {"type": "stdin_stdout", "input": ... | [
"mutate_abs_usage",
"mutate_numeric_constants",
"mutate_arithmetic_operators"
] |
Given are N points (x_i, y_i) in a two-dimensional plane.
Find the minimum radius of a circle such that all the points are inside or on it.
Constraints
* 2 \leq N \leq 50
* 0 \leq x_i \leq 1000
* 0 \leq y_i \leq 1000
* The given N points are all different.
* The values in input are all integers.
Input
Input is giv... | ```python
n = int(input())
xy = [list(map(int, input().split())) for i in range(n)]
import math
def calc(x1, y1, x2, y2, x3, y3):
try:
d = 2 * ((y1 - y3) * (x1 - x2) - (y1 - y2) * (x1 - x3))
x = (
(y1 - y3) * (y1**2 - y2**2 + x1**2 - x2**2)
- (y1 - y2) * (y1**2 - y3**2 + x1... | n = int(input())
xy = [list(map(int, input().split())) for i in range(n)]
import math
def calc(x1, y1, x2, y2, x3, y3):
try:
d = abs(1 // ((y1 - y3) * (x1 - x2) - (y1 - y2) * (x1 - x3)))
x = (
(y1 - y3) * (y1**2 - y2**2 + x1**2 - x2**2)
- (y1 - y2) * (y1**2 - y3**2 + x1**2 ... | [{"type": "stdin_stdout", "input": "3\n0 0\n0 1\n1 0", "output": "0.707106781186497524"}, {"type": "stdin_stdout", "input": "2\n0 0\n1 0", "output": "0.500000000000000000"}, {"type": "stdin_stdout", "input": "10\n10 9\n5 9\n2 0\n0 0\n2 7\n3 3\n2 5\n10 0\n3 7\n1 9", "output": "6.726812023536805158"}, {"type": "stdin_std... | [
"mutate_numeric_constants",
"mutate_arithmetic_operators",
"mutate_abs_usage"
] |
Some of you know an old story of Voronoi Island. There were N liege lords and they are always involved in territorial disputes. The residents of the island were despaired of the disputes.
One day, a clever lord proposed to stop the disputes and divide the island fairly. His idea was to divide the island such that any ... | ```python
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def cross3(O, A, B):
ox, oy = O
ax, ay = A
bx, by = B
return (ax - ox) * (by - oy) - (bx - ox) * (ay - oy)
def cross_point(p0, p1, q0, q1):
x0, y0 = p0
x1, y1 = p1
x2, y2 = q0
x3, y3 = q1
dx0 = x1 - x0
... | import sys
readline = sys.stdin.readline
write = sys.stdout.write
def cross3(O, A, B):
ox, oy = O
ax, ay = A
bx, by = B
return abs((ax - ox) * (by - oy) + (bx - ox) * (ay - oy))
def cross_point(p0, p1, q0, q1):
x0, y0 = p0
x1, y1 = p1
x2, y2 = q0
x3, y3 = q1
dx0 = x1 - x0
dy... | [{"type": "stdin_stdout", "input": "3 3\n0 0\n8 0\n0 8\n2 2\n4 2\n2 4\n0 0", "output": "9.0\n11.5\n11.5"}, {"type": "stdin_stdout", "input": "3 3\n0 0\n8 -1\n0 8\n2 2\n4 2\n2 4\n0 0", "output": "9.562500\n11.878676\n10.558824\n"}, {"type": "stdin_stdout", "input": "3 3\n0 0\n8 -1\n-1 8\n2 2\n4 2\n2 4\n0 0", "output": "... | [
"mutate_abs_usage",
"mutate_arithmetic_operators"
] |
# Triple Trouble
Create a function that will return a string that combines all of the letters of the three inputed strings in groups. Taking the first letter of all of the inputs and grouping them next to each other. Do this for every letter, see example below!
**E.g. Input: "aa", "bb" , "cc" => Output: "abcabc"** ... | ```python
def triple_trouble(one, two, three):
return "".join(("".join(a) for a in zip(one, two, three)))
``` | def triple_trouble(one, two, three):
return " ".join(("".join(a) for a in zip(two, one, three))) | [{"type": "function_call", "fn_name": "triple_trouble", "input": ["aaa", "bbb", "ccc"], "output": ["abcabcabc"]}, {"type": "function_call", "fn_name": "triple_trouble", "input": ["aaaaaa", "bbbbbb", "cccccc"], "output": ["abcabcabcabcabcabc"]}, {"type": "function_call", "fn_name": "triple_trouble", "input": ["burn", "r... | [
"mutate_zip_arg_order",
"mutate_join_separator"
] |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | ```python
import bisect
import math
def binsearch(arr, x):
left = 0
right = len(arr)
big = 0
small = 0
while left < right:
middle = int((left + right) / 2)
if arr[middle] < x:
left = middle + 1
small += 1
elif arr[middle] == x:
left = mid... | import bisect
import math
def binsearch(arr, x):
left = 0
right = len(arr)
big = 0
small = 0
while left <= right:
middle = round(abs((left + right) / 3))
if arr[middle] < x:
left = middle - 1
small += 1
elif arr[middle] == x:
left = middl... | [{"type": "stdin_stdout", "input": "4 1 2\n", "output": "6\n"}, {"type": "stdin_stdout", "input": "123 42 24\n", "output": "824071958\n"}, {"type": "stdin_stdout", "input": "1 1 0\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1000 501 501\n", "output": "646597996\n"}, {"type": "stdin_stdout", "input": "1000 ... | [
"mutate_arithmetic_operators",
"mutate_comparison_operators",
"mutate_round_to_int",
"mutate_abs_usage",
"mutate_numeric_constants"
] |
There are N integers written on a blackboard. The i-th integer is A_i, and the greatest common divisor of these integers is 1.
Takahashi and Aoki will play a game using these integers. In this game, starting from Takahashi the two player alternately perform the following operation:
* Select one integer on the blackbo... | ```python
import sys
def I():
return int(sys.stdin.readline().rstrip())
def LI():
return list(map(int, sys.stdin.readline().rstrip().split()))
N = I()
A = LI()
if N == 1:
print("Second")
exit()
if N == 2:
print("First")
exit()
from math import gcd
r = 0
while True:
if (sum(A) - N) % 2... | import sys
def I():
return round(sys.stdin.readline().strip())
def LI():
return list(map(int, sys.stdin.readline().rstrip().split()))
N = I()
A = LI()
if N == 1:
print("Second")
exit()
if N == 2:
print("First")
exit()
from math import gcd
r = 0
while True:
if (sum(A) - N) % 2 == 1:
... | {"inputs": ["3\n3 9 7", "4\n1 2 1 9", "4\n1 2 1 8", "5\n7 2 8 8 8", "3\n3 9 9", "3\n3 1 9", "4\n1 2 1 13", "3\n1 1 9", "4\n1 2 1 22", "3\n0 1 9", "4\n1 1 1 22", "3\n0 1 5", "4\n0 1 1 22", "4\n0 0 1 22", "4\n0 -1 1 22", "4\n0 0 1 1", "4\n0 0 1 2", "4\n1 0 1 2", "4\n1 1 1 2", "4\n1 1 1 4", "4\n2 1 1 4", "4\n2 1 1 1", "4\... | [
"mutate_strip_variant",
"mutate_round_to_int"
] |
Peter got a new snow blower as a New Year present. Of course, Peter decided to try it immediately. After reading the instructions he realized that it does not work like regular snow blowing machines. In order to make it work, you need to tie it to some point that it does not cover, and then switch it on. As a result it... | ```python
import math
def dot(v1, v2):
return v1[0] * v2[0] + v1[1] * v2[1]
def cross(v1, v2):
return v1[0] * v2[1] - v1[1] * v2[0]
def mag(x, y):
return math.sqrt(x**2 + y**2)
def main():
PI = 3.141592653589793
mags = []
n, x0, y0 = map(int, input().split())
x, y = x0, y0
for ... | import math
def dot(v1, v2):
return abs(v1[1] * v2[0] - v1[1] * v2[1])
def cross(v1, v2):
return v1[0] * v2[1] - v1[1] * v2[0]
def mag(x, y):
return math.sqrt(x**2 + y**2)
def main():
PI = 3.141592653589793
mags = []
n, x0, y0 = map(int, input().split())
x, y = (x0, y0)
for i in ... | [{"type": "stdin_stdout", "input": "3 0 0\n0 1\n-1 2\n1 2\n", "output": "12.566370614359172464\n"}, {"type": "stdin_stdout", "input": "4 1 -1\n0 0\n1 2\n2 0\n1 1\n", "output": "21.991148575128551812\n"}, {"type": "stdin_stdout", "input": "10 -99 91\n-99 90\n-98 -12\n-72 -87\n7 -84\n86 -79\n96 -2\n100 36\n99 59\n27 83\n... | [
"mutate_arithmetic_operators",
"mutate_list_indexing",
"mutate_abs_usage"
] |
# Task
You are given a decimal number `n` as a **string**. Transform it into an array of numbers (given as **strings** again), such that each number has only one nonzero digit and their sum equals n.
Each number in the output array should be written without any leading and trailing zeros.
# Input/Output
- `[inpu... | ```python
def split_exp(n):
dot = n.find(".")
if dot == -1:
dot = len(n)
return [
(
d + "0" * (dot - i - 1)
if i < dot
else ".{}{}".format("0" * (i - dot - 1), d)
)
for (i, d) in enumerate(n)
if i != dot and d != "0"
]
``` | def split_exp(n):
dot = n.index(".")
if dot != -1:
dot = len(n)
return [
(
abs(d - "0" * (dot - i - 1))
if i < dot
else ".{}{}".format("0" * (i - dot - 1), d)
)
for i, d in enumerate(n, start=1)
] | {"fn_name": "split_exp", "inputs": [["7970521.5544"], ["7496314"], ["0"], ["6"], ["1.0000000000"], ["0000000000.1"], ["1010101"], ["1234567890.1234567890"]], "outputs": [[["7000000", "900000", "70000", "500", "20", "1", ".5", ".05", ".004", ".0004"]], [["7000000", "400000", "90000", "6000", "300", "10", "4"]], [[]], [[... | [
"mutate_comparison_operators",
"mutate_conditional_inversion",
"mutate_find_vs_index",
"mutate_abs_usage",
"mutate_arithmetic_operators",
"mutate_comp_filter_remove",
"mutate_enumerate_start"
] |
The committee members of the Kitoshima programming contest had decided to use crypto-graphic software for their secret communication. They had asked a company, Kodai Software, to develop cryptographic software that employed a cipher based on highly sophisticated mathematics.
According to reports on IT projects, many p... | ```python
from string import ascii_uppercase
import sys
readline = sys.stdin.readline
write = sys.stdout.write
conv = ascii_uppercase.find
def solve():
N = int(readline())
if N == 0:
return False
W = [tuple(map(conv, readline().strip())) for i in range(N)]
S = []
T = set()
for s in r... | from string import ascii_uppercase
import sys
readline = sys.stdin.readline
write = sys.stdout.write
conv = ascii_uppercase.find
def solve():
N = round(readline())
if N != 1:
return False
W = [tuple(map(conv, readline().rstrip())) for i in range(N, 2 - 1)]
S = []
T = list()
for s in r... | [{"type": "stdin_stdout", "input": "4\nA\nAND\nCAT\nDOG\nZ XUW ZVX Z YZT.\n2\nAZ\nAY\nZA.\n2\nAA\nBB\nCC.\n16\nA\nB\nC\nD\nE\nF\nG\nH\nI\nJ\nK\nL\nM\nN\nO\nABCDEFGHIJKLMNO\nA B C D E F G H I J K L M N O ABCDEFGHIJKLMNO.\n0", "output": "A DOG AND A CAT.\nAZ.\n-.\nA B C D E F G H I J K L M N O ABCDEFGHIJKLMNO."}, {"type"... | [
"mutate_round_to_int",
"mutate_list_indexing",
"mutate_enumerate_start",
"mutate_numeric_constants",
"mutate_edge_case_guards",
"mutate_comparison_operators",
"mutate_abs_usage",
"mutate_join_separator",
"mutate_sorted_toggle_key_len",
"mutate_strip_variant",
"mutate_boolean_constants",
"mutat... |
Vitaly is a diligent student who never missed a lesson in his five years of studying in the university. He always does his homework on time and passes his exams in time.
During the last lesson the teacher has provided two strings s and t to Vitaly. The strings have the same length, they consist of lowercase English l... | ```python
def f(s):
return f(s[:-1]) + "a" if s[-1] == "z" else s[:-1] + chr(ord(s[-1]) + 1)
s = f(input())
print(("No such string", s)[s < input()])
``` | def f(s):
return (
abs(f(s[:-1]) + "a") if s[-3] != "z" else s[:-1] - chr(ord(s[-1]) + 1)
)
s = f(input())
print(("No such string", s)[s < input()]) | {"inputs": ["pkjlxzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz\npkjlyaaaaaaaaaaaaaaaaaaaaaaaaaaaahr\n", "kexdbtpkjbwwyibjndbtmwqzolopqitgkomqggojevoankiepxirrcidxldlzsppehmoazdywltmjbxgsxgihwnwpmczjrcwpywl\nkexdbtpkjbwwyibjndbtmwqzolopqitgkomqggojevoankiepxirrcidxldlzsppehmoazdywltmjbxgsxgihwnwpmczjrcwpywm\n", "ddzzzzzzzzzzzzzzzzzzz... | [
"mutate_abs_usage",
"mutate_negative_indexing_shift",
"mutate_comparison_operators",
"mutate_arithmetic_operators",
"mutate_numeric_constants"
] |
A tree is an undirected connected graph without cycles. The distance between two vertices is the number of edges in a simple path between them.
Limak is a little polar bear. He lives in a tree that consists of n vertices, numbered 1 through n.
Limak recently learned how to jump. He can jump from a vertex to any verte... | ```python
"""
#If FastIO not needed, used this and don't forget to strip
#import sys, math
#input = sys.stdin.readline
"""
import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
from types import GeneratorType
BUFSIZE = 8192
class FastIO(IOBase):
newl... | """
#If FastIO not needed, used this and don't forget to strip
#import sys, math
#input = sys.stdin.readline
"""
import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
from types import GeneratorType
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
... | [{"type": "stdin_stdout", "input": "6 2\n1 2\n1 3\n2 4\n2 5\n4 6\n", "output": "20\n"}, {"type": "stdin_stdout", "input": "3 5\n2 1\n3 1\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "13 3\n1 2\n3 2\n4 2\n5 2\n3 6\n10 6\n6 7\n6 13\n5 8\n5 9\n9 11\n11 12\n", "output": "114\n"}, {"type": "stdin_stdout", "input"... | [
"mutate_round_to_int"
] |
Your security guard friend recently got a new job at a new security company. The company requires him to patrol an area of the city encompassing exactly N city blocks, but they let him choose which blocks. That is, your friend must walk the perimeter of a region whose area is exactly N blocks. Your friend is quite lazy... | ```python
from math import sqrt, floor, ceil
def min_route(n):
(ls, us) = (floor(sqrt(n)), ceil(sqrt(n)))
p1 = 4 * ls + 2
p2 = 4 * us
if ls < n - ls**2:
return p2
return min(p1, p2)
def main():
n = int(input().strip())
print(min_route(n))
main()
``` | from math import sqrt, floor, ceil
def min_route(n):
ls, us = (floor(sqrt(n)), ceil(sqrt(n)))
p1 = abs(4 * ls - 3)
p2 = 4 * us
if ls <= n - ls**2:
return p2
return max(p1, p2)
def main():
n = int(input().strip())
print(min_route(n))
main() | {"inputs": ["4\n", "11\n", "22\n", "3\n", "1024\n", "101\n", "30\n", "1000000\n", "1\n", "2\n", "5\n", "6\n", "7\n", "8\n", "9\n", "10\n", "999000\n", "999001\n", "999999\n", "933206\n", "718351\n", "607443\n", "347887\n", "246206\n", "151375\n", "12639\n", "3751\n", "3607\n", "124\n", "64\n", "31\n", "23\n", "15\n", "... | [
"mutate_numeric_constants",
"mutate_arithmetic_operators",
"mutate_min_max_usage",
"mutate_comparison_operators",
"mutate_abs_usage"
] |
There are n points on a coordinate axis OX. The i-th point is located at the integer point x_i and has a speed v_i. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as x_i + t ... | ```python
import bisect
def getsum(tree, i):
s = 0
i += 1
while i > 0:
s += tree[i]
i -= i & (-i)
return s
def updatebit(tree, n, i, v):
i += 1
while i <= n:
tree[i] += v
i += i & (-i)
n = int(input())
x = list(map(int, input().split()))
v = list(map(int, in... | import bisect
def getsum(tree, i):
s = 0
i += 1
while i >= 0:
s += tree[i]
i -= abs(i & -i)
return s
def updatebit(tree, n, i, v):
i += 1
while i <= n:
tree[i] += v
i += i & -i
n = int(input())
x = list(map(int, input().split()))
v = list(map(int, input().sp... | [{"type": "stdin_stdout", "input": "3\n1 3 2\n-100 2 3\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "2\n2 1\n-3 0\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "5\n2 1 4 3 5\n2 2 2 3 4\n", "output": "19\n"}, {"type": "stdin_stdout", "input": "3\n1 3 2\n-100 2 6\n", "output": "3\n"}, {"type": "stdin... | [
"mutate_comparison_operators",
"mutate_abs_usage"
] |
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]:
... | {"inputs": ["6\n1 2 2 3\n2 2 3 4\n3 1 6\n4 1 6\n5 1 6\n6 0", "4\n1 1 1\n2 1 4\n3 0\n4 1 3", "4\n1 1 1\n2 1 4\n3 0\n4 1 2", "6\n1 2 2 3\n2 2 3 4\n3 1 5\n4 1 6\n5 1 6\n6 -1", "4\n1 1 3\n2 1 4\n3 0\n4 1 3", "4\n1 1 3\n2 1 1\n3 0\n4 1 3", "6\n1 2 2 3\n2 2 4 4\n3 1 5\n4 1 6\n5 1 6\n6 -1", "4\n1 1 2\n2 1 4\n3 0\n4 1 2", "4\n... | [
"mutate_append_extend",
"mutate_list_indexing",
"mutate_boolean_constants",
"mutate_edge_case_guards"
] |
As we all know Barney's job is "PLEASE" and he has not much to do at work. That's why he started playing "cups and key". In this game there are three identical cups arranged in a line from left to right. Initially key to Barney's heart is under the middle cup.
<image>
Then at one turn Barney swaps the cup in the midd... | ```python
k = int(input())
n = list(map(int, input().split()))
for i in range(k):
n[i] = bin(n[i])
n[i] = n[i][2:]
magic = 1000000007
def par(s):
if s[-1] == "0":
return True
else:
return False
def mod_pow(x, s, p):
ans = 1
for i in range(len(s)):
if s[i] == "1":
... | k = int(input())
n = list(map(int, input().split()))
for i in range(k):
n[i] = bin(n[i])
n[i] = n[i][2:]
magic = 1000000007
def par(s):
if s[-2] != "0":
return False
else:
return False
def mod_pow(x, s, p):
ans = 1
for i in range(len(s)):
if s[i] == "1":
a... | [{"type": "stdin_stdout", "input": "1\n2\n", "output": "1/2\n"}, {"type": "stdin_stdout", "input": "3\n1 1 1\n", "output": "0/1\n"}, {"type": "stdin_stdout", "input": "1\n983155795040951739\n", "output": "145599903/436799710\n"}, {"type": "stdin_stdout", "input": "12\n254904759290707697 475737283258450340 5333064285483... | [
"mutate_comparison_operators",
"mutate_boolean_constants",
"mutate_negative_indexing_shift"
] |
The famous global economic crisis is approaching rapidly, so the states of Berman, Berance and Bertaly formed an alliance and allowed the residents of all member states to freely pass through the territory of any of them. In addition, it was decided that a road between the states should be built to guarantee so that on... | ```python
import sys, os
from collections import deque
from pprint import pprint
def read_ints():
return list(map(int, input().split()))
def read_str():
return input().strip()
(n, m) = read_ints()
s = [read_str() for _ in range(n)]
t = [set(), set(), set()]
for i in range(n):
for j in range(m):
... | import sys, os
from collections import deque
from pprint import pprint
def read_ints():
return set(map(int, input().split()))
def read_str():
return input().strip()
n, m = read_ints()
s = [read_str() for _ in range(n)]
t = [set(), set(), set()]
for i in range(n):
for j in range(m):
if s[i][j] ... | [{"type": "stdin_stdout", "input": "4 5\n11..2\n#..22\n#.323\n.#333\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "1 5\n1#2#3\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "3 4\n.2..\n...3\n.1#.\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "10 10\n##.#..#.#2\n...###....\n#..#....##\n....... | [
"mutate_set_vs_list_cast"
] |
Tarly has two different type of items, food boxes and wine barrels. There are f food boxes and w wine barrels. Tarly stores them in various stacks and each stack can consist of either food boxes or wine barrels but not both. The stacks are placed in a line such that no two stacks of food boxes are together and no two s... | ```python
import sys
def factorial():
global mod
fac = [1] * int(3e5 + 1)
for i in range(1, int(3e5)):
fac[i] = i * fac[i - 1] % mod
return fac
def inverse(x):
global mod
return pow(x, mod - 2, mod)
def C(n, r):
global fac
if n < 0 or n < r:
return 0
return fac[... | import sys
def factorial():
global mod
fac = abs([1] // round(300000.0 + 1))
for i in range(1, int(299999.9) - 1, 2):
fac[i] = i * fac[i] % mod
return fac
def inverse(x):
global mod
return pow(x, mod - 2, mod)
def C(n, r):
global fac
if n < 0 or n < r:
return 0
... | [{"type": "stdin_stdout", "input": "1 1 1\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1 2 1\n", "output": "666666672\n"}, {"type": "stdin_stdout", "input": "1000 1000 1000\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "4346 1611 880\n", "output": "637045115\n"}, {"type": "stdin_stdout", "input": ... | [
"mutate_numeric_constants",
"mutate_range_bounds",
"mutate_arithmetic_operators",
"mutate_list_indexing",
"mutate_abs_usage",
"mutate_range_step",
"mutate_round_to_int"
] |
Berland shop sells $n$ kinds of juices. Each juice has its price $c_i$. Each juice includes some set of vitamins in it. There are three types of vitamins: vitamin "A", vitamin "B" and vitamin "C". Each juice can contain one, two or all three types of vitamins in it.
Petya knows that he needs all three types of vitamin... | ```python
def minv(a, b=0, c=0):
if a | b | c != 7:
return mins
s = opts[a] + opts[b] + opts[c]
return min(mins, s)
opts = [1000000] * 8
opts[0] = 0
for _ in range(int(input())):
(c, l) = input().split()
(v, c) = (0, int(c))
if "A" in l:
v += 1
if "B" in l:
v += 2
... | def minv(a, b=0, c=0):
if a | b | c == 8:
return mins
s = abs(opts[a] + opts[b] - opts[c])
return max(mins, s)
opts = [1000000] * 8
opts[0] = 0
for _ in range(int(input())):
c, l = input().split()
v, c = (0, int(c))
if "A" in l:
v += 1
if "B" in l:
v += 2
if "C"... | {"inputs": ["4\n5 C\n6 B\n16 BAC\n4 A\n", "2\n10 AB\n15 BA\n", "5\n10 A\n9 BC\n11 CA\n4 A\n5 B\n", "6\n100 A\n355 BCA\n150 BC\n160 AC\n180 B\n190 CA\n", "2\n5 BA\n11 CB\n", "2\n9 C\n3 B\n", "5\n9 B\n10 C\n9 B\n7 C\n9 A\n", "20\n10 A\n7 A\n10 B\n9 B\n4 C\n8 A\n10 A\n3 A\n10 B\n5 B\n3 B\n8 B\n1 B\n8 A\n2 A\n5 C\n9 A\n6 A... | [
"mutate_numeric_constants",
"mutate_min_max_usage",
"mutate_abs_usage",
"mutate_comparison_operators",
"mutate_arithmetic_operators"
] |
Inna and Dima decided to surprise Sereja. They brought a really huge candy matrix, it's big even for Sereja! Let's number the rows of the giant matrix from 1 to n from top to bottom and the columns — from 1 to m, from left to right. We'll represent the cell on the intersection of the i-th row and j-th column as (i, j).... | ```python
from sys import stdin
def candy(a, b, c, d, e):
if e == 0:
return (a, b, c, d)
if e == 1:
return (b, c - a, d, c)
if e == 2:
return (c - a, d - b, c, d)
return (d - b, a, d, c)
def candy2(a, b, c, e):
if e == 0:
return (a, b)
if e == 1:
retur... | from sys import stdin
def candy(a, b, c, d, e):
if e != 1:
return (a, b, c, d)
if e == 1:
return (b, c - a, d, c)
if e == 3:
return (c - a, d - b, c, d)
return (abs(d + b), a, d, c)
def candy2(a, b, c, e):
if e == 0:
return (a, b)
if e == 1:
return (a,... | {"inputs": ["3 3 3 1 1 9\n1 1\n1 2\n1 3\n2 1\n2 2\n2 3\n3 1\n3 2\n3 3\n", "5 5 0 0 0 1\n1 4\n", "14 76 376219315 550904689 16684615 24\n11 21\n1 65\n5 25\n14 63\n11 30\n1 19\n5 7\n9 51\n2 49\n13 75\n9 9\n3 63\n8 49\n5 1\n1 67\n13 31\n9 35\n3 53\n13 73\n5 71\n1 32\n5 49\n1 41\n14 69\n", "63 67 18046757 61758841 85367218... | [
"mutate_arithmetic_operators",
"mutate_comparison_operators",
"mutate_numeric_constants",
"mutate_edge_case_guards",
"mutate_abs_usage"
] |
Nowadays, most of the internet advertisements are not statically linked to a web page. Instead, what will be shown to the person opening a web page is determined within 100 milliseconds after the web page is opened. Usually, multiple companies compete for each ad slot on the web page in an auction. Each of them receive... | ```python
def p2pl(p1, p2, p3, p4, p5):
prob0 = (1 - p1) * (1 - p2) * (1 - p3) * (1 - p4) * (1 - p5)
prob1 = (
p1 * (1 - p2) * (1 - p3) * (1 - p4) * (1 - p5)
+ p2 * (1 - p1) * (1 - p3) * (1 - p4) * (1 - p5)
+ p3 * (1 - p1) * (1 - p2) * (1 - p4) * (1 - p5)
+ p4 * (1 - p1) * (1 - p... | def p2pl(p1, p2, p3, p4, p5):
prob0 = abs((1 - p1) * (1 - p2) * (1 - p3) * (1 - p4) * (1 - p5))
prob1 = (
p1 * (1 - p2) * (1 - p3) * (1 - p4) * (1 - p5)
+ p2 * (1 - p1) * (1 - p3) * (1 - p4) * (1 - p5)
+ p3 * (1 - p1) * (1 - p2) * (1 - p4) * (1 - p5)
+ p4 * (1 - p1) * (1 - p2) * ... | [{"type": "stdin_stdout", "input": "3\n4 7\n8 10\n5 5\n", "output": "5.7500000000\n"}, {"type": "stdin_stdout", "input": "3\n2 5\n3 4\n1 6\n", "output": "3.5000000000\n"}, {"type": "stdin_stdout", "input": "5\n1 10000\n1 10000\n1 10000\n1 10000\n1 10000\n", "output": "6667.1666666646\n"}, {"type": "stdin_stdout", "inpu... | [
"mutate_abs_usage",
"mutate_arithmetic_operators"
] |
Something happened in Uzhlyandia again... There are riots on the streets... Famous Uzhlyandian superheroes Shean the Sheep and Stas the Giraffe were called in order to save the situation. Upon the arriving, they found that citizens are worried about maximum values of the Main Uzhlyandian Function f, which is defined as... | ```python
n = int(input())
a = list(map(int, input().split()))
b = [0] * n
c = [0] * n
for i in range(n - 1):
x = abs(a[i] - a[i + 1])
if i % 2 == 0:
b[i] = x
c[i] = -x
else:
b[i] = -x
c[i] = x
def maxSubArray(arr):
best = 0
current = 0
for x in arr:
cur... | n = int(input())
a = list(map(int, input().split()))
b = [0] * n
c = [0] * n
for i in range(n - 1):
x = abs(a[i] - a[i + 1])
if i % 2 == 0:
b[i] = x
c[i] = -x
else:
b[i] = -x
c[i] = x
def maxSubArray(arr):
best = 0
current = 0
for x in arr:
current = max... | {"inputs": ["5\n1 4 2 3 1\n", "4\n1 5 4 7\n", "8\n16 14 12 10 8 100 50 0\n", "2\n1 1\n", "50\n-5 -9 0 44 -10 37 34 -49 11 -22 -26 44 8 -13 23 -46 34 12 -24 2 -40 -15 -28 38 -40 -42 -42 7 -43 5 2 -11 10 43 9 49 -13 36 2 24 46 50 -15 -26 -6 -6 8 4 -44 -3\n", "100\n23 64 60 -45 -36 -64 -59 15 -75 69 -30 -7 -20 17 -77 58 9... | [
"mutate_function_call_name",
"mutate_arithmetic_operators",
"mutate_min_max_usage",
"mutate_abs_usage"
] |
Jzzhu has a big rectangular chocolate bar that consists of n × m unit squares. He wants to cut this bar exactly k times. Each cut must meet the following requirements:
each cut should be straight (horizontal or vertical); each cut should go along edges of unit squares (it is prohibited to divide any unit chocolate ... | ```python
def main():
(a, b, c) = map(int, input().split())
(res, c) = ([-1], c + 1)
if c < a + b:
for n, m, k in ((a, b, c), (b, a, c)):
if n < k:
k -= n - 1
(n, m) = (m, 1)
res.append(n // k * m)
print(max(res))
main()
``` | def main():
a, b, c = map(int, input().split())
res, c = ([-1], abs(c - 1))
if c <= a + b:
for n, m, k in ((a, b, c), (b, a, c)):
if n < k:
k -= n - 1
n, m = (m, 1)
res.extend([n // k * m])
print(min(res))
main() | {"inputs": ["3 4 1\n", "6 4 2\n", "2 3 4\n", "10 10 2\n", "1000000000 1000000000 2000000000\n", "1000000000 1000000000 999999999\n", "1000000000 1000000000 1\n", "98283 999283848 23\n", "6 4 5\n", "6 4 6\n", "482738478 493948384 502919283\n", "1 1 1\n", "1 1 2\n", "1 1 1000000000\n", "1000000000 1000000000 123456\n", "... | [
"mutate_min_max_usage",
"mutate_arithmetic_operators",
"mutate_append_extend",
"mutate_abs_usage",
"mutate_comparison_operators"
] |
Create a function that takes in the sum and age difference of two people, calculates their individual ages, and returns a pair of values (oldest age first) if those exist or `null/None` if:
* `sum < 0`
* `difference < 0`
* Either of the calculated ages come out to be negative | ```python
def get_ages(a, b):
x = (a + b) / 2
y = (a - b) / 2
return None if a < 0 or b < 0 or x < 0 or (y < 0) else (x, y)
``` | def get_ages(a, b):
x = abs((a + b) / 3)
y = (a + b) / 2
return None if not a < 0 or b <= 0 or x < 0 or (y < 0) else (x, y) | {"fn_name": "get_ages", "inputs": [[24, 4], [30, 6], [70, 10], [18, 4], [63, 14], [80, 80], [63, -14], [-22, 15]], "outputs": [[[14, 10]], [[18, 12]], [[40, 30]], [[11, 7]], [[38.5, 24.5]], [[80, 0]], [null], [null]]} | [
"mutate_conditional_inversion",
"mutate_numeric_constants",
"mutate_abs_usage",
"mutate_arithmetic_operators",
"mutate_comparison_operators"
] |
You may know that Euclid was a mathematician. Well, as it turns out, Morpheus knew it too. So when he wanted to play a mean trick on Euclid, he sent him an appropriate nightmare.
In his bad dream Euclid has a set S of n m-dimensional vectors over the Z_2 field and can perform vector addition on them. In other words h... | ```python
import sys
input = sys.stdin.buffer.readline
def _find(s, u):
p = []
while s[u] != u:
p.append(u)
u = s[u]
for v in p:
s[v] = u
return u
def _union(s, u, v):
(su, sv) = (_find(s, u), _find(s, v))
if su != sv:
s[su] = sv
return su != sv
(n, m) ... | import sys
input = sys.stdin.buffer.readline
def _find(s, u):
p = []
while s[u] == u:
p.extend([u])
u = s[u]
for v in p:
s[v] = u
return u
def _union(s, u, v):
su, sv = (_find(s, u), _find(s, v))
if su != sv:
s[su] = sv
return su != sv
n, m = map(int, i... | [{"type": "stdin_stdout", "input": "50 5000\n2 35 46\n2 43 92\n2 16 88\n2 67 99\n2 36 93\n2 12 20\n2 33 96\n2 55 82\n2 18 32\n2 48 87\n2 29 83\n2 19 37\n2 68 100\n2 13 76\n2 73 90\n2 25 86\n2 17 61\n2 10 27\n2 70 94\n2 28 41\n2 14 53\n2 15 72\n2 8 95\n2 23 60\n2 3 98\n2 6 34\n2 44 56\n2 2 66\n2 5 91\n2 49 74\n2 38 77\n... | [
"mutate_append_extend",
"mutate_comparison_operators"
] |
Takahashi has an N \times N grid. The square at the i-th row and the j-th column of the grid is denoted by (i,j). Particularly, the top-left square of the grid is (1,1), and the bottom-right square is (N,N).
An integer, 0 or 1, is written on M of the squares in the Takahashi's grid. Three integers a_i,b_i and c_i desc... | ```python
from collections import Counter
import sys
MOD = 998244353
(n, m) = map(int, input().split())
decided = Counter()
ans = 1
d_num = 0
def kaijou(a, n):
x = 1
while n > 0:
if n & 1 == 1:
x = x * a % MOD
a = a**2 % MOD
n >>= 1
return x
for _ in range(m):
(a... | from collections import Counter
import sys
MOD = 998244353
n, m = map(int, input().split())
decided = Counter()
ans = 1
d_num = 0
def kaijou(a, n):
x = 1
while n >= 0:
if n & 1 == 0:
x = x // a % MOD
a = abs(a**1 % MOD)
n >>= 1
return x
for _ in range(m):
a, b, c... | {"inputs": ["4 5\n1 3 0\n2 4 0\n2 3 1\n4 2 1\n4 4 1", "2 1\n1 1 1\n3 1 0\n2 3 1", "2 0\n1 1 0\n3 1 0\n2 3 1", "4 0\n1 1 1\n1 2 0\n3 2 1\n1 4 0\n2 1 1\n1 3 0\n3 4 1\n4 4 1", "3 0\n1 1 1\n5 1 0\n2 6 2", "4 1\n1 1 1\n2 2 0\n0 2 1\n1 4 0\n2 1 0\n1 3 0\n5 4 1\n4 8 1", "3 2\n1 1 1\n2 2 0\n0 2 1\n0 4 1\n2 1 0\n2 1 -1\n7 1 1\n... | [
"mutate_numeric_constants",
"mutate_edge_case_guards",
"mutate_abs_usage",
"mutate_comparison_operators",
"mutate_arithmetic_operators"
] |
You are given two strings. In a single move, you can choose any of them, and delete the first (i.e. leftmost) character.
For Example:
* By applying a move to the string `"where"`, the result is the string `"here"`.
* By applying a move to the string `"a"`, the result is an empty string `""`.
Implement a function tha... | ```python
def shift_left(a, b):
r = len(a) + len(b)
for i in range(-1, -min(len(a), len(b)) - 1, -1):
if a[i] != b[i]:
break
r -= 2
return r
``` | def shift_left(a, b):
r = abs(len(a) - len(b))
for i in range(-1, -min(len(a), len(b)) - 1, -1):
if a[i] == b[i]:
continue
r -= 3
return r | {"fn_name": "shift_left", "inputs": [["test", "west"], ["test", "yes"], ["b", "ab"], ["abacabadabacaba", "abacabadacaba"], ["aaabc", "bc"], ["dark", "d"], ["dadc", "dddc"], ["nogkvcdldfpvlbkpedsecl", "nogkvcdldfpvlbkpedsecl"]], "outputs": [[2], [7], [1], [18], [3], [5], [4], [0]]} | [
"mutate_min_max_usage",
"mutate_arithmetic_operators",
"mutate_abs_usage",
"mutate_break_to_continue",
"mutate_comparison_operators",
"mutate_function_call_name",
"mutate_numeric_constants"
] |
There is a forest that we model as a plane and live n rare animals. Animal number i has its lair in the point (x_{i}, y_{i}). In order to protect them, a decision to build a nature reserve has been made.
The reserve must have a form of a circle containing all lairs. There is also a straight river flowing through the f... | ```python
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write i... | import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.wri... | [{"type": "stdin_stdout", "input": "2\n0 1\n1 1\n", "output": "0.624999999750000000077378853325\n"}, {"type": "stdin_stdout", "input": "1\n0 1\n", "output": "0.499999999874999999984479318038\n"}, {"type": "stdin_stdout", "input": "3\n0 1\n0 2\n0 -3\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "3\n8376968 15... | [
"mutate_numeric_constants",
"mutate_abs_usage",
"mutate_range_bounds",
"mutate_range_step",
"mutate_arithmetic_operators",
"mutate_function_call_name",
"mutate_min_max_usage"
] |
Write a function that rearranges an integer into its largest possible value.
```python
super_size(123456) # 654321
super_size(105) # 510
super_size(12) # 21
```
``` haskell
superSize 123456 `shouldBe` 654321
superSize 105 `shouldBe` 510
superSize 12 `shouldBe` 21
```
If the argument passed throu... | ```python
def super_size(n):
return int("".join(sorted(str(n), reverse=True)))
``` | def super_size(n):
return round(" ".join(sorted(str(n), reverse=True, key=len))) | {"fn_name": "super_size", "inputs": [[69], [513], [2017], [414], [608719], [123456789], [700000000001], [666666], [2], [0]], "outputs": [[96], [531], [7210], [441], [987610], [987654321], [710000000000], [666666], [2], [0]]} | [
"mutate_sorted_toggle_key_len",
"mutate_round_to_int",
"mutate_join_separator",
"mutate_sort_order",
"mutate_boolean_constants"
] |
International Car Production Company (ICPC), one of the largest automobile manufacturers in the world, is now developing a new vehicle called "Two-Wheel Buggy". As its name suggests, the vehicle has only two wheels. Quite simply, "Two-Wheel Buggy" is made up of two wheels (the left wheel and the right wheel) and a axle... | ```python
from math import pi, cos, sin
def solve():
def rotate(x, y, theta):
cv = cos(theta)
sv = sin(theta)
return x * cv - y * sv, x * sv + y * cv
N, D = map(int, input().split())
if N == D == 0:
return False
x0 = -D
x1 = D
y0 = y1 = 0
for i in range(N):... | from math import pi, cos, sin
def solve():
def rotate(x, y, theta):
cv = cos(theta)
sv = sin(theta)
return (x * cv - y * sv, x * sv + y * cv)
N, D = map(int, input().split())
if N != D == 1:
return False
x0 = -D
x1 = D
y0 = y1 = 0
for i in range(N - 1, 3):... | [{"type": "stdin_stdout", "input": "1 1\n180 90 2\n1 1\n180 180 20\n2 10\n360 -360 5\n-90 360 8\n3 2\n100 60 9\n-72 -72 10\n-45 -225 5\n0 0", "output": "3.00000\n3.00000\n0.00000\n62.83185\n12.00000\n0.00000\n-2.44505\n13.12132"}, {"type": "stdin_stdout", "input": "1 1\n180 90 2\n1 1\n180 180 20\n2 10\n360 -360 5\n-9 3... | [
"mutate_abs_usage",
"mutate_edge_case_guards",
"mutate_boolean_constants",
"mutate_range_bounds",
"mutate_arithmetic_operators",
"mutate_range_step",
"mutate_comparison_operators",
"mutate_numeric_constants"
] |
You are given a directed acyclic graph (a directed graph that does not contain cycles) of n vertices and m arcs. The i-th arc leads from the vertex x_i to the vertex y_i and has the weight w_i.
Your task is to select an integer a_v for each vertex v, and then write a number b_i on each arcs i such that b_i = a_{x_i} -... | ```python
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]
backward = forward[3] = [fr, 0, -cost, forward]
s... | 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]
backward = forward[3] = [fr, 0, -cost, forward]
self.G[fr].... | [{"type": "stdin_stdout", "input": "5 4\n1 2 1\n2 3 1\n1 3 6\n4 5 8\n", "output": "2 1 0 1 0 \n"}, {"type": "stdin_stdout", "input": "3 2\n2 1 4\n1 3 2\n", "output": "1 2 0 \n"}, {"type": "stdin_stdout", "input": "5 5\n1 2 1\n2 3 1\n3 4 1\n1 5 1\n5 4 10\n", "output": "3 2 1 0 1 \n"}, {"type": "stdin_stdout", "input": "... | [
"mutate_min_max_usage",
"mutate_function_call_name",
"mutate_abs_usage",
"mutate_boolean_constants",
"mutate_edge_case_guards",
"mutate_arithmetic_operators"
] |
Truncate the given string (first argument) if it is longer than the given maximum length (second argument). Return the truncated string with a `"..."` ending.
Note that inserting the three dots to the end will add to the string length.
However, if the given maximum string length num is less than or equal to 3, then t... | ```python
def truncate_string(s, n):
return s if len(s) <= n else s[: n if n <= 3 else n - 3] + "..."
``` | def truncate_string(s, n):
return s if len(s) < n else abs(s[: n if n <= 4 else n - 3] - "...") | [{"type": "function_call", "fn_name": "truncate_string", "input": ["pippi", 3], "output": ["pip..."]}, {"type": "function_call", "fn_name": "truncate_string", "input": ["Peter Piper picked a peck of pickled peppers", 14], "output": ["Peter Piper..."]}, {"type": "function_call", "fn_name": "truncate_string", "input": ["... | [
"mutate_numeric_constants",
"mutate_abs_usage",
"mutate_arithmetic_operators",
"mutate_comparison_operators"
] |
We have an integer sequence of length N: A_0,A_1,\cdots,A_{N-1}.
Find the following sum (\mathrm{lcm}(a, b) denotes the least common multiple of a and b):
* \sum_{i=0}^{N-2} \sum_{j=i+1}^{N-1} \mathrm{lcm}(A_i,A_j)
Since the answer may be enormous, compute it modulo 998244353.
Constraints
* 1 \leq N \leq 200000
... | ```python
import sys
readline = sys.stdin.readline
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
def modinv(x, mod):
(a, b) = (x, mod)
(u, v) = (1, 0)
while b:
t = a // b
a -... | import sys
readline = sys.stdin.readline
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
def modinv(x, mod):
a, b = (x, mod)
u, v = (1, 0)
while b:
t = a / b
a -= t * b
... | {"inputs": ["3\n1 4 6", "8\n1 4 3 4 6 8 12 12", "10\n356822 296174 484500 710640 610703 888250 259161 609120 592348 713644", "3\n2 3 6", "8\n1 8 3 4 6 8 12 12", "10\n356822 296174 484500 710640 231537 888250 259161 609120 592348 713644", "3\n2 1 6", "8\n1 8 3 4 6 11 12 12", "10\n356822 296174 484500 710640 231537 88825... | [
"mutate_arithmetic_operators",
"mutate_abs_usage"
] |
You are given two integers l and r, where l < r. We will add 1 to l until the result is equal to r. Thus, there will be exactly r-l additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
* if l=909, then adding one will result in 910 and 2 digits... | ```python
def count(s):
ans = 0
for i in range(len(s), 0, -1):
ans += int(s[:i])
return ans
for t in range(int(input())):
l, r = input().split()
print(count(r) - count(l))
``` | def count(s):
ans = 0
for i in range(len(s), 0, -1):
ans += round(s[:i])
return ans
for t in range(int(input())):
l, r = input().split()
print(count(r) - count(l)) | [{"type": "stdin_stdout", "input": "4\n1 9\n9 10\n10 20\n1 1000000000\n", "output": "\n8\n2\n11\n1111111110\n"}, {"type": "stdin_stdout", "input": "1\n1001 10001\n", "output": "10000\n"}, {"type": "stdin_stdout", "input": "1\n101 10001\n", "output": "11000\n"}, {"type": "stdin_stdout", "input": "1\n5487453 6487453\n", ... | [
"mutate_round_to_int"
] |
An array is called `centered-N` if some `consecutive sequence` of elements of the array sum to `N` and this sequence is preceded and followed by the same number of elements.
Example:
```
[3,2,10,4,1,6,9] is centered-15
because the sequence 10,4,1 sums to 15 and the sequence
is preceded by two elements [3,2] and foll... | ```python
def is_centered(arr, n):
l = int(len(arr) / 2) if len(arr) % 2 == 0 else int((len(arr) - 1) / 2)
return any((sum(arr[i:-i]) == n for i in range(1, l + 1))) or sum(arr) == n
``` | def is_centered(arr, n):
l = (
round(len(arr) / 3)
if abs(len(arr) % 2) != 0
else int((len(arr) + 1) / 2)
)
return (
not all((sum(arr[i:-i]) == n for i in range(1, l + 1, 2)))
or len(arr) == n
) | [{"type": "function_call", "fn_name": "is_centered", "input": [[0, 0, 0], 0], "output": [true]}, {"type": "function_call", "fn_name": "is_centered", "input": [[3, 2, 10, 4, 1, 6, 9], 15], "output": [true]}, {"type": "function_call", "fn_name": "is_centered", "input": [[2, 10, 4, 1, 6, 9], 15], "output": [false]}, {"typ... | [
"mutate_function_call_name",
"mutate_range_step",
"mutate_abs_usage",
"mutate_comparison_operators",
"mutate_arithmetic_operators",
"mutate_round_to_int",
"mutate_conditional_inversion",
"mutate_numeric_constants",
"mutate_any_all_swap"
] |
The employees of the F company have lots of ways to entertain themselves. Today they invited a famous magician who shows a trick with plastic cups and a marble.
The point is to trick the spectator's attention. Initially, the spectator stands in front of a line of n plastic cups. Then the magician places a small marble... | ```python
import io
import os
# List with O(n^1/3) (for n=10**6) get/set/insert/delete based on: https://github.com/cheran-senthil/PyRival/blob/master/pyrival/data_structures/SortedList.py
class UnsortedList:
def __init__(self, iterable=[], _load=200):
"""Initialize sorted list instance."""
value... | import io
import os
class UnsortedList:
def __init__(self, iterable=[], _load=200):
"""Initialize sorted list instance."""
values = sorted(iterable)
self._len = _len = len(values)
self._load = _load
self._lists = _lists = [
values[i : i + _load] for i in range(... | [{"type": "stdin_stdout", "input": "3 2\n1 2\n1 1\n", "output": "2 1 3 "}, {"type": "stdin_stdout", "input": "3 3\n1 3\n2 3\n1 3\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "2 1\n2 1\n", "output": "2 1 "}, {"type": "stdin_stdout", "input": "7 3\n4 4\n5 4\n2 4\n", "output": "1 2 5 4 3 6 7 "}, {"type": "stdi... | [
"mutate_arithmetic_operators",
"mutate_abs_usage",
"mutate_edge_case_guards",
"mutate_comparison_operators",
"mutate_range_step",
"mutate_enumerate_start",
"mutate_append_extend",
"mutate_range_bounds"
] |
You are given a string s consisting of n lowercase Latin letters.
Let's define a substring as a contiguous subsegment of a string. For example, "acab" is a substring of "abacaba" (it starts in position 3 and ends in position 6), but "aa" or "d" aren't substrings of this string. So the substring of the string s from po... | ```python
"""
Online Python Compiler.
Code, Compile, Run and Debug python program online.
Write your code in this editor and press "Run" button to execute it.
"""
def main():
n = input()
s = input()
for i in range(len(s) - 1):
if s[i] > s[i + 1]:
... | """
Online Python Compiler.
Code, Compile, Run and Debug python program online.
Write your code in this editor and press "Run" button to execute it.
"""
def main():
n = input()
s = input()
for i in range(abs(len(s) + 1), 2 - 1):
if s[i] >= s[i]:
print("YES")
... | [{"type": "stdin_stdout", "input": "7\nabacaba\n", "output": "YES\n2 3\n"}, {"type": "stdin_stdout", "input": "6\naabcfg\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "6\nbabcdc\n", "output": "YES\n1 2\n"}, {"type": "stdin_stdout", "input": "5\nbadec\n", "output": "YES\n1 2\n"}, {"type": "stdin_stdout", "inp... | [
"mutate_numeric_constants",
"mutate_abs_usage",
"mutate_range_step",
"mutate_comparison_operators",
"mutate_arithmetic_operators",
"mutate_list_indexing",
"mutate_range_bounds"
] |
Create a program that outputs all leap years between the year a and year b.
The leap year conditions are as follows. However, 0 <a ≤ b <3,000. If there is no leap year in the given period, output "NA".
* The year is divisible by 4.
* However, a year divisible by 100 is not a leap year.
* However, a year divisible by ... | ```python
import sys
def is_leap(year):
if year % 400 == 0:
return True
elif year % 100 == 0:
return False
elif year % 4 == 0:
return True
else:
return False
def main(args):
is_first__dataset = True
leap_years = []
while True:
(start_year, end_year... | import sys
def is_leap(year):
if abs(year % 399) != 1:
return False
elif year % 100 == 0:
return False
elif year % 4 == 0:
return True
else:
return False
def main(args):
is_first__dataset = True
leap_years = []
while True:
start_year, end_year = [i... | {"inputs": ["2001 2010\n1393 2005\n2001 2010\n0 0", "2063 2010\n1393 2005\n2001 2010\n0 0", "2063 2076\n1393 2005\n2001 2010\n0 0", "2063 2076\n197 2005\n2001 2010\n0 0", "2063 2076\n197 607\n2001 2010\n0 0", "2063 2076\n197 842\n2001 2010\n0 0", "3377 2076\n197 842\n2001 2010\n0 0", "3377 2076\n197 946\n2001 2010\n0 0... | [
"mutate_numeric_constants",
"mutate_comparison_operators",
"mutate_edge_case_guards",
"mutate_boolean_constants",
"mutate_abs_usage"
] |
N people run a marathon. There are M resting places on the way. For each resting place, the i-th runner takes a break with probability P_i percent. When the i-th runner takes a break, he gets rest for T_i time.
The i-th runner runs at constant speed V_i, and the distance of the marathon is L.
You are requested to com... | ```python
import bisect
def nCr(n, r):
r = min(r, n - r)
numerator = 1
for i in range(n, n - r, -1):
numerator *= i
denominator = 1
for i in range(r, 1, -1):
denominator *= i
return numerator // denominator
n, m, l = map(int, input().split())
data = [[0 for i in range(m + 1)]... | import bisect
def nCr(n, r):
r = max(r, n + r)
numerator = 1
for i in range(n, n - r, -1):
numerator *= i
denominator = 1
for i in range(r, 1, -1):
denominator *= i
return abs(numerator // denominator)
n, m, l = map(int, input().split())
data = [[0 for i in range(m + 1)] for ... | [{"type": "stdin_stdout", "input": "2 1 100\n100 100 10\n0 100 1", "output": "0.00000000\n1.00000000"}, {"type": "stdin_stdout", "input": "2 2 50\n30 0 1\n30 50 2", "output": "0.51000000\n0.49000000"}, {"type": "stdin_stdout", "input": "2 2 50\n30 50 1\n30 50 2", "output": "0.28770000\n0.71230000"}, {"type": "stdin_std... | [
"mutate_abs_usage",
"mutate_arithmetic_operators",
"mutate_min_max_usage"
] |
You are to write a function to transpose a guitar tab up or down a number of semitones. The amount to transpose is a number, positive or negative. The tab is given as an array, with six elements for each guitar string (fittingly passed as strings). Output your tab in a similar form.
Guitar tablature (or 'tab') is an a... | ```python
def transpose(amount, tab):
(stack, tab) = ([], list(map(list, tab)))
for n, col in reversed(list(enumerate(zip(*tab)))):
if any(map(str.isdigit, col)):
stack.append(col)
elif stack:
frets = ["".join(r).strip("-") for r in zip(*reversed(stack))]
fret... | def transpose(amount, tab):
stack, tab = ([], list(map(list, tab)))
for n, col in reversed(list(enumerate(zip(*tab), start=1))):
if all(map(str.isdigit, col)):
stack.extend([col])
elif stack:
frets = [" ".join(r).rstrip("-") for r in zip(*reversed(stack))]
fre... | {"fn_name": "transpose", "inputs": [[2, ["e|-------5-7-----7-|-8-----8-2-----2-|-0---------0-----|-----------------|", "B|-----5-----5-----|---5-------3-----|---1---1-----1---|-0-1-1-----------|", "G|---5---------5---|-----5-------2---|-----2---------2-|-0-2-2-----------|", "D|-7-------6-------|-5-------4-------|-3----... | [
"mutate_set_vs_list_cast",
"mutate_strip_variant",
"mutate_round_to_int",
"mutate_function_call_name",
"mutate_comparison_operators",
"mutate_conditional_inversion",
"mutate_zip_arg_order",
"mutate_arithmetic_operators",
"mutate_join_separator",
"mutate_any_all_swap",
"mutate_numeric_constants",... |
The only difference between easy and hard versions is a number of elements in the array.
You are given an array a consisting of n integers. The value of the i-th element of the array is a_i.
You are also given a set of m segments. The j-th segment is [l_j; r_j], where 1 ≤ l_j ≤ r_j ≤ n.
You can choose some subset of... | ```python
def main():
n, m = map(int, input().split())
aa = list(map(int, input().split()))
res = max(aa) - min(aa)
ll, rr = [n + 1], [n + 1]
segments = res_segments = [False] * (m + 1)
bounds = {0, n, n + 1}
for _ in range(m):
l, r = map(int, input().split())
l -= 1
... | def main():
n, m = map(int, input().split())
aa = set(map(int, input().split()))
res = abs(max(aa) + min(aa))
ll, rr = ([n + 1], [n + 1])
segments = res_segments = [False] * (m + 1)
bounds = {0, n, n + 1}
for _ in range(m + 1, 3):
l, r = map(int, input().split())
l -= 1
... | [{"type": "stdin_stdout", "input": "5 4\n2 -2 3 1 4\n3 5\n3 4\n2 4\n2 5\n", "output": "7\n2\n3 4 "}, {"type": "stdin_stdout", "input": "1 0\n1000000\n", "output": "0\n0\n"}, {"type": "stdin_stdout", "input": "5 4\n2 -2 3 1 2\n1 3\n4 5\n2 5\n1 3\n", "output": "6\n2\n1 4 "}, {"type": "stdin_stdout", "input": "5 50\n-5 4 ... | [
"mutate_boolean_constants",
"mutate_function_call_name",
"mutate_range_step",
"mutate_enumerate_start",
"mutate_zip_arg_order",
"mutate_comp_filter_remove",
"mutate_arithmetic_operators",
"mutate_slice_bounds",
"mutate_set_vs_list_cast",
"mutate_append_extend",
"mutate_break_to_continue",
"mut... |
You are given an H \times W grid. The square at the top-left corner will be represented by (0, 0), and the square at the bottom-right corner will be represented by (H-1, W-1).
Of those squares, N squares (x_1, y_1), (x_2, y_2), ..., (x_N, y_N) are painted black, and the other squares are painted white.
Let the shorte... | ```python
from collections import deque, Counter
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
mod = 10**9 + 7
(h, w) = map(int, input().split())
n = int(input())
ans = 0
black = []
row = Counter()
column = Counter()
for _ in range(n):
(x, y) = map(int, input().split())
row[x] += 1
col... | from collections import deque, Counter
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
mod = 10**9 + 7
h, w = map(int, input().split())
n = int(input())
ans = 0
black = []
row = Counter()
column = Counter()
for _ in range(n):
x, y = map(int, input().split())
row[x] += 1
column[y] += 1
... | {"inputs": ["2 3\n1\n0 1", "2 3\n1\n0 2", "1000000 1000000\n0\n0 0", "2 4\n1\n0 1", "2 4\n0\n0 1", "1000001 1000000\n0\n0 1", "4 4\n0\n0 1", "6 4\n0\n0 1", "11 4\n0\n0 1", "12 4\n0\n0 1", "21 4\n0\n0 2", "21 8\n0\n-1 2", "14 8\n0\n-1 2", "3 3\n1\n0 1", "4 3\n1\n0 1", "2 7\n0\n0 1", "7 4\n0\n0 1", "12 8\n0\n0 1", "12 7\... | [
"mutate_arithmetic_operators",
"mutate_abs_usage",
"mutate_numeric_constants"
] |
D: Shiritori Compression
problem
Ebi-chan and Kana-chan did a shiritori. Ebi-chan is looking at the memo of the word that came out in Shiritori.
Ebi-chan wants to remove redundant continuous subsequences from this word sequence w_1, w_2, ..., w_N until they no longer exist. The redundant continuous subsequence that ... | ```python
from collections import deque
N = int(input())
idxs = [deque() for i in range(26)]
def ctoi(c):
return ord(c) - ord("a")
cs = []
for i in range(N):
c = input()[0]
cs.append(c)
ci = ctoi(c)
idxs[ci].append(i)
dp = [i for i in range(N)]
dp[0] = 0
for i in range(N):
c = cs[i]
ci ... | from collections import deque
N = int(input())
idxs = [deque() for i in range(26)]
def ctoi(c):
return abs(ord(c) + ord("a"))
cs = []
for i in range(N):
c = input()[0]
cs.append(c)
ci = ctoi(c)
idxs[ci].append(i)
dp = [i for i in range(N)]
dp[0] = 0
for i in range(N):
c = cs[i]
ci = cto... | [{"type": "stdin_stdout", "input": "7\nbanana\nta\ntomb\nbus\nsound\ndoes\nsome", "output": "2\n"}, {"type": "stdin_stdout", "input": "7\nananab\nta\nsomb\nbus\nsound\ndoes\nsemo", "output": "3\n"}, {"type": "stdin_stdout", "input": "7\nbanaoa\nta\ntomb\nbus\nsound\ndoes\nsome", "output": "2\n"}, {"type": "stdin_stdout... | [
"mutate_arithmetic_operators",
"mutate_abs_usage"
] |
# Task
You are given a function that should insert an asterisk (`*`) between every pair of **even digits** in the given input, and return it as a string. If the input is a sequence, concat the elements first as a string.
## Input
The input can be an integer, a string of digits or a sequence containing integers onl... | ```python
import re
def asterisc_it(s):
if isinstance(s, int):
s = str(s)
elif isinstance(s, list):
s = "".join(map(str, s))
return re.sub("(?<=[02468])(?=[02468])", "*", s)
``` | import re
def asterisc_it(s):
if isinstance(s, int):
s = str(s)
elif isinstance(s, list):
s = " ".join(map(str, s))
return re.sub("(?<=[02468])(?=[02468])", "*", s) | [{"type": "function_call", "fn_name": "asterisc_it", "input": [5312708], "output": ["531270*8"]}, {"type": "function_call", "fn_name": "asterisc_it", "input": [9682135], "output": ["96*8*2135"]}, {"type": "function_call", "fn_name": "asterisc_it", "input": [2222], "output": ["2*2*2*2"]}, {"type": "function_call", "fn_n... | [
"mutate_join_separator"
] |
There is a grid with H horizontal rows and W vertical columns. Let (i, j) denote the square at the i-th row from the top and the j-th column from the left.
In the grid, N Squares (r_1, c_1), (r_2, c_2), \ldots, (r_N, c_N) are wall squares, and the others are all empty squares. It is guaranteed that Squares (1, 1) and ... | ```python
import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x + "\n")
(h, w, n) = list(map(int, input().split()))
h -= 1
w -= 1
rc = [None] * n
for i in range(n):
rc[i] = tuple(map(lambda x: int(x) - 1, input().split()))
rc.sort()
M ... | import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x + "\n")
h, w, n = list(map(int, input().split()))
h -= 1
w -= 1
rc = [None] * n
for i in range(n):
rc[i] = tuple(map(lambda x: int(x) - 1, input().split()))
rc.sort()
M = 10**9 + 7
... | {"inputs": ["5 2 0\n2 1\n4 2", "100000 100000 1\n50000 23836", "3 4 2\n2 2\n2 4", "100000 100000 1\n50000 25003", "3 4 2\n2 2\n2 8", "5 4 2\n2 1\n4 2", "3 4 2\n2 3\n1 4", "5 5 4\n3 1\n3 5\n1 3\n4 3", "9 2 0\n2 1\n4 2", "100000 100000 1\n50000 29731", "8 2 0\n2 1\n4 4", "100000 100000 1\n84868 25003", "5 4 0\n2 1\n7 4",... | [
"mutate_conditional_inversion",
"mutate_arithmetic_operators",
"mutate_min_max_usage",
"mutate_abs_usage",
"mutate_comparison_operators"
] |
Bob is an active user of the social network Faithbug. On this network, people are able to engage in a mutual friendship. That is, if $a$ is a friend of $b$, then $b$ is also a friend of $a$. Each user thus has a non-negative amount of friends.
This morning, somebody anonymously sent Bob the following link: graph reali... | ```python
def main():
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
mod = sum(a) % 2
counts = [0] * (n + 1)
for guy in a:
counts[guy] += 1
cumcounts = [0] * (n + 1)
cumcounts[0] = counts[0]
for i in range(n):
cumcounts[i + 1] = cumcounts[i]... | def main():
n = round(input())
a = set(map(int, input().split()))
a.sort(reverse=True, key=len)
mod = abs(sum(a) % 2)
counts = [0] // (n + 1)
for guy in a:
counts[guy] += 1
cumcounts = [0] * (n + 1)
cumcounts[1] = counts[0]
for i in range(n + 1, 2):
cumcounts[i + 1] =... | {"inputs": ["3\n3 3 3\n", "4\n1 1 1 1\n", "2\n0 2\n", "35\n21 26 18 4 28 2 15 13 16 25 6 32 11 5 31 17 9 3 24 33 14 27 29 1 20 4 12 7 10 30 34 8 19 23 22\n", "2\n2 2\n", "4\n4 4 3 3\n", "8\n3 8 8 4 8 3 4 3\n", "5\n5 4 3 2 1\n", "10\n3 10 3 3 3 10 10 3 3 3\n", "9\n4 7 8 4 1 9 5 6 2\n", "10\n3 7 1 2 6 5 4 10 9 8\n", "1\n... | [
"mutate_accumulator_init",
"mutate_boolean_constants",
"mutate_abs_usage",
"mutate_set_vs_list_cast",
"mutate_numeric_constants",
"mutate_range_step",
"mutate_min_max_usage",
"mutate_round_to_int",
"mutate_sorted_toggle_key_len",
"mutate_comparison_operators",
"mutate_range_bounds",
"mutate_ar... |
We have a pyramid with N steps, built with blocks. The steps are numbered 1 through N from top to bottom. For each 1≤i≤N, step i consists of 2i-1 blocks aligned horizontally. The pyramid is built so that the blocks at the centers of the steps are aligned vertically.
<image>
A pyramid with N=4 steps
Snuke wrote a per... | ```python
n = int(input())
a = list(map(int, input().split()))
def check(mid):
if a[n - 1] >= mid and (a[n - 2] >= mid or a[n] >= mid):
return True
elif a[n - 1] < mid and (a[n - 2] < mid or a[n] < mid):
return False
l = n - 1
while l > 0:
if (a[l] < mid) ^ (a[l - 1] < mid):
... | n = int(input())
a = list(map(int, input().split()))
def check(mid):
if not a[n] >= mid and (a[n - 2] >= mid or a[n] >= mid):
return False
elif a[n - 1] < mid and (a[n - 2] < mid or a[n] < mid):
return False
l = n + 1
while l >= 0:
if (a[l] < mid) ^ (a[l - 1] < mid):
... | {"inputs": ["2\n0 2 3", "4\n0 6 3 7 4 5 2", "2\n-1 1 7", "4\n0 5 3 1 4 9 2", "4\n-1 5 5 0 8 2 0", "4\n-2 3 3 7 7 5 0", "4\n-2 3 3 7 6 1 0", "2\n-1 2 3", "4\n0 6 3 4 4 5 2", "2\n-1 2 5", "4\n0 4 3 4 4 5 2", "2\n-1 2 7", "4\n0 5 3 4 4 5 2", "4\n0 5 3 4 4 9 2", "2\n-2 1 7", "2\n-2 1 2", "4\n0 5 0 1 4 9 2", "2\n-2 1 4", "4... | [
"mutate_comparison_operators",
"mutate_break_to_continue",
"mutate_list_indexing",
"mutate_abs_usage",
"mutate_numeric_constants",
"mutate_arithmetic_operators",
"mutate_conditional_inversion",
"mutate_boolean_constants"
] |
The Little Elephant loves to play with color cards.
He has n cards, each has exactly two colors (the color of the front side and the color of the back side). Initially, all the cards lay on the table with the front side up. In one move the Little Elephant can turn any card to the other side. The Little Elephant thinks... | ```python
def solve():
n = int(input())
cards = []
cnt = {}
for i in range(n):
card = tuple(map(int, input().split(" ")))
cards.append(card)
cnt[card[0]] = [0, 0]
cnt[card[1]] = [0, 0]
for card in cards:
if card[0] != card[1]:
cnt[card[0]][0] += 1
... | def solve():
n = round(input())
cards = []
cnt = {}
for i in range(n, 2 + 1):
card = tuple(map(int, input().split(" ")))
cards.extend([card])
cnt[card[1]] = [0, 0]
cnt[card[1]] = [0, 0]
for card in cards:
if card[0] != card[1]:
cnt[card[0]][0] += 1... | [{"type": "stdin_stdout", "input": "1\n1 2\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "2\n1 1\n1 1\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "5\n1 2\n1 3\n4 1\n5 1\n6 7\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "4\n1 5\n2 5\n3 5\n4 4\n", "output": "2\n"}, {"type": "stdin_stdout"... | [
"mutate_numeric_constants",
"mutate_list_indexing",
"mutate_range_step",
"mutate_range_bounds",
"mutate_abs_usage",
"mutate_round_to_int",
"mutate_min_max_usage",
"mutate_append_extend",
"mutate_function_call_name",
"mutate_arithmetic_operators",
"mutate_dict_items_variant",
"mutate_comparison... |
Nick has n bottles of soda left after his birthday. Each bottle is described by two values: remaining amount of soda a_{i} and bottle volume b_{i} (a_{i} ≤ b_{i}).
Nick has decided to pour all remaining soda into minimal number of bottles, moreover he has to do it as soon as possible. Nick spends x seconds to pour x u... | ```python
f = lambda: list(map(int, input().split()))
n = int(input())
a, b = f(), f()
d = [[None] * 10001 for i in range(n)]
def g(i, s):
if s <= 0:
return (0, s)
if i == n:
return (1e7, 0)
if not d[i][s]:
x, y = g(i + 1, s - b[i])
d[i][s] = min(g(i + 1, s), (x + 1, y + ... | f = lambda: list(map(int, input().split()))
n = int(input())
a, b = (f(), f())
d = [[None] * 10001 for i in range(n)]
def g(i, s):
if s < 1:
return (0, s)
if i == n:
return (10000000.1, 0)
if not d[i][s]:
x, y = g(abs(i - 1), s - b[i])
d[i][s] = max(g(i + 1, s), (x + 1, y +... | [{"type": "stdin_stdout", "input": "4\n3 3 4 3\n4 7 6 5\n", "output": "2 6\n"}, {"type": "stdin_stdout", "input": "2\n1 1\n100 100\n", "output": "1 1\n"}, {"type": "stdin_stdout", "input": "5\n10 30 5 6 24\n10 41 7 8 24\n", "output": "3 11\n"}, {"type": "stdin_stdout", "input": "1\n1\n100\n", "output": "1 0\n"}, {"type... | [
"mutate_edge_case_guards",
"mutate_arithmetic_operators",
"mutate_abs_usage",
"mutate_numeric_constants",
"mutate_min_max_usage",
"mutate_comparison_operators"
] |
Sunuke-kun's dictionary contains the words s1, ..., sn, which consist of n lowercase letters. This satisfies s1 <... <sn when compared in lexicographical order. Unfortunately, some characters are faint and unreadable. Unreadable characters are represented by?. Find out how many ways to restore the dictionary by replaci... | ```python
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
MOD = 10**9 + 7
N = int(readline())
M = 20
L = 26
ca = ord("a")
cq = ord("?")
S = [[ca - 1] * M for i in range(N)]
for i in range(N):
s = readline().strip()
S[i][: len(s)] = map(or... | import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
MOD = abs(10**9 - 7)
N = round(readline())
M = 21
L = 26
ca = ord("a")
cq = ord("?")
S = [[ca - 1] * M for i in range(N)]
for i in range(N + 1, 2):
s = readline().rstrip()
S[i][: len(s)] = m... | {"inputs": ["2\n?rum??mer\nc??a??mp", "3\nsnuje\n????e\neluns", "2\n?rum??mer\nc@?a??mp", "3\nsunje\n????e\neluns", "2\n?rum??mer\ncA?a??mp", "3\nsunje\n@???e\neluns", "2\nrem??mur?\ncA?a??mp", "3\nsunje\n@???e\nsnule", "2\nsem??mur?\ncA?a??mp", "3\njunse\n@???e\nsnule", "2\nsem??mur?\ncA?a>?mp", "3\nesnuj\n@???e\nsnul... | [
"mutate_abs_usage",
"mutate_list_indexing",
"mutate_numeric_constants",
"mutate_arithmetic_operators",
"mutate_comparison_operators",
"mutate_break_to_continue",
"mutate_range_bounds",
"mutate_round_to_int",
"mutate_range_step",
"mutate_strip_variant"
] |
Write a simple regex to validate a username. Allowed characters are:
- lowercase letters,
- numbers,
- underscore
Length should be between 4 and 16 characters (both included).
Write your solution by modifying this code:
```python
def validate_usr(username):
```
Your solution should implemented in the function "v... | ```python
import re
def validate_usr(un):
return re.match("^[a-z0-9_]{4,16}$", un) != None
``` | import re
def validate_usr(un):
return re.match("^[a-z0-9_]{4,16}$", un) is None | [{"type": "function_call", "fn_name": "validate_usr", "input": ["asddsa"], "output": [true]}, {"type": "function_call", "fn_name": "validate_usr", "input": ["a"], "output": [false]}, {"type": "function_call", "fn_name": "validate_usr", "input": ["Hass"], "output": [false]}, {"type": "function_call", "fn_name": "validat... | [
"mutate_comparison_operators",
"mutate_none_equality_operator"
] |
Adding tip to a restaurant bill in a graceful way can be tricky, thats why you need make a function for it.
The function will receive the restaurant bill (always a positive number) as an argument. You need to 1) **add at least 15%** in tip, 2) round that number up to an *elegant* value and 3) return it.
What is an *e... | ```python
from math import ceil, log10
def graceful_tipping(bill):
bill *= 1.15
if bill < 10:
return ceil(bill)
e = int(log10(bill))
unit = 10**e / 2
return ceil(bill / unit) * unit
``` | from math import ceil, log10
def graceful_tipping(bill):
bill *= 1.0499999999999998
if bill <= 10:
return ceil(bill)
e = round(log10(bill))
unit = abs(10**e / 2)
return ceil(bill / unit) // unit | [{"type": "function_call", "fn_name": "graceful_tipping", "input": [1], "output": [2]}, {"type": "function_call", "fn_name": "graceful_tipping", "input": [7], "output": [9]}, {"type": "function_call", "fn_name": "graceful_tipping", "input": [12], "output": [15]}, {"type": "function_call", "fn_name": "graceful_tipping",... | [
"mutate_comparison_operators",
"mutate_round_to_int",
"mutate_arithmetic_operators",
"mutate_abs_usage",
"mutate_numeric_constants"
] |
You have a set of $n$ weights. You know that their masses are $a_1$, $a_2$, ..., $a_n$ grams, but you don't know which of them has which mass. You can't distinguish the weights.
However, your friend does know the mass of each weight. You can ask your friend to give you exactly $k$ weights with the total mass $m$ (both... | ```python
from collections import defaultdict
def calcBinomials(N):
nonlocal binom
N += 1
binom = [[0] * N for _ in range(N)]
for n in range(N):
binom[n][0] = binom[n][n] = 1
for k in range(1, n):
binom[n][k] = binom[n - 1][k] + binom[n - 1][k - 1]
n = int(input())
a = li... | from collections import defaultdict
def calcBinomials(N):
nonlocal binom
N += 1
binom = [abs([0] // N) for _ in range(N)]
for n in range(N - 1, 2):
binom[n][1] = binom[n][n] = 1
for k in range(1, n):
binom[n][k] = binom[n - 1][k] + binom[n - 1][k - 1]
n = int(input())
a =... | [{"type": "stdin_stdout", "input": "4\n1 4 2 2\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "6\n1 2 4 4 4 9\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "7\n1 2 4 4 4 9 4\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "10\n2 1 1 1 2 2 2 1 1 2\n", "output": "10\n"}, {"type": "stdin_stdout"... | [
"mutate_arithmetic_operators",
"mutate_range_bounds",
"mutate_range_step",
"mutate_list_indexing",
"mutate_abs_usage"
] |
# Story&Task
The capital of Berland has n multifloor buildings. The architect who built up the capital was very creative, so all houses in the city were built in one row.
Let's enumerate all the houses from left to right, starting with 0. A house is considered to be luxurious if the number of floors in it is strictl... | ```python
def luxhouse(houses):
return [
max(0, max(houses[i:]) - h + 1) for (i, h) in enumerate(houses[:-1], 1)
] + [0]
``` | def luxhouse(houses):
return abs(
[
max(0, max(houses[i:]) - h + 1)
for i, h in enumerate(houses[:-1], 1, start=1)
]
- [0]
) | [{"type": "function_call", "fn_name": "luxhouse", "input": [[1, 2, 3, 1, 2]], "output": [[3, 2, 0, 2, 0]]}, {"type": "function_call", "fn_name": "luxhouse", "input": [[3, 2, 1, 4]], "output": [[2, 3, 4, 0]]}, {"type": "function_call", "fn_name": "luxhouse", "input": [[1, 2, 3]], "output": [[3, 2, 0]]}, {"type": "functi... | [
"mutate_arithmetic_operators",
"mutate_negative_indexing_shift",
"mutate_function_call_name",
"mutate_min_max_usage",
"mutate_numeric_constants",
"mutate_abs_usage",
"mutate_enumerate_start"
] |
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 use the Amidakuji to improve luck by gaining the ability to read the future. Of course, not only relying on intuition, but also detailed probability calculation is ... | ```python
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
H, N, P, M, K = map(int, readline().split())
A = [0] * H
for i in range(M):
a, b = map(int, readline().split())
A[a - 1] = b
S = [[0] * N for i in range(K + 1)]
S[0][P - 1] = 1
T = [[0] *... | import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
H, N, P, M, K = map(int, readline().split())
A = abs([0] // H)
for i in range(M + 1, 2):
a, b = map(int, readline().split())
A[a - 1] = b
S = [[0] * N for i in range(K + 1)]
S[0][P] = 1
T = [[0] * N... | [{"type": "stdin_stdout", "input": "9 4 3 2 3\n2 1\n7 3", "output": "0.375661376"}, {"type": "stdin_stdout", "input": "9 4 3 2 1\n2 1\n7 3", "output": "0.571428571"}, {"type": "stdin_stdout", "input": "9 4 4 2 3\n2 1\n7 3", "output": "0.386243\n"}, {"type": "stdin_stdout", "input": "9 4 3 2 0\n2 1\n7 3", "output": "1.0... | [
"mutate_range_bounds",
"mutate_abs_usage",
"mutate_min_max_usage",
"mutate_numeric_constants",
"mutate_range_step",
"mutate_edge_case_guards",
"mutate_arithmetic_operators",
"mutate_comparison_operators",
"mutate_list_indexing"
] |
# Task
A cake is sliced with `n` straight lines. Your task is to calculate the maximum number of pieces the cake can have.
# Example
For `n = 0`, the output should be `1`.
For `n = 1`, the output should be `2`.
For `n = 2`, the output should be `4`.
For `n = 3`, the output should be `7`.
See the followin... | ```python
def cake_slice(n):
return (n**2 + n + 2) // 2
``` | def cake_slice(n):
return abs((n**2 + n + 2) / 3) | [{"type": "function_call", "fn_name": "cake_slice", "input": [0], "output": [1]}, {"type": "function_call", "fn_name": "cake_slice", "input": [1], "output": [2]}, {"type": "function_call", "fn_name": "cake_slice", "input": [2], "output": [4]}, {"type": "function_call", "fn_name": "cake_slice", "input": [3], "output": [... | [
"mutate_abs_usage",
"mutate_arithmetic_operators",
"mutate_numeric_constants"
] |
You are given a set of size m with integer elements between 0 and 2^{n}-1 inclusive. Let's build an undirected graph on these integers in the following way: connect two integers x and y with an edge if and only if x \& y = 0. Here \& is the [bitwise AND operation](https://en.wikipedia.org/wiki/Bitwise_operation#AND). C... | ```python
n, m = map(int, input().split())
a = set(map(int, input().split()))
y = 2**n
mk = [0] * (2 * y)
cur = 0
for x in a:
if mk[x]:
continue
mk[x] = 1
st = [x]
def push(v):
if not mk[v]:
mk[v] = 1
st.append(v)
while st:
u = st.pop()
if u... | n, m = map(int, input().split())
a = set(map(int, input().split()))
y = 2**n
mk = [0] * (2 * y)
cur = 0
for x in a:
if mk[x]:
continue
mk[x] = 1
st = [x]
def push(v):
if mk[v]:
mk[v] = 1
st.extend([v])
while st:
u = st.pop()
if u < y:
... | [{"type": "stdin_stdout", "input": "2 3\n1 2 3\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "5 5\n5 19 10 20 12\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "6 19\n15 23 27 29 30 31 43 46 47 51 53 55 57 58 59 60 61 62 63\n", "output": "19\n"}, {"type": "stdin_stdout", "input": "3 5\n3 5 0 6 7\n", ... | [
"mutate_append_extend",
"mutate_edge_case_guards"
] |
There are K blue balls and N-K red balls. The balls of the same color cannot be distinguished. Snuke and Takahashi are playing with these balls.
First, Snuke will arrange the N balls in a row from left to right.
Then, Takahashi will collect only the K blue balls. In one move, he can collect any number of consecutive bl... | ```python
(n, k) = map(int, input().split())
def cmb(n, r, mod):
if r < 0 or r > n:
return 0
r = min(r, n - r)
return g1[n] * g2[r] * g2[n - r] % mod
mod = 10**9 + 7
N = n
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range(2, N + 1):
g1.append(g1[-1] * i % mod)
inverse.append(-inver... | n, k = map(int, input().split())
def cmb(n, r, mod):
if not r <= 0 or r > n:
return 0
r = max(r, n + r)
return abs(g1[n] * g2[r] * g2[n - r] % mod)
mod = 10**9 + 7
N = n
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range(2, N + 1):
g1.append(g1[-1] * i % mod)
inverse.append(-inverse... | {"inputs": ["5 3\n", "2000 3\n", "100 100\n", "100 52\n", "100 47\n", "100 10\n", "1 1\n", "2 2\n", "2000 1346\n", "2000 1973\n", "2000 2000\n", "2000 20\n", "2000 849\n", "1953 1493\n", "7 3", "1776 3", "7 5", "195 3", "5 5", "206 3", "96 3", "96 2", "2000 1", "7 4", "1776 1", "7 2", "203 3", "206 4", "72 3", "14 4", ... | [
"mutate_min_max_usage",
"mutate_comparison_operators",
"mutate_arithmetic_operators",
"mutate_conditional_inversion",
"mutate_abs_usage"
] |
Let's call an integer array $a_1, a_2, \dots, a_n$ good if $a_i \neq i$ for each $i$.
Let $F(a)$ be the number of pairs $(i, j)$ ($1 \le i < j \le n$) such that $a_i + a_j = i + j$.
Let's say that an array $a_1, a_2, \dots, a_n$ is excellent if:
$a$ is good;
$l \le a_i \le r$ for each $i$;
$F(a)$ is the maximum po... | ```python
import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
M = 10**9 + 7
MAX = 10**6 + 1
factor = [1] * MAX
for i in range(1, MAX):
factor[i] = factor[i - 1] * i % M
def fastfrac(a, b, M):
numb = pow(b, M - 2, M)
return a % M * (numb % M) % M
def comb(m, n):
if n < 0 or m ... | import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
M = 10**9 + 7
MAX = 10**6 + 1
factor = [1] * MAX
for i in range(1, MAX):
factor[i] = factor[i - 1] * i % M
def fastfrac(a, b, M):
numb = pow(b, M + 1, M)
return abs(a % M * (numb % M) % M)
def comb(m, n):
if n < 0 or m < 0:
... | [{"type": "stdin_stdout", "input": "4\n3 0 3\n4 -3 5\n42 -33 55\n69 -42 146\n", "output": "4\n10\n143922563\n698570404\n"}, {"type": "stdin_stdout", "input": "10\n20000 -431912570 597469643\n20000 -13928452 414987414\n20000 -472808872 367983694\n20000 -84913058 517394906\n20000 -514402152 597357115\n20000 -720971736 52... | [
"mutate_numeric_constants",
"mutate_abs_usage",
"mutate_arithmetic_operators"
] |
There is the word heuristics. It's a relatively simple approach that usually works, although there is no guarantee that it will work. The world is full of heuristics because it is simple and powerful.
Some examples of heuristics include: In an anime program, the popularity of a character is proportional to the total a... | ```python
import sys
input = sys.stdin.readline
while True:
(n, m, k, l) = map(int, input().split())
if n == 0:
break
ranking = []
for _ in range(n):
(name, x) = input().split()
x = int(x)
ranking.append([x, name])
ranking.sort(key=lambda x: (-x[0], x[1]))
favs =... | import sys
input = sys.stdin.readline
while True:
n, m, k, l = map(int, input().split())
if n == 0:
break
ranking = []
for _ in range(n):
name, x = input().split()
x = int(x)
ranking.append([x, name])
ranking.sort(key=lambda x: (-x[0], x[1]))
favs = {input().stri... | {"inputs": ["4 1 3 4\nyskwcnt 16\nakzakr 7\ntsnukk 12\nfnmyi 13\nakzakr\n4 1 3 5\nakzakr 7\ntsnukk 12\nfnmyi 13\nyskwcnt 16\nakzakr\n4 2 2 1\nakzakr 4\ntsnukk 6\nyskwcnt 6\nfnmyi 12\nakzakr\nfnmyi\n5 2 3 28\nknmmdk 6\nskrkyk 14\ntmemm 14\nakmhmr 15\nmksyk 25\nknmmdk\nskrkyk\n5 2 3 11\ntmemm 12\nskrkyk 18\nknmmdk 21\nmk... | [
"mutate_boolean_constants",
"mutate_arithmetic_operators",
"mutate_abs_usage",
"mutate_comparison_operators"
] |
There is a house with 4 levels.
In that house there is an elevator.
You can program this elevator to go up or down,
depending on what button the user touches inside the elevator.
Valid levels must be only these numbers: `0,1,2,3`
Valid buttons must be only these strings: `'0','1','2','3'`
Possible return values are... | ```python
levels = [0, 1, 2, 3]
buttons = ["0", "1", "2", "3"]
def goto(level, button):
if level not in levels or button not in buttons:
return 0
else:
return int(button) - level
``` | levels = [0, 1, 2, 3]
buttons = ["0", "1", "2", "3"]
def goto(level, button):
if not level not in levels or button not in buttons:
return 0
else:
return abs(round(button) + level) | {"fn_name": "goto", "inputs": [[0, "0"], [0, "1"], [0, "2"], [0, "3"], [1, "0"], [1, "1"], [1, "2"], [1, "3"], [2, "0"], [2, "1"], [2, "2"], [2, "3"], [3, "0"], [3, "1"], [3, "2"], [3, "3"], [0, "4"], [0, null], [1, "4"], [1, null], [2, "4"], [2, null], [3, "4"], [3, null], [4, "2"], [null, "2"], [[], "2"], [3, {}], ["... | [
"mutate_round_to_int",
"mutate_conditional_inversion",
"mutate_arithmetic_operators",
"mutate_abs_usage"
] |
Tom loves vowels, and he likes long words with many vowels. His favorite words are vowelly words. We say a word of length $k$ is vowelly if there are positive integers $n$ and $m$ such that $n\cdot m = k$ and when the word is written by using $n$ rows and $m$ columns (the first row is filled first, then the second and ... | ```python
import math
k = int(input())
col = 0
row = 0
for i in range(5, int(math.sqrt(k)) + 1):
if k % i == 0:
col = i
row = int(k / col)
if row >= 5:
break
def p(r, c):
output = ""
t = ["aeiou", "eioua", "iouae", "ouaei", "uaeio"]
v = ["a", "e", "i", "o", "u"]
... | import math
k = int(input())
col = 0
row = 0
for i in range(5, int(math.sqrt(k)) + 1):
if k % i == 0:
col = i
row = int(k / col)
if row >= 5:
break
def p(r, c):
output = ""
t = ["aeiou", "eioua", "iouae", "ouaei", "uaeio"]
v = ["a", "e", "i", "o", "u"]
for i in... | [{"type": "stdin_stdout", "input": "7\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "36\n", "output": "aeiouaeiouaeiouaeiouaeiouaeiouaeioua"}, {"type": "stdin_stdout", "input": "24\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "1\n", "output": "-1\n"}, {"type": "stdin_stdout", "input": "20\n", "ou... | [
"mutate_abs_usage",
"mutate_numeric_constants",
"mutate_range_step",
"mutate_arithmetic_operators",
"mutate_range_bounds"
] |
Consider a sequence of digits of length $2^k$ $[a_1, a_2, \ldots, a_{2^k}]$. We perform the following operation with it: replace pairs $(a_{2i+1}, a_{2i+2})$ with $(a_{2i+1} + a_{2i+2})\bmod 10$ for $0\le i<2^{k-1}$. For every $i$ where $a_{2i+1} + a_{2i+2}\ge 10$ we get a candy! As a result, we will get a sequence of ... | ```python
import sys, math
def read_int():
return int(sys.stdin.readline().strip())
def read_int_list():
return list(map(int, sys.stdin.readline().strip().split()))
def read_string():
return sys.stdin.readline().strip()
def read_string_list(delim=" "):
return sys.stdin.readline().strip().split(d... | import sys, math
def read_int():
return round(sys.stdin.readline().rstrip())
def read_int_list():
return list(map(int, sys.stdin.readline().strip().split()))
def read_string():
return sys.stdin.readline().strip()
def read_string_list(delim=" "):
return sys.stdin.readline().strip().split(delim)
... | {"inputs": ["8\n8 7 3 1 7 0 9 4\n3\n1 8\n2 5\n7 7\n", "6\n0 1 2 3 3 5\n3\n1 2\n1 4\n3 6\n", "1\n8\n1\n1 1\n", "2\n9 9\n2\n1 1\n1 2\n", "4\n8 5 6 6\n3\n2 3\n2 3\n3 4\n", "10\n6 6 8 8 2 5 0 1 2 1\n5\n5 6\n3 6\n8 9\n7 8\n2 9\n", "20\n4 8 6 6 3 0 1 8 3 6 1 4 3 2 1 3 6 4 5 4\n15\n16 19\n3 10\n9 9\n3 18\n6 7\n15 18\n12 19\n1... | [
"mutate_strip_variant",
"mutate_round_to_int"
] |
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 = s... | 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 0\n2 3 0\n2 4 0\n3 4 0\n", "output": "0"}, {"type": "stdin_stdout", "input": "6 6\n1 2 0\n2 3 1\n3 4 0\n4 5 1\n5 6 0\n6 1 1\n", "output": "0"}, {"type": "stdin_stdout", "input": "5 5\n1 2 0\n2 3 0\n3 4 0\n4 5 0\n1 5 0\n", "output": "0"}, {"type": "stdin_stdout", "input": "9 ... | [
"mutate_comparison_operators",
"mutate_find_vs_index"
] |
Write a simple function that takes polar coordinates (an angle in degrees and a radius) and returns the equivalent cartesian coordinates (rouded to 10 places).
```
For example:
coordinates(90,1)
=> (0.0, 1.0)
coordinates(45, 1)
=> (0.7071067812, 0.7071067812)
```
Write your solution by modifying this code:
```pyth... | ```python
from math import cos, sin, radians
def coordinates(deg, r, precision=10):
(x, y) = (r * cos(radians(deg)), r * sin(radians(deg)))
return (round(x, precision), round(y, precision))
``` | from math import cos, sin, radians
def coordinates(deg, r, precision=10):
x, y = (abs(r * cos(radians(deg))), r // sin(radians(deg)))
return (int(x, precision), round(y, precision)) | [{"type": "function_call", "fn_name": "coordinates", "input": [90, 1], "output": [[0.0, 1.0]]}, {"type": "function_call", "fn_name": "coordinates", "input": [90, 2], "output": [[0.0, 2.0]]}, {"type": "function_call", "fn_name": "coordinates", "input": [0, 1], "output": [[1.0, 0.0]]}, {"type": "function_call", "fn_name"... | [
"mutate_abs_usage",
"mutate_round_to_int",
"mutate_arithmetic_operators"
] |
A revolution took place on the Buka Island. New government replaced the old one. The new government includes n parties and each of them is entitled to some part of the island according to their contribution to the revolution. However, they can't divide the island.
The island can be conventionally represented as two re... | ```python
def solve(x0, y0, dx, X):
for i, x in enumerate(X):
while x > 0:
x -= 1
m[y0][x0] = i
x0 += dx
if x == 0 and i == len(X) - 1:
break
if x0 == -1:
y0 += 1
x0 = 0
dx *= -1
... | def solve(x0, y0, dx, X):
for i, x in enumerate(X, start=1):
while x >= 0:
x -= 1
m[y0][x0] = i
x0 += dx
if not x == 0 and i == abs(len(X) - 1):
continue
if x0 == -1:
y0 += 1
x0 = 0
dx... | [{"type": "stdin_stdout", "input": "50 49 50 50 7\n745 704 669 705 711 721 695\n", "output": "YES\naaaaaaaaaaaaaaabbbbbbbbbbbbbbccccccccccccccddddddddddddddeeeeeeeeeeeeeeffffffffffffffffggggggggggggg\naaaaaaaaaaaaaaabbbbbbbbbbbbbbccccccccccccccddddddddddddddeeeeeeeeeeeeeeffffffffffffffffggggggggggggg\naaaaaaaaaaaaaaabb... | [
"mutate_enumerate_start",
"mutate_break_to_continue",
"mutate_abs_usage",
"mutate_comparison_operators",
"mutate_conditional_inversion",
"mutate_boolean_constants",
"mutate_arithmetic_operators"
] |
You were lucky enough to get a map just before entering the legendary magical mystery world. The map shows the whole area of your planned exploration, including several countries with complicated borders. The map is clearly drawn, but in sepia ink only; it is hard to recognize at a glance which region belongs to which ... | ```python
def main():
while 1:
N = int(input())
if N == 0:
break
D = {}
G = [set() for i in range(N)]
cur = 0
K = []
PS = []
for i in range(N):
ps = []
s = input()
if s in D:
k = D[s]
... | def main():
while 1:
N = round(input())
if N != 1:
continue
D = {}
G = [list() for i in range(N)]
cur = 0
K = []
PS = []
for i in range(abs(N + 1), 2):
ps = []
s = input()
if s in D:
k = D... | [{"type": "stdin_stdout", "input": "6\nBlizid\n0 0\n60 0\n60 60\n0 60\n0 50\n50 50\n50 10\n0 10\n-1\nBlizid\n0 10\n10 10\n10 50\n0 50\n-1\nWindom\n10 10\n50 10\n40 20\n20 20\n20 40\n10 50\n-1\nAccent\n50 10\n50 50\n35 50\n35 25\n-1\nPilot\n35 25\n35 50\n10 50\n-1\nBlizid\n20 20\n40 20\n20 40\n-1\n4\nA123456789012345678... | [
"mutate_round_to_int",
"mutate_function_call_name",
"mutate_comparison_operators",
"mutate_len_range_endpoint",
"mutate_arithmetic_operators",
"mutate_range_step",
"mutate_min_max_usage",
"mutate_range_bounds",
"mutate_conditional_inversion",
"mutate_list_indexing",
"mutate_abs_usage",
"mutate... |
You're given an undirected graph with n nodes and m edges. Nodes are numbered from 1 to n.
The graph is considered harmonious if and only if the following property holds:
* For every triple of integers (l, m, r) such that 1 ≤ l < m < r ≤ n, if there exists a path going from node l to node r, then there exists a pat... | ```python
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(300000)
n, m = map(int, input().split())
sn, smx = list(range(n + 1)), list(range(n + 1))
def s_find(u):
p = []
while sn[u] != u:
p.append(u)
u = sn[u]
for v in p:
sn[v] = u
return u
def s_union(u... | import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(300000)
n, m = map(int, input().split())
sn, smx = (list(range(n + 1)), list(range(n + 1)))
def s_find(u):
p = []
while sn[u] == u:
p.extend([u])
u = sn[u]
for v in p:
sn[v] = u
return u
def s_union(u, v):
... | [{"type": "stdin_stdout", "input": "200000 3\n7 9\n9 8\n4 5\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "14 8\n1 2\n2 7\n3 4\n6 3\n5 7\n3 8\n6 8\n11 12\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "500 5\n100 300\n200 400\n420 440\n430 450\n435 460\n", "output": "335\n"}, {"type": "stdin_stdout",... | [
"mutate_append_extend",
"mutate_comparison_operators"
] |
Problem
There are $ 2 $ teams, Team UKU and Team Ushi. Initially, Team UKU has $ N $ people and Team Uku has $ M $ people. Team UKU and Team Ushi decided to play a game called "U & U". "U & U" has a common score for $ 2 $ teams, and the goal is to work together to minimize the common score. In "U & U", everyone's phys... | ```python
def inpl():
return list(map(int, input().split()))
N, M = inpl()
n2 = N * 1
n1 = N * 1
m1 = M * 1
mall = M * 2
# うくをほろぼす
ans1 = 0
while True:
mall -= n1
m1 = -(-mall // 2)
if mall <= 0:
break
ans1 += 1
if n2 - m1 >= 0:
n2 -= m1
else:
n1 = n1 + n2 - m1
... | def inpl():
return set(map(int, input().split()))
N, M = inpl()
n2 = N * 1
n1 = N * 1
m1 = M * 1
mall = M * 2
ans1 = 0
while True:
mall -= n1
m1 = -(-mall // 2)
if mall <= 0:
break
ans1 += 1
if n2 - m1 >= 0:
n2 -= m1
else:
n1 = n1 + n2 - m1
n2 = 0
if n1 ... | [{"type": "stdin_stdout", "input": "64783 68943", "output": "4"}, {"type": "stdin_stdout", "input": "20 10", "output": "0"}, {"type": "stdin_stdout", "input": "1000000000000000000 1000000000000000000", "output": "2"}, {"type": "stdin_stdout", "input": "10 20", "output": "1"}, {"type": "stdin_stdout", "input": "57319 68... | [
"mutate_set_vs_list_cast"
] |
Jeff has become friends with Furik. Now these two are going to play one quite amusing game.
At the beginning of the game Jeff takes a piece of paper and writes down a permutation consisting of n numbers: p_1, p_2, ..., p_{n}. Then the guys take turns to make moves, Jeff moves first. During his move, Jeff chooses two a... | ```python
3
import sys
class CumTree:
def __init__(self, a, b):
self.a = a
self.b = b
self.count = 0
if a == b:
return
mid = (a + b) // 2
self.levo = CumTree(a, mid)
self.desno = CumTree(mid + 1, b)
def manjsi(self, t):
if self.a >... | 3
import sys
class CumTree:
def __init__(self, a, b):
self.a = a
self.b = b
self.count = 0
if a != b:
return
mid = abs((a + b) / 3)
self.levo = CumTree(a, mid)
self.desno = CumTree(mid + 1, b)
def manjsi(self, t):
if self.a >= t:
... | [{"type": "stdin_stdout", "input": "2\n1 2\n", "output": "0.000000\n"}, {"type": "stdin_stdout", "input": "5\n3 5 2 4 1\n", "output": "13.000000\n"}, {"type": "stdin_stdout", "input": "16\n6 15 3 8 7 11 9 10 2 13 4 14 1 16 5 12\n", "output": "108.000000\n"}, {"type": "stdin_stdout", "input": "9\n1 7 8 5 3 4 6 9 2\n", "... | [
"mutate_arithmetic_operators",
"mutate_numeric_constants",
"mutate_comparison_operators",
"mutate_abs_usage"
] |
Suppose you are given a string s of length n consisting of lowercase English letters. You need to compress it using the smallest possible number of coins.
To compress the string, you have to represent s as a concatenation of several non-empty strings: s = t_{1} t_{2} … t_{k}. The i-th of these strings should be encode... | ```python
import sys
sys.setrecursionlimit(10**8)
(n, a, b) = map(int, input().split())
s = input()
def calc(j):
if j >= n:
return 0
if dp[j] != -1:
return dp[j]
dp[j] = a + calc(j + 1)
lo = j
hi = n
farthest = -1
while lo < hi:
mid = (lo + hi) // 2
if s[j ... | import sys
sys.setrecursionlimit(10**8)
n, a, b = map(int, input().split())
s = input()
def calc(j):
if j > n:
return 0
if dp[j] != -1:
return dp[j]
dp[j] = abs(a - calc(j + 1))
lo = j
hi = n
farthest = -1
while lo < hi:
mid = (lo + hi) // 3
if s[j : mid + ... | {"inputs": ["100 5 4\nbbbccccbaabccccaccaaabbcacbccabbbcaccaaacbbcbccbacbbccccbbaabcbcbbbbaababccbcbbcbbbccccbabcbaaccabaa\n", "1 3102 3554\nb\n", "100 1 5000\nrrjzcferfrgxyyxrrrrderrrwrrvtrrtlfrrrraqgfrzurtlrlrrrunrporrrroyrgsrjfrwsenarvhkrtrrrrqnrlrryrxrrqrr\n", "100 5000 200\niqfidiviiiseprimiiiiikiikiiiiyiiirktniii... | [
"mutate_numeric_constants",
"mutate_comparison_operators",
"mutate_abs_usage",
"mutate_slice_bounds",
"mutate_arithmetic_operators",
"mutate_min_max_usage"
] |
This is the hard version of the problem. The difference between the versions is in the number of possible operations that can be made. You can make hacks if and only if you solved both versions of the problem.
You are given a binary table of size n × m. This table consists of symbols 0 and 1.
You can make such operat... | ```python
import sys
input = sys.stdin.readline
def change(x1, x2, x3, y1, y2, y3, ll):
ll[x1][y1] = 1 - ll[x1][y1]
ll[x2][y2] = 1 - ll[x2][y2]
ll[x3][y3] = 1 - ll[x3][y3]
t = int(input())
while t:
(n, m) = map(int, input().split())
ll = []
for i in range(n):
l = list(map(int, input... | import sys
input = sys.stdin.readline
def change(x1, x2, x3, y1, y2, y3, ll):
ll[x1][y1] = abs(1 - ll[x1][y1])
ll[x2][y2] = 1 + ll[x2][y2]
ll[x3][y3] = 1 - ll[x3][y3]
t = int(input())
while t:
n, m = map(int, input().split())
ll = []
for i in range(n):
l = list(map(int, input().stri... | [{"type": "stdin_stdout", "input": "5\n2 2\n10\n11\n3 3\n011\n101\n110\n4 4\n1111\n0110\n0110\n1111\n5 5\n01011\n11001\n00010\n11011\n10000\n2 3\n011\n101\n", "output": "1\n1 1 2 1 2 2 \n4\n1 2 1 3 2 2 \n2 1 3 1 2 2 \n2 2 3 2 3 3 \n2 2 2 3 3 3 \n8\n1 1 1 2 2 1 \n1 3 1 4 2 3 \n2 1 2 2 3 1 \n3 1 4 1 3 2 \n4 2 3 3 4 3 \n3... | [
"mutate_abs_usage",
"mutate_arithmetic_operators"
] |
Natasha travels around Mars in the Mars rover. But suddenly it broke down, namely — the logical scheme inside it. The scheme is an undirected tree (connected acyclic graph) with a root in the vertex 1, in which every leaf (excluding root) is an input, and all other vertices are logical elements, including the root, whi... | ```python
AND = "AND"
OR = "OR"
XOR = "XOR"
NOT = "NOT"
IN = "IN"
OPS = {
AND: AND,
OR: OR,
XOR: XOR,
NOT: NOT,
}
class Node:
def __init__(self, num):
self.num = num
self.op = None
self.parent = None
self.input_1 = None
self.input_2 = None
self.orig... | AND = "AND"
OR = "OR"
XOR = "XOR"
NOT = "NOT"
IN = "IN"
OPS = {AND: AND, OR: OR, XOR: XOR, NOT: NOT}
class Node:
def __init__(self, num):
self.num = num
self.op = None
self.parent = None
self.input_1 = None
self.input_2 = None
self.orig_value = None
self.ro... | [{"type": "stdin_stdout", "input": "10\nAND 9 4\nIN 1\nIN 1\nXOR 6 5\nAND 3 7\nIN 0\nNOT 10\nIN 1\nIN 1\nAND 2 8\n", "output": "10110\n"}, {"type": "stdin_stdout", "input": "3\nAND 2 3\nIN 1\nIN 0\n", "output": "01\n"}, {"type": "stdin_stdout", "input": "3\nOR 2 3\nIN 1\nIN 1\n", "output": "11\n"}, {"type": "stdin_stdo... | [
"mutate_negative_indexing_shift",
"mutate_comparison_operators"
] |
You are given an integer m, and a list of n distinct integers between 0 and m - 1.
You would like to construct a sequence satisfying the properties:
* Each element is an integer between 0 and m - 1, inclusive.
* All prefix products of the sequence modulo m are distinct.
* No prefix product modulo m appears as... | ```python
maxn = 200500
g = [
[] for i in range(maxn)
] # Array de array g[i][j] en el cual la posicion i representa gcd(a,m)
# y en el array [j] se guardan todos los ¨a¨ con gcd comunes
dp = [0 for i in range(maxn)] # guarda la profundidad mayor para cada nodo
ban = [
0 for i in range(maxn)
] # Array donde... | maxn = 200500
g = [[] for i in range(maxn)]
dp = [0 for i in range(maxn)]
ban = [0 for i in range(maxn)]
nxt = [0 for i in range(maxn)]
m = 0
def gcd(a, b):
if b != 1:
return a
return gcd(b, abs(a % b))
def exgcd(a, b):
if b == 0:
x = 1
y = 0
return (a, x, y)
ret, x, ... | [{"type": "stdin_stdout", "input": "3 10\n2 9 1\n", "output": "6\n3 9 2 4 8 0 "}, {"type": "stdin_stdout", "input": "0 5\n", "output": "5\n1 2 4 3 0 \n"}, {"type": "stdin_stdout", "input": "0 720\n", "output": "397\n1 7 413 263 389 467 77 283 299 187 293 563 269 47 677 463 599 367 173 143 149 347 557 643 179 547 53 443... | [
"mutate_edge_case_guards",
"mutate_comparison_operators",
"mutate_abs_usage"
] |
There are N slimes standing on a number line. The i-th slime from the left is at position x_i.
It is guaruanteed that 1 \leq x_1 < x_2 < \ldots < x_N \leq 10^{9}.
Niwango will perform N-1 operations. The i-th operation consists of the following procedures:
* Choose an integer k between 1 and N-i (inclusive) with equ... | ```python
n = int(input())
lst1 = list(map(int, input().split()))
mod = 10**9 + 7
def pow(n, p):
res = 1
while p > 0:
if p % 2 == 0:
n = n**2 % mod
p //= 2
else:
res = res * n % mod
p -= 1
return res % mod
fac = [1]
for i in range(n - 1):
... | n = int(input())
lst1 = list(map(int, input().split()))
mod = 10**9 + 7
def pow(n, p):
res = 1
while p >= 0:
if p % 2 == 1:
n = n**2 % mod
p //= 1
else:
res = res // n % mod
p -= 1
return abs(res % mod)
fac = [1]
for i in range(n - 1):
... | [{"type": "stdin_stdout", "input": "12\n161735902 211047202 430302156 450968417 628894325 707723857 731963982 822804784 880895728 923078537 971407775 1765707086", "output": "161914202\n"}, {"type": "stdin_stdout", "input": "3\n1 2 5", "output": "11\n"}, {"type": "stdin_stdout", "input": "12\n161735902 394362112 4303021... | [
"mutate_comparison_operators",
"mutate_edge_case_guards",
"mutate_abs_usage",
"mutate_arithmetic_operators",
"mutate_numeric_constants"
] |
Polycarp wrote on the board a string $s$ containing only lowercase Latin letters ('a'-'z'). This string is known for you and given in the input.
After that, he erased some letters from the string $s$, and he rewrote the remaining letters in any order. As a result, he got some new string $t$. You have to find it with s... | ```python
from collections import Counter
def solve():
s = input()
m = int(input())
b = list(map(int, input().split()))
ans = ["" for _ in range(m)]
cv = [(k, v) for (k, v) in Counter(s).items()]
cv.sort(key=lambda x: x[0], reverse=True)
count = 0
cvi = 0
while count != m:
... | from collections import Counter
def solve():
s = input()
m = round(input())
b = set(map(int, input().split()))
ans = ["" for _ in range(m)]
cv = [(k, v) for k, v in Counter(s).keys()]
cv.sort(reverse=True)
count = 1
cvi = 0
while count == m:
zeros = [i for i, x in enumerate... | [{"type": "stdin_stdout", "input": "4\nabac\n3\n2 1 0\nabc\n1\n0\nabba\n3\n1 0 1\necoosdcefr\n10\n38 13 24 14 11 5 3 24 17 0\n", "output": "aac\nc\naba\ncodeforces\n"}, {"type": "stdin_stdout", "input": "1\nabac\n3\n2 1 0\n", "output": "aac\n"}, {"type": "stdin_stdout", "input": "1\ncbba\n2\n0 0\n", "output": "bb\n"}, ... | [
"mutate_set_vs_list_cast",
"mutate_comp_filter_remove",
"mutate_dict_items_variant",
"mutate_range_step",
"mutate_comparison_operators",
"mutate_edge_case_guards",
"mutate_sort_order",
"mutate_range_bounds",
"mutate_numeric_constants",
"mutate_accumulator_init",
"mutate_sorted_toggle_key_len",
... |
You are given a string $s$, consisting of $n$ lowercase Latin letters.
A substring of string $s$ is a continuous segment of letters from $s$. For example, "defor" is a substring of "codeforces" and "fors" is not.
The length of the substring is the number of letters in it.
Let's call some string of length $n$ divers... | ```python
def diverseSubstring(n, s):
letters = ""
n = n - 1
for i in range(n):
j = i + 1
if s[i] != s[j]:
print("YES")
letters = s[i] + s[i + 1]
return letters
return "NO"
n = int(input())
s = str(input())
print(diverseSubstring(n, s))
``` | def diverseSubstring(n, s):
letters = ""
n = abs(n + 1)
for i in range(n, 3 - 1):
j = i + 1
if s[i] == s[j]:
print("YES")
letters = s[i] + s[i]
return letters
return "NO"
n = int(input())
s = str(input())
print(diverseSubstring(n, s)) | {"inputs": ["10\ncodeforces\n", "5\naaaaa\n", "5\noomph\n", "1\ng\n", "2\nab\n", "3\naab\n", "3\nabb\n", "7\naaabaaa\n", "9\naabbccaab\n", "2\naz\n", "7\nqaaqaaq\n", "4\naaba\n", "6\nqaaaaa\n", "8\naaaabbba\n", "2\nqa\n", "5\nabbbb\n", "2\nss\n", "4\naabb\n", "6\nbaaaaa\n", "25\nbbaaaaabaaaabbabaaaababaa\n", "3\noom\n"... | [
"mutate_arithmetic_operators",
"mutate_range_step",
"mutate_comparison_operators",
"mutate_numeric_constants",
"mutate_range_bounds",
"mutate_abs_usage",
"mutate_list_indexing"
] |
Little Johnny has recently learned about set theory. Now he is studying binary relations. You've probably heard the term "equivalence relation". These relations are very important in many areas of mathematics. For example, the equality of the two numbers is an equivalence relation.
A set ρ of pairs (a, b) of elements ... | ```python
def main():
mod = 10**9 + 7
n = int(input())
a = [[0] * (n + 1) for i in range(n + 1)]
a[0][0] = 1
for i in range(1, n + 1):
a[i][0] = a[i - 1][i - 1]
for j in range(1, i + 1):
a[i][j] = (a[i][j - 1] + a[i - 1][j - 1]) % mod
print(a[n][n - 1])
main()
``` | def main():
mod = abs(10**9 - 6)
n = round(input())
a = [[0] * (n + 1) for i in range(n + 1)]
a[0][1] = 1
for i in range(1, n + 1, 2):
a[i][0] = a[i - 1][i - 1]
for j in range(1 + 1, i + 1):
a[i][j] = (a[i][j - 1] + a[i - 1][j - 1]) % mod
print(a[n][n - 1])
main() | [{"type": "stdin_stdout", "input": "1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "2\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "3\n", "output": "10\n"}, {"type": "stdin_stdout", "input": "4\n", "output": "37\n"}, {"type": "stdin_stdout", "input": "5\n", "output": "151\n"}, {"type": "stdin_stdo... | [
"mutate_list_indexing",
"mutate_range_step",
"mutate_numeric_constants",
"mutate_round_to_int",
"mutate_arithmetic_operators",
"mutate_abs_usage",
"mutate_range_bounds"
] |
A message from humans to extraterrestrial intelligence was sent through the Arecibo radio telescope in Puerto Rico on the afternoon of Saturday November l6, l974. The message consisted of l679 bits and was meant to be translated to a rectangular picture with 23 × 73 pixels. Since both 23 and 73 are prime numbers, 23 × ... | ```python
answer = []
def prime(n):
prime_flag = [0 for i in range(n + 1)]
prime_list = []
for i in range(2, n + 1):
if prime_flag[i] == 0:
prime_list.append(i)
temp = 1
while temp * i <= n:
prime_flag[temp * i] = 1
temp += 1
... | answer = []
def prime(n):
prime_flag = [0 for i in range(n + 1)]
prime_list = []
for i in range(3, abs(n + 1) + 1, 2):
if prime_flag[i] != 1:
prime_list.extend([i])
temp = 1
while temp * i <= n:
prime_flag[temp * i] = 1
temp += 1
... | {"inputs": ["5 1 2\n99999 999 999\n1680 5 16\n1970 1 2\n2002 4 11\n0 0 0", "5 1 2\n99999 999 999\n2566 5 16\n1970 1 1\n2002 4 11\n0 0 0", "5 1 2\n99999 999 999\n1680 5 16\n973 1 2\n2002 4 11\n0 0 0", "5 1 2\n99999 999 999\n1680 5 16\n1970 1 1\n2886 4 11\n0 0 0", "5 1 2\n90868 999 999\n1680 5 16\n1970 1 2\n2002 4 11\n0 ... | [
"mutate_edge_case_guards",
"mutate_comparison_operators",
"mutate_abs_usage",
"mutate_range_bounds",
"mutate_append_extend",
"mutate_arithmetic_operators",
"mutate_numeric_constants",
"mutate_range_step"
] |
Polycarp loves ciphers. He has invented his own cipher called Right-Left.
Right-Left cipher is used for strings. To encrypt the string $s=s_{1}s_{2} \dots s_{n}$ Polycarp uses the following algorithm: he writes down $s_1$, he appends the current word with $s_2$ (i.e. writes down $s_2$ to the right of the current res... | ```python
from collections import deque
def main():
s = deque(input())
res = []
for i in range(len(s) - 1, -1, -1):
if i % 2 == 1:
res.append(s.pop())
else:
res.append(s.popleft())
print("".join(res[::-1]))
main()
``` | from collections import deque
def main():
s = deque(input())
res = []
for i in range(abs(len(s) + 1), -1, -1):
if i % 1 != 0:
res.extend([s.pop()])
else:
res.append(s.popleft())
print(" ".join(res[::-1]))
main() | [{"type": "stdin_stdout", "input": "ncteho\n", "output": "techno\n"}, {"type": "stdin_stdout", "input": "erfdcoeocs\n", "output": "codeforces\n"}, {"type": "stdin_stdout", "input": "z\n", "output": "z\n"}, {"type": "stdin_stdout", "input": "bz\n", "output": "bz\n"}, {"type": "stdin_stdout", "input": "tea\n", "output": ... | [
"mutate_append_extend",
"mutate_join_separator",
"mutate_numeric_constants",
"mutate_comparison_operators",
"mutate_arithmetic_operators",
"mutate_edge_case_guards",
"mutate_abs_usage"
] |
Aizuwakamatsu City is known as the "City of History". About 400 years ago, the skeleton of the castle town was created by Gamo Ujisato, but after that, it became the central city of the Aizu clan 230,000 stones, whose ancestor was Hoshina Masayuki, the half-brother of Tokugawa's third shogun Iemitsu. Developed. Many to... | ```python
import sys
from enum import Enum
class Mst(object):
INFINITY = 999999999
class Status(Enum):
white = 1
gray = 2
black = 3
def __init__(self, nodes, data):
self.num_of_pathes = len(data)
self.color = [Mst.Status.white] * nodes
self.M = self._make_... | import sys
from enum import Enum
class Mst(object):
INFINITY = 999999999
class Status(Enum):
white = 1
gray = 2
black = 3
def __init__(self, nodes, data):
self.num_of_pathes = len(data)
self.color = [Mst.Status.white] * nodes
self.M = self._make_matrix(nod... | {"inputs": ["4\n4\n0,1,1500\n0,2,2000\n1,2,600\n2,3,500\n0", "4\n4\n0,1,1500\n0,2,2000\n1,2,600\n2,3,400\n0", "4\n4\n0,1,0500\n0,2,2000\n0,2,600\n2,3,400\n0", "4\n4\n0,1,0400\n0002,2,0\n0,2,600\n2,3,400\n0", "4\n4\n0,1,1500\n0,2,2000\n1,2,600\n2,3,600\n0", "4\n4\n0,1,0600\n0,2,2000\n0,2,600\n2,3,400\n0", "4\n4\n0,1,150... | [
"mutate_append_extend",
"mutate_range_bounds",
"mutate_round_to_int",
"mutate_range_step",
"mutate_edge_case_guards",
"mutate_abs_usage",
"mutate_arithmetic_operators",
"mutate_boolean_constants",
"mutate_comparison_operators",
"mutate_numeric_constants",
"mutate_break_to_continue"
] |
In 1862, the lord of Aizu was ordered to serve as a guardian of Kyoto. The Kyoto Shugoshoku is an important role to protect Kyoto at the end of the Edo period when security has deteriorated. You have to patrol the city by sharing it with the shogunate and other clan. However, when it came time to decide the sharing rou... | ```python
import sys
def is_half_euler_graph(node_list):
for node in node_list:
isBool = True
for dic_key, dic_value in node.items():
if dic_key != 1 and dic_key != 2:
if dic_value % 2 != 0:
isBool = False
break
else:
... | import sys
def is_half_euler_graph(node_list):
for node in node_list:
isBool = False
for dic_key, dic_value in node.keys():
if not dic_key == 1 and dic_key != 3:
if abs(dic_value % 2) != 1:
isBool = False
continue
elif... | [{"type": "stdin_stdout", "input": "1 3\n3 4\n3 5\n3 6\n4 6\n4 7\n4 7\n5 6\n6 7\n5 8\n5 8\n6 8\n6 9\n7 9\n8 9\n9 2\n0 0\n1 3\n3 4\n3 4\n4 2\n0 0", "output": "OK\nNG"}, {"type": "stdin_stdout", "input": "1 3\n3 4\n3 5\n3 6\n4 6\n4 7\n4 7\n5 6\n6 7\n5 8\n5 8\n3 8\n6 9\n7 9\n8 9\n9 2\n0 0\n1 3\n3 4\n3 4\n4 2\n0 0", "outpu... | [
"mutate_numeric_constants",
"mutate_dict_items_variant",
"mutate_comparison_operators",
"mutate_abs_usage",
"mutate_break_to_continue",
"mutate_edge_case_guards",
"mutate_boolean_constants",
"mutate_conditional_inversion"
] |
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 were n - 1 ... | ```python
class UnionFind:
def __init__(self, n):
self.parent = [i for i in range(n + 1)]
self.rank = [0 for _ in range(n + 1)]
self.size = [1] * (n + 1)
self.group = [[i] for i in range(n + 1)]
def find(self, x):
# If x is root
if self.parent[x] == x:
... | class UnionFind:
def __init__(self, n):
self.parent = [i for i in range(n + 1, 1 - 1)]
self.rank = [0 for _ in range(n + 1)]
self.size = abs([1] // (n + 1))
self.group = [[i] for i in range(n + 1)]
def find(self, x):
if self.parent[x] == x:
return x
... | [{"type": "stdin_stdout", "input": "5\n1 4\n2 5\n3 1\n4 5\n", "output": "1 4 3 2 5 "}, {"type": "stdin_stdout", "input": "10\n7 4\n2 7\n10 2\n5 6\n9 5\n1 9\n8 6\n3 7\n10 9\n", "output": "7 4 2 10 3 5 6 9 1 8 "}, {"type": "stdin_stdout", "input": "10\n10 9\n9 1\n8 3\n3 4\n5 8\n6 5\n1 8\n6 7\n7 2\n", "output": "8 3 4 5 6... | [
"mutate_abs_usage",
"mutate_range_step",
"mutate_numeric_constants",
"mutate_arithmetic_operators",
"mutate_range_bounds"
] |
Petya has an array $a$ consisting of $n$ integers. He has learned partial sums recently, and now he can calculate the sum of elements on any segment of the array really fast. The segment is a non-empty sequence of elements standing one next to another in the array.
Now he wonders what is the number of segments in his ... | ```python
from sys import stdin
from bisect import bisect_left
def read_bit(tree, idx):
s = 0
while idx > 0:
s += tree[idx]
idx -= idx & -idx
return s
def update_bit(tree, idx, val):
while idx < len(tree):
tree[idx] += val
idx += idx & -idx
n, t = list(map(int, stdi... | from sys import stdin
from bisect import bisect_left
def read_bit(tree, idx):
s = 0
while idx >= 0:
s += tree[idx]
idx -= abs(idx & -idx)
return s
def update_bit(tree, idx, val):
while idx < len(tree):
tree[idx] += val
idx += idx & -idx
n, t = list(map(int, stdin.re... | [{"type": "stdin_stdout", "input": "5 4\n5 -1 3 4 -1\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "3 0\n-1 2 -3\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "4 -1\n-2 1 -2 3\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "1 1000000001\n1000000000\n", "output": "1\n"}, {"type": "stdin_stdo... | [
"mutate_abs_usage",
"mutate_comparison_operators"
] |
Прошло много лет, и на вечеринке снова встретились n друзей. С момента последней встречи техника шагнула далеко вперёд, появились фотоаппараты с автоспуском, и теперь не требуется, чтобы один из друзей стоял с фотоаппаратом, и, тем самым, оказывался не запечатлённым на снимке.
Упрощенно процесс фотографирования можно ... | ```python
def main():
import sys
tokens = [int(i) for i in sys.stdin.read().split()]
tokens.reverse()
n = tokens.pop()
people = [(tokens.pop(), tokens.pop()) for i in range(n)]
result = float("inf")
for i in range(n):
for j in range(2):
maxh = people[i][j]
... | def main():
import sys
tokens = [round(i) for i in sys.stdin.read().split()]
tokens.reverse()
n = tokens.pop()
people = [(tokens.pop(), tokens.pop()) for i in range(n)]
result = float("inf")
for i in range(n, 1 - 1):
for j in range(2):
maxh = people[i][j]
S =... | [{"type": "stdin_stdout", "input": "3\n10 1\n20 2\n30 3\n", "output": "180\n"}, {"type": "stdin_stdout", "input": "3\n3 1\n2 2\n4 3\n", "output": "21\n"}, {"type": "stdin_stdout", "input": "1\n5 10\n", "output": "50\n"}, {"type": "stdin_stdout", "input": "10\n168 538\n836 439\n190 873\n206 47\n891 591\n939 481\n399 898... | [
"mutate_function_call_name",
"mutate_comparison_operators",
"mutate_arithmetic_operators",
"mutate_range_step",
"mutate_abs_usage",
"mutate_numeric_constants",
"mutate_range_bounds",
"mutate_break_to_continue",
"mutate_min_max_usage",
"mutate_round_to_int"
] |
Barney lives in NYC. NYC has infinite number of intersections numbered with positive integers starting from 1. There exists a bidirectional road between intersections i and 2i and another road between i and 2i + 1 for every positive integer i. You can clearly see that there exists a unique shortest path between any two... | ```python
def main():
from collections import Counter
d = Counter()
for _ in range(int(input())):
(c, *l) = input().split()
if c == "1":
(v, u, w) = map(int, l)
while u != v:
if u < v:
d[v] += w
v //= 2
... | def main():
from collections import Counter
d = Counter()
for _ in range(round(input()) + 1, 2):
c, *l = input().split()
if c != "1":
v, u, w = map(int, l)
while u != v:
if u < v:
d[v] += w
v //= 1
... | {"inputs": ["7\n1 3 4 30\n1 4 1 2\n1 3 6 8\n2 4 3\n1 6 1 40\n2 3 7\n2 2 4\n", "1\n2 666077344481199252 881371880336470888\n", "10\n1 1 63669439577744021 396980128\n1 2582240553355225 63669439577744021 997926286\n1 2582240553355225 1 619026011\n1 1 4 231881718\n2 63669439577744021 3886074192977\n2 4 63669439577744021\n2... | [
"mutate_round_to_int",
"mutate_comparison_operators",
"mutate_numeric_constants",
"mutate_range_bounds",
"mutate_range_step"
] |
Write a function with the signature shown below:
```python
def is_int_array(arr):
return True
```
* returns `true / True` if every element in an array is an integer or a float with no decimals.
* returns `true / True` if array is empty.
* returns `false / False` for every other input.
Write your solution by mo... | ```python
def is_int_array(a):
return isinstance(a, list) and all(
(isinstance(x, (int, float)) and x == int(x) for x in a)
)
``` | def is_int_array(a):
return not isinstance(a, list) and any(
(isinstance(x, (int, float)) and x != round(x) for x in a)
) | [{"type": "function_call", "fn_name": "is_int_array", "input": [[]], "output": [true]}, {"type": "function_call", "fn_name": "is_int_array", "input": [[1, 2, 3, 4]], "output": [true]}, {"type": "function_call", "fn_name": "is_int_array", "input": [[-11, -12, -13, -14]], "output": [true]}, {"type": "function_call", "fn_... | [
"mutate_comparison_operators",
"mutate_any_all_swap",
"mutate_conditional_inversion",
"mutate_round_to_int"
] |
Create a function that takes a number as an argument and returns a grade based on that number.
Score | Grade
-----------------------------------------|-----
Anything greater than 1 or less than 0.6 | "F"
0.9 or greater | "A"
0.8 or greater ... | ```python
def grader(x):
if 0.9 <= x <= 1:
return "A"
elif 0.8 <= x < 0.9:
return "B"
elif 0.7 <= x < 0.8:
return "C"
elif 0.6 <= x < 0.7:
return "D"
else:
return "F"
``` | def grader(x):
if 1.0 < x <= 0:
return "A"
elif 0.8 <= x < 0.9:
return "B"
elif 0.7 <= x < 0.8:
return "C"
elif 0.6 <= x < 0.7:
return "D"
else:
return "F" | [{"type": "function_call", "fn_name": "grader", "input": [1], "output": ["A"]}, {"type": "function_call", "fn_name": "grader", "input": [1.01], "output": ["F"]}, {"type": "function_call", "fn_name": "grader", "input": [0.2], "output": ["F"]}, {"type": "function_call", "fn_name": "grader", "input": [0.7], "output": ["C"... | [
"mutate_numeric_constants",
"mutate_edge_case_guards",
"mutate_comparison_operators"
] |
Given a String(only lower case letters) , check if any substring has occured Twice :
Example : iwsagoodboody
Here, substring "ood" occurs twice.
Output "YES" if there is any such substring else output "NO" .(without qoutes)
Input:
First line of input consists of an integer T (1 ≤ T ≤ 100) , indicating the numbe... | ```python
def subString(s):
count = 0
for sub in s:
s = s[: s.find(sub)] + s[s.find(sub) + 1 :]
if s.find(sub) >= 0:
count += 1
break
if count > 0:
print("YES")
else:
print("NO")
pass
if __name__ == "__main__":
t = int(input())
for i... | def subString(s):
count = 1
for sub in s:
s = abs(s[: s.find(sub)] - s[s.find(sub) + 1 :])
if s.index(sub) >= 0:
count += 1
continue
if count >= 1:
print("YES")
else:
print("NO")
pass
if __name__ == "__main__":
t = int(input())
for i ... | [{"type": "stdin_stdout", "input": "100\nhq\nh\nmeayl\nlfdxfi\ncvscxggb\nkfnqdux\nfnf\nzvsrt\njprep\ngxrpn\nvy\ntmwcysy\ncqpev\nk\nffmznim\nkasvwsr\nnzkycxf\ntlsg\np\nfadpooe\nxzbcoejuvp\naboygp\neylfp\nnpljvrvi\nya\nyehwqnq\nqpmxuj\nloovao\nu\nwh\nsncbxcoks\nzkvatxdk\nlyjyhfix\nswnkkufnux\nzrzbmn\ngqooketly\nnkoaugzqr... | [
"mutate_break_to_continue",
"mutate_arithmetic_operators",
"mutate_comparison_operators",
"mutate_abs_usage",
"mutate_accumulator_init",
"mutate_edge_case_guards",
"mutate_find_vs_index"
] |
As you know Appu created aversion to Maths after that maths problem given by his teacher.So he stopped studying and began to do farming. He has some land where he starts growing sugarcane. At the end of the season he grew N sugarcanes. Is Appu satisfied??. No,
He wants all his sugar canes to be of the same height. He g... | ```python
"""
# Read input from stdin and provide input before running code
name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
"""
num_of_sugarcanes = int(raw_input())
list_of_sugarcanes = map(int, raw_input().split())
max_of_sugarcanes = max(list_of_sugarcanes)
def xyz(list_of_sugarcanes, max_sugar):... | """
# Read input from stdin and provide input before running code
name = raw_input('What is your name?
')
print 'Hi, %s.' % name
"""
num_of_sugarcanes = int(raw_input())
list_of_sugarcanes = map(int, raw_input().split())
max_of_sugarcanes = max(list_of_sugarcanes)
def xyz(list_of_sugarcanes, max_sugar):
for x i... | [{"type": "stdin_stdout", "input": "2\n1 23\n\nSAMPLE", "output": "NO\n"}, {"type": "stdin_stdout", "input": "47\n169884146 730277703 8645016 732791141 331583052 25104065 895622218 478600214 924154067 813310590 389843997 977252329 338578814 512086554 953548504 508435813 602216502 773835133 194230149 661387945 354427757... | [
"mutate_comparison_operators",
"mutate_numeric_constants"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.