description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
If you have ever interacted with a cat, you have probably noticed that they are quite particular about how to pet them. Here is an approximate map of a normal cat.
<image>
However, some cats won't tolerate this nonsense from the humans. Here is a map of a grumpy cat.
<image>
You have met a cat. Can you figure out w... | import sys
seen_cool = False
no_counter = 0
normal = ["great", "bad", "think", "touch", "cool"]
for i in range(10):
print(i)
sys.stdout.flush()
s = input()
if s == "no":
no_counter += 1
if no_counter > 3:
print("normal")
break
else:
found = False
... | IMPORT ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST STRING STRING STRING STRING STRING FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR STRING VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR ASSIGN VAR NUMBER IF VAR... |
If you have ever interacted with a cat, you have probably noticed that they are quite particular about how to pet them. Here is an approximate map of a normal cat.
<image>
However, some cats won't tolerate this nonsense from the humans. Here is a map of a grumpy cat.
<image>
You have met a cat. Can you figure out w... | i = 0
exec(
"""print(i,flush=1);i+=1;x=input()
if x!='no':print('grumpy'if x[-2:]in'lenuseay'else'normal');quit()
"""
* 7
) | ASSIGN VAR NUMBER EXPR FUNC_CALL VAR BIN_OP STRING NUMBER |
If you have ever interacted with a cat, you have probably noticed that they are quite particular about how to pet them. Here is an approximate map of a normal cat.
<image>
However, some cats won't tolerate this nonsense from the humans. Here is a map of a grumpy cat.
<image>
You have met a cat. Can you figure out w... | import sys
grum = [
"don't even",
"are you serious",
"go die in a hole",
"worse",
"terrible",
"no way",
]
for i in range(10):
print(i)
sys.stdout.flush()
s = sys.stdin.readline().strip().lower()
if s != "no":
print("grumpy" if s in grum else "normal")
sys.exit() | IMPORT ASSIGN VAR LIST STRING STRING STRING STRING STRING STRING FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR IF VAR STRING EXPR FUNC_CALL VAR VAR VAR STRING STRING EXPR FUNC_CALL VAR |
If you have ever interacted with a cat, you have probably noticed that they are quite particular about how to pet them. Here is an approximate map of a normal cat.
<image>
However, some cats won't tolerate this nonsense from the humans. Here is a map of a grumpy cat.
<image>
You have met a cat. Can you figure out w... | import sys
i = 0
while i < 10:
print(i)
sys.stdout.flush()
ans = sys.stdin.readline().strip().lower()
if ans == "no":
i += 1
continue
if ans[:3] in ["gre", "not", "coo", "don"] and ans[-4:] != "even":
print("normal")
else:
print("grumpy")
sys.stdout.flush()
... | IMPORT ASSIGN VAR NUMBER WHILE VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR IF VAR STRING VAR NUMBER IF VAR NUMBER LIST STRING STRING STRING STRING VAR NUMBER STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR |
If you have ever interacted with a cat, you have probably noticed that they are quite particular about how to pet them. Here is an approximate map of a normal cat.
<image>
However, some cats won't tolerate this nonsense from the humans. Here is a map of a grumpy cat.
<image>
You have met a cat. Can you figure out w... | import sys
normal_only = ["not bad\n", "great\n", "don't touch me\n", "don't think so\n", "cool\n"]
grumpy_only = [
"don't even\n",
"terrible\n",
"worse\n",
"no way\n",
"go die in a hole\n",
"are you serious\n",
]
def query(a):
print(str(a), flush=True)
res = sys.stdin.readline()
... | IMPORT ASSIGN VAR LIST STRING STRING STRING STRING STRING ASSIGN VAR LIST STRING STRING STRING STRING STRING STRING FUNC_DEF EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR RETURN VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING NUMBER EXPR F... |
If you have ever interacted with a cat, you have probably noticed that they are quite particular about how to pet them. Here is an approximate map of a normal cat.
<image>
However, some cats won't tolerate this nonsense from the humans. Here is a map of a grumpy cat.
<image>
You have met a cat. Can you figure out w... | import sys
a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
for i in a:
sys.stdout.flush()
print(i, flush=True)
sys.stdout.flush()
s = str(input())
sys.stdout.flush()
if s == "no":
sys.stdout.flush()
continue
if (
s == "great"
or s == "cool"
or s == "not bad"
... | IMPORT ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FOR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR IF VAR STRING EXPR FUNC_CALL VAR IF VAR STRING VAR STRING VAR STRING VAR STRING VAR STRIN... |
If you have ever interacted with a cat, you have probably noticed that they are quite particular about how to pet them. Here is an approximate map of a normal cat.
<image>
However, some cats won't tolerate this nonsense from the humans. Here is a map of a grumpy cat.
<image>
You have met a cat. Can you figure out w... | import sys
for i in range(0, 10):
print(i)
sys.stdout.flush()
res = input()
if res != "no":
if res in [
"great",
"don't think so",
"don't touch me",
"not bad",
"cool",
"great",
]:
print("normal")
... | IMPORT FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR STRING IF VAR LIST STRING STRING STRING STRING STRING STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR |
If you have ever interacted with a cat, you have probably noticed that they are quite particular about how to pet them. Here is an approximate map of a normal cat.
<image>
However, some cats won't tolerate this nonsense from the humans. Here is a map of a grumpy cat.
<image>
You have met a cat. Can you figure out w... | ans = ""
i = 0
while not ans:
print(i, flush=1)
s = input()
if s != "no":
if s in [
"great",
"great!",
"don't think so",
"not bad",
"cool",
"don't touch me",
"don't touch me!",
]:
ans = "normal"
... | ASSIGN VAR STRING ASSIGN VAR NUMBER WHILE VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR IF VAR STRING IF VAR LIST STRING STRING STRING STRING STRING STRING STRING ASSIGN VAR STRING ASSIGN VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR |
If you have ever interacted with a cat, you have probably noticed that they are quite particular about how to pet them. Here is an approximate map of a normal cat.
<image>
However, some cats won't tolerate this nonsense from the humans. Here is a map of a grumpy cat.
<image>
You have met a cat. Can you figure out w... | normal = ["great", "don't think so", "don't touch me", "not bad", "cool"]
response = "no"
x = 0
while response == "no":
print(x, flush=True)
response = input()
x += 1
print("normal") if response in normal else print("grumpy") | ASSIGN VAR LIST STRING STRING STRING STRING STRING ASSIGN VAR STRING ASSIGN VAR NUMBER WHILE VAR STRING EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER EXPR VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING |
You have an array $a_1, a_2, \dots, a_n$ where $a_i = i$.
In one step, you can choose two indices $x$ and $y$ ($x \neq y$) and set $a_x = \left\lceil \frac{a_x}{a_y} \right\rceil$ (ceiling function).
Your goal is to make array $a$ consist of $n - 1$ ones and $1$ two in no more than $n + 5$ steps. Note that you don't ... | T = int(input())
r = 1
def getans(target, n):
ans = []
num1 = target
num2 = n
flag = True
while True:
if num1 > num2:
num1 = (num1 - 1) // num2 + 1
ans.append([target, n])
elif num1 < num2:
num2 = (num2 - 1) // num1 + 1
ans.append([n,... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR LIST ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE NUMBER IF VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR LIST VAR VAR IF VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL ... |
You have an array $a_1, a_2, \dots, a_n$ where $a_i = i$.
In one step, you can choose two indices $x$ and $y$ ($x \neq y$) and set $a_x = \left\lceil \frac{a_x}{a_y} \right\rceil$ (ceiling function).
Your goal is to make array $a$ consist of $n - 1$ ones and $1$ two in no more than $n + 5$ steps. Note that you don't ... | def cd(x, y):
return (x + y - 1) // y
t = int(input())
for _ in range(t):
out = []
n = int(input())
large = n
for i in range(n - 1, 1, -1):
while cd(large, i) in [i, i + 1]:
out.append(str(n) + " " + str(i))
large = cd(large, i)
out.append(str(i) + " " + str... | FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER WHILE FUNC_CALL VAR VAR VAR LIST VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR B... |
You have an array $a_1, a_2, \dots, a_n$ where $a_i = i$.
In one step, you can choose two indices $x$ and $y$ ($x \neq y$) and set $a_x = \left\lceil \frac{a_x}{a_y} \right\rceil$ (ceiling function).
Your goal is to make array $a$ consist of $n - 1$ ones and $1$ two in no more than $n + 5$ steps. Note that you don't ... | import sys
def input():
return sys.stdin.readline().strip()
def solve():
for t in range(int(input())):
n = int(input())
j = n
res = []
while j != 2:
x = int(j**0.5)
if x * x < j:
x += 1
for i in range(x + 1, j):
... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR LIST WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FU... |
You have an array $a_1, a_2, \dots, a_n$ where $a_i = i$.
In one step, you can choose two indices $x$ and $y$ ($x \neq y$) and set $a_x = \left\lceil \frac{a_x}{a_y} \right\rceil$ (ceiling function).
Your goal is to make array $a$ consist of $n - 1$ ones and $1$ two in no more than $n + 5$ steps. Note that you don't ... | for _ in range(int(input())):
n = int(input())
cur = n
down = {cur}
while cur > 2:
bsl, bsr = 1, cur
while bsl + 1 < bsr:
bsm = (bsl + bsr) // 2
if bsm**2 < cur:
bsl = bsm
else:
bsr = bsm
cur = bsr
down.a... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR WHILE VAR NUMBER ASSIGN VAR VAR NUMBER VAR WHILE BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR NUMBER VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR V... |
You have an array $a_1, a_2, \dots, a_n$ where $a_i = i$.
In one step, you can choose two indices $x$ and $y$ ($x \neq y$) and set $a_x = \left\lceil \frac{a_x}{a_y} \right\rceil$ (ceiling function).
Your goal is to make array $a$ consist of $n - 1$ ones and $1$ two in no more than $n + 5$ steps. Note that you don't ... | t = int(input())
for _ in range(t):
n = int(input())
ans = []
if n > 12:
for i in range(13, n):
ans.append((i, n))
prod = 1
while prod < n:
ans.append((n, 12))
prod *= 12
for i in range(5, 12):
ans.append((i, 12))
ans.ap... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST IF VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VA... |
You have an array $a_1, a_2, \dots, a_n$ where $a_i = i$.
In one step, you can choose two indices $x$ and $y$ ($x \neq y$) and set $a_x = \left\lceil \frac{a_x}{a_y} \right\rceil$ (ceiling function).
Your goal is to make array $a$ consist of $n - 1$ ones and $1$ two in no more than $n + 5$ steps. Note that you don't ... | ansl = []
for _ in range(int(input())):
al = []
n = int(input())
v = n
if n <= 16:
for i in range(3, n):
al.append((i, n))
while v > 1:
al.append((n, 2))
v = (v - 1) // 2 + 1
ansl.append(al)
continue
for i in range(3, n):
if... | ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR VAR VAR WHILE VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER EXPR F... |
You have an array $a_1, a_2, \dots, a_n$ where $a_i = i$.
In one step, you can choose two indices $x$ and $y$ ($x \neq y$) and set $a_x = \left\lceil \frac{a_x}{a_y} \right\rceil$ (ceiling function).
Your goal is to make array $a$ consist of $n - 1$ ones and $1$ two in no more than $n + 5$ steps. Note that you don't ... | for i in range(int(input())):
n = int(input())
if n <= 4:
print(n - 1)
for i in range(3, n):
print(i, i + 1)
print(n, 2)
print(n, 2)
elif n <= 8:
print(n)
for i in range(3, n):
print(i, i + 1)
for i in range(3):
prin... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR F... |
You have an array $a_1, a_2, \dots, a_n$ where $a_i = i$.
In one step, you can choose two indices $x$ and $y$ ($x \neq y$) and set $a_x = \left\lceil \frac{a_x}{a_y} \right\rceil$ (ceiling function).
Your goal is to make array $a$ consist of $n - 1$ ones and $1$ two in no more than $n + 5$ steps. Note that you don't ... | t = int(input())
while t:
t -= 1
n = int(input())
l = []
x = 2
while x < n:
l.append(x)
x *= x
l.append(n)
ans = []
for i in range(3, n):
if not i in l:
ans.append([i, n])
l = l[::-1]
y = len(l)
for i in range(0, y - 1):
ans.append(... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR VAR NUMBER ASSIG... |
You have an array $a_1, a_2, \dots, a_n$ where $a_i = i$.
In one step, you can choose two indices $x$ and $y$ ($x \neq y$) and set $a_x = \left\lceil \frac{a_x}{a_y} \right\rceil$ (ceiling function).
Your goal is to make array $a$ consist of $n - 1$ ones and $1$ two in no more than $n + 5$ steps. Note that you don't ... | for _ in range(int(input())):
n = int(input())
if n <= 8:
temp = n
cnt = 0
while temp != 1:
temp = (temp + 1) // 2
cnt += 1
print(cnt + n - 3)
for i in range(3, n):
print(i, n)
for i in range(cnt):
print(n, 2)
el... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR VAR VAR FOR V... |
You have an array $a_1, a_2, \dots, a_n$ where $a_i = i$.
In one step, you can choose two indices $x$ and $y$ ($x \neq y$) and set $a_x = \left\lceil \frac{a_x}{a_y} \right\rceil$ (ceiling function).
Your goal is to make array $a$ consist of $n - 1$ ones and $1$ two in no more than $n + 5$ steps. Note that you don't ... | for _ in range(int(input())):
n = int(input())
a = [2, 3, 5, 22, 448, 200000]
na = []
for i in range(len(a)):
if a[i] < n:
na.append(a[i])
else:
na.append(n)
break
na.reverse()
ans = []
for i in range(1, len(na)):
for j in range(na[... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL... |
You have an array $a_1, a_2, \dots, a_n$ where $a_i = i$.
In one step, you can choose two indices $x$ and $y$ ($x \neq y$) and set $a_x = \left\lceil \frac{a_x}{a_y} \right\rceil$ (ceiling function).
Your goal is to make array $a$ consist of $n - 1$ ones and $1$ two in no more than $n + 5$ steps. Note that you don't ... | import sys
input = sys.stdin.readline
def main():
n = int(input())
if n <= 2:
print(0)
return
if n < 10:
mv = [n]
else:
num = n
mv = []
while num > 2:
mv.append(num)
num = num // 10
if mv[-1] > 10:
mv.append(5... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN IF VAR NUMBER ASSIGN VAR LIST VAR ASSIGN VAR VAR ASSIGN VAR LIST WHILE VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST FOR VA... |
You have an array $a_1, a_2, \dots, a_n$ where $a_i = i$.
In one step, you can choose two indices $x$ and $y$ ($x \neq y$) and set $a_x = \left\lceil \frac{a_x}{a_y} \right\rceil$ (ceiling function).
Your goal is to make array $a$ consist of $n - 1$ ones and $1$ two in no more than $n + 5$ steps. Note that you don't ... | t = int(input())
for i in range(t):
n = int(input())
if n == 3:
print(2)
print(3, 2)
print(3, 2)
continue
if n < 28:
num = n
temp = 0
while num > 1:
temp2 = int(num % 3 != 0)
num //= 3
num += temp2
temp +... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUM... |
You have an array $a_1, a_2, \dots, a_n$ where $a_i = i$.
In one step, you can choose two indices $x$ and $y$ ($x \neq y$) and set $a_x = \left\lceil \frac{a_x}{a_y} \right\rceil$ (ceiling function).
Your goal is to make array $a$ consist of $n - 1$ ones and $1$ two in no more than $n + 5$ steps. Note that you don't ... | import sys
input = sys.stdin.readline
for _ in range(int(input())):
n = int(input())
if n == 3:
ans = [[3, 2], [3, 2]]
elif n == 4:
ans = [[3, 4], [4, 2], [4, 2]]
elif n < 9:
ans = []
for i in range(3, n):
ans.append([i, n])
for i in range(4):
... | IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR LIST LIST NUMBER NUMBER LIST NUMBER NUMBER IF VAR NUMBER ASSIGN VAR LIST LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER IF VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NU... |
You have an array $a_1, a_2, \dots, a_n$ where $a_i = i$.
In one step, you can choose two indices $x$ and $y$ ($x \neq y$) and set $a_x = \left\lceil \frac{a_x}{a_y} \right\rceil$ (ceiling function).
Your goal is to make array $a$ consist of $n - 1$ ones and $1$ two in no more than $n + 5$ steps. Note that you don't ... | from sys import stdin
def main():
from sys import stdin
input = stdin.buffer.readline
for _ in range(int(input())):
n = int(input())
for i in range(1, n):
x = n
y = i
c = 0
while min(x, y) > 1:
if x < y:
x... | FUNC_DEF ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR VAR NU... |
You have an array $a_1, a_2, \dots, a_n$ where $a_i = i$.
In one step, you can choose two indices $x$ and $y$ ($x \neq y$) and set $a_x = \left\lceil \frac{a_x}{a_y} \right\rceil$ (ceiling function).
Your goal is to make array $a$ consist of $n - 1$ ones and $1$ two in no more than $n + 5$ steps. Note that you don't ... | def solve1(n):
a = []
c = 0
for i in range(3, n):
a.append(i)
a.append(i + 1)
c = c + 1
t = 0
z = n
while z != 1:
z = (z + 1) // 2
t = t + 1
for i in range(t):
a.append(n)
a.append(2)
print(c + t)
d = 0
for i in range(0, len... | FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FU... |
You have an array $a_1, a_2, \dots, a_n$ where $a_i = i$.
In one step, you can choose two indices $x$ and $y$ ($x \neq y$) and set $a_x = \left\lceil \frac{a_x}{a_y} \right\rceil$ (ceiling function).
Your goal is to make array $a$ consist of $n - 1$ ones and $1$ two in no more than $n + 5$ steps. Note that you don't ... | import sys
input = sys.stdin.buffer.readline
def multiLineArrayOfArraysPrint(arr):
print("\n".join([" ".join([str(x) for x in y]) for y in arr]))
numbers = [2, 4]
while numbers[-1] < 200000:
numbers.append(numbers[-1] * numbers[-2])
t = int(input())
for _ in range(t):
n = int(input())
if n == 1 or ... | IMPORT ASSIGN VAR VAR FUNC_DEF EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR VAR VAR ASSIGN VAR LIST NUMBER NUMBER WHILE VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL ... |
You have an array $a_1, a_2, \dots, a_n$ where $a_i = i$.
In one step, you can choose two indices $x$ and $y$ ($x \neq y$) and set $a_x = \left\lceil \frac{a_x}{a_y} \right\rceil$ (ceiling function).
Your goal is to make array $a$ consist of $n - 1$ ones and $1$ two in no more than $n + 5$ steps. Note that you don't ... | t = int(input())
lg = [0] * (2 * 10**5 + 5)
for i in range(2, 2 * 10**5 + 1):
lg[i] = lg[i // 2] + 1
for _ in range(t):
n = int(input())
if n == 3:
print(2)
print(3, 2)
print(3, 2)
else:
max_lg = lg[n]
keep = []
cand = set(range(2, n + 1))
while ma... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP NUMBER BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR N... |
You have an array $a_1, a_2, \dots, a_n$ where $a_i = i$.
In one step, you can choose two indices $x$ and $y$ ($x \neq y$) and set $a_x = \left\lceil \frac{a_x}{a_y} \right\rceil$ (ceiling function).
Your goal is to make array $a$ consist of $n - 1$ ones and $1$ two in no more than $n + 5$ steps. Note that you don't ... | UPOW = 4
for _ in " " * int(input()):
n = int(input())
sq = int(n ** (1 / UPOW))
if sq**UPOW != n:
sq += 1
nt = n
sqt = sq
ops = []
for i in range(3, n):
if i != sq:
ops.append((i, n))
while nt > 1:
ops.append((n, sq))
nt = (nt + sq - 1) // sq
... | ASSIGN VAR NUMBER FOR VAR BIN_OP STRING FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER VAR IF BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR WHILE VAR... |
You have an array $a_1, a_2, \dots, a_n$ where $a_i = i$.
In one step, you can choose two indices $x$ and $y$ ($x \neq y$) and set $a_x = \left\lceil \frac{a_x}{a_y} \right\rceil$ (ceiling function).
Your goal is to make array $a$ consist of $n - 1$ ones and $1$ two in no more than $n + 5$ steps. Note that you don't ... | import sys
for _ in range(int(sys.stdin.readline().strip())):
n = int(sys.stdin.readline().strip())
s = 0
m = n
o = []
n -= 1
while n > 1:
while (n - 1) ** 2 > m:
o.append(str(n) + " " + str(m) + "\n")
s += 1
n -= 1
s += 2
o.append(str... | IMPORT FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR LIST VAR NUMBER WHILE VAR NUMBER WHILE BIN_OP BIN_OP VAR NUMBER NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR STRING FUNC_CALL VAR VAR ST... |
You have an array $a_1, a_2, \dots, a_n$ where $a_i = i$.
In one step, you can choose two indices $x$ and $y$ ($x \neq y$) and set $a_x = \left\lceil \frac{a_x}{a_y} \right\rceil$ (ceiling function).
Your goal is to make array $a$ consist of $n - 1$ ones and $1$ two in no more than $n + 5$ steps. Note that you don't ... | def solve():
N = int(input())
s = set()
i = 2
while i < N:
s.add(i)
i **= 2
s.add(N)
ans = []
for i in range(2, N + 1):
if i not in s:
ans.append((i, N))
s = sorted(list(s))
for i in range(len(s) - 2, -1, -1):
ans.append((s[i + 1], s[i]))
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_C... |
You have an array $a_1, a_2, \dots, a_n$ where $a_i = i$.
In one step, you can choose two indices $x$ and $y$ ($x \neq y$) and set $a_x = \left\lceil \frac{a_x}{a_y} \right\rceil$ (ceiling function).
Your goal is to make array $a$ consist of $n - 1$ ones and $1$ two in no more than $n + 5$ steps. Note that you don't ... | import sys
t = int(sys.stdin.readline().strip())
for _ in range(t):
n = int(sys.stdin.readline().strip())
if n <= 8:
cnt = n - 1 - 2
tl = 0
x = n
while x != 1:
x = (x + 1) // 2
tl += 1
print(cnt + tl)
for j in range(n - 1, 2, -1):
... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VA... |
You have an array $a_1, a_2, \dots, a_n$ where $a_i = i$.
In one step, you can choose two indices $x$ and $y$ ($x \neq y$) and set $a_x = \left\lceil \frac{a_x}{a_y} \right\rceil$ (ceiling function).
Your goal is to make array $a$ consist of $n - 1$ ones and $1$ two in no more than $n + 5$ steps. Note that you don't ... | def dev(n, m):
ret = n // m
if n % m != 0:
ret += 1
return ret
T = int(input())
lis = [int(input()) for i in range(T)]
for t in range(T):
n = lis[t]
count = 1
tmp = 2
for i in range(10):
tmp = tmp * tmp
if tmp >= n:
break
count += 1
dic = {(2... | FUNC_DEF ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF... |
You have an array $a_1, a_2, \dots, a_n$ where $a_i = i$.
In one step, you can choose two indices $x$ and $y$ ($x \neq y$) and set $a_x = \left\lceil \frac{a_x}{a_y} \right\rceil$ (ceiling function).
Your goal is to make array $a$ consist of $n - 1$ ones and $1$ two in no more than $n + 5$ steps. Note that you don't ... | t = int(input())
for _ in range(t):
n = int(input())
if n <= 2**5:
print(n + 2)
for i in range(3, n):
print(i, i + 1)
for i in range(1, 6):
print(n, 2)
else:
print(n + 5)
so = 3
while so**5 <= n:
so += 1
for i in ran... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_C... |
You have an array $a_1, a_2, \dots, a_n$ where $a_i = i$.
In one step, you can choose two indices $x$ and $y$ ($x \neq y$) and set $a_x = \left\lceil \frac{a_x}{a_y} \right\rceil$ (ceiling function).
Your goal is to make array $a$ consist of $n - 1$ ones and $1$ two in no more than $n + 5$ steps. Note that you don't ... | t = int(input())
while t > 0:
n = int(input())
ans = []
if n <= 8:
for i in range(n - 1, 2, -1):
ans.append([i, n])
temp = n
while temp > 1:
ans.append([n, 2])
if temp / 2 == temp // 2:
temp = temp / 2
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST IF VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR VAR WHILE VAR NUMBER EXPR FUNC_CALL VAR LIST VAR NUMBER IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASS... |
You have an array $a_1, a_2, \dots, a_n$ where $a_i = i$.
In one step, you can choose two indices $x$ and $y$ ($x \neq y$) and set $a_x = \left\lceil \frac{a_x}{a_y} \right\rceil$ (ceiling function).
Your goal is to make array $a$ consist of $n - 1$ ones and $1$ two in no more than $n + 5$ steps. Note that you don't ... | def oot(n):
lst1 = [n]
nt = n
while nt > 2:
nt = nt ** (1 / 2)
if nt != int(nt):
nt = int(nt) + 1
lst1.append(int(nt))
print(n - 3 + len(lst1))
for i in range(3, n):
if i not in lst1:
print(i, i + 1)
for i in range(len(lst1) - 1):
p... | FUNC_DEF ASSIGN VAR LIST VAR ASSIGN VAR VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER NUMBER IF VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR EXPR ... |
You have an array $a_1, a_2, \dots, a_n$ where $a_i = i$.
In one step, you can choose two indices $x$ and $y$ ($x \neq y$) and set $a_x = \left\lceil \frac{a_x}{a_y} \right\rceil$ (ceiling function).
Your goal is to make array $a$ consist of $n - 1$ ones and $1$ two in no more than $n + 5$ steps. Note that you don't ... | T = int(input())
for t in range(T):
d = int(input())
n = d
ans = []
while n > 2:
for i in range(n):
if i * i >= n:
if n >= (i - 1) * (i - 1) + i - 1:
for j in range(n - 1, i, -1):
ans.append([j, n])
ans.a... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR LIST WHILE VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR IF VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR N... |
You have an array $a_1, a_2, \dots, a_n$ where $a_i = i$.
In one step, you can choose two indices $x$ and $y$ ($x \neq y$) and set $a_x = \left\lceil \frac{a_x}{a_y} \right\rceil$ (ceiling function).
Your goal is to make array $a$ consist of $n - 1$ ones and $1$ two in no more than $n + 5$ steps. Note that you don't ... | import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
n = int(input())
a = [(i + 1) for i in range(n)]
ans = []
for i in range(3, n)[::-1]:
x, y = i, n
if -(-a[y - 1] // a[x - 1]) >= a[x - 1]:
ans.append((y, x))
a[y - 1] = -(-a[y - 1] /... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR IF BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP... |
You have an array $a_1, a_2, \dots, a_n$ where $a_i = i$.
In one step, you can choose two indices $x$ and $y$ ($x \neq y$) and set $a_x = \left\lceil \frac{a_x}{a_y} \right\rceil$ (ceiling function).
Your goal is to make array $a$ consist of $n - 1$ ones and $1$ two in no more than $n + 5$ steps. Note that you don't ... | import sys
input = sys.stdin.readline
for _ in range(int(input())):
n = int(input())
ans = []
if n <= 8:
temp = n
cnt = 0
while temp != 1:
temp = (temp + 1) // 2
cnt += 1
for i in range(3, n):
ans.append(f"{i} {n}")
for i in range(... | IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR VAR STRING VAR FOR VAR ... |
You have an array $a_1, a_2, \dots, a_n$ where $a_i = i$.
In one step, you can choose two indices $x$ and $y$ ($x \neq y$) and set $a_x = \left\lceil \frac{a_x}{a_y} \right\rceil$ (ceiling function).
Your goal is to make array $a$ consist of $n - 1$ ones and $1$ two in no more than $n + 5$ steps. Note that you don't ... | import sys
input = sys.stdin.readline
t = int(input())
for you in range(t):
n = int(input())
l = []
if n == 3:
print(2)
print(3, 2)
print(3, 2)
continue
curr = n
for i in range(n - 1, 3, -1):
if i == 65536 or i == 256 or i == 16 or i == 4:
z = cur... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF ... |
You have an array $a_1, a_2, \dots, a_n$ where $a_i = i$.
In one step, you can choose two indices $x$ and $y$ ($x \neq y$) and set $a_x = \left\lceil \frac{a_x}{a_y} \right\rceil$ (ceiling function).
Your goal is to make array $a$ consist of $n - 1$ ones and $1$ two in no more than $n + 5$ steps. Note that you don't ... | import sys
input = sys.stdin.buffer.readline
def multiLineArrayOfArraysPrint(arr):
print("\n".join([" ".join([str(x) for x in y]) for y in arr]))
t = int(input())
for _ in range(t):
n = int(input())
if n == 1 or n == 2:
print(0)
else:
ans = []
top = n
while top > 2:
... | IMPORT ASSIGN VAR VAR FUNC_DEF EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR VAR WHILE VAR NUMBER... |
You have an array $a_1, a_2, \dots, a_n$ where $a_i = i$.
In one step, you can choose two indices $x$ and $y$ ($x \neq y$) and set $a_x = \left\lceil \frac{a_x}{a_y} \right\rceil$ (ceiling function).
Your goal is to make array $a$ consist of $n - 1$ ones and $1$ two in no more than $n + 5$ steps. Note that you don't ... | def solve():
n = int(input())
num = n - 1
den = n
ans = ""
count = 0
while den > 2:
while not (den / num <= num and den / (num - 1) > num - 1):
ans += "\n" + str(num) + " " + str(den)
count += 1
num -= 1
ans += "\n" + str(den) + " " + str(num)
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR STRING ASSIGN VAR NUMBER WHILE VAR NUMBER WHILE BIN_OP VAR VAR VAR BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR BIN_OP BIN_OP BIN_OP STRING FUNC_CALL VAR VAR STRING FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER VAR BI... |
You have an array $a_1, a_2, \dots, a_n$ where $a_i = i$.
In one step, you can choose two indices $x$ and $y$ ($x \neq y$) and set $a_x = \left\lceil \frac{a_x}{a_y} \right\rceil$ (ceiling function).
Your goal is to make array $a$ consist of $n - 1$ ones and $1$ two in no more than $n + 5$ steps. Note that you don't ... | def readLine():
return [int(s) for s in input().split(" ")]
zbior = {2, 4, 16, 256, 65536}
def solve():
n = int(input())
ans = []
maxi = 2
for i in range(2, n + 1):
y = {i}
if y.issubset(zbior):
continue
elif i < n:
ans.append([i, n])
else:... | FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER NUMBER NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR IF FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR LIST VAR V... |
You have an array $a_1, a_2, \dots, a_n$ where $a_i = i$.
In one step, you can choose two indices $x$ and $y$ ($x \neq y$) and set $a_x = \left\lceil \frac{a_x}{a_y} \right\rceil$ (ceiling function).
Your goal is to make array $a$ consist of $n - 1$ ones and $1$ two in no more than $n + 5$ steps. Note that you don't ... | from sys import stdin, stdout
T = int(stdin.readline().strip())
for caso in range(T):
n = int(stdin.readline().strip())
ans = []
if n <= 15:
for i in range(3, n):
ans.append([i, i + 1])
x = n
while x != 1:
ans.append([n, 2])
x = (x + 1) // 2
e... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST IF VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR LIST VAR BIN_OP VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER EXPR FUNC_CALL VAR LIST VAR NUMBER ASSIGN VAR BIN_OP BI... |
You have an array $a_1, a_2, \dots, a_n$ where $a_i = i$.
In one step, you can choose two indices $x$ and $y$ ($x \neq y$) and set $a_x = \left\lceil \frac{a_x}{a_y} \right\rceil$ (ceiling function).
Your goal is to make array $a$ consist of $n - 1$ ones and $1$ two in no more than $n + 5$ steps. Note that you don't ... | for no_test in range(int(input())):
k = int(input())
if k == 3:
print("2\n3 2\n3 2")
continue
a5, a1, a3 = k, 1, 1
def ceil(x):
if x > int(x):
return int(x) + 1
else:
return int(x)
a3 = ceil(a5 ** (3 / 5))
a1 = ceil(a5 ** (1 / 5))
n1 ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR VAR VAR NUMBER NUMBER FUNC_DEF IF VAR FUNC_CALL VAR VAR RETURN BIN_OP FUNC_CALL VAR VAR NUMBER RETURN FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER NUMBER... |
You have an array $a_1, a_2, \dots, a_n$ where $a_i = i$.
In one step, you can choose two indices $x$ and $y$ ($x \neq y$) and set $a_x = \left\lceil \frac{a_x}{a_y} \right\rceil$ (ceiling function).
Your goal is to make array $a$ consist of $n - 1$ ones and $1$ two in no more than $n + 5$ steps. Note that you don't ... | t = int(input())
def chk(n):
g = n
c = 0
if n > 12:
while n != 0:
n = int(n / 12)
c += 1
print(g + c)
for i in range(g - 4):
if i < 9:
print(i + 3, g)
else:
print(i + 4, g)
for i in range(c):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP... |
You have an array $a_1, a_2, \dots, a_n$ where $a_i = i$.
In one step, you can choose two indices $x$ and $y$ ($x \neq y$) and set $a_x = \left\lceil \frac{a_x}{a_y} \right\rceil$ (ceiling function).
Your goal is to make array $a$ consist of $n - 1$ ones and $1$ two in no more than $n + 5$ steps. Note that you don't ... | t = int(input())
while t:
t += -1
n = int(input())
check = [0] * (n + 1)
ans = []
tmp = []
a = n
while a > 2:
check[a] = 1
tmp.append(a)
b = a**0.5
if b != int(b):
b = int(b) + 1
a = int(b)
for i in range(3, n + 1):
if check[i] ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR WHILE VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR FUNC_CALL VAR VAR ASSIGN VAR... |
The territory of Berland is represented by a rectangular field n Γ m in size. The king of Berland lives in the capital, located on the upper left square (1, 1). The lower right square has coordinates (n, m). One day the king decided to travel through the whole country and return back to the capital, having visited ever... | def d(a, b):
print(a + 1, b)
return a + 1, b
def u(a, b):
print(a - 1, b)
return a - 1, b
def l(a, b):
print(a, b - 1)
return a, b - 1
def r(a, b):
print(a, b + 1)
return a, b + 1
a, b = map(int, input().split(" "))
if a == 1:
if b == 2:
print(0)
else:
pri... | FUNC_DEF EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR RETURN BIN_OP VAR NUMBER VAR FUNC_DEF EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR RETURN BIN_OP VAR NUMBER VAR FUNC_DEF EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER RETURN VAR BIN_OP VAR NUMBER FUNC_DEF EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER RETURN VAR BIN_OP VAR NUMBER ASSI... |
The territory of Berland is represented by a rectangular field n Γ m in size. The king of Berland lives in the capital, located on the upper left square (1, 1). The lower right square has coordinates (n, m). One day the king decided to travel through the whole country and return back to the capital, having visited ever... | from sys import stdin
input_tokens = stdin.readline()
tokens = [int(x) for x in input_tokens.split()]
assert len(tokens) == 2
n, m = tokens[0], tokens[1]
if n == 1 and m > 2:
print(1)
print(n, m, 1, 1)
for i in range(1, m + 1):
print(1, i)
elif m == 1 and n > 2:
print(1)
print(n, m, 1, 1)
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR IF VAR NUMBER VAR... |
The territory of Berland is represented by a rectangular field n Γ m in size. The king of Berland lives in the capital, located on the upper left square (1, 1). The lower right square has coordinates (n, m). One day the king decided to travel through the whole country and return back to the capital, having visited ever... | def inRows():
print(0)
row = 1
column = 1
print(row, column)
while row <= n:
if row % 2 == 1:
column = 2
while column <= m:
print(row, column)
column += 1
else:
column = m
while column >= 2:
... | FUNC_DEF EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR VAR WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUM... |
The territory of Berland is represented by a rectangular field n Γ m in size. The king of Berland lives in the capital, located on the upper left square (1, 1). The lower right square has coordinates (n, m). One day the king decided to travel through the whole country and return back to the capital, having visited ever... | def p(a, b, swap):
if swap:
a, b = b, a
print(a, b)
n, m = [int(x) for x in input().split()]
if (n == 1 or m == 1) and n * m > 2:
print(1)
print(n, m, 1, 1)
for r in range(n):
for c in range(m):
print(r + 1, c + 1)
print(1, 1)
exit(0)
if n * m % 2 == 0:
prin... | FUNC_DEF IF VAR ASSIGN VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP V... |
Did you know that Chwee kueh, a cuisine of Singapore, means water rice cake ? Its a variety of the most popular South Indian savory cake, only that we call it here idli :). The tastiest idlis are made in Chennai, by none other than our famous chef, Dexter Murugan. Being very popular, he is flown from Marina to Miami, t... | for i in range(0, int(input())):
n = int(input())
m = list(map(int, input().split()))
m.sort()
count = 0
s = 0
for i in range(0, len(m)):
s = s + m[i]
if s % len(m) != 0:
print(-1)
else:
while m[-1] != m[0]:
dif = m[-1] - m[0]
if dif % 2 ==... | FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF BIN_OP VAR FUNC_CALL V... |
Did you know that Chwee kueh, a cuisine of Singapore, means water rice cake ? Its a variety of the most popular South Indian savory cake, only that we call it here idli :). The tastiest idlis are made in Chennai, by none other than our famous chef, Dexter Murugan. Being very popular, he is flown from Marina to Miami, t... | def solve(A, N):
total = sum(A)
if total % N != 0:
print(-1)
return
ans = 0
while True:
A.sort()
maxx, minn = A[-1], A[0]
if maxx == minn:
break
ans += 1
extra = (maxx - minn + 1) // 2
A = A[1:-1]
A.append(maxx - extra)
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR NUMBER WHILE NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VA... |
Did you know that Chwee kueh, a cuisine of Singapore, means water rice cake ? Its a variety of the most popular South Indian savory cake, only that we call it here idli :). The tastiest idlis are made in Chennai, by none other than our famous chef, Dexter Murugan. Being very popular, he is flown from Marina to Miami, t... | for t in range(int(input())):
n = int(input())
a = [int(x) for x in input().split()]
s = sum(a)
if s % n != 0:
print("-1")
else:
x = [0] * (n + 1)
for e in a:
x[e] += 1
i = 0
j = n
c = 0
while i < j:
while x[i] == 0:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER A... |
Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits a and b. Vitaly calls a good number excellent, if the sum of its digits is a good number.
For example, let's say that Vitaly's favourite digits are ... | fact = [1] * 1000007
for i in range(1, 1000007):
fact[i] = i * fact[i - 1] % 1000000007
def nCr(n, r):
a = fact[n]
b = fact[r] * fact[n - r] % 1000000007
c = pow(b, 1000000005, 1000000007)
return a * c % 1000000007
count = 0
a, b, n = map(int, input().split())
for i in range(n + 1):
s = a * ... | ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER RETURN BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER A... |
Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits a and b. Vitaly calls a good number excellent, if the sum of its digits is a good number.
For example, let's say that Vitaly's favourite digits are ... | import sys
inf = float("inf")
mod, MOD = 1000000007, 998244353
def get_array():
return list(map(int, sys.stdin.readline().strip().split()))
def get_ints():
return map(int, sys.stdin.readline().strip().split())
def input():
return sys.stdin.readline().strip()
def is_beautiful(sum):
if sum == 0:
... | IMPORT ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR NUMBER RETURN NUMBER WHILE VAR IF BIN_OP VAR N... |
Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits a and b. Vitaly calls a good number excellent, if the sum of its digits is a good number.
For example, let's say that Vitaly's favourite digits are ... | def ncr(n, r, p):
num = den = 1
for i in range(r):
num = num * (n - i) % p
den = den * (i + 1) % p
return num * pow(den, p - 2, p) % p
a, b, n = map(int, input().split())
ans = 0
p = 10**9 + 7
num = 1
den = 1
for i in range(n + 1):
s = a * i + b * (n - i)
if i != 0:
num = n... | FUNC_DEF ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR RETURN BIN_OP BIN_OP VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_O... |
Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits a and b. Vitaly calls a good number excellent, if the sum of its digits is a good number.
For example, let's say that Vitaly's favourite digits are ... | fact = [1]
mod = 10**9 + 7
def factorial(n):
global mod
global fact
fact = [1]
mod = 10**9 + 7
for i in range(1, n + 1):
fact.append(fact[-1] * i)
fact[-1] %= mod
def C(n, k):
global mod
return (
fact[n]
* pow(fact[k], mod - 2, mod)
% mod
*... | ASSIGN VAR LIST NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR LIST NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR NUMBER VAR FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR ... |
Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits a and b. Vitaly calls a good number excellent, if the sum of its digits is a good number.
For example, let's say that Vitaly's favourite digits are ... | ans = 0
mod = 1000000007
a, b, n = list(map(int, input().split()))
s = set()
for x in range(2, 1 << 8):
z = 0
while x > 1:
z = z * 10 + (a, b)[x & 1]
x >>= 1
s.add(z)
f = [1] * (n + 1)
for i in range(1, n + 1):
f[i] = f[i - 1] * i % mod
for x in range(n + 1):
if x * a + (n - x) * b i... | ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ASS... |
Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits a and b. Vitaly calls a good number excellent, if the sum of its digits is a good number.
For example, let's say that Vitaly's favourite digits are ... | fact = {}
modulo = 1000000007
def check(val, a, b):
while val:
if val % 10 == a or val % 10 == b:
val //= 10
else:
return False
return True
def modpow(base, exp, mod):
if exp == 0:
return 1
if exp & 1:
return modpow(base, exp - 1, mod) * base %... | ASSIGN VAR DICT ASSIGN VAR NUMBER FUNC_DEF WHILE VAR IF BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF IF VAR NUMBER RETURN NUMBER IF BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR RET... |
Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits a and b. Vitaly calls a good number excellent, if the sum of its digits is a good number.
For example, let's say that Vitaly's favourite digits are ... | def power(x, y, m):
if y == 0:
return 1
p = power(x, y // 2, m) % m
p = p * p % m
if y % 2 == 0:
return p
else:
return x * p % m
def gcd(a, b):
if a == 0:
return b
return gcd(b % a, a)
a, b, n = map(int, input().split())
ans = 0
m = 1000000007
fct = [1] * ... | FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER RETURN VAR RETURN BIN_OP BIN_OP VAR VAR VAR FUNC_DEF IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR F... |
Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits a and b. Vitaly calls a good number excellent, if the sum of its digits is a good number.
For example, let's say that Vitaly's favourite digits are ... | MOD = 1000000007
MX = 1000000
fact = [1] * (MX + 1)
for i in range(1, MX + 1):
fact[i] = fact[i - 1] * i % MOD
def power(a, b):
res = 1
while b > 0:
if b % 2 == 1:
res = res * a % MOD
a = a * a % MOD
b //= 2
return res
def inv(n):
return power(n, MOD - 2)
de... | ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN... |
Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits a and b. Vitaly calls a good number excellent, if the sum of its digits is a good number.
For example, let's say that Vitaly's favourite digits are ... | MOD = int(1000000000.0 + 7)
def fast_power(b, e):
res = 1
while e > 0:
if e % 2 == 1:
res = res * b % MOD
b = b * b % MOD
e //= 2
return res
a, b, n = map(int, input().split())
s, res = set(), 0
for x in range(2, 1 << 8):
z = 0
while x > 1:
z = z * 10 ... | ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR NUMBER FOR VAR F... |
Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits a and b. Vitaly calls a good number excellent, if the sum of its digits is a good number.
For example, let's say that Vitaly's favourite digits are ... | import sys
a, b, n = map(int, input().split())
input = sys.stdin.readline
p = 10**9 + 7
pri = p
fac = [(1) for i in range(10**6 + 1)]
for i in range(2, len(fac)):
fac[i] = fac[i - 1] * (i % pri) % pri
def modi(x):
return pow(x, p - 2, p) % p
def ncr(n, r):
x = fac[n] * (modi(fac[r]) % p * (modi(fac[n -... | IMPORT ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP ... |
Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits a and b. Vitaly calls a good number excellent, if the sum of its digits is a good number.
For example, let's say that Vitaly's favourite digits are ... | a, b, n = list(map(int, input().split()))
m = 1000000007
fact = [1]
for i in range(1, n + 1):
fact.append(fact[-1] * i % m)
ans = 0
for i in range(n + 1):
su = a * i + b * (n - i)
coef = 1
while su > 0:
if su % 10 != a and su % 10 != b:
coef = 0
su //= 10
if coef:
... | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR BIN... |
Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits a and b. Vitaly calls a good number excellent, if the sum of its digits is a good number.
For example, let's say that Vitaly's favourite digits are ... | def egcd(a, b):
if a == 0:
return b, 0, 1
else:
g, y, x = egcd(b % a, a)
return g, x - b // a * y, y
def modinv(a, m):
g, x, y = egcd(a, m)
return x % m
a, b, n = map(int, input().split())
c = str(a) + str(b)
f, mod, ans = [1], 1000000007, 0
for i in range(1, n + 1):
f.ap... | FUNC_DEF IF VAR NUMBER RETURN VAR NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR RETURN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR VAR VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR RETURN BIN_OP VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR... |
Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits a and b. Vitaly calls a good number excellent, if the sum of its digits is a good number.
For example, let's say that Vitaly's favourite digits are ... | MOD = int(1000000000.0 + 7)
fact = [1]
for i in range(1, int(1000000.0) + 1, 1):
fact.append(fact[i - 1] * i % MOD)
A, B, N = list(map(int, input().split()))
ans = 0
for i in range(N + 1):
f = A * i + B * (N - i)
ng = False
while f:
t = f % 10
if t != A and t != B:
ng = True
... | ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BI... |
Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits a and b. Vitaly calls a good number excellent, if the sum of its digits is a good number.
For example, let's say that Vitaly's favourite digits are ... | N = 10**6
mod = 10**9 + 7
def checkgood(val, a, b):
while val:
if val % 10 != a and val % 10 != b:
return False
val //= 10
return True
def power(x, a):
if a == 0:
return 1
z = power(x, a // 2)
z = z**2 % mod
if a % 2:
z = z * x % mod
return z
... | ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF WHILE VAR IF BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR RETURN NUMBER VAR NUMBER RETURN NUMBER FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR IF BIN_OP VAR... |
Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits a and b. Vitaly calls a good number excellent, if the sum of its digits is a good number.
For example, let's say that Vitaly's favourite digits are ... | MOD = 10**9 + 7
p = 1000009
fact = [0] * p
fact[0] = 1
for i in range(1, p):
fact[i] = fact[i - 1] * i % MOD
def MI(a, MOD):
return pow(a, MOD - 2, MOD)
def ncr(n, k, MOD):
if n == k or k == 0:
return 1
if n < k:
return 0
return fact[n] * MI(fact[k], MOD) % MOD * MI(fact[n - k], ... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR FUNC_DEF IF VAR VAR VAR NUMBER RETURN NUMBER IF V... |
Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits a and b. Vitaly calls a good number excellent, if the sum of its digits is a good number.
For example, let's say that Vitaly's favourite digits are ... | MOD = 10**9 + 7
a, b, n = list(map(int, input().strip().split(" ")))
def check(a, b, x):
temp = x % 10
if temp != a and temp != b:
return 0
while x > 0:
temp = x % 10
if temp != a and temp != b:
return 0
x = x // 10
return 1
fact = [1]
infact = [1]
temp = ... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR RETURN NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR RETURN NUMBER ASSIGN VAR BIN_OP VAR NUMBER RET... |
Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits a and b. Vitaly calls a good number excellent, if the sum of its digits is a good number.
For example, let's say that Vitaly's favourite digits are ... | N = 1000007
m = int(1000000000.0 + 7)
sum = 0
ans = 0
fact = [(0) for i in range(0, 1000007)]
def modularexponentiation(a: int, b: int, m: int):
res = 1
a = a % m
while b > 0:
if b & 1:
res = res * a % m
a = a * a % m
b = b // 2
return res
def modinverse(a: int, m... | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER NUMBER FUNC_DEF VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR WHILE VAR NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR V... |
Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits a and b. Vitaly calls a good number excellent, if the sum of its digits is a good number.
For example, let's say that Vitaly's favourite digits are ... | def check(x):
while x:
if x % 10 != a and x % 10 != b:
return False
x //= 10
return True
a, b, n = map(int, input().split())
factorial, ans = [1], 0
for i in range(1, n + 1):
factorial.append(factorial[-1] * i % 1000000007)
for i in range(n + 1):
if check(a * i + b * (n - i... | FUNC_DEF WHILE VAR IF BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR RETURN NUMBER VAR NUMBER RETURN NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL ... |
Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits a and b. Vitaly calls a good number excellent, if the sum of its digits is a good number.
For example, let's say that Vitaly's favourite digits are ... | mxn = 10**6 + 10
fact = [1] * mxn
mod = 10**9 + 7
for i in range(1, mxn):
fact[i] = fact[i - 1] * i % mod
def nck(n, k):
return fact[n] * pow(fact[k] * fact[n - k], mod - 2, mod) % mod
def log(n):
ans = 0
while n:
ans += 1
n //= 10
return ans
a, b, n = map(int, input().split())... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR BIN_OP VAR NUMBE... |
Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits a and b. Vitaly calls a good number excellent, if the sum of its digits is a good number.
For example, let's say that Vitaly's favourite digits are ... | z = 1000000007
def modinv(p, q):
res = 1
while q:
if q % 2:
res = res * p % z
q -= 1
else:
p = p * p % z
q //= 2
return res
a, b, n = map(int, input().split())
times = n
s = 0
arr = [1] * (n + 1)
p = 1
for i in range(1, n + 1):
p = p * ... | ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER WHILE VAR IF BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NU... |
Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits a and b. Vitaly calls a good number excellent, if the sum of its digits is a good number.
For example, let's say that Vitaly's favourite digits are ... | a, b, n = map(int, input().split())
dic = {(0): 1}
m = 10**9 + 7
for i in range(1, n + 1):
dic[i] = dic[i - 1] * i % m
def modExp(a, n, m=10**9 + 7):
if n == 0:
return 1
elif n == 1:
return a
else:
while n >= 2:
if n % 2 == 0:
n = n // 2
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR FUNC_DEF BIN_OP BIN_OP NUMBER NUMBER NUMBER IF VAR NUMBER RETURN NUMBER IF VA... |
Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits a and b. Vitaly calls a good number excellent, if the sum of its digits is a good number.
For example, let's say that Vitaly's favourite digits are ... | def read():
return list(map(int, input().strip().split(" ")))
MOD = 10**9 + 7
def fact():
N = 10**6 + 1
facto = [0] * (N + 1)
facto[0] = 1
for i in range(1, N + 1):
facto[i] = facto[i - 1] % MOD * i % MOD
return facto
facto = fact()
def chk(n, a, b):
s = 0
while n > 0:
... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR... |
Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits a and b. Vitaly calls a good number excellent, if the sum of its digits is a good number.
For example, let's say that Vitaly's favourite digits are ... | mod = 1000000007
fact = []
def Beautiful_Numbers(a, b, n):
result = 0
Factorial(n)
comb = []
if n == 1:
return 2
for m in range(0, n + 1):
x = m * a + (n - m) * b
if Es_Bueno(x, a, b):
if m <= n // 2:
c = Combinaciones(n, m)
comb.... | ASSIGN VAR NUMBER ASSIGN VAR LIST FUNC_DEF ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST IF VAR NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR VAR IF FUNC_CALL VAR VAR VAR VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR... |
Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits a and b. Vitaly calls a good number excellent, if the sum of its digits is a good number.
For example, let's say that Vitaly's favourite digits are ... | def egcd(a, b):
if b == 0:
return a, 1, 0
g, x1, y1 = egcd(b, a % b)
x = y1
y = x1 - y1 * (a // b)
return g, x, y
def mod_inv(a, b):
return (egcd(a, b)[1] % b + b) % b
def gud(a, b, x):
a = str(a)
b = str(b)
x = set(str(x))
if len(x) > 2:
return False
elif... | FUNC_DEF IF VAR NUMBER RETURN VAR NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR BIN_OP VAR VAR RETURN VAR VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL V... |
Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits a and b. Vitaly calls a good number excellent, if the sum of its digits is a good number.
For example, let's say that Vitaly's favourite digits are ... | a, b, n = [int(x) for x in input().split()]
m = 1000000007
fact = [1]
def helper(a, b, n):
while n:
curr = n % 10
if curr != a and curr != b:
return False
n = n // 10
return True
for i in range(1, n + 1):
fact.append(fact[-1] * i % m)
s = b * n
ans = 0
for i in range(... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER FUNC_DEF WHILE VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR RETURN NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER... |
Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits a and b. Vitaly calls a good number excellent, if the sum of its digits is a good number.
For example, let's say that Vitaly's favourite digits are ... | import sys
M = 1000000007
def alele():
return list(map(int, sys.stdin.readline().strip().split()))
def ilele():
return map(int, sys.stdin.readline().strip().split())
def input():
return sys.stdin.readline().strip()
a, b, n = ilele()
Ans = 0
fact = [1] * (n + 1)
for i in range(1, n + 1):
fact[i]... | IMPORT ASSIGN VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VA... |
Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits a and b. Vitaly calls a good number excellent, if the sum of its digits is a good number.
For example, let's say that Vitaly's favourite digits are ... | a, b, n = list(map(int, input().split()))
def ok(s):
while s:
if s % 10 != a and s % 10 != b:
return False
s = int(s / 10)
return True
ans = 0
p = int(1000000000.0 + 7)
A = [1]
for i in range(1, n + 1):
A.append(int(i * A[i - 1] % p))
for x in range(0, n + 1):
y = n - x
... | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF WHILE VAR IF BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR... |
Vitaly is a very weird man. He's got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits a and b. Vitaly calls a good number excellent, if the sum of its digits is a good number.
For example, let's say that Vitaly's favourite digits are ... | f = [0] * (10**6 + 1)
f[0] = f[1] = 1
mod = 10**9 + 7
for i in range(2, 10**6 + 1):
f[i] = f[i - 1] * i % mod
def comb(n, r):
return f[n] * pow(f[n - r] * f[r], mod - 2, mod) % mod
a, b, n = map(int, input().split())
ans = 0
def is_good(x, a, b):
x = str(x)
a = str(a)
b = str(b)
flag = Tru... | ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR FUNC_CALL VA... |
Tug of war is a sport that directly puts two teams against each other in a test of strength.
During school days, both Chef Shifu and Chef Po were champions of tug of war.
On behalf of restaurant's anniversary, Chef Shifu and Chef Po have decided to conduct
a tug of war game for their customers.
Master Chef Oogway ha... | import sys
mod = 100000000000007
motzkin = [1, 0]
catalan = [1, 1, 2]
for i in range(1, 10009):
motzkin.append(0)
for j in range(0, 10006):
catalan.append(0)
for i in range(2, 10006):
motzkin[i] = (i - 1) * (2 * motzkin[i - 1] + 3 * motzkin[i - 2])
motzkin[i] = motzkin[i] // (i + 1)
for i in range(1000... | IMPORT ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR NUMBER BIN_OP BIN_OP NUMBER VAR BIN... |
Tug of war is a sport that directly puts two teams against each other in a test of strength.
During school days, both Chef Shifu and Chef Po were champions of tug of war.
On behalf of restaurant's anniversary, Chef Shifu and Chef Po have decided to conduct
a tug of war game for their customers.
Master Chef Oogway ha... | import sys
dp1 = [1, 1]
dp2 = [1, 1]
N = 10010
M = 100000000000007
for i in range(2, N):
dp1.append((3 * (i - 1) * dp1[i - 2] + (2 * i + 1) * dp1[i - 1]) // (i + 2))
dp2.append(2 * (2 * i - 1) * dp2[i - 1] // (i + 1))
t = int(input())
while t:
t = t - 1
n, k = input().split()
if int(k) == 0:
... | IMPORT ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_C... |
Joi has an array $a$ of $n$ positive integers. Koxia wants you to determine whether there exists a positive integer $x > 0$ such that $\gcd(a_i+x,a_j+x)=1$ for all $1 \leq i < j \leq n$.
Here $\gcd(y, z)$ denotes the
greatest common divisor (GCD)
of integers $y$ and $z$.
-----Input-----
Each test consists of mult... | k = int(input())
p = [2]
for i in range(3, 102):
t = True
for j in range(2, i):
if i % j == 0:
t = False
break
if t:
p.append(i)
for _ in range(k):
n = int(input())
lst = [int(i) for i in input().split()]
e = sum([(1) for i in lst if i % 2 == 0])
o = l... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ... |
Joi has an array $a$ of $n$ positive integers. Koxia wants you to determine whether there exists a positive integer $x > 0$ such that $\gcd(a_i+x,a_j+x)=1$ for all $1 \leq i < j \leq n$.
Here $\gcd(y, z)$ denotes the
greatest common divisor (GCD)
of integers $y$ and $z$.
-----Input-----
Each test consists of mult... | t = int(input())
count = [([0] * 51) for _ in range(51)]
while t > 0:
for i in range(51):
for j in range(51):
count[i][j] = 0
n = int(input())
A = list(map(int, input().split()))
ans = True
for i in range(n):
for j in range(i + 1, n):
if A[j] == A[i]:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR NUMBER WHILE VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR N... |
Joi has an array $a$ of $n$ positive integers. Koxia wants you to determine whether there exists a positive integer $x > 0$ such that $\gcd(a_i+x,a_j+x)=1$ for all $1 \leq i < j \leq n$.
Here $\gcd(y, z)$ denotes the
greatest common divisor (GCD)
of integers $y$ and $z$.
-----Input-----
Each test consists of mult... | t = int(input())
for _ in range(t):
n = int(input())
a = list(map(int, input().split()))
wefucked = "YES"
for i in range(2, n):
cnt = [0] * i
for j in range(n):
cnt[a[j] % i] += 1
if min(cnt) >= 2:
wefucked = "NO"
break
for i in range(n):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR NUMBER IF FUNC_... |
Joi has an array $a$ of $n$ positive integers. Koxia wants you to determine whether there exists a positive integer $x > 0$ such that $\gcd(a_i+x,a_j+x)=1$ for all $1 \leq i < j \leq n$.
Here $\gcd(y, z)$ denotes the
greatest common divisor (GCD)
of integers $y$ and $z$.
-----Input-----
Each test consists of mult... | P = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]
for s in [*open(0)][2::2]:
a = [*map(int, s.split())]
if len(a) != len({*a}):
print("NO")
continue
for p in P:
cnt = [0] * p
for x in a:
cnt[x % p] += 1
if min(cnt) >= 2:
print("NO")
... | ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FOR VAR LIST FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING FOR VAR VAR ASSIGN VAR BIN_OP LIST NUM... |
Joi has an array $a$ of $n$ positive integers. Koxia wants you to determine whether there exists a positive integer $x > 0$ such that $\gcd(a_i+x,a_j+x)=1$ for all $1 \leq i < j \leq n$.
Here $\gcd(y, z)$ denotes the
greatest common divisor (GCD)
of integers $y$ and $z$.
-----Input-----
Each test consists of mult... | tests = int(input())
for i in range(tests):
length = int(input())
arr = list(map(int, input().split()))
ans = "YES"
if length != len(set(arr)):
ans = "NO"
else:
for j in range(2, length // 2 + 1):
freq = [0] * j
for k in arr:
rem = k % j
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING IF VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BI... |
Joi has an array $a$ of $n$ positive integers. Koxia wants you to determine whether there exists a positive integer $x > 0$ such that $\gcd(a_i+x,a_j+x)=1$ for all $1 \leq i < j \leq n$.
Here $\gcd(y, z)$ denotes the
greatest common divisor (GCD)
of integers $y$ and $z$.
-----Input-----
Each test consists of mult... | for _ in range(int(input())):
x = int(input())
y = list(map(int, input().split()))
z = set(y)
primes = [
2,
3,
5,
7,
11,
13,
17,
19,
23,
29,
31,
37,
41,
43,
47,
53,
59,... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ... |
Joi has an array $a$ of $n$ positive integers. Koxia wants you to determine whether there exists a positive integer $x > 0$ such that $\gcd(a_i+x,a_j+x)=1$ for all $1 \leq i < j \leq n$.
Here $\gcd(y, z)$ denotes the
greatest common divisor (GCD)
of integers $y$ and $z$.
-----Input-----
Each test consists of mult... | primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]
for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
if len(set(a)) != len(a):
print("NO")
continue
cnt = {p: {} for p in primes}
for x in a:
for p in primes:
if x % p ... | ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CAL... |
Joi has an array $a$ of $n$ positive integers. Koxia wants you to determine whether there exists a positive integer $x > 0$ such that $\gcd(a_i+x,a_j+x)=1$ for all $1 \leq i < j \leq n$.
Here $\gcd(y, z)$ denotes the
greatest common divisor (GCD)
of integers $y$ and $z$.
-----Input-----
Each test consists of mult... | T = int(input())
for _ in range(T):
n = int(input())
a = sorted(list(map(int, input().split())))
isSuccess = True
for i in range(1, n):
if a[i - 1] == a[i]:
print("NO")
isSuccess = False
break
if not isSuccess:
continue
for x in range(2, int(n ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR ... |
Joi has an array $a$ of $n$ positive integers. Koxia wants you to determine whether there exists a positive integer $x > 0$ such that $\gcd(a_i+x,a_j+x)=1$ for all $1 \leq i < j \leq n$.
Here $\gcd(y, z)$ denotes the
greatest common divisor (GCD)
of integers $y$ and $z$.
-----Input-----
Each test consists of mult... | from itertools import groupby
print(
*map(
lambda a: ["NO", "YES"][
len(a) == len({*a})
and all(
sum(1 for _, v in groupby(sorted(x % p for x in a)) if len([*v]) > 1)
< p
for p in (
2,
3,
... | EXPR FUNC_CALL VAR FUNC_CALL VAR LIST STRING STRING FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR FUNC_CALL VAR LIST VAR NUMBER VAR VAR NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NU... |
Joi has an array $a$ of $n$ positive integers. Koxia wants you to determine whether there exists a positive integer $x > 0$ such that $\gcd(a_i+x,a_j+x)=1$ for all $1 \leq i < j \leq n$.
Here $\gcd(y, z)$ denotes the
greatest common divisor (GCD)
of integers $y$ and $z$.
-----Input-----
Each test consists of mult... | import sys
T = int(sys.stdin.readline().strip())
for t in range(0, T):
n = int(sys.stdin.readline().strip())
a = list(map(int, sys.stdin.readline().strip().split()))
ans = True
if len(set(a)) != n:
ans = False
for i in range(2, n):
c = set()
d = set()
for x in a:
... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER V... |
Joi has an array $a$ of $n$ positive integers. Koxia wants you to determine whether there exists a positive integer $x > 0$ such that $\gcd(a_i+x,a_j+x)=1$ for all $1 \leq i < j \leq n$.
Here $\gcd(y, z)$ denotes the
greatest common divisor (GCD)
of integers $y$ and $z$.
-----Input-----
Each test consists of mult... | M = [
2,
3,
5,
7,
11,
13,
17,
19,
23,
29,
31,
37,
41,
43,
47,
53,
59,
61,
67,
71,
73,
79,
83,
89,
97,
]
def g(X):
for j in X:
if j < 2:
return False
return True
def f(L, n):
x = 0
... | ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FUNC_DEF FOR VAR VAR IF VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR BIN_OP BIN_OP ... |
Joi has an array $a$ of $n$ positive integers. Koxia wants you to determine whether there exists a positive integer $x > 0$ such that $\gcd(a_i+x,a_j+x)=1$ for all $1 \leq i < j \leq n$.
Here $\gcd(y, z)$ denotes the
greatest common divisor (GCD)
of integers $y$ and $z$.
-----Input-----
Each test consists of mult... | T = int(input())
prime = [
2,
3,
5,
7,
11,
13,
17,
19,
23,
29,
31,
37,
41,
43,
47,
53,
59,
61,
67,
71,
73,
79,
83,
89,
97,
]
for t in range(T):
n = int(input())
a = list(map(int, input().split()))
cnt = {}
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ... |
Joi has an array $a$ of $n$ positive integers. Koxia wants you to determine whether there exists a positive integer $x > 0$ such that $\gcd(a_i+x,a_j+x)=1$ for all $1 \leq i < j \leq n$.
Here $\gcd(y, z)$ denotes the
greatest common divisor (GCD)
of integers $y$ and $z$.
-----Input-----
Each test consists of mult... | import sys
def fn(a, l):
repeat_check = set(a)
if len(repeat_check) != l:
return "NO"
for i in range(2, l):
mask = [0] * i
for item in a:
mask[item % i] += 1
if min(mask) >= 2:
return "NO"
return "YES"
input = sys.stdin.readlines()
for i in ran... | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR RETURN STRING FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR VAR VAR BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER RETURN STRING RETURN STRING ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ... |
Joi has an array $a$ of $n$ positive integers. Koxia wants you to determine whether there exists a positive integer $x > 0$ such that $\gcd(a_i+x,a_j+x)=1$ for all $1 \leq i < j \leq n$.
Here $\gcd(y, z)$ denotes the
greatest common divisor (GCD)
of integers $y$ and $z$.
-----Input-----
Each test consists of mult... | def prime(x):
return all(x % i for i in range(2, min(x, int(x**0.5) + 5)))
pr = [x for x in range(2, 1001) if prime(x)]
for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
b = sorted(a)
if any(b[i] == b[i + 1] for i in range(n - 1)):
print("NO")
conti... | FUNC_DEF RETURN FUNC_CALL VAR BIN_OP VAR VAR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CA... |
Joi has an array $a$ of $n$ positive integers. Koxia wants you to determine whether there exists a positive integer $x > 0$ such that $\gcd(a_i+x,a_j+x)=1$ for all $1 \leq i < j \leq n$.
Here $\gcd(y, z)$ denotes the
greatest common divisor (GCD)
of integers $y$ and $z$.
-----Input-----
Each test consists of mult... | def solve(a, n):
a = sorted(a)
for j in range(n - 1):
if a[j] == a[j + 1]:
print("NO")
return
for m in range(2, int(n / 2) + 3):
mod = [0] * m
for a_i in a:
mod[a_i % m] += 1
if min(mod) > 1:
print("NO")
return
p... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR VAR VAR BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER E... |
Joi has an array $a$ of $n$ positive integers. Koxia wants you to determine whether there exists a positive integer $x > 0$ such that $\gcd(a_i+x,a_j+x)=1$ for all $1 \leq i < j \leq n$.
Here $\gcd(y, z)$ denotes the
greatest common divisor (GCD)
of integers $y$ and $z$.
-----Input-----
Each test consists of mult... | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
if len(set(a)) != n:
print("NO")
else:
flag = False
for i in range(2, n // 2 + 1):
ost = [0] * i
for j in a:
ost[j % i] += 1
ans = 0
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP LI... |
Joi has an array $a$ of $n$ positive integers. Koxia wants you to determine whether there exists a positive integer $x > 0$ such that $\gcd(a_i+x,a_j+x)=1$ for all $1 \leq i < j \leq n$.
Here $\gcd(y, z)$ denotes the
greatest common divisor (GCD)
of integers $y$ and $z$.
-----Input-----
Each test consists of mult... | T = int(input())
for _ in range(T):
n = int(input())
a = list(map(int, input().split()))
if len(a) != len({*a}):
print("NO")
continue
ans = True
for i in range(2, 55):
cnt = [0] * i
for x in a:
cnt[x % i] += 1
if min(cnt) >= 2:
ans = Fa... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER ... |
Joi has an array $a$ of $n$ positive integers. Koxia wants you to determine whether there exists a positive integer $x > 0$ such that $\gcd(a_i+x,a_j+x)=1$ for all $1 \leq i < j \leq n$.
Here $\gcd(y, z)$ denotes the
greatest common divisor (GCD)
of integers $y$ and $z$.
-----Input-----
Each test consists of mult... | t = int(input(""))
mx = 0
inputs = []
arrays = []
for _ in range(t):
n = int(input(""))
a = [int(x) for x in input("").split(" ")]
inputs.append(n)
arrays.append(a)
mx = max(mx, n // 2)
p = [1] * (mx + 1)
p[0] = 0
p[1] = 0
i = 2
while i * i <= mx:
if p[i]:
j = i * i
while j <= mx... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.