problem_spec stringlengths 29 9.53k | correct_answer stringlengths 46 289k | corrupted_answer stringlengths 32 289k | tests stringlengths 272 51.6M | applied_mutations listlengths 1 11 |
|---|---|---|---|---|
Dee is lazy but she's kind and she likes to eat out at all the nice restaurants and gastropubs in town. To make paying quick and easy she uses a simple mental algorithm she's called The Fair %20 Rule. She's gotten so good she can do this in a few seconds and it always impresses her dates but she's perplexingly still si... | ```python
def calc_tip(p, r):
if p % 10 < 5:
p //= 10
else:
p = p // 10 + 1
if r == 1:
tip = p + 1
elif r == 0:
tip = p - 1
else:
tip = int(p / 2) - 1
return tip if tip >= 0 else 0
``` | def calc_tip(p, r):
if p % 10 <= 4:
p //= 10
else:
p = p // 10 - 1
if r == 0:
tip = p + 1
elif r == 0:
tip = p - 1
else:
tip = int(p / 2) - 1
return tip if tip >= 0 else 0 | [{"type": "function_call", "fn_name": "calc_tip", "input": [4, 1], "output": [1]}, {"type": "function_call", "fn_name": "calc_tip", "input": [4, 0], "output": [0]}, {"type": "function_call", "fn_name": "calc_tip", "input": [4, -1], "output": [0]}, {"type": "function_call", "fn_name": "calc_tip", "input": [5, 1], "outpu... | [
"mutate_numeric_constants",
"mutate_edge_case_guards",
"mutate_comparison_operators",
"mutate_arithmetic_operators"
] |
Since I got tired to write long problem statements, I decided to make this problem statement short. For given positive integer L, how many pairs of positive integers a, b (a ≤ b) such that LCM(a, b) = L are there? Here, LCM(a, b) stands for the least common multiple of a and b.
Constraints
* 1 ≤ L ≤ 1012
Input
For ... | ```python
# AOJ 1060: No Story
# Python3 2018.6.8 bal4u
MAX = 1000004
ptbl = [
3,
5,
7,
11,
13,
17,
19,
23,
29,
31,
37,
41,
43,
47,
53,
59,
61,
67,
71,
73,
79,
83,
89,
97,
101,
103,
107,
109,
113,
12... | MAX = 1000004
ptbl = [
3,
5,
7,
11,
13,
17,
19,
23,
29,
31,
37,
41,
43,
47,
53,
59,
61,
67,
71,
73,
79,
83,
89,
97,
101,
103,
107,
109,
113,
127,
131,
137,
139,
149,
151,
157,
... | [{"type": "stdin_stdout", "input": "12\n9\n2\n0", "output": "8\n3\n2"}, {"type": "stdin_stdout", "input": "12\n11\n2\n0", "output": "8\n2\n2\n"}, {"type": "stdin_stdout", "input": "12\n9\n3\n0", "output": "8\n3\n2\n"}, {"type": "stdin_stdout", "input": "12\n8\n2\n0", "output": "8\n4\n2\n"}, {"type": "stdin_stdout", "in... | [
"mutate_arithmetic_operators",
"mutate_range_step",
"mutate_comparison_operators",
"mutate_numeric_constants",
"mutate_edge_case_guards"
] |
Vasya plays a computer game with ninjas. At this stage Vasya's ninja should get out of a deep canyon.
The canyon consists of two vertical parallel walls, their height is n meters. Let's imagine that we split these walls into 1 meter-long areas and number them with positive integers from 1 to n from bottom to top. Some... | ```python
from collections import deque
l, j = [int(i) for i in input().split(" ")]
wallA = list(input())
wallB = list(input())
g = {}
for i in range(l):
# Each 4-tuple represents: (Visited?, Current Height, Current Water Height, Drowned?)
if wallA[i] == "-":
g[(1, i + 1)] = (-1, 0, 0, False)
if w... | from collections import deque
l, j = [int(i) for i in input().split(" ")]
wallA = list(input())
wallB = list(input())
g = {}
for i in range(l):
if wallA[i] == "-":
g[1, i + 1] = (-1, 0, 0, False)
if wallB[i] == "-":
g[-1, i + 1] = (-1, 0, 0, False)
g[1, 1] = ("VISITED", 1, 0, False)
q = deque([... | [{"type": "stdin_stdout", "input": "6 2\n--X-X-\nX--XX-\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "7 3\n---X--X\n-X--XX-\n", "output": "YES\n"}, {"type": "stdin_stdout", "input": "5 4\n-X---\n----X\n", "output": "NO\n"}, {"type": "stdin_stdout", "input": "10 1\n-X-X-X-X-X\nX-X-X-X-X-\n", "output": "YES\n... | [
"mutate_boolean_constants",
"mutate_conditional_inversion",
"mutate_arithmetic_operators",
"mutate_comparison_operators",
"mutate_list_indexing",
"mutate_numeric_constants"
] |
There is an automatic door at the entrance of a factory. The door works in the following way: when one or several people come to the door and it is closed, the door immediately opens automatically and all people immediately come inside, when one or several people come to the door and it is open, all people immediatel... | ```python
BigNum = 10**20
(n, m, a, d) = map(int, input().split(" "))
ts = [0] + list(map(int, input().split(" "))) + [BigNum]
def empsInRange(l, r):
em1 = l // a + 1
em2 = r // a
return (em1, min(em2, n))
empDoorGroup = d // a + 1
def moveEmps(emps, last):
(em1, em2) = emps
if em1 > em2:
... | BigNum = 10**20
n, m, a, d = map(int, input().split(" "))
ts = [0] + list(map(int, input().split(" "))) + [BigNum]
def empsInRange(l, r):
em1 = l // a - 1
em2 = r // a
return (em1, min(em2, n))
empDoorGroup = d // a + 1
def moveEmps(emps, last):
em1, em2 = emps
if em1 > em2:
return (la... | [{"type": "stdin_stdout", "input": "1 1 3 4\n7\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "4 3 4 2\n7 9 11\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "10 10 51 69\n154 170 170 183 251 337 412 426 445 452\n", "output": "6\n"}, {"type": "stdin_stdout", "input": "70 10 26 17\n361 371 579 585 629 ... | [
"mutate_arithmetic_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
# seishin.py
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... | import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
MOD = 10**9 - 7
N = int(readline())
M = 19
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().strip()
S[i][: len(s)] = map(ord, ... | [{"type": "stdin_stdout", "input": "2\n?sum??mer\nc??a??mp", "output": "703286064"}, {"type": "stdin_stdout", "input": "3\nsnuje\n????e\nsnule", "output": "1"}, {"type": "stdin_stdout", "input": "2\n?rum??mer\nc??a??mp", "output": "715167440\n"}, {"type": "stdin_stdout", "input": "3\nsnuje\n????e\neluns", "output": "0\... | [
"mutate_list_indexing",
"mutate_range_step",
"mutate_comparison_operators",
"mutate_numeric_constants",
"mutate_range_bounds",
"mutate_arithmetic_operators"
] |
Lеt's create function to play cards. Our rules:
We have the preloaded `deck`:
```
deck = ['joker','2♣','3♣','4♣','5♣','6♣','7♣','8♣','9♣','10♣','J♣','Q♣','K♣','A♣',
'2♦','3♦','4♦','5♦','6♦','7♦','8♦','9♦','10♦','J♦','Q♦','K♦','A♦',
'2♥','3♥','4♥','5♥','6♥','7♥','8♥','9♥','10♥','J♥','Q♥... | ```python
vals = "2345678910JQKA"
def card_game(card_1, card_2, trump):
print((card_1, card_2, trump))
if card_1 == card_2:
return "Someone cheats."
elif "joker" in [card_1, card_2]:
return ["The first card won.", "The second card won."][
card_1 != "joker"
]
elif ca... | vals = "2345678910JQKA"
def card_game(card_1, card_2, trump):
print((card_1, card_2, trump))
if card_1 != card_2:
return "Someone cheats."
elif "joker" in [card_1, card_2]:
return ["The first card won.", "The second card won."][
card_1 != "joker"
]
elif card_1[-1] =... | [{"type": "function_call", "fn_name": "card_game", "input": ["Q\u2663", "3\u2663", "\u2666"], "output": ["The first card won."]}, {"type": "function_call", "fn_name": "card_game", "input": ["3\u2663", "Q\u2663", "\u2666"], "output": ["The second card won."]}, {"type": "function_call", "fn_name": "card_game", "input": [... | [
"mutate_list_indexing",
"mutate_comparison_operators"
] |
There is a complete graph of m vertices. Initially, the edges of the complete graph are uncolored. Sunuke did the following for each i (1 ≤ i ≤ n): Select ai vertices from the complete graph and color all edges connecting the selected vertices with color i. None of the sides were painted in multiple colors. Find the mi... | ```python
N = int(input())
A = [int(input()) for i in range(N)]
INF = 10**18
N2 = 2**N
def dfs(i, D):
if i == N:
return sum(D)
b = 1 << i
a = A[i]
def sel(j, state, u):
if j == N2:
D2 = D[:]
for e in u:
D2[e] -= 1
D2[e | b] += 1
... | N = int(input())
A = [int(input()) for i in range(N)]
INF = 10**18
N2 = 2**N
def dfs(i, D):
if i != N:
return len(D)
b = 1 << i
a = A[i]
def sel(j, state, u):
if j == N2:
D2 = D[:]
for e in u:
D2[e] -= 1
D2[e | b] += 1
... | {"inputs": ["5\n2\n3\n3\n5\n6", "2\n6\n3", "2\n6\n2", "2\n5\n2", "2\n1\n2", "2\n1\n3", "5\n2\n3\n5\n5\n6", "5\n2\n3\n3\n2\n6", "2\n8\n3", "2\n5\n1", "2\n14\n2", "2\n14\n4", "2\n3\n2", "2\n14\n8", "2\n15\n2", "2\n14\n16", "2\n11\n2", "2\n14\n5", "2\n21\n2", "2\n21\n3", "2\n21\n4", "2\n21\n6", "2\n40\n6", "2\n40\n12", "2... | [
"mutate_conditional_inversion",
"mutate_comparison_operators",
"mutate_function_call_name",
"mutate_arithmetic_operators"
] |
Little Petya likes points a lot. Recently his mom has presented him n points lying on the line OX. Now Petya is wondering in how many ways he can choose three distinct points so that the distance between the two farthest of them doesn't exceed d.
Note that the order of the points inside the group of three chosen point... | ```python
def Search(L, aa, x):
a = aa
b = len(L)
while b - a > 1:
i = (b + a) // 2
if L[i] > x:
b = i
elif L[i] < x:
a = i
else:
return (i + 1) - aa - 1
return b - aa - 1
import math
n, d = list(map(int, input().split()))
P = list(... | def Search(L, aa, x):
a = aa
b = len(L)
while b - a >= 1:
i = (b + a) // 1
if L[i] > x:
b = i
elif L[i] < x:
a = i
else:
return i + 1 - aa - 1
return b - aa + 1
import math
n, d = list(map(int, input().split()))
P = list(map(int, inp... | [{"type": "stdin_stdout", "input": "4 3\n1 2 3 4\n", "output": "4\n"}, {"type": "stdin_stdout", "input": "4 2\n-3 -2 -1 0\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "5 19\n1 10 20 30 50\n", "output": "1\n"}, {"type": "stdin_stdout", "input": "10 5\n31 36 43 47 48 50 56 69 71 86\n", "output": "2\n"}, {"type... | [
"mutate_arithmetic_operators",
"mutate_comparison_operators",
"mutate_numeric_constants"
] |
We have a sequence of N integers: x=(x_0,x_1,\cdots,x_{N-1}). Initially, x_i=0 for each i (0 \leq i \leq N-1).
Snuke will perform the following operation exactly M times:
* Choose two distinct indices i, j (0 \leq i,j \leq N-1,\ i \neq j). Then, replace x_i with x_i+2 and x_j with x_j+1.
Find the number of differe... | ```python
(N, M) = map(int, input().split())
MOD = 998244353
if N < M:
one = N - (N - M) % 2
two = (3 * M - one) // 2
else:
(one, two) = (M, M)
L = M + M // 2 + N - 1
fac = [0] * (L + 1)
inv = [0] * (L + 1)
(fac[0], inv[0]) = (1, 1)
for i in range(1, L + 1):
fac[i] = fac[i - 1] * i % MOD
inv[i] = po... | N, M = map(int, input().split())
MOD = 998244353
if N < M:
one = N - (N - M) % 2
two = (3 * M - one) // 2
else:
one, two = (M, M)
L = M + M // 2 + N - 1
fac = [0] * (L + 1)
inv = [0] * (L + 1)
fac[0], inv[0] = (1, 1)
for i in range(1, L + 1):
fac[i] = fac[i - 1] * i % MOD
inv[i] = pow(fac[i], MOD - ... | {"inputs": ["100001 50000", "5 10", "0 2", "100001 27098", "5 7", "101001 27098", "6 7", "101000 27098", "3 7", "101000 9586", "3 10", "101000 14296", "2 10", "101000 4853", "101000 3325", "101001 3325", "101001 365", "101011 365", "101011 172", "101011 164", "101011 129", "101111 129", "101111 145", "101111 54", "1010... | [
"mutate_comparison_operators",
"mutate_conditional_inversion",
"mutate_arithmetic_operators"
] |
Polycarp thinks about the meaning of life very often. He does this constantly, even when typing in the editor. Every time he starts brooding he can no longer fully concentrate and repeatedly presses the keys that need to be pressed only once. For example, instead of the phrase "how are you" he can type "hhoow aaaare yy... | ```python
from collections import deque
def plugin(s):
string_stack = deque()
arr_s = [c for c in s]
for c in arr_s:
string_stack.append(c)
if len(string_stack) > 1:
if string_stack[-1] == string_stack[-2]:
string_stack.pop()
string_stack.pop()
... | from collections import deque
def plugin(s):
string_stack = deque()
arr_s = [c for c in s]
for c in arr_s:
string_stack.append(c)
if len(string_stack) >= 0:
if string_stack[-1] == string_stack[-1]:
string_stack.pop()
string_stack.pop()
return... | [{"type": "stdin_stdout", "input": "xraccabccbry\n", "output": "xy\n"}, {"type": "stdin_stdout", "input": "abb\n", "output": "a\n"}, {"type": "stdin_stdout", "input": "a\n", "output": "a\n"}, {"type": "stdin_stdout", "input": "aab\n", "output": "b\n"}, {"type": "stdin_stdout", "input": "babbbbabbabbbababbabbbbbbabaabaa... | [
"mutate_comparison_operators",
"mutate_numeric_constants",
"mutate_edge_case_guards"
] |
There are N towns in JOI, which are connected by M bidirectional roads. There are shopping malls in K towns, and the people go to one of those towns through the road to shop.
Depending on the location of your home, you may have to travel long distances to go shopping, which is very inconvenient. To understand this sit... | ```python
from heapq import heappop as pop
from heapq import heappush as push
INF = 10**18
class edge:
def __init__(self, to, cost):
self.to = to
self.cost = cost
(N, M, K) = map(int, input().split())
G = [[] for i in range(N)]
d = [INF for i in range(N)]
def dijkstra(lst):
que = []
... | from heapq import heappop as pop
from heapq import heappush as push
INF = 10**18
class edge:
def __init__(self, to, cost):
self.to = to
self.cost = cost
N, M, K = map(int, input().split())
G = [[] for i in range(N)]
d = [INF for i in range(N)]
def dijkstra(lst):
que = []
for s in lst... | {"inputs": ["4 3 1\n1 2 1\n2 3 1\n3 1 1\n1", "4 3 1\n1 2 1\n2 3 2\n1 1 1\n1", "4 3 1\n1 2 1\n2 3 1\n1 2 1\n2", "4 3 1\n1 2 1\n2 3 4\n1 1 1\n1", "8 3 1\n1 1 2\n2 3 4\n3 1 0\n1", "4 3 1\n1 2 2\n2 4 4\n1 1 1\n1", "4 3 1\n1 1 0\n1 3 0\n3 2 0\n1", "10 3 1\n1 2 5\n3 3 2\n3 1 1\n2", "4 3 1\n1 2 1\n2 3 1\n1 1 1\n1", "4 3 1\n1 ... | [
"mutate_range_bounds",
"mutate_list_indexing",
"mutate_comparison_operators",
"mutate_range_step",
"mutate_arithmetic_operators",
"mutate_numeric_constants"
] |
Ujan has been lazy lately, but now has decided to bring his yard to good shape. First, he decided to paint the path from his house to the gate.
The path consists of n consecutive tiles, numbered from 1 to n. Ujan will paint each tile in some color. He will consider the path aesthetic if for any two different tiles wit... | ```python
def prime_factor(n):
ass = []
for i in range(2, int(n**0.5) + 1):
while n % i == 0:
ass.append(i)
n = n // i
if n != 1:
ass.append(n)
return ass
n = int(input())
p = list(set(prime_factor(n)))
if len(p) == 1:
print(p[0])
else:
print(1)
``` | def prime_factor(n):
ass = []
for i in range(1, int(n**0.5) - 1, 2):
while n % i == 0:
ass.append(i)
n = n // i
if n == 0:
ass.append(n)
return ass
n = int(input())
p = list(set(prime_factor(n)))
if len(p) == 1:
print(p[0])
else:
print(1) | {"inputs": ["2\n", "54241012609\n", "4294967318\n", "370758709373\n", "546739553053\n", "922350872881\n", "442654694329\n", "832972004929\n", "931667836027\n", "6469693230\n", "9\n", "243\n", "549755813888\n", "902076349729\n", "2000006\n", "916517107801\n", "200001286\n", "964483090561\n", "2000000014\n", "85289103744... | [
"mutate_numeric_constants",
"mutate_edge_case_guards",
"mutate_comparison_operators",
"mutate_range_step",
"mutate_arithmetic_operators"
] |
The greatest common divisor is an indispensable element in mathematics handled on a computer. Using the greatest common divisor can make a big difference in the efficiency of the calculation. One of the algorithms to find the greatest common divisor is "Euclidean algorithm". The flow of the process is shown below.
<im... | ```python
def solve():
from sys import stdin
f_i = stdin
ans = ""
while True:
(a, b) = map(int, f_i.readline().split())
if a == 0 and b == 0:
break
if a < b:
(a, b) = (b, a)
cnt = 1
while a % b != 0:
cnt += 1
(a, b)... | def solve():
from sys import stdin
f_i = stdin
ans = ""
while False:
a, b = map(int, f_i.readline().split())
if not a == 0 and b == 0:
break
if a <= b:
a, b = (b, a)
cnt = 1
while a % b != 0:
cnt += 1
a, b = (b, a %... | [{"type": "stdin_stdout", "input": "1071 1029\n5 3\n0 0", "output": "21 3\n1 3\n"}, {"type": "stdin_stdout", "input": "1251 1029\n5 3\n0 0", "output": "3 8\n1 3\n"}, {"type": "stdin_stdout", "input": "1251 1802\n5 3\n0 0", "output": "1 9\n1 3\n"}, {"type": "stdin_stdout", "input": "1071 446\n5 3\n0 0", "output": "1 5\n... | [
"mutate_comparison_operators",
"mutate_conditional_inversion",
"mutate_boolean_constants"
] |
Well met with Fibonacci bigger brother, AKA Tribonacci.
As the name may already reveal, it works basically like a Fibonacci, but summing the last 3 (instead of 2) numbers of the sequence to generate the next. And, worse part of it, regrettably I won't get to hear non-native Italian speakers trying to pronounce it :(
... | ```python
def tribonacci(signature, n):
res = signature[:n]
for i in range(n - 3):
res.append(sum(res[-3:]))
return res
``` | def tribonacci(signature, n):
res = signature[:n]
for i in range(n - 2 + 1, 2):
res.append(len(res[-3:]))
return res | [{"type": "function_call", "fn_name": "tribonacci", "input": [[1, 1, 1], 10], "output": [[1, 1, 1, 3, 5, 9, 17, 31, 57, 105]]}, {"type": "function_call", "fn_name": "tribonacci", "input": [[0, 0, 1], 10], "output": [[0, 0, 1, 1, 2, 4, 7, 13, 24, 44]]}, {"type": "function_call", "fn_name": "tribonacci", "input": [[0, 1,... | [
"mutate_range_bounds",
"mutate_numeric_constants",
"mutate_arithmetic_operators",
"mutate_function_call_name",
"mutate_range_step"
] |
Alice, Bob and Charlie are playing Card Game for Three, as below:
- At first, each of the three players has a deck consisting of some number of cards. Alice's deck has N cards, Bob's deck has M cards, and Charlie's deck has K cards. Each card has a letter a, b or c written on it. The orders of the cards in the decks c... | ```python
import sys
input = sys.stdin.readline
import numpy as np
MOD = 10**9 + 7
N, M, K = map(int, input().split())
def cumprod(arr):
L = len(arr)
Lsq = int(L**0.5 + 1)
arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)
for n in range(1, Lsq):
arr[:, n] *= arr[:, n - 1]
arr[:, n] %=... | import sys
input = sys.stdin.readline
import numpy as np
MOD = 10**9 + 7
N, M, K = map(int, input().split())
def cumprod(arr):
L = len(arr)
Lsq = int(L**0.5 - 1)
arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)
for n in range(1, Lsq, 3):
arr[:, n] *= arr[:, n - 1]
arr[:, n] %= MOD
... | [{"type": "stdin_stdout", "input": "1 1 1\n", "output": "17\n"}, {"type": "stdin_stdout", "input": "4 2 2\n", "output": "1227\n"}, {"type": "stdin_stdout", "input": "1000 1000 1000\n", "output": "261790852\n"}, {"type": "stdin_stdout", "input": "1 2 5\n", "output": "5709\n"}, {"type": "stdin_stdout", "input": "1 1000 1... | [
"mutate_arithmetic_operators",
"mutate_range_step",
"mutate_range_bounds",
"mutate_numeric_constants"
] |
Gilbert is the network admin of Ginkgo company. His boss is mad about the messy network cables on the floor. He finally walked up to Gilbert and asked the lazy network admin to illustrate how computers and switches are connected. Since he is a programmer, he is very reluctant to move throughout the office and examine c... | ```python
def solve():
from sys import stdin
f_i = stdin
# function to update distance between switch and computer
def dfs(sw_id, prev, dist):
switch[sw_id].append(dist)
for next_sw in adj[sw_id]:
if next_sw != prev:
dfs(next_sw, sw_id, dist + 1)
while ... | def solve():
from sys import stdin
f_i = stdin
def dfs(sw_id, prev, dist):
switch[sw_id].append(dist)
for next_sw in adj[sw_id]:
if next_sw != prev:
dfs(next_sw, sw_id, dist - 1)
while False:
N = int(f_i.readline())
if N != 1:
br... | [{"type": "stdin_stdout", "input": "4\n 0 2 2 2\n 2 0 2 2\n 2 2 0 2\n 2 2 2 0\n4\n 0 2 4 4\n 2 0 4 4\n 4 4 0 2\n 4 4 2 0\n2\n 0 12\n 12 0\n0", "output": "4\n2 3 3\n2 2 2 2 2 2 2 2 2 2 2"}, {"type": "stdin_stdout", "input": "4\n0 2 2 2\n2 0 2 2\n2 2 0 2\n2 2 2 0\n4... | [
"mutate_sort_order",
"mutate_numeric_constants",
"mutate_range_bounds",
"mutate_arithmetic_operators",
"mutate_range_step",
"mutate_boolean_constants",
"mutate_comparison_operators",
"mutate_edge_case_guards",
"mutate_slice_bounds"
] |
One quite ordinary day Valera went to school (there's nowhere else he should go on a week day). In a maths lesson his favorite teacher Ms. Evans told students about divisors. Despite the fact that Valera loved math, he didn't find this particular topic interesting. Even more, it seemed so boring that he fell asleep in ... | ```python
def pr(x):
d = 2
while d * d <= x:
if x % d == 0:
return 0
d += 1
return 1
def cnt(n, k):
if not pr(k) or n < k:
return 0
n1 = n // k
return n1 - sum(cnt(n1, i) for i in range(2, min(k, n1 + 1)))
a, b, k = map(int, input().split())
ans = cnt(b, k... | def pr(x):
d = 3
while d // d < x:
if x % d == 1:
return 0
d += 1
return 1
def cnt(n, k):
if not pr(k) or n < k:
return 0
n1 = n // k
return n1 - sum((cnt(n1, i) for i in range(2, min(k, n1 + 1))))
a, b, k = map(int, input().split())
ans = cnt(b, k) - cnt(... | [{"type": "stdin_stdout", "input": "12 23 3\n", "output": "2\n"}, {"type": "stdin_stdout", "input": "1 10 2\n", "output": "5\n"}, {"type": "stdin_stdout", "input": "6 19 5\n", "output": "0\n"}, {"type": "stdin_stdout", "input": "1 2000000000 10007\n", "output": "16746\n"}, {"type": "stdin_stdout", "input": "19431 20000... | [
"mutate_numeric_constants",
"mutate_comparison_operators",
"mutate_arithmetic_operators",
"mutate_edge_case_guards"
] |
Let's assume that
* v(n) is the largest prime number, that does not exceed n;
* u(n) is the smallest prime number strictly greater than n.
Find <image>.
Input
The first line contains integer t (1 ≤ t ≤ 500) — the number of testscases.
Each of the following t lines of the input contains integer n (2 ≤ n ≤ ... | ```python
T = int(input())
# for every prime x
# (b-a)/ab
# 1/a-1/b
MAX = 33000
bePrime = [0] * MAX
primNum = []
for j in range(2, MAX):
if bePrime[j] == 0:
primNum.append(j)
i = j
while i < MAX:
bePrime[i] = 1
i = i + j
def isPrime(a):
for j in primNum:
... | T = int(input())
MAX = 33000
bePrime = [0] * MAX
primNum = []
for j in range(2, MAX):
if bePrime[j] == 0:
primNum.append(j)
i = j
while i < MAX:
bePrime[i] = 1
i = i + j
def isPrime(a):
for j in primNum:
if j > a:
return True
if a % j... | [{"type": "stdin_stdout", "input": "2\n2\n3\n", "output": "1/6\n7/30\n"}, {"type": "stdin_stdout", "input": "5\n72\n72\n30\n75\n11\n", "output": "71/146\n71/146\n29/62\n5615/11534\n119/286\n"}, {"type": "stdin_stdout", "input": "5\n79\n149\n136\n194\n124\n", "output": "6393/13114\n22199/44998\n135/274\n37631/76042\n141... | [
"mutate_boolean_constants",
"mutate_comparison_operators",
"mutate_edge_case_guards"
] |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 4