description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | t = int(input())
for i in range(t):
l, r = map(int, input().strip().split(" "))
def calculate(n):
n = str(n)
res = 0
for i in range(len(n) - 1):
res += int(n[i] * (len(n) - i - 1))
res += int(n)
return res
print(calculate(r) - calculate(l)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NU... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | def num_change(n):
sum_ = 0
while n != 0:
sum_ = sum_ + n
n = int(n / 10)
return sum_
T = int(input())
while T != 0:
a, b = map(int, input().split())
print(num_change(b) - num_change(a))
T -= 1 | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR NUMBER |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | def _i():
return int(input())
def _f():
return float(input())
def _iln():
ln = input().split(" ")
return [int(i) for i in ln]
def _ln():
return input().split(" ")
def upto(n):
k = n
dp = []
while n:
dp.append(n % 10)
n = (n - dp[-1]) // 10
n = k
for i in r... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING RETURN FUNC_CALL VAR VAR VAR VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR VAR ASSIGN VAR LIST WHILE VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | for _ in range(int(input())):
l, r = map(int, input().split())
nl = len(str(l))
rl = len(str(r))
ansl = l % 10 + 11 * (l // 10)
ansr = r % 10 + 11 * (r // 10)
for i in range(2, nl):
temp = 10**i
ansl += l // temp
for i in range(2, rl):
temp = 10**i
ansr += r /... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP NUMBER BIN_OP VA... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | import sys
input = sys.stdin.readline
t = int(input())
c = [1, 11, 111, 1111, 11111, 111111, 1111111, 11111111, 111111111, 1111111111]
for _ in range(t):
l, r = map(int, input().split())
aa = 0
a = len(str(r))
r = str(r)
for i in range(a):
aa += int(r[i]) * c[a - i - 1]
bb = 0
b = l... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | for _ in range(int(input())):
l, r = map(int, input().split())
arr = [1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000]
ans = 0
for i in arr:
ans += r // i - l // i
print(ans) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | import sys
input = sys.stdin.readline
T = int(input())
for i in range(T):
n, m = map(int, input().split())
s = 0
while m:
s += m
m = m // 10
while n:
s -= n
n = n // 10
print(s) | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | def f(n):
if n < 10:
return n
else:
return n + f(n // 10)
n = int(input())
for test in range(n):
l, r = map(int, input().split())
print(f(r) - f(l)) | FUNC_DEF IF VAR NUMBER RETURN VAR RETURN BIN_OP VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | for ii in range(int(input())):
l, r = map(int, input().split())
cr = 0
while r != 0:
cr += r
r //= 10
cl = 0
while l != 0:
cl += l
l //= 10
print(cr - cl) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | T = int(input())
for _ in range(T):
a, b = input().split()
n = len(b)
a = a.zfill(n)
i = 0
while i < n and a[i] == b[i]:
i += 1
if i == n:
print(0)
continue
cost = 0
i = n - 1
delta = 1
carry = 0
while i > 0:
if carry or a[i] != "0":
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMB... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | t = int(input())
for i in range(t):
l, r = input().split()
bigger = len(r)
m = "0" * (bigger - len(l)) + l
total = int(r) - int(l)
for j in range(bigger - 1):
total = total + int(r[: -1 - j]) - int(m[: -1 - j])
print(total) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | import sys
pl = 2
sys.setrecursionlimit(10**5)
if pl:
input = sys.stdin.readline
else:
sys.stdin = open("input.txt", "r")
sys.stdout = open("outpt.txt", "w")
def li():
return [int(xxx) for xxx in input().split()]
def fi():
return int(input())
def si():
return list(input().rstrip())
def ... | IMPORT ASSIGN VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER IF VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR STRING STRING FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL FUNC_CALL... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | def solve(n):
temp = 1
ans = 0
for i in range(0, 12):
ans += n // temp
temp *= 10
return ans
t = int(input())
l, r = 1, 1000000
for _ in range(t):
n1, n2 = map(int, input().split())
n1, n2 = n2, n1
n1, n2 = n2, n1
print(solve(n2) - solve(n1)) | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER VAR BIN_OP VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR E... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | for _ in range(int(input())):
l, r = input().split()
l = "0" * (len(r) - len(l)) + l
out = 0
for i in range(len(r)):
out += int(r[: len(r) - i]) - int(l[: len(r) - i])
print(out) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL V... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | def func(n):
ans = 0
while n != 0:
ans += n
n = n // 10
return ans
t = int(input())
for _ in range(t):
l, r = [int(i) for i in input().strip().split()]
print(func(r) - func(l)) | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | def noc(x, y, d):
n = y - x + 1
n += x % d
if (y + 1) % d != 0:
n += d - (y + 1) % d
return int(n / d) - 1
for tc in range(int(input())):
x, y = map(int, input().split())
ans = 0
i = 0
while True:
temp = noc(x, y, 10**i)
ans += temp
i += 1
if tem... | FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR IF BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER VAR RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR N... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | for _ in range(int(input())):
l, r = list(map(int, input().split()))
cnt = 0
for i in range(11):
cnt += r // pow(10, i)
cnt2 = 0
for i in range(11):
cnt2 += l // pow(10, i)
print(cnt - cnt2) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR BIN_OP VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR BIN_OP VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | k = int(input())
for x in range(k):
ans = 0
x = str(input())
x = x.split()
r = int(x[1])
l = int(x[0])
while r != 0 or l != 0:
ans += r - l
l = l // 10
r = r // 10
k += 1
if k == 1:
print()
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER WHILE VAR NUMBER VAR NUMBER VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUM... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | t = int(input())
def get(idk):
ans = 0
temp = idk
while temp:
ans += temp
temp //= 10
return ans
for _ in range(t):
l, r = map(int, input().split())
print(get(r) - get(l)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR VAR VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | t = int(input())
for w in range(t):
inp = input().split()
left = int(inp[0])
right = int(inp[1])
ans = 0
while left > 0 or right > 0:
ans += right - left
left = left // 10
right = right // 10
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | q = int(input())
for _ in range(q):
n, m = map(int, input().split())
first = 0
second = 0
for i in range(10):
first += n // 10**i
second += m // 10**i
print(second - first) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR BIN_OP VAR BIN_OP NUMBER VAR VAR BIN_OP VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | t = int(input())
for i in range(t):
x = input()
l = int(x.split()[0])
r = int(x.split()[1])
if r // 10 == 0 and l // 10 == 0:
print(r - l)
continue
k = r
while k // 10 >= 1:
r += k // 10
k = k // 10
k = l
while k // 10 >= 1:
l += k // 10
k ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR WHILE BIN_OP VAR NUMBER NUMBER VAR B... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | def f(x):
r = 0
while x:
r += x
x //= 10
return r
for s in [*open(0)][1:]:
l, r = map(int, s.split())
print(f(r) - f(l)) | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR NUMBER RETURN VAR FOR VAR LIST FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | ll = [0, 1, 11, 111, 1111, 11111, 111111, 1111111, 11111111, 111111111, 1111111111]
for _ in range(int(input())):
l, r = map(int, input().split())
x = str(l)
y = str(r)
if len(x) == 1:
ans1 = l
else:
b = len(x)
ans1 = 0
c = b
for i in x:
ans1 += in... | ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CAL... |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | def f(x):
return sum([(x // pow(10, i)) for i in range(11)])
for _ in range(int(input())):
l, r = map(int, input().split())
print(f(r) - f(l)) | FUNC_DEF RETURN FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR NUMBER VAR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR |
You are given two integers $l$ and $r$, where $l < r$. We will add $1$ to $l$ until the result is equal to $r$. Thus, there will be exactly $r-l$ additions performed. For each such addition, let's look at the number of digits that will be changed after it.
For example:
if $l=909$, then adding one will result in $910$... | def solve(l, r):
ans = 0
while l != 0 or r != 0:
ans += r - l
l //= 10
r //= 10
return ans
for _ in range(int(input())):
l, r = map(int, input().split())
print(solve(l, r)) | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER VAR BIN_OP VAR VAR VAR NUMBER VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR |
Peter decided to wish happy birthday to his friend from Australia and send him a card. To make his present more mysterious, he decided to make a chain. Chain here is such a sequence of envelopes A = {a1, a2, ..., an}, where the width and the height of the i-th envelope is strictly higher than the width and the height o... | import sys
firstline = sys.stdin.readline().split()
n = int(firstline[0])
w = int(firstline[1])
h = int(firstline[2])
envelopes = [(w, h)]
locations = {(w, h): 0}
for i in range(n):
e = tuple(map(int, sys.stdin.readline().split()))
if e[0] > w and e[1] > h:
locations[e] = i + 1
envelopes.append... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST VAR VAR ASSIGN VAR DICT VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR VAR ... |
Peter decided to wish happy birthday to his friend from Australia and send him a card. To make his present more mysterious, he decided to make a chain. Chain here is such a sequence of envelopes A = {a1, a2, ..., an}, where the width and the height of the i-th envelope is strictly higher than the width and the height o... | import sys
class Envelope:
def __init__(self, w=0, h=0, e_id=0, pre=0, num=0):
self.w = w
self.h = h
self.e_id = e_id
self.pre = pre
self.num = num
def __str__(self):
return "Envelope: w is % s, h is % s, id is %s" % (self.w, self.h, self.e_id)
def compare(a... | IMPORT CLASS_DEF FUNC_DEF NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF RETURN BIN_OP STRING VAR VAR VAR FUNC_DEF IF VAR VAR RETURN VAR VAR RETURN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR V... |
Peter decided to wish happy birthday to his friend from Australia and send him a card. To make his present more mysterious, he decided to make a chain. Chain here is such a sequence of envelopes A = {a1, a2, ..., an}, where the width and the height of the i-th envelope is strictly higher than the width and the height o... | import sys
def log(*args):
print(*args, file=sys.stderr)
def line():
return sys.stdin.readline().split()
def main():
n, w, h = (int(x) for x in line())
d = [[int(x) for x in line()] for _ in range(n)]
e = sorted(range(n), key=lambda x: d[x])
c = [None for _ in range(n)]
for i in range(... | IMPORT FUNC_DEF EXPR FUNC_CALL VAR VAR VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NONE VAR FUNC_CALL VAR VAR FOR VAR FUNC_CA... |
Peter decided to wish happy birthday to his friend from Australia and send him a card. To make his present more mysterious, he decided to make a chain. Chain here is such a sequence of envelopes A = {a1, a2, ..., an}, where the width and the height of the i-th envelope is strictly higher than the width and the height o... | import sys
def get_ints():
return map(int, sys.stdin.readline().split())
n, w, h = get_ints()
A = []
for i in range(n):
x, y = get_ints()
if x > w and y > h:
A.append([x, y, i + 1])
A = sorted(A, key=lambda x: (x[0], x[1]))
n1 = len(A)
if n1 == 0:
print(0)
elif n1 == 1:
print(1)
prin... | IMPORT FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF... |
Peter decided to wish happy birthday to his friend from Australia and send him a card. To make his present more mysterious, he decided to make a chain. Chain here is such a sequence of envelopes A = {a1, a2, ..., an}, where the width and the height of the i-th envelope is strictly higher than the width and the height o... | inputi = [int(i) for i in input().split(" ")]
amt = inputi[0]
cardW = inputi[1]
cardH = inputi[2]
envelopes = []
cur_amt = 1
for i in range(amt):
inputi = [int(i) for i in input().split(" ")]
if inputi[0] > cardW and inputi[1] > cardH:
envelopes.append((inputi[0], inputi[1], inputi[0] * inputi[1], cur_a... | ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR NUMBER VAR VAR NUMBER VAR EXPR FUNC_CALL VAR VAR NUMBER VAR... |
Peter decided to wish happy birthday to his friend from Australia and send him a card. To make his present more mysterious, he decided to make a chain. Chain here is such a sequence of envelopes A = {a1, a2, ..., an}, where the width and the height of the i-th envelope is strictly higher than the width and the height o... | n, x, y = map(int, input().strip().split())
envs = []
for h in range(n):
envs.append(list(map(int, input().strip().split())) + [h])
envs.sort(key=lambda x: (x[0], x[1]))
dp = [(1) for i in range(n)]
anc = [(-1) for i in range(n)]
flag = 0
for i in range(n):
if envs[i][0] > x and envs[i][1] > y:
flag = 1... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR LIST VAR EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUN... |
Peter decided to wish happy birthday to his friend from Australia and send him a card. To make his present more mysterious, he decided to make a chain. Chain here is such a sequence of envelopes A = {a1, a2, ..., an}, where the width and the height of the i-th envelope is strictly higher than the width and the height o... | [n, W, H] = [int(a) for a in input().split(" ")]
arr = []
for i in range(n):
[w, h] = [int(a) for a in input().split(" ")]
arr.append((w, h, i, 0, 0))
arr.sort()
arr.append((10000000, 10000000, n, 0, 0))
cnt = 0
for i in range(n + 1):
w, h, x, a, pre = arr[i]
a = 0
pre = -1
if W < w and H < h:
... | ASSIGN LIST VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN LIST VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER NUMBER VAR NUMBER NUMBER ASSIGN VAR NU... |
Peter decided to wish happy birthday to his friend from Australia and send him a card. To make his present more mysterious, he decided to make a chain. Chain here is such a sequence of envelopes A = {a1, a2, ..., an}, where the width and the height of the i-th envelope is strictly higher than the width and the height o... | n, max_width, max_height = map(int, input().split())
array_w_h_i = list()
array_w_h_i.append([max_width, max_height, 0])
for i in range(n):
width, height = map(int, input().split())
if width > max_width and height > max_height:
array_w_h_i.append([width, height, i + 1])
array_w_h_i.sort()
length = len(a... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR... |
Peter decided to wish happy birthday to his friend from Australia and send him a card. To make his present more mysterious, he decided to make a chain. Chain here is such a sequence of envelopes A = {a1, a2, ..., an}, where the width and the height of the i-th envelope is strictly higher than the width and the height o... | def f(L):
return L[0] * L[1]
ln = input().split(" ")
n = int(ln[0])
w = int(ln[1])
h = int(ln[2])
nums = dict()
envs = []
x_max = 0
y_max = 0
start = w, h
envs.append(start)
blank = 0, []
nums[start] = 0
for i in range(1, n + 1):
w1, h1 = [int(x) for x in input().split(" ")]
if w1 <= w or h1 <= h:
... | FUNC_DEF RETURN BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN... |
Peter decided to wish happy birthday to his friend from Australia and send him a card. To make his present more mysterious, he decided to make a chain. Chain here is such a sequence of envelopes A = {a1, a2, ..., an}, where the width and the height of the i-th envelope is strictly higher than the width and the height o... | def solution(a):
if len(a) <= 1:
return a
dp = [1] * len(a)
back = {}
maxval = 0
for j in range(len(a)):
for i in range(j):
if a[i][0] < a[j][0] and a[i][1] < a[j][1]:
if dp[i] + 1 > dp[j]:
dp[j] = dp[i] + 1
back[j] ... | FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER VAR VAR ASSIGN VAR VAR BIN_OP VAR VA... |
Peter decided to wish happy birthday to his friend from Australia and send him a card. To make his present more mysterious, he decided to make a chain. Chain here is such a sequence of envelopes A = {a1, a2, ..., an}, where the width and the height of the i-th envelope is strictly higher than the width and the height o... | class Envelope:
def __init__(self, w, h, n, prev):
self.w = w
self.h = h
self.n = n
self.prev = prev
def max_chain_size(envelopes, w, h):
dp = list()
dp.append(0)
for i in range(1, len(envelopes) + 1):
dp.append(1)
env = envelopes[i - 1]
env.pre... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NONE FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR B... |
Peter decided to wish happy birthday to his friend from Australia and send him a card. To make his present more mysterious, he decided to make a chain. Chain here is such a sequence of envelopes A = {a1, a2, ..., an}, where the width and the height of the i-th envelope is strictly higher than the width and the height o... | import sys
input = sys.stdin.readline
n, w, h = map(int, input().split())
a = []
for i in range(n):
x, y = map(int, input().split())
if x > w and y > h:
a.append([x, y, i + 1])
a.sort()
n = len(a)
dp = [[1, i] for i in range(n)]
for i in range(1, n):
for j in range(i):
if a[j][0] < a[i][0] ... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBE... |
Peter decided to wish happy birthday to his friend from Australia and send him a card. To make his present more mysterious, he decided to make a chain. Chain here is such a sequence of envelopes A = {a1, a2, ..., an}, where the width and the height of the i-th envelope is strictly higher than the width and the height o... | def contains(a, b):
if a[0] > b[0] and a[1] > b[1]:
return True
return False
n, w, h = map(int, input().split(" "))
postcard = w, h
envelopes = []
for _ in range(n):
w, h = map(int, input().split(" "))
envelopes += [(w, h)]
eh = sorted(enumerate(envelopes), key=lambda p: p[1])
envelopes = [e[1... | FUNC_DEF IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING VAR LIST VAR VAR ASSIGN VAR FUNC_CALL VAR F... |
Peter decided to wish happy birthday to his friend from Australia and send him a card. To make his present more mysterious, he decided to make a chain. Chain here is such a sequence of envelopes A = {a1, a2, ..., an}, where the width and the height of the i-th envelope is strictly higher than the width and the height o... | n, w, h = map(int, input().split())
whi = [(list(map(int, input().split())) + [_ + 1]) for _ in range(n)]
whi.sort(key=lambda _: _[0])
whi = list(filter(lambda _: _[0] > w and _[1] > h, whi))
whi = [(w, h, 0)] + whi
answer = [(0, 0) for _ in range(n + 1)]
n = len(whi)
for i in range(0, n):
for j in range(i + 1, n):... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR LIST BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR VAR NUMBER VAR VAR ASSIGN VAR BIN_OP LIST VAR VAR NUMBER... |
Peter decided to wish happy birthday to his friend from Australia and send him a card. To make his present more mysterious, he decided to make a chain. Chain here is such a sequence of envelopes A = {a1, a2, ..., an}, where the width and the height of the i-th envelope is strictly higher than the width and the height o... | class Envelope:
def __init__(self, w, h, i):
self.w = w
self.h = h
self.i = i
self.a = w * h
n, w, h = list(map(int, input().split()))
card = Envelope(w, h, -1)
envs = []
for i in range(n):
w, h = list(map(int, input().split()))
envs.append(Envelope(w, h, i))
envs = sorted... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EX... |
Peter decided to wish happy birthday to his friend from Australia and send him a card. To make his present more mysterious, he decided to make a chain. Chain here is such a sequence of envelopes A = {a1, a2, ..., an}, where the width and the height of the i-th envelope is strictly higher than the width and the height o... | import sys
input = sys.stdin.readline
RI = lambda: [int(x) for x in sys.stdin.readline().strip().split()]
rw = lambda: input().strip().split()
n, w, h = RI()
l = []
d = {}
for i in range(n):
a, b = RI()
l.append((a, b, i))
l.sort()
index = -1
for i in range(n):
if l[i][0] > w and l[i][1] > h:
index... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBE... |
Peter decided to wish happy birthday to his friend from Australia and send him a card. To make his present more mysterious, he decided to make a chain. Chain here is such a sequence of envelopes A = {a1, a2, ..., an}, where the width and the height of the i-th envelope is strictly higher than the width and the height o... | cards = []
a, w, h = map(int, input().split(" "))
for i in range(a):
w1, h1 = map(int, input().split(" "))
if w < w1 and h < h1:
cards.append([w1, h1, i + 1])
if len(cards) == 0:
print(0)
quit()
cards.sort()
rem = len(cards)
dp = [1] * rem
seq = [[cards[_][2]] for _ in range(rem)]
for i in range... | ASSIGN VAR LIST ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR VAR VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR EXPR... |
Peter decided to wish happy birthday to his friend from Australia and send him a card. To make his present more mysterious, he decided to make a chain. Chain here is such a sequence of envelopes A = {a1, a2, ..., an}, where the width and the height of the i-th envelope is strictly higher than the width and the height o... | n, w, h = map(int, input().split())
arr = []
for i in range(0, n):
x, y = map(int, input().split())
if x > w and y > h:
arr.append((x, y, i))
arr.sort(key=lambda x: (x[0], -x[1]))
n = len(arr)
dp = [(1, -1) for i in range(0, n)]
res = 0
end = 0
for i in range(0, n):
x, y, _ = arr[i]
for j in ran... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER VAR FUNC... |
Peter decided to wish happy birthday to his friend from Australia and send him a card. To make his present more mysterious, he decided to make a chain. Chain here is such a sequence of envelopes A = {a1, a2, ..., an}, where the width and the height of the i-th envelope is strictly higher than the width and the height o... | class Size:
def __init__(self, width, height, id=""):
self._w = width
self._h = height
self.id = id
def __lt__(self, other):
return self._w < other._w and self._h < other._h
def __str__(self):
return "({}, {})".format(self._w, self._h)
num, cardWidth, cardHeight ... | CLASS_DEF FUNC_DEF STRING ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF RETURN VAR VAR VAR VAR FUNC_DEF RETURN FUNC_CALL STRING VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR ... |
Peter decided to wish happy birthday to his friend from Australia and send him a card. To make his present more mysterious, he decided to make a chain. Chain here is such a sequence of envelopes A = {a1, a2, ..., an}, where the width and the height of the i-th envelope is strictly higher than the width and the height o... | class A:
def solve(self):
n = int(input())
other = n - 2
if other > 0 and other % 2 == 0:
print("YES")
else:
print("NO")
class B:
def solve(self):
[d, w] = [int(x) for x in input().split(" ")]
times = []
for i in range(d):
... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING CLASS_DEF FUNC_DEF ASSIGN LIST VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUN... |
Peter decided to wish happy birthday to his friend from Australia and send him a card. To make his present more mysterious, he decided to make a chain. Chain here is such a sequence of envelopes A = {a1, a2, ..., an}, where the width and the height of the i-th envelope is strictly higher than the width and the height o... | n, w, h = map(int, input().split())
A = []
for i in range(n):
wi, hi = map(int, input().split())
if wi > w and hi > h:
A.append((wi, hi, i + 1))
A.sort()
n = len(A)
Length = [(10000000, -1)] * (n + 1)
Length[0] = 0, -1
Before = [-1] * 5000
def bs(h):
beg, last = 0, n
while 1:
mid = (la... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER BIN_OP VAR ... |
Peter decided to wish happy birthday to his friend from Australia and send him a card. To make his present more mysterious, he decided to make a chain. Chain here is such a sequence of envelopes A = {a1, a2, ..., an}, where the width and the height of the i-th envelope is strictly higher than the width and the height o... | n, cw, ch = map(int, input().split())
envs = []
for i in range(n):
w, h = map(int, input().split())
if w > cw and h > ch:
envs.append((w, h, i + 1))
envs.sort()
l = len(envs)
if l > 0:
adj = [[1, -1] for _ in range(l)]
mx, x = 1, 0
for i in range(l - 2, -1, -1):
m = 0
for j i... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER VAR ... |
Peter decided to wish happy birthday to his friend from Australia and send him a card. To make his present more mysterious, he decided to make a chain. Chain here is such a sequence of envelopes A = {a1, a2, ..., an}, where the width and the height of the i-th envelope is strictly higher than the width and the height o... | n, w, h = list(map(int, input().split()))
x = []
for i in range(n):
a, b = map(int, input().split())
x.append((a, b, i + 1))
x.sort()
dp = [0] * (n + 1)
p = [-1] * (n + 1)
found = False
for i in range(n):
if x[i][0] > w and x[i][1] > h:
dp[i] = 1
found = True
for j in range(i):
i... | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_... |
Peter decided to wish happy birthday to his friend from Australia and send him a card. To make his present more mysterious, he decided to make a chain. Chain here is such a sequence of envelopes A = {a1, a2, ..., an}, where the width and the height of the i-th envelope is strictly higher than the width and the height o... | def main():
n, w, h = map(int, input().split())
cards = []
for i in range(n):
wi, hi = map(int, input().split())
if wi > w and hi > h:
cards.append((wi, hi, i + 1))
cards.sort()
if not cards:
print(0)
return
ans = []
dp = [1] * len(cards)
backp... | FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR IF VAR EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR LIST ASSIGN VAR B... |
Peter decided to wish happy birthday to his friend from Australia and send him a card. To make his present more mysterious, he decided to make a chain. Chain here is such a sequence of envelopes A = {a1, a2, ..., an}, where the width and the height of the i-th envelope is strictly higher than the width and the height o... | def lis(arr):
n = len(arr)
lis = [1] * n
back = []
for i in range(0, n):
back.append(i)
for i in range(1, n):
for j in range(0, i):
if arr[i][0] > arr[j][0] and arr[i][1] > arr[j][1] and lis[i] < lis[j] + 1:
lis[i] = lis[j] + 1
back[i] = j
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR VAR BI... |
Peter decided to wish happy birthday to his friend from Australia and send him a card. To make his present more mysterious, he decided to make a chain. Chain here is such a sequence of envelopes A = {a1, a2, ..., an}, where the width and the height of the i-th envelope is strictly higher than the width and the height o... | n, w, h = [int(j) for j in input().split()]
e = list()
e.append([0, w, h, 0])
mwi, mhi = 0, 0
for i in range(n):
wi, hi = [int(j) for j in input().split()]
mwi = max(mwi, wi)
mhi = max(mhi, hi)
e.append([i + 1, wi, hi, 0])
if w >= mwi or h >= mhi:
print(0)
exit()
s = sorted(e, key=lambda x: x[1]... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR LIST NUMBER VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EX... |
Peter decided to wish happy birthday to his friend from Australia and send him a card. To make his present more mysterious, he decided to make a chain. Chain here is such a sequence of envelopes A = {a1, a2, ..., an}, where the width and the height of the i-th envelope is strictly higher than the width and the height o... | n, w, h = map(int, input().split())
a = []
for i in range(n):
x, y = map(int, input().split())
if x > w and y > h:
a.append([x, y, i + 1])
r = [1] * len(a)
p = [0] * (n + 1)
ans = 0
a.sort()
for j in range(len(a)):
for i in range(j):
if a[j][0] > a[i][0] and a[j][1] > a[i][1]:
if... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NU... |
Peter decided to wish happy birthday to his friend from Australia and send him a card. To make his present more mysterious, he decided to make a chain. Chain here is such a sequence of envelopes A = {a1, a2, ..., an}, where the width and the height of the i-th envelope is strictly higher than the width and the height o... | n, w, h = map(int, input().split())
ans = []
for i in range(n):
x, y = map(int, input().split())
if x > w and y > h:
ans.append([x, y, i + 1])
ans.sort()
dp = [(1) for i in range(len(ans))]
index = [[ans[i][2]] for i in range(len(ans))]
for i in range(len(ans)):
cover = 1
end = -1
for j in r... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VA... |
Peter decided to wish happy birthday to his friend from Australia and send him a card. To make his present more mysterious, he decided to make a chain. Chain here is such a sequence of envelopes A = {a1, a2, ..., an}, where the width and the height of the i-th envelope is strictly higher than the width and the height o... | n, w, h = map(int, input().split())
g = []
for i in range(n):
g.append(list(map(int, input().split())) + [i])
g.sort()
dp = [0] * n
par = [-1] * n
for i in range(n):
if g[i][0] > w and g[i][1] > h:
dp[i] = 1
for i in range(n):
for j in range(i):
if (
g[i][0] > g[j][0]
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR LIST VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NU... |
Peter decided to wish happy birthday to his friend from Australia and send him a card. To make his present more mysterious, he decided to make a chain. Chain here is such a sequence of envelopes A = {a1, a2, ..., an}, where the width and the height of the i-th envelope is strictly higher than the width and the height o... | R = lambda: map(int, input().split())
n, w, h = R()
arr = []
for i in range(n):
wi, hi = R()
if wi > w and hi > h:
arr.append((wi, hi, i))
if not arr:
print(0)
exit(0)
arr.sort()
ls = [0] * n
for x in arr:
ls[x[-1]] = 1
ps = [-1] * n
for i in range(len(arr)):
wi, hi, idxi = arr[i]
fo... | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR IF VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR F... |
Pashmak's homework is a problem about graphs. Although he always tries to do his homework completely, he can't solve this problem. As you know, he's really weak at graph theory; so try to help him in solving the problem.
You are given a weighted directed graph with n vertices and m edges. You need to find a path (perh... | from sys import *
a = list(map(int, stdin.read().split()))
n = a[0]
m = a[1]
inf = 10**5 + 1
g = [[] for i in range(inf)]
for i in range(2, len(a), 3):
b, c, w = a[i : i + 3]
g[w].append((c, b))
n += 1
s = [0] * n
for l in g:
for i, k in [(i, s[j]) for i, j in l]:
s[i] = max(s[i], k + 1)
print(max(... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR... |
Sonya was unable to think of a story for this problem, so here comes the formal description.
You are given the array containing n positive integers. At one turn you can pick any element and increase or decrease it by 1. The goal is the make the array strictly increasing by making the minimum possible number of operati... | n = int(input())
a = list(map(int, input().split()))
for i in range(n):
a[i] -= i
sorted_a = sorted(a)
dp = [0.0] * n
dp2 = [0.0] * n
for i in range(n):
mn_prev_state = 10000000000000.0
for j in range(n):
mn_prev_state = min(mn_prev_state, dp[j])
dp2[j] = mn_prev_state + abs(a[i] - sorted_a[... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VA... |
Sonya was unable to think of a story for this problem, so here comes the formal description.
You are given the array containing n positive integers. At one turn you can pick any element and increase or decrease it by 1. The goal is the make the array strictly increasing by making the minimum possible number of operati... | N = int(input())
s = list(map(int, input().split()))
for i in range(N):
s[i] -= i
X = sorted(s)
dp = [0] * N
for i in s:
mi = 7e77
for j in range(N):
mi = min(mi, dp[j])
dp[j] = mi + abs(i - X[j])
print(min(dp)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR BIN_O... |
Polycarp is in really serious trouble — his house is on fire! It's time to save the most valuable items. Polycarp estimated that it would take t_{i} seconds to save i-th item. In addition, for each item, he estimated the value of d_{i} — the moment after which the item i will be completely burned and will no longer be ... | from sys import stdin, stdout
T = 2001
INF = int(1000000000.0)
n = int(stdin.readline())
items = []
for i in range(n):
c, d, t = map(int, stdin.readline().split())
items.append((d, c, t, i + 1))
items.sort()
dp = [[None for i in range(T)] for j in range(n)]
def solve(pos, time):
if pos >= n or time >= T:... | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NONE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ... |
Polycarp is in really serious trouble — his house is on fire! It's time to save the most valuable items. Polycarp estimated that it would take t_{i} seconds to save i-th item. In addition, for each item, he estimated the value of d_{i} — the moment after which the item i will be completely burned and will no longer be ... | from sys import stdin, stdout
n = int(stdin.readline())
items = []
for i in range(n):
t, d, p = map(int, stdin.readline().split())
items.append((d, p, t, i + 1))
items.sort()
N = 2000 + 1
dp = [(0) for i in range(N)]
cur = [[] for i in range(N)]
for d, p, t, it in items:
for i in range(d - 1, t - 1, -1):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR ... |
Polycarp is in really serious trouble — his house is on fire! It's time to save the most valuable items. Polycarp estimated that it would take t_{i} seconds to save i-th item. In addition, for each item, he estimated the value of d_{i} — the moment after which the item i will be completely burned and will no longer be ... | P = [0] * 2001
S = [[] for i in range(2001)]
q = [(list(map(int, input().split())) + [str(i + 1)]) for i in range(int(input()))]
q.sort(key=lambda q: q[1])
for t, d, p, i in q:
for x in range(t, d)[::-1]:
if P[x] < P[x - t] + p:
P[x] = P[x - t] + p
S[x] = S[x - t] + [i]
k = P.index(m... | ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR LIST FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER FOR VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR VAR N... |
Polycarp is in really serious trouble — his house is on fire! It's time to save the most valuable items. Polycarp estimated that it would take t_{i} seconds to save i-th item. In addition, for each item, he estimated the value of d_{i} — the moment after which the item i will be completely burned and will no longer be ... | n = int(input())
a = []
for i in range(n):
t, d, p = map(int, input().split())
a.append([t, d, p, i + 1])
a.sort(key=lambda x: x[1])
d = {(0): [0, []]}
for i in a:
e = {}
for j in d:
if d[j][0] + i[0] < i[1]:
if j + i[2] in d:
if d[j][0] + i[0] < d[j + i[2]][0]:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR DICT NUMBER LIST NUMBER LIST FOR VAR VAR ASSIGN VAR DICT FOR VAR VAR IF BIN_OP VAR ... |
Polycarp is in really serious trouble — his house is on fire! It's time to save the most valuable items. Polycarp estimated that it would take t_{i} seconds to save i-th item. In addition, for each item, he estimated the value of d_{i} — the moment after which the item i will be completely burned and will no longer be ... | import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(2 * 10**5 + 10)
write = lambda x: sys.stdout.write(x + "\n")
debug = lambda x: sys.stderr.write(x + "\n")
writef = lambda x: print("{:.12f}".format(x))
n = int(input())
tdp = [list(map(int, input().split())) for _ in range(n)]
index = list(... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ... |
Polycarp is in really serious trouble — his house is on fire! It's time to save the most valuable items. Polycarp estimated that it would take t_{i} seconds to save i-th item. In addition, for each item, he estimated the value of d_{i} — the moment after which the item i will be completely burned and will no longer be ... | from sys import stdin
input = stdin.readline
n = int(input())
T = 2001
t, d, p, idx = [], [], [], []
ans = []
arr = []
for i in range(n):
a, b, c = map(int, input().split())
arr.append([a, b, c, i])
arr.sort(key=lambda x: x[1])
for i in arr:
t.append(i[0])
d.append(i[1])
p.append(i[2])
idx.appe... | ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR LIST LIST LIST LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER FOR VAR VAR EXPR... |
Polycarp is in really serious trouble — his house is on fire! It's time to save the most valuable items. Polycarp estimated that it would take t_{i} seconds to save i-th item. In addition, for each item, he estimated the value of d_{i} — the moment after which the item i will be completely burned and will no longer be ... | n = int(input())
items = []
max_time = 0
for i in range(1, n + 1):
t, d, p = map(int, input().split())
max_time = max(max_time, d)
items.append((t, d, p, i))
items.sort(key=lambda x: x[1])
dp = [[(0, []) for _ in range(n + 1)] for _ in range(max_time + 1)]
for time in range(1, max_time + 1):
for it in r... | 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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER LIST VAR FUNC_CALL VAR ... |
Polycarp is in really serious trouble — his house is on fire! It's time to save the most valuable items. Polycarp estimated that it would take t_{i} seconds to save i-th item. In addition, for each item, he estimated the value of d_{i} — the moment after which the item i will be completely burned and will no longer be ... | from sys import stdin
n = int(stdin.readline())
items = []
for i in range(n):
t, d, p = [int(x) for x in stdin.readline().split()]
items.append((d, t, p, i))
items.sort()
mem = [{} for x in range(n)]
mem2 = [{} for x in range(n)]
def best(time, x):
time += items[x][1]
if time in mem[x]:
retur... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR DICT VAR FUNC_CALL VAR VAR ASSIGN VAR DICT VAR FUNC_CALL VAR VAR FUNC_DEF VAR VAR VAR NUMBER IF VAR VAR VAR R... |
Evlampiy has found one more cool application to process photos. However the application has certain limitations.
Each photo i has a contrast v_{i}. In order for the processing to be truly of high quality, the application must receive at least k photos with contrasts which differ as little as possible.
Evlampiy alread... | def f(m):
nonlocal dp, sdp
l = 0
for i in range(n):
while l < n and v[l] < v[i] - m:
l += 1
if l - 1 > i - k:
dp[i] = False
else:
dp[i] = sdp[i - k + 1] != sdp[l - 1]
sdp[i + 1] = sdp[i] + (1 if dp[i] else 0)
return dp[n - 1]
n, k = m... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR WHILE VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER BIN_OP VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR VAR NUMBER NUMBER RETURN VAR BIN_OP VAR... |
Fatal Eagle has finally teamed up with Arjit to take on this weird army of zombies and vampires. And they are coming up with strategies to beat these guys on a roll. The simple thing they figured out is that these creatures attack everything by the method of brute force - i.e., the total power they have while attacking... | from itertools import permutations
doors = [0, 0]
powers_sum = 0
arrangement_sum = 0
def recurse(item, idx):
if idx == len(item):
global arrangement_sum
arrangement_sum += 1
return
for i in range(2):
if i == 0 and doors[0] + item[idx] > doors[1]:
continue
d... | ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF IF VAR FUNC_CALL VAR VAR VAR NUMBER RETURN FOR VAR FUNC_CALL VAR NUMBER IF VAR NUMBER BIN_OP VAR NUMBER VAR VAR VAR NUMBER VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUM... |
Now you get Baby Ehab's first words: "Given an integer $n$, find the longest subsequence of $[1,2, \ldots, n-1]$ whose product is $1$ modulo $n$." Please solve the problem.
A sequence $b$ is a subsequence of an array $a$ if $b$ can be obtained from $a$ by deleting some (possibly all) elements. The product of an empty ... | n = int(input())
primes = []
is_prime = [1] * (n + 1)
for i in range(2, n + 1):
if is_prime[i]:
for j in range(2 * i, n + 1, i):
is_prime[j] = 0
primes.append(i)
def egcd(a, b):
if a == 0:
return b, 0, 1
else:
g, y, x = egcd(b % a, a)
return g, x - b // ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR FUNC_DEF IF VAR NUMBER RETURN VAR NUMBER NUMBER ASSI... |
Now you get Baby Ehab's first words: "Given an integer $n$, find the longest subsequence of $[1,2, \ldots, n-1]$ whose product is $1$ modulo $n$." Please solve the problem.
A sequence $b$ is a subsequence of an array $a$ if $b$ can be obtained from $a$ by deleting some (possibly all) elements. The product of an empty ... | n = int(input())
x = n
kek = set()
i = 2
while i * i <= n:
while n % i == 0:
kek.add(i)
n //= i
i += 1
if n != 1:
kek.add(n)
ans = 0
num = 1
keku = 0
keke = []
bebe = []
for i in range(1, x):
flag = True
for elem in kek:
if i % elem == 0:
flag = False
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR WHILE BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR V... |
Now you get Baby Ehab's first words: "Given an integer $n$, find the longest subsequence of $[1,2, \ldots, n-1]$ whose product is $1$ modulo $n$." Please solve the problem.
A sequence $b$ is a subsequence of an array $a$ if $b$ can be obtained from $a$ by deleting some (possibly all) elements. The product of an empty ... | D = {}
q = 2
plist = []
while q < 100000:
if q not in D:
plist.append(q)
D[q * q] = [q]
else:
for p in D[q]:
D.setdefault(p + q, []).append(p)
del D[q]
q += 1
n = int(input())
a = [(True) for _ in range(n)]
a[0] = False
for p in plist:
if n % p == 0:
f... | ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR LIST VAR FOR VAR VAR VAR EXPR FUNC_CALL FUNC_CALL VAR BIN_OP VAR VAR LIST VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER... |
Now you get Baby Ehab's first words: "Given an integer $n$, find the longest subsequence of $[1,2, \ldots, n-1]$ whose product is $1$ modulo $n$." Please solve the problem.
A sequence $b$ is a subsequence of an array $a$ if $b$ can be obtained from $a$ by deleting some (possibly all) elements. The product of an empty ... | def prod(arr):
p = 1
for i in arr:
p = p * i % n
return p
n = int(input())
lst = [0] * n
for i in range(2, n // 2 + 1):
if not n % i:
j = i
while j < n:
lst[j] = 1
j += i
arr = [i for i in range(1, n) if lst[i] == 0]
x = prod(arr)
if x != 1:
arr.pop(... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR VAR ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR VAR NUMBER VAR VAR ASSIGN VAR VAR VAR FUN... |
Now you get Baby Ehab's first words: "Given an integer $n$, find the longest subsequence of $[1,2, \ldots, n-1]$ whose product is $1$ modulo $n$." Please solve the problem.
A sequence $b$ is a subsequence of an array $a$ if $b$ can be obtained from $a$ by deleting some (possibly all) elements. The product of an empty ... | def ld(n):
i = 1
p = n**0.5
l = []
while i <= p:
if n % i == 0:
if n / i == i:
if i != 1:
l.append(i)
else:
if i != 1:
l.append(i)
l.append(n // i)
i = i + 1
l.sort()
r... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST WHILE VAR VAR IF BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR RETURN VAR ASSIGN VAR FUNC_CALL... |
Now you get Baby Ehab's first words: "Given an integer $n$, find the longest subsequence of $[1,2, \ldots, n-1]$ whose product is $1$ modulo $n$." Please solve the problem.
A sequence $b$ is a subsequence of an array $a$ if $b$ can be obtained from $a$ by deleting some (possibly all) elements. The product of an empty ... | lim = 10**5 + 1
isPrime = [True] * lim
p = []
for i in range(2, lim):
if isPrime[i]:
p.append(i)
for j in range(i * i, lim, i):
isPrime[j] = False
n = int(input())
facts = set()
for prime in p:
if n % prime == 0:
facts.add(prime)
ans = set()
prod = 1
for i in range(1, n):
... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF BIN_OP VAR ... |
Now you get Baby Ehab's first words: "Given an integer $n$, find the longest subsequence of $[1,2, \ldots, n-1]$ whose product is $1$ modulo $n$." Please solve the problem.
A sequence $b$ is a subsequence of an array $a$ if $b$ can be obtained from $a$ by deleting some (possibly all) elements. The product of an empty ... | def computeGCD(x, y):
while y:
x, y = y, x % y
return x
n = int(input())
prod = 1
H = [0] * 100005
for i in range(1, n + 1):
if computeGCD(n, i) == 1:
H[i] = 1
prod = prod * i % n
if prod != 1:
H[prod] = 0
print(H.count(1))
for i in range(1, n):
if H[i]:
print(i, en... | FUNC_DEF WHILE VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF VAR NUMBER ASSIGN VAR... |
Now you get Baby Ehab's first words: "Given an integer $n$, find the longest subsequence of $[1,2, \ldots, n-1]$ whose product is $1$ modulo $n$." Please solve the problem.
A sequence $b$ is a subsequence of an array $a$ if $b$ can be obtained from $a$ by deleting some (possibly all) elements. The product of an empty ... | def get_mod(n, r):
c = 1
for e in r:
c = c * e % n
return c
def solve(n):
def factorize(n):
v = []
p = 2
while n > 1:
if n % p == 0:
v.append(p)
while n % p == 0:
n //= p
p += 1
return ... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR RETURN VAR FUNC_DEF FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR WHILE BIN_OP VAR VAR NUMBER VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR ASSIGN V... |
Now you get Baby Ehab's first words: "Given an integer $n$, find the longest subsequence of $[1,2, \ldots, n-1]$ whose product is $1$ modulo $n$." Please solve the problem.
A sequence $b$ is a subsequence of an array $a$ if $b$ can be obtained from $a$ by deleting some (possibly all) elements. The product of an empty ... | def gcd(a, b):
if b == 0:
return a
return gcd(b, a % b)
res = []
n = int(input())
if n == 2:
print(1)
print(1)
else:
prod = 1
res = [x for x in range(n) if gcd(x, n) == 1]
for i in res:
prod = prod * i % n
if prod != 1:
res.pop()
print(len(res))
print(*r... | FUNC_DEF IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR ... |
Now you get Baby Ehab's first words: "Given an integer $n$, find the longest subsequence of $[1,2, \ldots, n-1]$ whose product is $1$ modulo $n$." Please solve the problem.
A sequence $b$ is a subsequence of an array $a$ if $b$ can be obtained from $a$ by deleting some (possibly all) elements. The product of an empty ... | from sys import stdin, stdout
get_string = lambda: stdin.readline().strip(" ")
get_intmap = lambda: map(int, get_string().split(" "))
def testcase():
n = n1 = int(input())
prime_factors = []
for i in range(2, int(n**0.5) + 4):
q, r = divmod(n1, i)
if r == 0:
prime_factors.appe... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR W... |
Now you get Baby Ehab's first words: "Given an integer $n$, find the longest subsequence of $[1,2, \ldots, n-1]$ whose product is $1$ modulo $n$." Please solve the problem.
A sequence $b$ is a subsequence of an array $a$ if $b$ can be obtained from $a$ by deleting some (possibly all) elements. The product of an empty ... | N = int(input())
divs = set()
m = 2
while m * m <= N:
if N % m == 0:
divs.add(m)
divs.add(N // m)
m += 1
ans = set(range(1, N))
for d in divs:
for n in range(d, N, d):
if n in ans:
ans.remove(n)
ans = sorted(ans)
r = 1
for a in ans:
r *= a
r %= N
if r == 1:
pr... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR FOR VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR EXPR FUNC_CAL... |
Now you get Baby Ehab's first words: "Given an integer $n$, find the longest subsequence of $[1,2, \ldots, n-1]$ whose product is $1$ modulo $n$." Please solve the problem.
A sequence $b$ is a subsequence of an array $a$ if $b$ can be obtained from $a$ by deleting some (possibly all) elements. The product of an empty ... | def gcd(a, b):
while b != 0:
a = a % b
a, b = b, a
return a
n = int(input())
res = [1]
prod = 1
for i in range(2, n):
if gcd(n, i) == 1:
res.append(i)
prod = prod * i % n
if prod != 1:
res.remove(prod)
print(len(res))
print(" ".join(str(r) for r in res)) | FUNC_DEF WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL ... |
Now you get Baby Ehab's first words: "Given an integer $n$, find the longest subsequence of $[1,2, \ldots, n-1]$ whose product is $1$ modulo $n$." Please solve the problem.
A sequence $b$ is a subsequence of an array $a$ if $b$ can be obtained from $a$ by deleting some (possibly all) elements. The product of an empty ... | def f(n):
l = []
i = 2
while i <= n**0.5:
if n % i != 0:
i += 1
else:
l.append(i)
n //= i
if n != 1:
l.append(n)
if len(l) == 1:
x = 2
elif l == [2, 2]:
x = 2
elif len(l) == 2:
if l[0] == 2:
x = 2... | FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR LIST NUMBER NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR NUMBER IF VAR NUMBER NUMBER ASSIGN... |
Now you get Baby Ehab's first words: "Given an integer $n$, find the longest subsequence of $[1,2, \ldots, n-1]$ whose product is $1$ modulo $n$." Please solve the problem.
A sequence $b$ is a subsequence of an array $a$ if $b$ can be obtained from $a$ by deleting some (possibly all) elements. The product of an empty ... | def gcd(a, b):
if a == 0:
return b
return gcd(b % a, a)
def f(N):
result = [1]
p = 1
for i in range(2, N):
if gcd(i, N) == 1:
p *= i
p %= n
if i == N - 1:
if p % N == 1:
result.append(i)
else:
... | FUNC_DEF IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR BIN_OP VAR VAR VAR FUNC_DEF ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF FUNC_CALL VAR VAR VAR NUMBER VAR VAR VAR VAR IF VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR RETURN VAR ASSIGN V... |
Now you get Baby Ehab's first words: "Given an integer $n$, find the longest subsequence of $[1,2, \ldots, n-1]$ whose product is $1$ modulo $n$." Please solve the problem.
A sequence $b$ is a subsequence of an array $a$ if $b$ can be obtained from $a$ by deleting some (possibly all) elements. The product of an empty ... | n = int(input())
def gcd(a, b):
if b == 0:
return a
else:
return gcd(b, a % b)
length = 0
product = 1
P = []
for i in range(1, n):
if gcd(i, n) == 1:
product = product * i % n
P.append(i)
length += 1
if product == n - 1 and n != 2:
P.pop()
length -= 1
prin... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR IF FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER IF VAR BIN_OP VAR N... |
Now you get Baby Ehab's first words: "Given an integer $n$, find the longest subsequence of $[1,2, \ldots, n-1]$ whose product is $1$ modulo $n$." Please solve the problem.
A sequence $b$ is a subsequence of an array $a$ if $b$ can be obtained from $a$ by deleting some (possibly all) elements. The product of an empty ... | import sys
input = sys.stdin.readline
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)
if g != 1:
return 0
else:
return x % m
n = int(input())
a = [1]
b = []
for ... | IMPORT ASSIGN VAR VAR 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 IF VAR NUMBER RETURN NUMBER RETURN BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN ... |
You are given a complete directed graph $K_n$ with $n$ vertices: each pair of vertices $u \neq v$ in $K_n$ have both directed edges $(u, v)$ and $(v, u)$; there are no self-loops.
You should find such a cycle in $K_n$ that visits every directed edge exactly once (allowing for revisiting vertices).
We can write such c... | from sys import stdin
input = stdin.buffer.readline
for _ in range(int(input())):
n, l, r = map(int, input().split())
l -= 1
r -= 1
flag, tmp, s = 1, 0, 0
ans = []
x, y = n, n - 1
for i in range(1, n):
s += 2 * (n - i)
if l < s and flag:
x, tmp = i, (i > 1) * (s ... | ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP NUMBER BIN_OP VAR VAR IF VAR VAR VA... |
You are given a complete directed graph $K_n$ with $n$ vertices: each pair of vertices $u \neq v$ in $K_n$ have both directed edges $(u, v)$ and $(v, u)$; there are no self-loops.
You should find such a cycle in $K_n$ that visits every directed edge exactly once (allowing for revisiting vertices).
We can write such c... | t = int(input())
def query(i, n, x):
if x % 2 == 1:
return i
else:
return i + x // 2
for _ in range(t):
n, l, r = map(int, input().split())
i = 1
s = 0
includeOne = False
if r == n * (n - 1) + 1:
includeOne = True
r -= 1
if l == n * (n - 1) + 1:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF IF BIN_OP VAR NUMBER NUMBER RETURN VAR RETURN BIN_OP VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN... |
You are given a complete directed graph $K_n$ with $n$ vertices: each pair of vertices $u \neq v$ in $K_n$ have both directed edges $(u, v)$ and $(v, u)$; there are no self-loops.
You should find such a cycle in $K_n$ that visits every directed edge exactly once (allowing for revisiting vertices).
We can write such c... | import sys
readline = sys.stdin.readline
def overlap(a, b, c, d):
if b <= c or d <= a:
return False
return True
T = int(readline())
Ans = [None] * T
for qu in range(T):
N, l, r = map(int, readline().split())
l -= 1
ans = []
num = [0] + [(2 * (N - i - 1)) for i in range(N - 1)] + [1]... | IMPORT ASSIGN VAR VAR FUNC_DEF IF VAR VAR VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NONE VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR BIN_OP BIN_OP LIST NUMBER BIN_OP NUMBER BIN_OP... |
You are given a complete directed graph $K_n$ with $n$ vertices: each pair of vertices $u \neq v$ in $K_n$ have both directed edges $(u, v)$ and $(v, u)$; there are no self-loops.
You should find such a cycle in $K_n$ that visits every directed edge exactly once (allowing for revisiting vertices).
We can write such c... | import sys
t = int(sys.stdin.readline())
for _ in range(t):
n, l, r = map(int, sys.stdin.readline().split())
prev = 0
cur = 0
start = 1
if l == r and l == n * (n - 1) + 1:
print(1)
else:
ans = []
while True:
cur += (n - start) * 2
if l <= cur:
... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST WHILE NUMBER VAR BIN_OP BIN_OP VA... |
You are given a complete directed graph $K_n$ with $n$ vertices: each pair of vertices $u \neq v$ in $K_n$ have both directed edges $(u, v)$ and $(v, u)$; there are no self-loops.
You should find such a cycle in $K_n$ that visits every directed edge exactly once (allowing for revisiting vertices).
We can write such c... | for _ in range(int(input())):
n, left, right = tuple(map(int, input().split()))
maximal = n * (n - 1) + 1
if left == maximal:
print("1")
continue
if right == maximal:
end_1 = True
else:
end_1 = False
a = []
summa = 0
i = (n - 1) * 2
cnt = 0
while s... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_O... |
You are given a complete directed graph $K_n$ with $n$ vertices: each pair of vertices $u \neq v$ in $K_n$ have both directed edges $(u, v)$ and $(v, u)$; there are no self-loops.
You should find such a cycle in $K_n$ that visits every directed edge exactly once (allowing for revisiting vertices).
We can write such c... | def go():
n, l, r = map(int, input().split())
tot = n * (n - 1) + 1
add = []
if r == tot:
add = ["1"]
r -= 1
res = []
if l <= r:
cur = 0
nextg = n - 1
while cur + 2 * nextg < l:
cur += 2 * nextg
nextg -= 1
g = n - nextg
... | FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST IF VAR VAR ASSIGN VAR LIST STRING VAR NUMBER ASSIGN VAR LIST IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE BIN_OP VAR BIN_OP NUMBER VAR VAR VAR BIN_OP NUMBER VAR ... |
You are given a complete directed graph $K_n$ with $n$ vertices: each pair of vertices $u \neq v$ in $K_n$ have both directed edges $(u, v)$ and $(v, u)$; there are no self-loops.
You should find such a cycle in $K_n$ that visits every directed edge exactly once (allowing for revisiting vertices).
We can write such c... | T = int(input().strip())
for t in range(T):
n, l, r = map(int, input().strip().split())
if l == n * (n - 1) + 1:
print(1)
continue
k = int((2 * n - 1 - ((2 * n - 1) ** 2 - 4 * l) ** 0.5) / 2)
if l <= 2 * k * n - k * (k + 1):
k -= 1
if l > 2 * (k + 1) * n - (k + 1) * (k + 2):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER BIN_OP BIN_OP BIN_OP BIN_OP... |
You are given a complete directed graph $K_n$ with $n$ vertices: each pair of vertices $u \neq v$ in $K_n$ have both directed edges $(u, v)$ and $(v, u)$; there are no self-loops.
You should find such a cycle in $K_n$ that visits every directed edge exactly once (allowing for revisiting vertices).
We can write such c... | import sys
def minp():
return sys.stdin.readline().strip()
def mint():
return int(minp())
def mints():
return map(int, minp().split())
def stupid(x, n):
k = (n - 1) * 2
r = 0
while x >= k:
x -= k
r += 1
k -= 2
return r
def findl(x, n):
l, r = 0, n
wh... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR VAR NUMBER VAR WHILE BIN_O... |
You are given a complete directed graph $K_n$ with $n$ vertices: each pair of vertices $u \neq v$ in $K_n$ have both directed edges $(u, v)$ and $(v, u)$; there are no self-loops.
You should find such a cycle in $K_n$ that visits every directed edge exactly once (allowing for revisiting vertices).
We can write such c... | import sys
def oracle(n, start, end):
nod = 0
t = n - 1
ii = 0
while start - ii > t * 2:
if t == 0:
nod += 1
break
nod += 1
ii += t * 2
t -= 1
if t < -10:
import sys
sys.exit()
R = []
for cur in range(nod,... | IMPORT FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER IMPORT EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR V... |
You are given a complete directed graph $K_n$ with $n$ vertices: each pair of vertices $u \neq v$ in $K_n$ have both directed edges $(u, v)$ and $(v, u)$; there are no self-loops.
You should find such a cycle in $K_n$ that visits every directed edge exactly once (allowing for revisiting vertices).
We can write such c... | for i in range(int(input())):
n, l, r = map(int, input().split())
l -= 1
r -= 1
c = 0
for j in range(n):
if c + (n - j - 1) * 2 < l or c > r:
c += (n - j - 1) * 2
continue
for k in range(j + 1, n):
if l <= c <= r:
print(j + 1, end="... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_O... |
You are given a complete directed graph $K_n$ with $n$ vertices: each pair of vertices $u \neq v$ in $K_n$ have both directed edges $(u, v)$ and $(v, u)$; there are no self-loops.
You should find such a cycle in $K_n$ that visits every directed edge exactly once (allowing for revisiting vertices).
We can write such c... | import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
n, l, r = map(int, input().split())
begin = 1
while l > (n - begin) * 2 + 1:
if begin == n:
break
l -= (n - begin) * 2
r -= (n - begin) * 2
begin += 1
if begin == n:
ans = [n, 1... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER IF VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER IF VAR VAR AS... |
You are given a complete directed graph $K_n$ with $n$ vertices: each pair of vertices $u \neq v$ in $K_n$ have both directed edges $(u, v)$ and $(v, u)$; there are no self-loops.
You should find such a cycle in $K_n$ that visits every directed edge exactly once (allowing for revisiting vertices).
We can write such c... | def check(x, n, l):
val = 2 * n * x - x * x - x
if val < l:
return True
return False
def solve(n, l, r, ans):
low = 1
high = n - 1
x = 0
while low <= high:
mid = (low + high) // 2
if check(mid, n, l):
x = mid
low = mid + 1
else:
... | FUNC_DEF ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR VAR BIN_OP VAR VAR VAR IF VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBE... |
You are given a complete directed graph $K_n$ with $n$ vertices: each pair of vertices $u \neq v$ in $K_n$ have both directed edges $(u, v)$ and $(v, u)$; there are no self-loops.
You should find such a cycle in $K_n$ that visits every directed edge exactly once (allowing for revisiting vertices).
We can write such c... | def solve():
n, l, r = [int(i) for i in input().split()]
seq = []
i = 1
while l <= r:
while l > 2 * n - 2:
if l == 3:
i = 1
break
l -= 2 * n - 2
r -= 2 * n - 2
n -= 1
i += 1
if l % 2 == 0:
... | FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR WHILE VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EX... |
You are given a complete directed graph $K_n$ with $n$ vertices: each pair of vertices $u \neq v$ in $K_n$ have both directed edges $(u, v)$ and $(v, u)$; there are no self-loops.
You should find such a cycle in $K_n$ that visits every directed edge exactly once (allowing for revisiting vertices).
We can write such c... | import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
n, l, r = map(int, input().split())
lb, ub = 0, n
while ub - lb > 1:
m = (lb + ub) // 2
if m * (2 * n - m - 1) < l:
lb = m
else:
ub = m
i = ub
s = lb * (2 * n - lb - 1) + 1
... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER VAR ASSIGN VAR VAR AS... |
You are given a complete directed graph $K_n$ with $n$ vertices: each pair of vertices $u \neq v$ in $K_n$ have both directed edges $(u, v)$ and $(v, u)$; there are no self-loops.
You should find such a cycle in $K_n$ that visits every directed edge exactly once (allowing for revisiting vertices).
We can write such c... | def genGroup(lo, n):
if lo == n:
return [1]
s = []
for i in range(lo + 1, n + 1):
s.append(lo)
s.append(i)
return s
for tc in range(int(input())):
n, beg, end = map(int, input().split())
if beg == n * (n - 1) + 1:
print(1)
else:
past = 0
i = ... | FUNC_DEF IF VAR VAR RETURN LIST NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP BIN_OP VAR BIN_OP VAR NUM... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.