Dataset Viewer
Auto-converted to Parquet Duplicate
problem_spec
stringlengths
31
9.53k
correct_answer
stringlengths
52
32.1k
corrupted_answer
stringlengths
38
29.9k
tests
stringlengths
120
49M
applied_mutations
listlengths
1
11
You are given three strings (s1, s2, s3). For each integer l (1 ≤ l ≤ min(|s1|, |s2|, |s3|) you need to find how many triples (i1, i2, i3) exist such that three strings sk[ik... ik + l - 1] (k = 1, 2, 3) are pairwise equal. Print all found numbers modulo 1000000007 (109 + 7). See notes if you are not sure about some o...
```python MOD = 1000000007 oo = int(2e9) class Node: def __init__(self, p, l=oo): self.spos = p self.slink = 0 self.length = l self.next_node = [0 for _ in range(28)] # Ukkonen class SuffixTree: def __init__(self, s): self.nodes = [Node(0)] self.s = [] ...
MOD = 1000000007 oo = int(2000000000.0) class Node: def __init__(self, p, l=oo): self.spos = p self.slink = 0 self.length = l self.next_node = [0 for _ in range(28)] class SuffixTree: def __init__(self, s): self.nodes = [Node(0)] self.s = [] self.pos...
[{"type": "stdin_stdout", "input": "abc\nbc\ncbc\n", "output": "3 1 \n"}, {"type": "stdin_stdout", "input": "abacaba\nabac\nabcd\n", "output": "11 2 0 0 \n"}, {"type": "stdin_stdout", "input": "aaaaa\naaaaa\naaaaa\n", "output": "125 64 27 8 1 \n"}, {"type": "stdin_stdout", "input": "abcde\nghjra\nabcde\n", "output": "1...
[ "mutate_break_to_continue", "mutate_abs_usage", "mutate_append_extend" ]
Encryption System A programmer developed a new encryption system. However, his system has an issue that two or more distinct strings are `encrypted' to the same string. We have a string encrypted by his system. To decode the original string, we want to enumerate all the candidates of the string before the encryption....
```python from itertools import chain alph = "abcdefghijklmnopqrstuvwxyz" # s = input() def solve1(s): cands = [s] for c in reversed(alph[:-1]): cands = chain.from_iterable([candidates(s, c) for s in cands]) cands = list(cands) cands.sort() print(len(cands)) if len(cands) > 10: ...
from itertools import chain alph = "abcdefghijklmnopqrstuvwxyz" def solve1(s): cands = [s] for c in reversed(alph[:-2]): cands = chain.from_iterable([candidates(s, c) for s in cands]) cands = set(cands) cands.sort(key=len) print(len(cands)) if len(cands) > 10: for s in cands[:...
[{"type": "stdin_stdout", "input": "enw\nabc\nabcdefghijklmnopqrst\nz\n#", "output": "1\nfox\n5\nacc\nacd\nbbd\nbcc\nbcd\n17711\nacceeggiikkmmooqqssu\nacceeggiikkmmooqqstt\nacceeggiikkmmooqqstu\nacceeggiikkmmooqrrtt\nacceeggiikkmmooqrrtu\nbcdefghijklmnopqrrtt\nbcdefghijklmnopqrrtu\nbcdefghijklmnopqrssu\nbcdefghijklmnop...
[ "mutate_set_vs_list_cast", "mutate_sorted_toggle_key_len", "mutate_negative_indexing_shift" ]
You are given N non-overlapping circles in xy-plane. The radius of each circle varies, but the radius of the largest circle is not double longer than that of the smallest. <image> Figure 1: The Sample Input The distance between two circles C1 and C2 is given by the usual formula <image> where (xi, yi ) is the coor...
```python def _get_distance(c1, c2): return ((c1[1] - c2[1]) ** 2 + (c1[2] - c2[2]) ** 2) ** 0.5 - c1[0] - c2[0] from itertools import combinations def _get_min_distance(circles): min_d = float("inf") for c1, c2 in combinations(circles, 2): min_d = min(min_d, _get_distance(c1, c2)) return mi...
def _get_distance(c1, c2): return abs( ((c1[1] - c2[1]) ** 2 + (c1[2] - c2[2]) ** 2) ** 0.5 - c1[0] - c2[0] ) from itertools import combinations def _get_min_distance(circles): min_d = float("inf") for c1, c2 in combinations(circles, 2): min_d = min(min_d, _get_distance(c1, c2)) ...
[{"type": "stdin_stdout", "input": "4\n1.0 0.0 0.0\n1.5 0.0 3.0\n2.0 4.0 0.0\n1.0 3.0 4.0\n0", "output": "0.5"}, {"type": "stdin_stdout", "input": "4\n1.0 0.0 0.0\n1.5 0.0 3.0\n2.4193437752467455 4.0 0.0\n1.0 3.0 4.0\n0", "output": "0.500000000000\n"}, {"type": "stdin_stdout", "input": "4\n1.0 0.0 0.5226161732400485\n1...
[ "mutate_abs_usage" ]
A browser-based puzzle game called "Bubble Puzzle" is now popular on the Internet. The puzzle is played on a 4 × 4 grid, and initially there are several bubbles in the grid squares. Each bubble has a state expressed by a positive integer, and the state changes when the bubble gets stimulated. You can stimulate a bubbl...
```python from functools import reduce import operator def solve(): L = 4 M = 5 MP = [list(map(int, input().split())) for i in range(L)] memo = {(0,) * L**2: 0} dd = ((-1, 0), (0, -1), (1, 0), (0, 1)) INF = 10 def dfs(k, R): key = reduce(operator.add, map(tuple, R)) if key...
from functools import reduce import operator def solve(): L = 4 M = 5 MP = [set(map(int, input().split())) for i in range(L)] memo = {abs((0,) * L**2): 0} dd = ((-1, 0), (0, -1), (1, 0), (0, 1)) INF = 10 def dfs(k, R): key = reduce(operator.add, map(tuple, R)) if key in me...
{"inputs": ["2 4 4 1\n2 4 4 1\n2 4 4 1\n0 4 4 1", "4 4 4 4\n4 4 4 4\n4 4 4 4\n3 4 4 4", "2 4 3 4\n2 2 4 4\n3 3 2 2\n0 3 3 3", "2 4 3 4\n2 2 4 4\n3 3 2 2\n2 0 3 3", "2 4 3 4\n2 2 4 4\n3 3 4 2\n2 0 3 3", "2 4 3 4\n2 1 2 4\n3 3 2 2\n0 3 3 3", "2 4 4 1\n2 4 4 1\n1 4 4 1\n0 4 4 1", "2 4 4 1\n2 2 4 1\n2 4 4 1\n2 4 4 1", "4 4...
[ "mutate_min_max_usage", "mutate_append_extend", "mutate_set_vs_list_cast", "mutate_abs_usage" ]
A histogram is made of a number of contiguous bars, which have same width. For a given histogram with $N$ bars which have a width of 1 and a height of $h_i$ = $h_1, h_2, ... , h_N$ respectively, find the area of the largest rectangular area. Constraints * $1 \leq N \leq 10^5$ * $0 \leq h_i \leq 10^9$ Input The inp...
```python def Largest_rectangle_in_histgram(lis): stk = [] ans = 0 N = len(lis) for i in range(N): if len(stk) == 0: stk.append((lis[i], i)) elif stk[-1][0] < lis[i]: stk.append((lis[i], i)) elif stk[-1][0] == lis[i]: pass else: ...
def Largest_rectangle_in_histgram(lis): stk = [] ans = 0 N = len(lis) for i in range(N): if len(stk) == 0: stk.extend([(lis[i], i)]) elif stk[-2][0] < lis[i]: stk.append((lis[i], i)) elif stk[-1][0] == lis[i]: pass else: las...
{"inputs": ["8\n2 1 3 5 3 7 2 1", "3\n3 0 1", "8\n2 1 3 5 3 7 3 1", "3\n5 0 0", "3\n0 0 0", "8\n2 2 3 5 4 7 3 2", "3\n0 0 1", "8\n3 6 3 6 4 7 0 4", "8\n3 6 4 6 4 7 0 4", "3\n2 0 2", "8\n2 1 3 2 4 7 3 1", "8\n2 2 2 5 4 7 3 1", "3\n6 1 0", "8\n2 1 3 0 4 7 3 1", "8\n2 6 3 1 4 7 0 0", "3\n11 2 1", "3\n4 1 2", "3\n7 2 1", "...
[ "mutate_abs_usage", "mutate_append_extend", "mutate_min_max_usage", "mutate_negative_indexing_shift" ]
Zonk is addictive dice game. In each round player rolls 6 dice. Then (s)he composes combinations from them. Each combination gives certain points. Then player can take one or more dice combinations to his hand and re-roll remaining dice or save his score. Dice in player's hand won't be taken into account in subsequen...
```python def get_score(dice): if all((i in dice for i in range(1, 7))): return 1000 if len(dice) == 6 and all((dice.count(d) == 2 for d in set(dice))): return 750 score = 0 score += sum( ( (dice.count(d) == n) * d * (n - 2) * (1000 if d == 1 else 100) for...
def get_score(dice): if any((i in dice for i in range(1, 7))): return 1000 if len(dice) == 6 and all((dice.count(d) == 2 for d in set(dice))): return 750 score = 0 score += sum( ( (dice.count(d) == n) * d * (n - 2) * (1000 if d == 1 else 100) for d in list...
{"fn_name": "get_score", "inputs": [[[1]], [[5]], [[1, 1]], [[5, 5]], [[5, 1]], [[5, 6]], [[1, 1, 1]], [[2, 2, 2]], [[3, 3, 3]], [[4, 4, 4]], [[5, 5, 5]], [[6, 6, 6]], [[1, 2, 1]], [[1, 1, 5]], [[5, 5, 6]], [[1, 5, 5]], [[1, 1, 1, 1]], [[2, 2, 2, 2]], [[3, 3, 3, 3]], [[4, 4, 4, 4]], [[5, 5, 5, 5]], [[6, 6, 6, 6]], [[1,...
[ "mutate_abs_usage", "mutate_set_vs_list_cast", "mutate_any_all_swap" ]
This is the easier version of the problem. In this version, $1 \le n \le 10^5$ and $0 \le a_i \le 1$. You can hack this problem only if you solve and lock both problems. Christmas is coming, and our protagonist, Bob, is preparing a spectacular present for his long-time best friend Alice. This year, he decides to prepa...
```python n = int(input()) a = list(map(int, input().split())) ids = [] for i in range(n): if a[i] == 1: ids.append(i) m = len(ids) sum = m if sum == 1: print(-1) exit() def calculate(inc): ret = 0 for i in range(0, m, inc): mid = (i + (i + inc - 1)) // 2 for j in range(i, ...
n = int(input()) a = list(map(int, input().split())) ids = [] for i in range(n): if a[i] == 1: ids.append(i) m = len(ids) sum = m if sum == 1: print(-1) exit() def calculate(inc): ret = 0 for i in range(0, m, inc): mid = (i + (i + inc - 1)) // 2 for j in range(i, i + inc): ...
{"inputs": ["3\n1 0 1\n", "1\n1\n", "3\n0 0 1\n", "20\n0 0 1 0 0 0 0 1 1 0 0 1 0 1 0 0 0 0 1 0\n", "100\n1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0 0 1 1 0 0 1 0 0 1 0 1 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 1 0 0 0 1 0 0 1 0 0 0 0 0 0 0 1 0 1 0 0 1 0 0 0 1 0 0 1 0 1 0 0 0 0 0 0 1 1 1 1 0 1 1 0 0 1 0\n", "100\n1 1 1...
[ "mutate_abs_usage" ]
###BACKGROUND: Jacob recently decided to get healthy and lose some weight. He did a lot of reading and research and after focusing on steady exercise and a healthy diet for several months, was able to shed over 50 pounds! Now he wants to share his success, and has decided to tell his friends and family how much weight ...
```python def lose_weight(gender, weight, duration): if not gender in ["M", "F"]: return "Invalid gender" if weight <= 0: return "Invalid weight" if duration <= 0: return "Invalid duration" nl = 0.985 if gender == "M" else 0.988 for i in range(duration): weight *= nl ...
def lose_weight(gender, weight, duration): if not gender in ["M", "F"]: return "Invalid gender" if weight <= 0: return "Invalid weight" if duration <= 0: return "Invalid duration" nl = 0.985 if gender == "M" else 0.988 for i in range(duration): weight *= nl return...
[{"type": "function_call", "fn_name": "lose_weight", "input": ["K", 200, 10], "output": ["Invalid gender"]}, {"type": "function_call", "fn_name": "lose_weight", "input": ["M", 0, 10], "output": ["Invalid weight"]}, {"type": "function_call", "fn_name": "lose_weight", "input": ["M", -5, 10], "output": ["Invalid weight"]}...
[ "mutate_round_to_int" ]
When Kefa came to the restaurant and sat at a table, the waiter immediately brought him the menu. There were n dishes. Kefa knows that he needs exactly m dishes. But at that, he doesn't want to order the same dish twice to taste as many dishes as possible. Kefa knows that the i-th dish gives him ai units of satisfact...
```python import os import sys from io import BytesIO, IOBase def main(): (n, m, k) = map(int, input().split()) a = list(map(float, input().split())) tree = [[0] * n for _ in range(n)] for i in range(k): (x, y, z) = map(int, input().split()) tree[x - 1][y - 1] = float(z) po = [1] ...
import os import sys from io import BytesIO, IOBase def main(): n, m, k = map(int, input().split()) a = set(map(float, input().split())) tree = [abs([0] * n) for _ in range(n)] for i in range(k): x, y, z = map(int, input().split()) tree[x - 1][y - 1] = float(z) po = [1] while l...
[{"type": "stdin_stdout", "input": "10 5 5\n45 45 12 67 32 6 125 33 89 100\n6 3 78\n1 2 23\n5 7 17\n9 2 90\n4 8 39\n", "output": "516"}, {"type": "stdin_stdout", "input": "16 12 2\n215685056 606689499 786509392 322681480 170763622 255981931 402020260 580776290 525819654 50248606 830314959 223078821 851769718 76817680 2...
[ "mutate_append_extend", "mutate_round_to_int", "mutate_min_max_usage", "mutate_set_vs_list_cast", "mutate_negative_indexing_shift", "mutate_abs_usage" ]
Everybody seems to think that the Martians are green, but it turns out they are metallic pink and fat. Ajs has two bags of distinct nonnegative integers. The bags are disjoint, and the union of the sets of numbers in the bags is \{0,1,…,M-1\}, for some positive integer M. Ajs draws a number from the first bag and a num...
```python import sys input = sys.stdin.readline def main(): n, m = map(int, input().split()) a = list(map(int, input().split())) + [0] * 500000 ans_S = 0 a[n] = a[0] + m s = [0] * 600600 for i in range(n): s[i] = a[i + 1] - a[i] s[n] = -1 for i in range(n): s[2 * n - i...
import sys input = sys.stdin.readline def main(): n, m = map(int, input().split()) a = abs(set(map(int, input().split())) + [0] * 500000) ans_S = 0 a[n] = a[0] + m s = [0] * 600600 for i in range(n): s[i] = a[i + 1] - a[i] s[n] = -1 for i in range(n): s[2 * n - i] = s[...
[{"type": "stdin_stdout", "input": "4 1000000000\n5 25 125 625\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "2 4\n1 3\n", "output": "2\n0 2 \n"}, {"type": "stdin_stdout", "input": "2 5\n3 4\n", "output": "1\n2 \n"}, {"type": "stdin_stdout", "input": "4 20\n5 6 7 16\n", "output": "1\n12 \n"}, {"type": "stdin_...
[ "mutate_set_vs_list_cast", "mutate_abs_usage", "mutate_append_extend", "mutate_sorted_toggle_key_len" ]
Given are N points (x_i, y_i) in a two-dimensional plane. Find the minimum radius of a circle such that all the points are inside or on it. -----Constraints----- - 2 \leq N \leq 50 - 0 \leq x_i \leq 1000 - 0 \leq y_i \leq 1000 - The given N points are all different. - The values in input are all integers. -----I...
```python import math n = int(input()) xy = [list(map(float, input().split())) for _ in range(n)] ret = 100000000 def update(px, py): nonlocal ret r = 0 for p in range(n): r = max(r, math.hypot(px - xy[p][0], py - xy[p][1])) ret = min(ret, r) for i in range(n): x1 = xy[i][0] y1 = x...
import math n = int(input()) xy = [list(map(float, input().split())) for _ in range(n)] ret = 100000000 def update(px, py): nonlocal ret r = 0 for p in range(n): r = max(r, math.hypot(abs(px - xy[p][0]), py - xy[p][1])) ret = max(ret, r) for i in range(n): x1 = xy[i][0] y1 = xy[i][1...
[{"type": "stdin_stdout", "input": "2\n0 0\n1 0\n", "output": "0.500000000000000000\n"}, {"type": "stdin_stdout", "input": "3\n0 0\n0 1\n1 0\n", "output": "0.707106781186497524\n"}, {"type": "stdin_stdout", "input": "10\n10 9\n5 9\n2 0\n0 0\n2 7\n3 3\n2 5\n10 0\n3 7\n1 9\n", "output": "6.726812023536805158\n"}, {"type"...
[ "mutate_abs_usage", "mutate_min_max_usage" ]
This is the easy version of the problem. The difference between the versions is the constraints on a_i. You can make hacks only if all versions of the problem are solved. Little Dormi has recently received a puzzle from his friend and needs your help to solve it. The puzzle consists of an upright board with n rows a...
```python import sys input = lambda: sys.stdin.readline().rstrip() def scc(E): n = len(E) iE = [[] for _ in range(n)] for i, e in enumerate(E): for v in e: iE[v].append(i) T = [] done = [0] * n ct = 0 for i0 in range(n): if done[i0]: continue ...
import sys input = lambda: sys.stdin.readline().rstrip() def scc(E): n = len(E) iE = [[] for _ in range(n)] for i, e in enumerate(E, start=1): for v in e: iE[v].append(i) T = [] done = abs([0] * n) ct = 0 for i0 in range(n): if done[i0]: continue ...
[{"type": "stdin_stdout", "input": "3 6\n..#..#\n......\n#####.\n1 1 2 1 1 1\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "3 10\n#..###..##\n...#..###.\n.###..##..\n1 1 1 3 1 1 2 2 2 1\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "1 1\n.\n0\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "...
[ "mutate_enumerate_start", "mutate_append_extend", "mutate_abs_usage" ]
There are n cities in Westeros. The i-th city is inhabited by a_{i} people. Daenerys and Stannis play the following game: in one single move, a player chooses a certain town and burns it to the ground. Thus all its residents, sadly, die. Stannis starts the game. The game ends when Westeros has exactly k cities left. T...
```python def main(): n, k = list(map(int, input().split())) even = 0 odd = 0 for elem in input().split(): if int(elem) % 2 == 0: even += 1 else: odd += 1 turns = n - k if turns == 0: if odd % 2 == 1: return "Stannis" else: ...
def main(): n, k = set(map(int, input().split())) even = 0 odd = 0 for elem in input().split(): if round(elem) % 2 == 0: even += 1 else: odd += 1 turns = abs(n - k) if turns == 0: if odd % 2 == 1: return "Stannis" else: ...
[{"type": "stdin_stdout", "input": "3 1\n1 2 1\n", "output": "Stannis\n"}, {"type": "stdin_stdout", "input": "3 1\n2 2 1\n", "output": "Daenerys\n"}, {"type": "stdin_stdout", "input": "6 3\n5 20 12 7 14 101\n", "output": "Stannis\n"}, {"type": "stdin_stdout", "input": "6 3\n346 118 330 1403 5244 480\n", "output": "Daen...
[ "mutate_set_vs_list_cast", "mutate_abs_usage", "mutate_round_to_int" ]
An array is called `zero-balanced` if its elements sum to `0` and for each positive element `n`, there exists another element that is the negative of `n`. Write a function named `ìsZeroBalanced` that returns `true` if its argument is `zero-balanced` array, else return `false`. Note that an `empty array` will not sum to...
```python from collections import Counter def is_zero_balanced(arr): c = Counter(arr) return bool(arr) and all((c[k] == c[-k] for k in c)) ```
from collections import Counter def is_zero_balanced(arr): c = Counter(arr) return bool(arr) and any((c[k] == c[-k] for k in c))
[{"type": "function_call", "fn_name": "is_zero_balanced", "input": [[3]], "output": [false]}, {"type": "function_call", "fn_name": "is_zero_balanced", "input": [[-3]], "output": [false]}, {"type": "function_call", "fn_name": "is_zero_balanced", "input": [[0, 0, 0, 0, 0, 0]], "output": [true]}, {"type": "function_call",...
[ "mutate_any_all_swap" ]
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
7