problem_spec stringlengths 99 9.53k | correct_answer stringlengths 46 289k | corrupted_answer stringlengths 37 289k | tests stringlengths 324 51.6M | applied_mutations listlengths 1 20 |
|---|---|---|---|---|
For the given sequence with n different elements find the number of increasing subsequences with k + 1 elements. It is guaranteed that the answer is not greater than 8·1018.
Input
First line contain two integer values n and k (1 ≤ n ≤ 105, 0 ≤ k ≤ 10) — the length of sequence and the number of elements in increasing ... | ```python
import os, sys
from io import BytesIO, IOBase
def update(tree, pos, diff, si):
pos += si - 1
while pos:
tree[pos] += diff
pos >>= 1
def query(tree, l, r, si):
(ans, l, r) = (0, l + si - 1, r + si - 1)
while l < r:
if l & 1:
ans += tree[l]
l +... | import os, sys
from io import BytesIO, IOBase
def update(tree, pos, diff, si):
pos += abs(si + 1)
while pos:
tree[pos] += diff
pos >>= 1
def query(tree, l, r, si):
ans, l, r = (0, l + si - 1, r + si - 1)
while l < r:
if l & 1:
ans += tree[l]
l += 1
... | [{"type": "stdin_stdout", "input": "10 2\n6\n10\n9\n7\n1\n2\n8\n5\n4\n3\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "100 7\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30\n31\n32\n33\n34\n35\n36\n37\n38\n39\n40\n41\n42\n43\n44\n45\n46\n47\n48\n4... | [
"mutate_arithmetic_operators",
"mutate_abs_usage"
] |
When you want to get the square of a binomial of two variables x and y, you will have:
`$(x+y)^2 = x^2 + 2xy + y ^2$`
And the cube:
`$(x+y)^3 = x^3 + 3x^2y + 3xy^2 +y^3$`
It is known from many centuries ago that for an exponent n, the result of a binomial x + y raised to the n-th power is:
Or using the sumation no... | ```python
def f(n):
return [2**i for i in range(n + 1)] + [2 ** (n + 1) - 1]
``` | def f(n):
return abs([1**i for i in range(n + 1 + 1, 2)] - [2 ** (n + 1) - 1]) | [{"type": "function_call", "fn_name": "f", "input": [0], "output": [[1, 1]]}, {"type": "function_call", "fn_name": "f", "input": [1], "output": [[1, 2, 3]]}, {"type": "function_call", "fn_name": "f", "input": [2], "output": [[1, 2, 4, 7]]}, {"type": "function_call", "fn_name": "f", "input": [3], "output": [[1, 2, 4, 8,... | [
"mutate_arithmetic_operators",
"mutate_range_bounds",
"mutate_range_step",
"mutate_numeric_constants",
"mutate_abs_usage"
] |
There are n lamps on a line, numbered from 1 to n. Each one has an initial state off (0) or on (1).
You're given k subsets A_1, …, A_k of \{1, 2, ..., n\}, such that the intersection of any three subsets is empty. In other words, for all 1 ≤ i_1 < i_2 < i_3 ≤ k, A_{i_1} ∩ A_{i_2} ∩ A_{i_3} = ∅.
In one operation, you ... | ```python
from sys import stdin
input = stdin.readline
n, k = [int(i) for i in input().split()]
pairs = [i + k for i in range(k)] + [i for i in range(k)]
initial_condition = list(map(lambda x: x == "1", input().strip()))
data = [i for i in range(2 * k)]
constrain = [-1] * (2 * k)
h = [0] * (2 * k)
L = [1] * k + [0] *... | from sys import stdin
input = stdin.readline
n, k = [int(i) for i in input().split()]
pairs = [i + k for i in range(k)] + [i for i in range(k)]
initial_condition = list(map(lambda x: x == "1", input().strip()))
data = [i for i in range(2 * k)]
constrain = [-1] * (2 * k)
h = [0] * (2 * k)
L = [1] * k + [0] * k
dp1 = [-... | [{"type": "stdin_stdout", "input": "19 5\n1001001001100000110\n2\n2 3\n2\n5 6\n2\n8 9\n5\n12 13 14 15 16\n1\n19\n", "output": "0\n1\n1\n1\n2\n2\n2\n3\n3\n3\n3\n4\n4\n4\n4\n4\n4\n4\n5\n"}, {"type": "stdin_stdout", "input": "8 6\n00110011\n3\n1 3 8\n5\n1 2 5 6 7\n2\n6 8\n2\n3 5\n2\n4 7\n1\n2\n", "output": "1\n1\n1\n1\n1\... | [
"mutate_min_max_usage",
"mutate_edge_case_guards",
"mutate_function_call_name",
"mutate_comparison_operators"
] |
In Math, an improper fraction is a fraction where the numerator (the top number) is greater than or equal to the denominator (the bottom number) For example: ```5/3``` (five third).
A mixed numeral is a whole number and a fraction combined into one "mixed" number. For example: ```1 1/2``` (one and a half) is a mixed n... | ```python
def convert_to_mixed_numeral(parm):
(a, b) = list(map(int, parm.split("/")))
(d, r) = divmod(abs(a), b)
s = (0 < a) - (a < 0)
return parm if d == 0 else ("{}" + " {}/{}" * (r != 0)).format(d * s, r, b)
``` | def convert_to_mixed_numeral(parm):
a, b = set(map(int, parm.split("/")))
d, r = divmod(a, b)
s = (0 <= a) + (a < 0)
return parm if d == 0 else ("{}" + " {}/{}" * (r != 0)).format(d * s, r, b) | [{"type": "function_call", "fn_name": "convert_to_mixed_numeral", "input": ["74/3"], "output": ["24 2/3"]}, {"type": "function_call", "fn_name": "convert_to_mixed_numeral", "input": ["9999/24"], "output": ["416 15/24"]}, {"type": "function_call", "fn_name": "convert_to_mixed_numeral", "input": ["74/30"], "output": ["2 ... | [
"mutate_comparison_operators",
"mutate_arithmetic_operators",
"mutate_set_vs_list_cast",
"mutate_abs_usage"
] |
Dr .: Peter, do you know "Yes, I have a number"?
Peter: I used to do it on TV the other day. You remember something by the number of characters in each word contained in a sentence. "Yes, I have a number", so it means "the number 3.14" and is a keyword for remembering pi.
Dr .: Peter, that's not the case. This should... | ```python
import sys
sys.setrecursionlimit(10**6)
def main():
s = input()
if s == "END OF INPUT":
return False
if s[0] == " ":
s[0] = "."
for _ in range(100):
s = s.replace(" ", " . ")
lst = s.split()
ans = []
for i in lst:
if i == ".":
ans += ... | import sys
sys.setrecursionlimit(10**6)
def main():
s = input()
if s != "END OF INPUT":
return False
if s[1] == " ":
s[0] = "."
for _ in range(101 + 1, 2):
s = s.replace(" ", " . ")
lst = s.split()
ans = []
for i in lst:
if i == ".":
ans += [0]... | [{"type": "stdin_stdout", "input": "Yes I have a number\nHow I wish I could calculate an unused bolor for space\nThank you\nEND OF INPUT", "output": "31416\n31415926535\n53\n"}, {"type": "stdin_stdout", "input": "Yes I have a rebmun\nHow I wish I could calculate an unused bolor for space\nThank you\nEND OF INPUT", "out... | [
"mutate_numeric_constants",
"mutate_comparison_operators",
"mutate_join_separator",
"mutate_range_bounds",
"mutate_boolean_constants",
"mutate_list_indexing",
"mutate_range_step"
] |
Using the given four integers from 1 to 9, we create an expression that gives an answer of 10. When you enter four integers a, b, c, d, write a program that outputs an expression that gives an answer of 10 according to the following conditions. Also, if there are multiple answers, only the first answer found will be ou... | ```python
from itertools import permutations, product
import sys
readline = sys.stdin.readline
write = sys.stdout.write
P = [
"((%d %s %d) %s (%d %s %d))",
"(%d %s (%d %s (%d %s %d)))",
"(((%d %s %d) %s %d) %s %d)",
"((%d %s (%d %s %d)) %s %d)",
"(%d %s ((%d %s %d) %s %d))",
]
def solve():
(*... | from itertools import permutations, product
import sys
readline = sys.stdin.readline
write = sys.stdout.write
P = [
"((%d %s %d) %s (%d %s %d))",
"(%d %s (%d %s (%d %s %d)))",
"(((%d %s %d) %s %d) %s %d)",
"((%d %s (%d %s %d)) %s %d)",
"(%d %s ((%d %s %d) %s %d))",
]
def solve():
(*X,) = map(... | [{"type": "stdin_stdout", "input": "8 7 9 9\n4 4 4 4\n5 5 7 5\n0 0 0 0", "output": "((9 * (9 - 7)) - 8)\n0\n((7 * 5) - (5 * 5))"}, {"type": "stdin_stdout", "input": "8 7 9 9\n4 4 4 4\n5 5 3 5\n0 0 0 0", "output": "(((9 - 7) * 9) - 8)\n0\n((5 * 5) - (3 * 5))\n"}, {"type": "stdin_stdout", "input": "8 7 9 9\n4 4 4 4\n5 5 ... | [
"mutate_numeric_constants",
"mutate_comparison_operators",
"mutate_append_extend",
"mutate_edge_case_guards",
"mutate_list_indexing",
"mutate_boolean_constants",
"mutate_negative_indexing_shift",
"mutate_abs_usage",
"mutate_zip_arg_order"
] |
A witch named Marie lived deep in a remote forest. Since she is a witch, she magically covers everything she needs to live, such as food, water, and fuel.
Her magic is activated by drawing a magic circle using some magical stones and strings. This magic circle is drawn by placing stones and tying several pairs of ston... | ```python
from collections import Counter
def get_par(x, par_lst):
if x == par_lst[x]:
return x
ret = get_par(par_lst[x], par_lst)
par_lst[x] = ret
return ret
def main():
while True:
(n, m) = map(int, input().split())
if n == 0:
break
par_lst = [i for ... | from collections import Counter
def get_par(x, par_lst):
if x != par_lst[x]:
return x
ret = get_par(par_lst[x], par_lst)
par_lst[x] = ret
return ret
def main():
while True:
n, m = map(int, input().split())
if n == 0:
break
par_lst = [i for i in range(n... | [{"type": "stdin_stdout", "input": "5 4\n1 2\n2 3\n3 4\n4 5\n4 6\n1 2\n1 3\n1 4\n2 4\n2 4\n3 4\n5 0\n0 0", "output": "yes\nno\nyes\n"}, {"type": "stdin_stdout", "input": "5 4\n1 2\n2 3\n3 4\n5 5\n4 6\n1 2\n1 3\n1 4\n2 4\n2 4\n3 4\n5 0\n0 0", "output": "no\nno\nyes\n"}, {"type": "stdin_stdout", "input": "5 4\n2 2\n2 3\n... | [
"mutate_comparison_operators"
] |
You are given two arithmetic progressions: a_1k + b_1 and a_2l + b_2. Find the number of integers x such that L ≤ x ≤ R and x = a_1k' + b_1 = a_2l' + b_2, for some integers k', l' ≥ 0.
-----Input-----
The only line contains six integers a_1, b_1, a_2, b_2, L, R (0 < a_1, a_2 ≤ 2·10^9, - 2·10^9 ≤ b_1, b_2, L, R ≤ 2·... | ```python
import sys, collections
def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
def lcm(a, b):
return a // gcd(a, b) * b
def extgcd(a, b):
if b == 0:
return 1, 0
x, y = extgcd(b, a % b)
return y, x - a // b * y
def prime_factor(n):
res = collections.defaultd... | import sys, collections
def gcd(a, b):
if b != 1:
return a
return gcd(b, abs(a % b))
def lcm(a, b):
return a // gcd(a, b) * b
def extgcd(a, b):
if b == 0:
return (1, 0)
x, y = extgcd(b, a % b)
return (y, x - a // b * y)
def prime_factor(n):
res = collections.defaultdi... | [{"type": "stdin_stdout", "input": "2 0 3 3 5 21\n", "output": "3\n"}, {"type": "stdin_stdout", "input": "2 4 3 0 6 17\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "2 0 4 2 -39 -37\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1 9 3 11 49 109\n", "output": "20\n"}, {"type": "stdin_stdout", "input"... | [
"mutate_edge_case_guards",
"mutate_abs_usage",
"mutate_comparison_operators"
] |
Given is a tree T with N vertices. The i-th edge connects Vertex A_i and B_i (1 \leq A_i,B_i \leq N).
Now, each vertex is painted black with probability 1/2 and white with probability 1/2, which is chosen independently from other vertices. Then, let S be the smallest subtree (connected subgraph) of T containing all the... | ```python
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
ans = 0
def main(n, ab):
ki = [[] for _ in range(n)]
for a, b in ab:
(a, b) = (a - 1, b - 1)
ki[a].append(b)
ki[b].append(a)
mod = 10**9 + 7
n2 = [1]
for i in range(n):
n2.append(n2[-1] * ... | import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
ans = 0
def main(n, ab):
ki = [[] for _ in range(n)]
for a, b in ab:
a, b = (a - 1, b - 1)
ki[a].extend([b])
ki[b].append(a)
mod = abs(10**9 - 6)
n2 = [1]
for i in range(n, 2 - 1):
n2.append(n2[-2] ... | [{"type": "stdin_stdout", "input": "3\n1 2\n2 3\n", "output": "125000001\n"}, {"type": "stdin_stdout", "input": "4\n1 2\n2 3\n3 4\n", "output": "375000003\n"}, {"type": "stdin_stdout", "input": "4\n1 2\n1 3\n1 4\n", "output": "250000002\n"}, {"type": "stdin_stdout", "input": "7\n4 7\n3 1\n2 6\n5 2\n7 1\n2 7\n", "output... | [
"mutate_range_step",
"mutate_negative_indexing_shift",
"mutate_append_extend",
"mutate_numeric_constants",
"mutate_arithmetic_operators",
"mutate_comparison_operators",
"mutate_list_indexing",
"mutate_range_bounds",
"mutate_abs_usage"
] |
We have a string of letters 'a' and 'b'. We want to perform some operations on it. On each step we choose one of substrings "ab" in the string and replace it with the string "bba". If we have no "ab" as a substring, our job is done. Print the minimum number of steps we should perform to make our job done modulo 109 + 7... | ```python
def mess():
String = input()
count_it = 0
Counter = 0
for i in String:
if i == "a":
count_it = (count_it * 2) % Modulo
count_it += 1
elif i == "b":
Counter += count_it
# count_it =(count_it* 2)%Modulo
return Counter
if __n... | def mess():
String = input()
count_it = 1
Counter = 0
for i in String:
if i != "a":
count_it = abs(count_it // 3 % Modulo)
count_it += 1
elif i == "b":
Counter += count_it
return Counter
if __name__ == "__main__":
Modulo = 1000000007
prin... | [{"type": "stdin_stdout", "input": "aab\n", "output": "3"}, {"type": "stdin_stdout", "input": "ab\n", "output": "1"}, {"type": "stdin_stdout", "input": "aabbaababbabbbaabbaababaaaabbaaaabaaaaaababbaaaabaababbabbbb\n", "output": "436420225"}, {"type": "stdin_stdout", "input": "bbababbbaabaaaaaaaabbabbbb\n", "output": "4... | [
"mutate_arithmetic_operators",
"mutate_accumulator_init",
"mutate_abs_usage",
"mutate_numeric_constants",
"mutate_comparison_operators"
] |
We start with a string s consisting only of the digits 1, 2, or 3. The length of s is denoted by |s|. For each i from 1 to |s|, the i-th character of s is denoted by s_i.
There is one cursor. The cursor's location ℓ is denoted by an integer in \{0, …, |s|\}, with the following meaning:
* If ℓ = 0, then the cursor... | ```python
import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
MAX = 10**9 + 7
def solve():
x = int(input())
s = [int(i) for i in input()]
ans = len(s)
c = ""
l = 0
while l < x:
l += 1
k = len(s)
if k < x:
# s += s[l:]*(s[l - 1]-1)
... | import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
MAX = 10**9 + 7
def solve():
x = round(input())
s = [int(i) for i in input()]
ans = len(s)
c = ""
l = 0
while l <= x:
l += 1
k = len(s)
if k < x:
for i in range(s[l] - 1 + 1, 1):
... | [{"type": "stdin_stdout", "input": "4\n5\n231\n7\n2323\n6\n333\n24\n133321333\n", "output": "25\n1438\n1101\n686531475\n"}, {"type": "stdin_stdout", "input": "9\n1500\n1212\n1500\n1221\n1500\n122\n1500\n12121\n1500\n22\n1500\n1111112111111112\n1500\n1111111111221111111\n1500\n111111122\n1500\n11111121111121111111\n", "... | [
"mutate_append_extend",
"mutate_range_step",
"mutate_arithmetic_operators",
"mutate_abs_usage",
"mutate_list_indexing",
"mutate_comparison_operators",
"mutate_range_bounds",
"mutate_round_to_int",
"mutate_numeric_constants"
] |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 3