description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
It is well known that the planet suffers from the energy crisis. Little Petya doesn't like that and wants to save the world. For this purpose he needs every accumulator to contain the same amount of energy. Initially every accumulator has some amount of energy: the i-th accumulator has ai units of energy. Energy can be... | n, k = map(int, input().split())
a = list(map(int, input().split()))
sum_energy = sum(a)
left = 0
right = 1000
while right - left > 1e-07:
mid = (left + right) / 2
sum_transfer = 0
for x in a:
if x > mid:
sum_transfer += x - mid
if mid * n < sum_energy - sum_transfer * k / 100:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL 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 NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR BIN_OP VAR VAR IF ... |
It is well known that the planet suffers from the energy crisis. Little Petya doesn't like that and wants to save the world. For this purpose he needs every accumulator to contain the same amount of energy. Initially every accumulator has some amount of energy: the i-th accumulator has ai units of energy. Energy can be... | n, k = [int(n) for n in input().split()]
accums = [int(n) for n in input().split()]
k = 100 - k
right = max(accums)
left = min(accums)
guess = 0
if len(accums) == 1:
print(accums[0])
elif right == left:
print(left)
else:
while right - left > 1e-08:
guess = (left + right) / 2.0
excess = 0
... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR WHILE... |
It is well known that the planet suffers from the energy crisis. Little Petya doesn't like that and wants to save the world. For this purpose he needs every accumulator to contain the same amount of energy. Initially every accumulator has some amount of energy: the i-th accumulator has ai units of energy. Energy can be... | s = input().strip().split()
n = int(s[0])
k = 100 - int(s[1])
a = list()
for i in input().strip().split():
a.append(int(i))
left = min(a)
right = max(a)
guess = max(a)
while right - left > 10**-6:
guess = (left + right) / 2
needed = 0
excess = 0
for i in a:
if i > guess:
excess +... | ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VA... |
It is well known that the planet suffers from the energy crisis. Little Petya doesn't like that and wants to save the world. For this purpose he needs every accumulator to contain the same amount of energy. Initially every accumulator has some amount of energy: the i-th accumulator has ai units of energy. Energy can be... | n, k = map(int, input().split())
A = list(map(int, input().split()))
def f(x):
over = 0
need = 0
for a in A:
if a > x:
over += a - x
else:
need += x - a
return need <= over * (1 - k / 100)
left = 0
right = 1000
while right - left > 1e-12:
m = (left + right... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR RETURN VAR BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ... |
It is well known that the planet suffers from the energy crisis. Little Petya doesn't like that and wants to save the world. For this purpose he needs every accumulator to contain the same amount of energy. Initially every accumulator has some amount of energy: the i-th accumulator has ai units of energy. Energy can be... | n, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse=True)
s = sum(l)
s1 = 0
s2 = s
ans = 0
k = 100 - k
for i in range(n - 1):
s1 += l[i]
s2 -= l[i]
a = (s1 * k + 100 * s2) / ((i + 1) * k + 100 * (n - i - 1))
if a <= l[i] and a >= l[i + 1]:
ans = max(ans, a)
if len... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR V... |
It is well known that the planet suffers from the energy crisis. Little Petya doesn't like that and wants to save the world. For this purpose he needs every accumulator to contain the same amount of energy. Initially every accumulator has some amount of energy: the i-th accumulator has ai units of energy. Energy can be... | n, k = [int(d) for d in input().split()]
a = [int(d) for d in input().split()]
def test(v):
ia = [d for d in a if d > v]
ea = [d for d in a if d < v]
dis = sum(ia) - v * len(ia)
dem = v * len(ea) - sum(ea)
pas = dis * (1 - k / 100)
if dem <= pas:
return True
return False
def bs(l... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR A... |
It is well known that the planet suffers from the energy crisis. Little Petya doesn't like that and wants to save the world. For this purpose he needs every accumulator to contain the same amount of energy. Initially every accumulator has some amount of energy: the i-th accumulator has ai units of energy. Energy can be... | n, k = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
def check(x):
pw = 0
for i in a:
if i >= x:
rem = i - x
pw += rem - rem * k / 100
else:
pw -= x - i
if pw >= 0:
return True
return False
l = 0
h = max(a)
ans = 0
whi... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR IF VAR NUMBER RETURN NUMBER RETURN NUMBER A... |
It is well known that the planet suffers from the energy crisis. Little Petya doesn't like that and wants to save the world. For this purpose he needs every accumulator to contain the same amount of energy. Initially every accumulator has some amount of energy: the i-th accumulator has ai units of energy. Energy can be... | u = input
n, k = map(int, u().split())
k = 100 - k
M = [int(i) for i in u().split()]
M.sort()
sl = 0.0
sr = sum(M)
x = M[0]
if M[0] != M[len(M) - 1]:
for j in range(n - 1):
sl += M[j]
sr -= M[j]
if sl >= sr:
break
t = (sl + k * sr / 100.0) / (j + 1.0 + k * (n - 1 - j) / 1... | ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER IF VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BI... |
It is well known that the planet suffers from the energy crisis. Little Petya doesn't like that and wants to save the world. For this purpose he needs every accumulator to contain the same amount of energy. Initially every accumulator has some amount of energy: the i-th accumulator has ai units of energy. Energy can be... | nk = list(map(int, input("").split()))
n, k = nk
aList = list(map(int, input("").split()))
aList.sort()
def isPossible(val, aList, k):
rightSum = 0
leftSum = 0
for item in aList:
if item > val:
rightSum += item - val
else:
leftSum += val - item
return rightSum -... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR RETURN BIN_OP VAR BIN_OP BIN... |
It is well known that the planet suffers from the energy crisis. Little Petya doesn't like that and wants to save the world. For this purpose he needs every accumulator to contain the same amount of energy. Initially every accumulator has some amount of energy: the i-th accumulator has ai units of energy. Energy can be... | a = []
def check(valueToBeChecked):
extraPower = 0
for i in a:
if i >= valueToBeChecked:
powerDonated = i - valueToBeChecked
extraPower += powerDonated - powerDonated * k / 100
else:
extraPower -= valueToBeChecked - i
return extraPower >= 0
n, k = map(... | ASSIGN VAR LIST FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR RETURN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VA... |
It is well known that the planet suffers from the energy crisis. Little Petya doesn't like that and wants to save the world. For this purpose he needs every accumulator to contain the same amount of energy. Initially every accumulator has some amount of energy: the i-th accumulator has ai units of energy. Energy can be... | def check_possibility(_accumulators, max_value, n, k):
less = 0
more = 0
for i in range(n):
if _accumulators[i] > max_value:
more += _accumulators[i] - max_value
else:
less += max_value - _accumulators[i]
return more - k * more / 100 >= less
def solution():
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR VAR RETURN BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CAL... |
It is well known that the planet suffers from the energy crisis. Little Petya doesn't like that and wants to save the world. For this purpose he needs every accumulator to contain the same amount of energy. Initially every accumulator has some amount of energy: the i-th accumulator has ai units of energy. Energy can be... | TOL = 10**-9
n, k = map(int, input().split())
arr = list(map(int, input().split()))
arr = sorted(arr)
lef = arr[0]
rit = arr[n - 1]
while rit - lef > TOL:
mid = (lef + rit) / 2
pls = 0
mns = 0
for i in range(n):
if arr[i] > mid:
pls += arr[i] - mid
else:
mns += mi... | ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL 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 VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER WHILE BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMB... |
It is well known that the planet suffers from the energy crisis. Little Petya doesn't like that and wants to save the world. For this purpose he needs every accumulator to contain the same amount of energy. Initially every accumulator has some amount of energy: the i-th accumulator has ai units of energy. Energy can be... | n, k = map(int, input().split())
a = [int(x) for x in input().split()]
l = 0
r = 1001
while r - l > 1e-07:
m = (r + l) / 2
plus = 0
minus = 0
for i in range(n):
if a[i] <= m:
plus += m - a[i]
else:
minus += a[i] - m
minus = minus * (100 - k) / 100
if minus... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR BIN_OP VAR VAR VAR VA... |
It is well known that the planet suffers from the energy crisis. Little Petya doesn't like that and wants to save the world. For this purpose he needs every accumulator to contain the same amount of energy. Initially every accumulator has some amount of energy: the i-th accumulator has ai units of energy. Energy can be... | n, k = map(float, input().split())
lst = list(map(float, input().split()))
n = int(n)
lst.sort()
lst.reverse()
def cout(x):
a, b = 0, 0
for i, x in enumerate(lst):
if x > mid:
x -= mid
a += x * (100.0 - k) / 100.0
elif x < mid:
b += mid - x
return a, b
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR NU... |
It is well known that the planet suffers from the energy crisis. Little Petya doesn't like that and wants to save the world. For this purpose he needs every accumulator to contain the same amount of energy. Initially every accumulator has some amount of energy: the i-th accumulator has ai units of energy. Energy can be... | n, k = list(map(int, input().split(" ")))
inp = list(map(int, input().split(" ")))
x, y = [1, 3]
_sum = sum(inp)
right = _sum / n
left = 0
mid = (right + left) / 2
while right - left > 1e-11:
lost = 0
get = 0
for i in inp:
if mid < i:
lost += (i - mid) * (1 - k / 100)
else:
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER WHILE BIN_OP VAR VAR ... |
It is well known that the planet suffers from the energy crisis. Little Petya doesn't like that and wants to save the world. For this purpose he needs every accumulator to contain the same amount of energy. Initially every accumulator has some amount of energy: the i-th accumulator has ai units of energy. Energy can be... | (n, k), t = map(int, input().split()), sorted(map(int, input().split()))
i, d, s = 1, t[0], sum(t)
while i < n and 100 * s - k * (s - d) > t[i] * (100 * n - k * (n - i)):
d += t[i]
i += 1
print((100 * s - k * (s - d)) / (100 * n - k * (n - i))) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER FUNC_CALL VAR VAR WHILE VAR VAR BIN_OP BIN_OP NUMBER VAR BIN_OP VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP NUMBER VAR BIN_OP VAR BIN_OP VAR VAR VAR VAR VAR VAR N... |
An array is called beautiful if all the elements in the array are equal.
You can transform an array using the following steps any number of times:
1. Choose two indices i and j (1 β€ i,j β€ n), and an integer x (1 β€ x β€ a_i). Let i be the source index and j be the sink index.
2. Decrease the i-th element by x, an... | from sys import maxsize, stdin, stdout
R = lambda: stdin.readline().strip()
RL = lambda f=None: list(map(f, R().split(" "))) if f else list(R().split(" "))
output = lambda x: stdout.write(str(x) + "\n")
output_list = lambda x: output(" ".join(map(str, x)))
M = int(1000000000.0) + 7
def fact(n, M):
ans = 1
fo... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NONE VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR NUMB... |
An array is called beautiful if all the elements in the array are equal.
You can transform an array using the following steps any number of times:
1. Choose two indices i and j (1 β€ i,j β€ n), and an integer x (1 β€ x β€ a_i). Let i be the source index and j be the sink index.
2. Decrease the i-th element by x, an... | def pow(a, n):
if n == 0:
return 1
if n % 2 == 0:
return pow(a**2 % MOD, n // 2)
return a * pow(a, n - 1) % MOD
def C(n, k):
return fact[n] * pow(fact[n - k], MOD - 2) * pow(fact[k], MOD - 2) % MOD
MOD = 10**9 + 7
n = int(input())
a = list(map(int, input().split()))
fact = [1] * (n +... | FUNC_DEF IF VAR NUMBER RETURN NUMBER IF BIN_OP VAR NUMBER NUMBER RETURN FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR BIN_... |
An array is called beautiful if all the elements in the array are equal.
You can transform an array using the following steps any number of times:
1. Choose two indices i and j (1 β€ i,j β€ n), and an integer x (1 β€ x β€ a_i). Let i be the source index and j be the sink index.
2. Decrease the i-th element by x, an... | n = int(input())
a = (*map(int, input().split()),)
s = sum(a)
if s % n:
print(0)
exit(0)
M = 10**9 + 7
s //= n
f = [1] * (n + 1)
b = [0] * 3
d = dict()
for i in range(2, n + 1):
f[i] = f[i - 1] * i % M
for x in a:
b[(x > s) - (x < s)] += 1
try:
d[x] += 1
except:
d[x] = 1
k = 1
fo... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMB... |
An array is called beautiful if all the elements in the array are equal.
You can transform an array using the following steps any number of times:
1. Choose two indices i and j (1 β€ i,j β€ n), and an integer x (1 β€ x β€ a_i). Let i be the source index and j be the sink index.
2. Decrease the i-th element by x, an... | import sys
from sys import stdin
def modfac(n, MOD):
f = 1
factorials = [1]
for m in range(1, n + 1):
f *= m
f %= MOD
factorials.append(f)
inv = pow(f, MOD - 2, MOD)
invs = [1] * (n + 1)
invs[n] = inv
for m in range(n, 1, -1):
inv *= m
inv %= MOD
... | IMPORT FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER VAR VAR VAR VAR ASS... |
An array is called beautiful if all the elements in the array are equal.
You can transform an array using the following steps any number of times:
1. Choose two indices i and j (1 β€ i,j β€ n), and an integer x (1 β€ x β€ a_i). Let i be the source index and j be the sink index.
2. Decrease the i-th element by x, an... | a = (*map(int, [*open(0)][1].split()),)
n = len(a)
s = sum(a)
if s % n:
exit(print(0))
M = 10**9 + 7
f = [1] * (n + 1)
b = [0] * 3
d = {}
k = 1
for i in range(2, n + 1):
f[i] = f[i - 1] * i % M
for x in a:
b[(n * x > s) - (n * x < s)] += 1
d[x] = d[x] + 1 if x in d else 1
for x in d:
k *= f[d[x]]
A,... | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL LIST FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER A... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | p = input().split()
w = int(p[0])
m = int(p[1])
a = m
cost = int(p[2])
c = 0
while m != 0:
m = m // 10
c = c + 1
sum = 0
x = 10**c - a
if cost * c * x >= w:
print(w // (cost * c))
else:
sum = sum + x
w = w - cost * c * x
for i in range(c + 1, 18):
y = 9 * 10 ** (i - 1)
if y * i *... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR IF BIN_OP B... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | import sys
w, m, k = (int(x) for x in sys.stdin.readline().split(" "))
n = w // k
def S(x):
i = 0
while x:
i += 1
x //= 10
return i
c = 0
l = S(m)
while True:
num = 10**l - m
if n > num * l:
n -= num * l
c += num
m = 10**l
l += 1
else:
... | IMPORT ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR IF VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR ... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | def f(x):
digs = len(str(x))
ndig = digs * (x - 10 ** (digs - 1) + 1)
for i in range(1, digs):
ndig += i * 9 * 10 ** (i - 1)
return ndig
a, b, c = list(map(int, input().split(" ")))
num = a // c
need = num + f(b - 1)
lo = 0
hi = 10**18
while lo < hi:
mid = (lo + hi + 1) // 2
if f(mid) ... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP BIN_OP VAR NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING AS... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | w, m, k = map(int, input().split())
ten = []
power = []
ten.append(0)
power.append(0)
ten.append(1)
power.append(9)
for x in range(1, 30):
ten.append(ten[len(ten) - 1] * 10)
power.append(power[len(power) - 1] * 10 + 9)
cnt = 0
foo = m
while foo > 0:
cnt = cnt + 1
foo = foo // 10
ini = m
end = power[cnt]... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | read = lambda: tuple(map(int, input().split()))
w, m, k = read()
l = [(10**v - 1) for v in range(64)]
cv = m
s = lambda v: len(str(v)) * k
cd = 0
ln = 0
for lv in l:
if cv <= lv:
d = min(w, (lv - cv + 1) * s(cv)) // s(cv)
w -= d * s(cv)
ln += d
cv = lv + 1
if w <= 0:
brea... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP FUNC_C... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | w, m, k = map(int, input().split())
z = m
dig = 0
while z > 0:
dig += 1
z = z // 10
if dig * k > w:
print(0)
exit(0)
lo = m - 1
hi = w + m + 5
while lo + 1 < hi:
mid = (lo + hi) // 2
cost, t, d = 0, 0, 0
x = mid
while x > 0:
x = x // 10
d += 1
if d == dig:
cos... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER WHILE BIN_OP VAR NUMBER VA... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | w, m, k = map(int, input().split())
def size(a):
return len(str(a))
def how_many(m, n):
len1 = size(m)
len2 = size(n)
if len1 == len2:
return (n - m + 1) * len1
else:
cnt = 0
for len in range(len1, len2 + 1):
if len == len1:
cnt += (pow(10, len... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR RETURN BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP BI... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | def findten(x):
ans = 1
while ans <= x:
ans *= 10
return ans
def s(x):
ans = 0
while x:
ans += 1
x //= 10
return ans
w, m, k = (int(i) for i in input().split())
ans = 0
p = findten(m)
while w > 0:
temp = s(m) * k * (p - m)
if w - temp >= 0:
ans += p - ... | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR BIN_OP VAR ... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | w, m, k = map(int, input().split())
def f(x):
p = 1
njir = 1
lol = 0
while 10 * p <= x:
lol = lol + 9 * njir * p
njir += 1
p = p * 10
return (lol + njir * (x - p + 1)) * k
lo = 1
hi = 1
ans = 0
while len(str(hi)) <= 30:
hi = hi * 10
while lo <= hi:
mid = (lo + hi)... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP NUMBER VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP NUMBER VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER VAR ASSIGN V... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | pow10 = [(10**i) for i in range(20)]
w, m, k = map(int, input().split())
x = 1
while m > pow10[x]:
x += 1
if (pow10[x] - m) * x * k >= w:
print(w // (x * k))
exit()
cur = (pow10[x] - m) * x * k
tmp = pow10[x] - m
x += 1
while cur + 9 * pow10[x - 1] * x * k <= w:
cur += 9 * pow10[x - 1] * x * k
tmp +... | ASSIGN VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR NUMBER IF BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VA... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | def fhelp(a):
s = 1
f = 10
res = 0
while a >= s:
if a >= s and a < f:
break
res += len(str(s)) * k * (f - s)
s *= 10
f *= 10
res += len(str(a)) * k * (a - s + 1)
return res
def f(a, b):
return fhelp(b) - fhelp(a - 1)
w, m, k = list(map(int, inp... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR VAR BIN_OP BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR NUMBER VAR NUMBER VAR BIN_OP BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER RETURN VAR FUNC_DEF RETURN BIN_OP FUNC_CALL VAR VA... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | a, b, c = map(int, input().split())
ans = 0
temp = len(str(b))
while a > 0:
cnt = "1" + "0" * temp
d = int(cnt) - b
cur = a // (temp * c)
a -= min(d, cur) * c * temp
ans += min(d, cur)
b = int(cnt)
temp += 1
if cur == 0:
break
print(ans) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP STRING BIN_OP STRING VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR VAR VAR VAR FUNC_CALL... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | def sum(k):
ret = 0
pw = 10
len = 1
while 1 == 1:
cur = min(pw - 1, k)
prev = pw // 10
ret += (cur - prev + 1) * len
if pw - 1 >= k:
break
len += 1
pw *= 10
return ret
w, m, k = map(int, input().split())
lo = 0
hi = int(1e18)
while hi - l... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR IF BIN_OP VAR NUMBER VAR VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VA... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | w, m, k = list(map(int, input().split()))
ans = 0
c = 0
n = 0
while 10**n <= m:
n += 1
while c + (10**n - m) * n * k <= w:
c += (10**n - m) * n * k
ans += 10**n - m
m = 10**n
n += 1
ans += (w - c) // (n * k)
print(ans) | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP NUMBER VAR VAR VAR NUMBER WHILE BIN_OP VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR VAR VAR VAR VAR VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR VAR VAR VAR VAR BIN_OP BIN_OP NUMBER ... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | lst = input().split()
lst = [int(x) for x in lst]
w, m, k = lst[0], lst[1], lst[2]
idx = 10
ans = 0
start = 1
while idx <= m:
start += 1
idx *= 10
while w:
tmpc = start * (idx - m) * k
if tmpc < w:
ans += idx - m
w -= tmpc
m = idx
idx *= 10
start += 1
else:
... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER VAR NUMBER WHILE VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR IF VAR VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | w, m, k = map(int, input().split())
def erc(x):
an = 0
for i in range(x):
an = an * 10 + 9
return an
def s(x):
y = 0
while x > 0:
y += 1
x //= 10
return y
cnt = 0
for i in range(s(m), 30):
cnt += min(erc(i) - m + 1, w // (i * k))
if erc(i) - m + 1 >= w / (i ... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_C... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | import sys
w, m, k = map(int, input().split())
def next(n):
a, cnt = 1, 1
while a <= n:
a *= 10
cnt += 1
return a, cnt - 1
m0 = m
while w > 0:
M, s = next(m)
if (M - m) * s * k >= w:
M = (w + m * s * k) // (s * k)
print(M - m0)
return
else:
w ... | IMPORT ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER WHILE VAR VAR VAR NUMBER VAR NUMBER RETURN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP BIN_... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | a = input().split()
l = len(a[1])
p = int(a[1])
d = 10**l
m = int(a[2])
w = int(a[0])
c = 0
while l * m <= w:
r = min(int(w / (l * m)), d - p)
c += r
w -= r * l * m
p = d
d *= 10
l += 1
print(c) | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR BIN_... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | w, m, k = list(map(int, list(input().split())))
w = w // k
logm = len(str(m))
nextpow = 10**logm - m
total = 0
while w >= logm * nextpow:
total += nextpow
w -= logm * nextpow
nextpow = 9 * 10**logm
logm += 1
total += w // logm
print(total) | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR VAR VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP NUMBER BIN_OP NUMBER VAR VAR NUMBE... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | def fhelp(a):
s = 1
f = 10
res = 0
while a >= s:
if a >= s and a < f:
break
res += len(str(s)) * k * (f - s)
s *= 10
f *= 10
res += len(str(a)) * k * (a - s + 1)
return res
def f(a, b):
return fhelp(b) - fhelp(a - 1)
w, m, k = map(int, input().... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR VAR BIN_OP BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR NUMBER VAR NUMBER VAR BIN_OP BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER RETURN VAR FUNC_DEF RETURN BIN_OP FUNC_CALL VAR VA... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | def s(n):
return len(str(n))
def main():
mode = "filee"
if mode == "file":
f = open("test.txt", "r")
get = lambda: [
int(x) for x in (f.readline() if mode == "file" else input()).split()
]
[w, m, k] = get()
ans = 0
while w >= (10 ** s(m) - m) * s(m) * k:
w -= (1... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR STRING IF VAR STRING ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR FUNC_CALL VAR ASSIGN LIST VAR VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER FUNC_CALL... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | pow10 = [(1) for i in range(19)]
for i in range(1, 19):
pow10[i] = pow10[i - 1] * 10
w, m, k = map(int, input().split())
x = 1
while m > pow10[x]:
x += 1
if (pow10[x] - m) * x * k >= w:
print(int(w / (x * k)))
else:
cur = (pow10[x] - m) * x * k
temp = pow10[x] - m
while True:
x += 1
... | ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR NUMBER IF BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR B... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | import sys
def solve():
w, m, k = rv()
small, large = 0, int(1e16)
while small < large:
avg = (small + large + 1) // 2
if works(avg, w, m, k):
small = avg
else:
large = avg - 1
print(small)
def works(numbers, maxcost, startnum, multiplier):
maxnumb... | IMPORT FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER FUNC_CALL VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER IF FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR ... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | def s():
[w, m, k] = list(map(int, input().split()))
r = 0
c = 1
while c > 0:
l = len(str(m))
c = min(w // (l * k), 10**l - m)
m += c
w -= c * l * k
r += c
print(r)
s() | FUNC_DEF ASSIGN LIST VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR BIN_OP BIN_OP NUMBER VAR VAR VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR EXPR FUNC... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | have, start, k = map(int, input().split())
ans = 0
while have > 0:
length = len(str(start))
howMany = 10**length - start
cost = k * howMany * length
if cost <= have:
ans += howMany
have -= cost
start = 10**length
else:
ans += max(0, have // (k * length))
have ... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR BIN_OP VAR V... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | def dec_len(n):
s = str(n)
return len(s)
def last(mx, m, k):
return mx - (mx - m) % k
def quanto(m, st):
mx = int(10**st)
cl = mx - m
m = mx
return cl, m
w, m, k = map(int, input().split(" "))
d = 0
while 1:
l = dec_len(m)
cl, nm = quanto(m, l)
if w > cl * k * l:
w ... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR VAR FUNC_DEF RETURN BIN_OP VAR BIN_OP BIN_OP VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR RETURN VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER WHILE NUMB... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | def number_of_digits(n):
if n == 0:
return 0
else:
return 1 + number_of_digits(n // 10)
def calc(n):
if n <= 0:
return 0
d = number_of_digits(n)
ret = 0
for i in range(1, d):
ret += 9 * 10 ** (i - 1) * i
ret += (n - 10 ** (d - 1) + 1) * d
return ret
de... | FUNC_DEF IF VAR NUMBER RETURN NUMBER RETURN BIN_OP NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP BIN_OP NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER VAR VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP NUMBER BIN_OP VA... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | def nxt_num(n):
return 10 ** len(str(n))
class CodeforcesTask373BSolution:
def __init__(self):
self.result = ""
self.w_m_k = []
def read_input(self):
self.w_m_k = [int(x) for x in input().split(" ")]
def process_task(self):
k = self.w_m_k[2]
budget = self.w_m... | FUNC_DEF RETURN BIN_OP NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR CLASS_DEF FUNC_DEF ASSIGN VAR STRING ASSIGN VAR LIST FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF BIN_OP BIN_OP BIN_OP FU... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | w, m, k = map(int, input().split())
w //= k
pre = 0
cur = 9
len = 1
saved_m = m
while m > cur:
pre += cur * len
m -= cur
cur *= 10
len += 1
pre += (m - 1) * len
w += pre
ans = 0
cur = 9
len = 1
while w > cur * len:
w -= cur * len
ans += cur
cur *= 10
len += 1
ans += w // len
print(ans - ... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR NUMBER VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR VAR... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | w, m, k = map(int, input().split())
cost, num = 0, 0
ln = len(str(m))
aim = 10**ln
if (aim - m) * ln * k <= w:
cost += (aim - m) * ln * k
num += aim - m
m = aim
ln += 1
while True:
if ln * k * 9 * 10 ** (ln - 1) + cost <= w:
cost += ln * k * 9 * 10 ** (ln - 1)
num += ... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER VAR IF BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR NUMBER WHILE NUMBER IF BIN_OP BIN_O... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | w, m, k = map(int, input().split())
L = len(str(m))
end = m
flag = False
while True:
if w > (10**L - end) * k * L:
w -= (10**L - end) * k * L
end = 10**L
L += 1
else:
end += w // (L * k)
break
if not flag:
print(end - m) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE NUMBER IF VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR VAR VAR VAR VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR VAR VAR VAR ASSIGN VAR BIN_OP NUMBER VAR VAR NUMBER VAR BIN_OP VAR BI... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | w, m, k = map(int, input().split())
n = m - 1
l = len(str(m))
while w > 0:
t = (10**l - n - 1) * l * k
if w <= t:
n += w // (l * k)
w = 0
else:
n = 10**l
w = w - t - (l + 1) * k
l += 1
print(n - m + 1) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER VAR VAR IF VAR VAR VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | w, m, k = (int(string) for string in input().split())
answer = 0
digitCount = len(str(m))
while w > 0:
ceiling = 10**digitCount
numberCountInThisLength = ceiling - m
cost = digitCount * k * numberCountInThisLength
if w > cost:
w -= cost
answer += numberCountInThisLength
m = ceili... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER VAR BIN_OP VAR BIN_OP VAR VAR EX... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | w, m, k = input().split()
w = int(w)
m = int(m)
k = int(k)
ans = 0
clen = len(str(m))
while w > 0:
mx = pow(10, clen) - 1
diff = mx - m + 1
cost = clen * diff * k
if w >= cost:
w -= cost
ans += diff
else:
diff = w // clen
diff = diff // k
ans += diff
b... | ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | 3
def readln():
return tuple(map(int, input().split()))
w, m, k = readln()
s = 1
ans = 0
while w:
while m >= 10**s:
s += 1
cnt = 10**s - m
if cnt * s * k <= w:
ans += cnt
w -= cnt * s * k
m = 10**s
else:
ans += w // (s * k)
w = 0
print(ans) | EXPR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR WHILE VAR BIN_OP NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN ... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | def cnt(x, y):
return y - x
w, m, k = list(map(int, input().split()))
p, d, res = 1, 0, 0
while p <= m:
p *= 10
d += 1
while cnt(m, p) * d * k <= w:
w -= cnt(m, p) * d * k
res += cnt(m, p)
m = p
p *= 10
d += 1
res += w // (d * k)
print(res) | FUNC_DEF RETURN BIN_OP VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER WHILE VAR VAR VAR NUMBER VAR NUMBER WHILE BIN_OP BIN_OP FUNC_CALL VAR VAR VAR VAR VAR VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | w, m, k = list(map(int, input().split()))
ans = 0
c = 0
n = 0
while 10**n <= m:
n += 1
if (10**n - m) * n * k >= w:
print(w // (n * k))
exit()
else:
c += (10**n - m) * n * k
ans += 10**n - m
n += 1
while c + 10 ** (n - 1) * 9 * n * k <= w:
c += 10 ** (n - 1) * 9 * n * k
ans += 10 ** (n - 1) ... | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP NUMBER VAR VAR VAR NUMBER IF BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP BIN_O... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | w, m, k = map(int, input().split())
ans = 0
while w >= len(str(m)) * k:
ans += min(w // (k * len(str(m))), 10 ** len(str(m)) - m)
w1 = w
m1 = m
m += min(w1 // (k * len(str(m1))), 10 ** len(str(m1)) - m1)
w -= k * len(str(m1)) * min(w1 // (k * len(str(m1))), 10 ** len(str(m1)) - m1)
print(ans) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP BIN_OP NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP VAR ... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | w, m, k = input().split()
k = int(w) // int(k)
l, m = len(m), int(m)
s = pow(10, l)
if (s - m) * l > k:
print(k // l)
else:
k -= (s - m) * l
l += 1
d = 9 * s
while d * l <= k:
k -= d * l
l += 1
s += d
d = 9 * s
print(s - m + k // l) | ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | w, m, k = map(int, input().split())
cur = len(str(m))
g = 9
base = 1
g = g * 10 ** (cur - 1)
base = base * 10 ** (cur - 1)
gg = g - (m - base)
ans = 0
while w:
if w > cur * gg * k:
w -= cur * gg * k
ans += gg
cur += 1
gg = g * 10
g *= 10
else:
ans += w // (cur * k... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR IF VAR ... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | w, m, k = tuple(map(int, input().split()))
s = len(str(m))
t = m
n = 10**s
r = (n - t) * s * k
while w >= r:
w -= r
t = n
n *= 10
s += 1
r = (n - t) * s * k
if w != 0:
n //= 10
if n < m:
n = 0
else:
n -= m
r = s * k
n += w // r
else:
n = n // 10 - m
print(n) | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR WHILE VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR IF ... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | w, m, k = list(map(int, input().split()))
z = a = 10 ** len(str(m)) - m
if a * len(str(m)) * k >= w:
print(w // (len(str(m)) * k))
else:
w -= a * len(str(m)) * k
c = len(str(m)) + 1
while w > 0:
a = 9 * 10 ** (c - 1)
if a * c * k >= w:
print(w // (c * k) + z)
brea... | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP BIN_OP NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR VAR IF BIN_OP BIN_OP VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR BIN_OP BIN_OP VAR FUNC_CALL VAR FUN... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | w, m, k = map(int, input().split())
ans = 0
while w > 0:
l = len(str(m))
ans += min(w / (l * k), 10**l - m)
w -= k * (10**l - m) * l
m = 10**l
print(int(ans)) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR VAR BIN_OP BIN_OP NUMBER VAR VAR VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP NUMBER VAR VAR VAR ASSIGN VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR FUNC_... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | def cnt(x, y):
return y - x
w, m, k = map(int, input().split())
p, d, res = 1, 0, 0
while p <= m:
p *= 10
d += 1
while cnt(m, p) * d * k <= w:
w -= cnt(m, p) * d * k
res += cnt(m, p)
m = p
p *= 10
d += 1
lo, hi = m, p
while hi - lo > 1:
mid = (lo + hi) // 2
if cnt(m, mid) * d *... | FUNC_DEF RETURN BIN_OP VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER WHILE VAR VAR VAR NUMBER VAR NUMBER WHILE BIN_OP BIN_OP FUNC_CALL VAR VAR VAR VAR VAR VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR NUMBE... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | def log10_(a):
ans = 0
while a // 10:
ans += 1
a = a // 10
return ans
def pow10(a):
ans = 1
for i in range(a):
ans *= 10
return ans
w, m, k = [int(x) for x in input().split()]
ans = 0
costo = k * (log10_(m) + 1)
for i in range(log10_(m) + 1, 18):
if (pow10(i) - m)... | FUNC_DEF ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VA... |
We'll define S(n) for positive integer n as follows: the number of the n's digits in the decimal base. For example, S(893) = 3, S(114514) = 6.
You want to make a consecutive integer sequence starting from number m (m, m + 1, ...). But you need to pay S(n)Β·k to add the number n to the sequence.
You can spend a cost up... | w, m, k = map(int, input().split())
d = len(str(m))
ans = 0
c = min(10**d - m, w // (k * d))
while c:
ans += c
w -= c * k * d
m = 10**d
d += 1
c = min(10**d - m, w // (k * d))
print(ans) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR VAR BIN_OP VAR BIN_OP VAR VAR WHILE VAR VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP NUMBER VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_O... |
Chouti was tired of the tedious homework, so he opened up an old programming problem he created years ago.
You are given a connected undirected graph with $n$ vertices and $m$ weighted edges. There are $k$ special vertices: $x_1, x_2, \ldots, x_k$.
Let's define the cost of the path as the maximum weight of the edges ... | n, m, k = map(int, input().split())
a = list(map(int, input().split()))
g = []
f = list(range(n + 1))
s = [0] * (n + 1)
def search(n):
while f[n] != n:
f[n] = f[f[n]]
n = f[n]
return n
def can_merge(u, v):
u = search(u)
v = search(v)
f[u] = v
if u == v:
return False
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FUNC_DEF WHILE VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR VAR VA... |
Chouti was tired of the tedious homework, so he opened up an old programming problem he created years ago.
You are given a connected undirected graph with $n$ vertices and $m$ weighted edges. There are $k$ special vertices: $x_1, x_2, \ldots, x_k$.
Let's define the cost of the path as the maximum weight of the edges ... | n, m, k = map(int, input().split())
x = list(map(int, input().split()))
e = []
for _ in range(m):
e.append(tuple(map(int, input().split())))
e.sort(key=lambda x: x[2])
fa = list(range(n + 1))
sz = [0] * (n + 1)
for u in x:
sz[u] += 1
def find(x):
while fa[x] != x:
fa[x] = fa[fa[x]]
x = fa[... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP... |
Chouti was tired of the tedious homework, so he opened up an old programming problem he created years ago.
You are given a connected undirected graph with $n$ vertices and $m$ weighted edges. There are $k$ special vertices: $x_1, x_2, \ldots, x_k$.
Let's define the cost of the path as the maximum weight of the edges ... | import sys
def int_reader():
yield from (int(d) for d in sys.stdin.read().split())
ints = int_reader()
n, m, k = [next(ints) for i in range(3)]
sp = {next(ints) for i in range(k)}
edges = []
for i in range(m):
u, v, w = [next(ints) for j in range(3)]
edges.append((w, u, v))
edges.sort()
fu = [i for i in... | IMPORT FUNC_DEF EXPR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER EXPR FUNC_C... |
Chouti was tired of the tedious homework, so he opened up an old programming problem he created years ago.
You are given a connected undirected graph with $n$ vertices and $m$ weighted edges. There are $k$ special vertices: $x_1, x_2, \ldots, x_k$.
Let's define the cost of the path as the maximum weight of the edges ... | def g():
return map(int, input().split())
n, m, k = g()
p = list(range(n + 1))
z = [0] * (n + 1)
for x in g():
z[x] = 1
e = []
for i in range(m):
u, v, w = g()
e += [(w, u, v)]
e = sorted(e)
def q(x):
if x != p[x]:
p[x] = q(p[x])
return p[x]
for w, u, v in e:
u = q(u)
v = q... | FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR L... |
Chouti was tired of the tedious homework, so he opened up an old programming problem he created years ago.
You are given a connected undirected graph with $n$ vertices and $m$ weighted edges. There are $k$ special vertices: $x_1, x_2, \ldots, x_k$.
Let's define the cost of the path as the maximum weight of the edges ... | import sys
input = sys.stdin.readline
n, m, k = list(map(int, input().split()))
x = list(map(int, input().split()))
uf = [(-1) for _ in range(n + 1)]
def find(p, uf):
if uf[p] < 0:
return p
uf[p] = find(uf[p], uf)
return uf[p]
def union(p, q, uf, specials):
proot = find(p, uf)
qroot = f... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_DEF IF VAR VAR NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR RETURN VAR VAR FUNC_DEF... |
Chouti was tired of the tedious homework, so he opened up an old programming problem he created years ago.
You are given a connected undirected graph with $n$ vertices and $m$ weighted edges. There are $k$ special vertices: $x_1, x_2, \ldots, x_k$.
Let's define the cost of the path as the maximum weight of the edges ... | def put():
return list(map(int, input().split()))
def find(i):
if i == p[i]:
return i
p[i] = find(p[i])
return p[i]
def union(i, j):
if rank[i] < rank[j]:
i, j = j, i
elif rank[i] == rank[j]:
rank[i] += 1
p[j] = i
z[i] += z[j]
return z[i]
n, m, k = put()... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR RETURN VAR VAR FUNC_DEF IF VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR VAR RETURN VAR VAR ASSIGN VAR VAR VAR FUNC_CA... |
Chouti was tired of the tedious homework, so he opened up an old programming problem he created years ago.
You are given a connected undirected graph with $n$ vertices and $m$ weighted edges. There are $k$ special vertices: $x_1, x_2, \ldots, x_k$.
Let's define the cost of the path as the maximum weight of the edges ... | import sys
sys.setrecursionlimit(300000)
n, m, k = list(map(int, input().split()))
x = list(map(int, input().split()))
edges = []
for i in range(m):
a, b, c = list(map(int, input().split()))
edges.append((c, a, b))
edges.sort()
tree = [i for i in range(n + 1)]
used = []
edgess = 0
def q(x):
if x != tree[... | IMPORT EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN 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 VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR V... |
Chouti was tired of the tedious homework, so he opened up an old programming problem he created years ago.
You are given a connected undirected graph with $n$ vertices and $m$ weighted edges. There are $k$ special vertices: $x_1, x_2, \ldots, x_k$.
Let's define the cost of the path as the maximum weight of the edges ... | def find(x):
while f[x] != x:
f[x] = f[f[x]]
x = f[x]
return x
def merge(u, v):
u, v = map(find, (u, v))
f[u] = v
if u == v:
return False
ret = s[u] > 0 and s[v] > 0
s[v] += s[u]
return ret
n, m, k = map(int, input().split())
x = list(map(int, input().split())... | FUNC_DEF WHILE VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR VAR IF VAR VAR RETURN NUMBER ASSIGN VAR VAR VAR NUMBER VAR VAR NUMBER VAR VAR VAR VAR RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FU... |
Chouti was tired of the tedious homework, so he opened up an old programming problem he created years ago.
You are given a connected undirected graph with $n$ vertices and $m$ weighted edges. There are $k$ special vertices: $x_1, x_2, \ldots, x_k$.
Let's define the cost of the path as the maximum weight of the edges ... | class Union:
def __init__(self, n, list_k):
self.p = {i: i for i in range(n + 1)}
self.rank = {i: (0) for i in range(n + 1)}
for k in list_k:
self.rank[k] = 1
def find(self, x):
if x < 0:
return x
if self.p[x] != x:
self.p[x] = self.f... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR VAR ASSIGN VAR VAR NUMBER FUNC_DEF IF VAR NUMBER RETURN VAR IF VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR RETURN VAR VAR FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN ASSIGN VAR F... |
Chouti was tired of the tedious homework, so he opened up an old programming problem he created years ago.
You are given a connected undirected graph with $n$ vertices and $m$ weighted edges. There are $k$ special vertices: $x_1, x_2, \ldots, x_k$.
Let's define the cost of the path as the maximum weight of the edges ... | import sys
class UnionFind:
def __init__(self, n, List):
self.n = n
self.parents = [-1] * (n + 1)
self.Parents = [-1] * (n + 1)
for v in List:
self.Parents[v] -= 1
def find(self, x):
if self.parents[x] < 0:
return x
else:
se... | IMPORT CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR VAR VAR VAR NUMBER FUNC_DEF IF VAR VAR NUMBER RETURN VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR RETURN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL... |
Pak Chanek plans to build a garage. He wants the garage to consist of a square and a right triangle that are arranged like the following illustration.
Define $a$ and $b$ as the lengths of two of the sides in the right triangle as shown in the illustration. An integer $x$ is suitable if and only if we can construct a g... | def f(x):
ans = max((x - 1) // 2, 0)
ans += max(0, (x - 4) // 4)
return ans
def binsearch(n):
low = 1
flag = 0
high = 10**20
while low <= high:
mid = (low + high) // 2
a = f(mid)
if a == n:
for x in range(mid - 10, mid + 10):
if f(x) == n... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR FOR VAR ... |
Pak Chanek plans to build a garage. He wants the garage to consist of a square and a right triangle that are arranged like the following illustration.
Define $a$ and $b$ as the lengths of two of the sides in the right triangle as shown in the illustration. An integer $x$ is suitable if and only if we can construct a g... | n = int(input())
if n == 1:
print(3)
elif n == 2:
print(5)
elif n == 3:
print(7)
elif n == 4:
print(8)
else:
s = 8
n -= 4
r = n % 3
n = n // 3
s += n * 4
if r == 1:
s += 1
elif r == 2:
s += 3
print(s) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER IF VAR NUMBE... |
Pak Chanek plans to build a garage. He wants the garage to consist of a square and a right triangle that are arranged like the following illustration.
Define $a$ and $b$ as the lengths of two of the sides in the right triangle as shown in the illustration. An integer $x$ is suitable if and only if we can construct a g... | n = int(input())
if n == 1:
print(3)
elif (n - 1) % 3 == 0:
o = int((n - 1) / 3)
print(4 * o + 4)
else:
o = int((n - 1) / 3)
oo = n - o
ooo = oo + 1
print(ooo * ooo - oo * oo) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN V... |
Pak Chanek plans to build a garage. He wants the garage to consist of a square and a right triangle that are arranged like the following illustration.
Define $a$ and $b$ as the lengths of two of the sides in the right triangle as shown in the illustration. An integer $x$ is suitable if and only if we can construct a g... | n = int(input())
if n <= 5:
print([3, 5, 7, 8, 9][n - 1])
else:
a, b = (n - 6) // 15, (n - 6) % 15
print((2 * a + 1 + (b > 6)) * 10 + [1, 2, 3, 5, 6, 7, 9, 0, 1, 3, 4, 5, 7, 8, 9][b]) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER VAR NUMBER NUMBER LIST NUMBER NUMBER NU... |
Pak Chanek plans to build a garage. He wants the garage to consist of a square and a right triangle that are arranged like the following illustration.
Define $a$ and $b$ as the lengths of two of the sides in the right triangle as shown in the illustration. An integer $x$ is suitable if and only if we can construct a g... | n = int(input())
b = 1
a = 0
if n % 3 == 1 and n != 1:
d = n // 3
c = 8 + (d - 1) * 4
print(c)
elif n != 1 and n != 2 and n != 3:
e = (n - 1) % 3
d = (n - e) // 3
c = 8 + (d - 1) * 4
if e == 1:
print(c + e)
elif e == 2:
print(c + e + 1)
elif n == 1 or n == 2 or n == 3:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP ... |
Pak Chanek plans to build a garage. He wants the garage to consist of a square and a right triangle that are arranged like the following illustration.
Define $a$ and $b$ as the lengths of two of the sides in the right triangle as shown in the illustration. An integer $x$ is suitable if and only if we can construct a g... | n = int(input())
if n == 1:
print(3)
else:
n -= 1
a, b = n // 3, n % 3
ans = 4 * (a + 1)
if b == 1:
ans += 1
elif b == 2:
ans += 3
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
Pak Chanek plans to build a garage. He wants the garage to consist of a square and a right triangle that are arranged like the following illustration.
Define $a$ and $b$ as the lengths of two of the sides in the right triangle as shown in the illustration. An integer $x$ is suitable if and only if we can construct a g... | n = int(input())
if n == 1:
print(3)
exit()
a = (n - 1) // 3 + 1
b = n % 3
if b == 0:
print(4 * a + 3)
elif b == 1:
print(4 * a)
else:
print(4 * a + 1) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR B... |
Pak Chanek plans to build a garage. He wants the garage to consist of a square and a right triangle that are arranged like the following illustration.
Define $a$ and $b$ as the lengths of two of the sides in the right triangle as shown in the illustration. An integer $x$ is suitable if and only if we can construct a g... | a = int(input())
x = (a - 1) // 3
if a == 1:
print(3)
elif (a - 1) % 3:
print(2 * (a - x) + 1)
else:
print(4 * (x + 1)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER BIN_OP VAR NUMBER |
Pak Chanek plans to build a garage. He wants the garage to consist of a square and a right triangle that are arranged like the following illustration.
Define $a$ and $b$ as the lengths of two of the sides in the right triangle as shown in the illustration. An integer $x$ is suitable if and only if we can construct a g... | n = int(input())
if n == 1:
print(3)
elif n == 2:
print(5)
elif n == 3:
print(7)
else:
print((n - 3) // 3 * 4 + (n - 3) % 3 + 7) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER |
Pak Chanek plans to build a garage. He wants the garage to consist of a square and a right triangle that are arranged like the following illustration.
Define $a$ and $b$ as the lengths of two of the sides in the right triangle as shown in the illustration. An integer $x$ is suitable if and only if we can construct a g... | n = int(input())
l = 0
r = 3 * n
c = 0
d = 0
while l <= r:
mid = (l + r) // 2
val1 = 0
if mid >= 8:
val1 = mid // 4 - 1
val2 = 0
if mid >= 3:
val2 = (mid - (1 - mid % 2)) // 2
if val1 + val2 <= n:
l = mid + 1
c = val1
d = val2
else:
r = mid - 1... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP N... |
Pak Chanek plans to build a garage. He wants the garage to consist of a square and a right triangle that are arranged like the following illustration.
Define $a$ and $b$ as the lengths of two of the sides in the right triangle as shown in the illustration. An integer $x$ is suitable if and only if we can construct a g... | n = int(input())
if n == 1:
print(3)
else:
k = ((n - 1) // 3 + 1) * 4
if (n - 1) % 3 == 1:
k += 1
if (n - 1) % 3 == 2:
k += 3
print(k) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER NUMBER IF BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
Pak Chanek plans to build a garage. He wants the garage to consist of a square and a right triangle that are arranged like the following illustration.
Define $a$ and $b$ as the lengths of two of the sides in the right triangle as shown in the illustration. An integer $x$ is suitable if and only if we can construct a g... | n = int(input())
def cal(n):
if n == 1:
return 3
if n == 2:
return 5
if n == 3:
return 7
a = ((n - 1) // 3 + 1) * 4
if (n - 1) % 3 == 1:
a += 1
elif (n - 1) % 3 == 2:
a += 3
return a
print(cal(n)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER NUMBER IF BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER VAR NUMBER RETURN VAR ... |
Pak Chanek plans to build a garage. He wants the garage to consist of a square and a right triangle that are arranged like the following illustration.
Define $a$ and $b$ as the lengths of two of the sides in the right triangle as shown in the illustration. An integer $x$ is suitable if and only if we can construct a g... | def area1(num):
num = num - 1
if num == 0:
return 3
elif num == 1:
return 5
elif num == 2:
return 7
elif num % 3 == 0:
return 8 + 4 * int(num / 3 - 1)
elif num % 3 == 1:
div = int(num / 3)
final = 8 + 4 * (div - 1) + 1
return final
else... | FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF BIN_OP VAR NUMBER NUMBER RETURN BIN_OP NUMBER BIN_OP NUMBER FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP ... |
Pak Chanek plans to build a garage. He wants the garage to consist of a square and a right triangle that are arranged like the following illustration.
Define $a$ and $b$ as the lengths of two of the sides in the right triangle as shown in the illustration. An integer $x$ is suitable if and only if we can construct a g... | N = int(input())
if N == 1:
print(3)
elif N == 2:
print(5)
elif N % 3 == 1:
print(4 + 4 * (N // 3))
elif N % 3 == 2:
print(5 + 4 * (N // 3))
elif N % 3 == 0:
print(3 + 4 * (N // 3)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR N... |
Pak Chanek plans to build a garage. He wants the garage to consist of a square and a right triangle that are arranged like the following illustration.
Define $a$ and $b$ as the lengths of two of the sides in the right triangle as shown in the illustration. An integer $x$ is suitable if and only if we can construct a g... | def ctle(x):
ct = 0
for b in [1, 2]:
jump = (x - b * b) // (2 * b)
if jump <= 0:
break
ct += jump
return ct
n = int(input())
lo = 1
hi = int(100000000000000.0)
while lo < hi:
m = (lo + hi) // 2
if ctle(m) >= n:
hi = m - 1
else:
lo = m + 1
if ... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR LIST NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR BIN_OP NUMBER VAR IF VAR NUMBER VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR ASS... |
Pak Chanek plans to build a garage. He wants the garage to consist of a square and a right triangle that are arranged like the following illustration.
Define $a$ and $b$ as the lengths of two of the sides in the right triangle as shown in the illustration. An integer $x$ is suitable if and only if we can construct a g... | sequence = int(input())
if sequence == 1:
print(3)
elif sequence == 2:
print(5)
else:
first_one_in_your_group = (int((sequence - 3) / 6) + 1) * 8 - 1
ranking = int(sequence - 3) % 6
if ranking == 0:
print(first_one_in_your_group)
elif ranking == 1:
print(first_one_in_your_group +... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR N... |
Dexter was good in finding the K th smallest number from a set of numbers. He thought he could solve any problem related to K th smallest number. His friend Pipi challenged him with a problem.
He gave him various ranges of number, These numbers were arranged in increasing order(only distinct numbers to be taken into ac... | for i in range(eval(input())):
n, q = list(map(int, input().split()))
ran = []
l = []
for i in range(n):
l = list(map(int, input().split()))
ran.append(l)
ran.sort()
a = [0]
b = [0]
a[0] = ran[0][0]
b[0] = ran[0][1]
k = 0
for i in range(1, n):
if ran[i... | 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 LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VA... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | n, x, pos = map(int, input().split())
a = [0] * n
low, high = x - 1, n - x
l, r = 0, n
found = False
ans = 0
while l < r:
m = (l + r) // 2
if pos < m:
if high == 0:
ans = -1
break
a[m] = high
high -= 1
r = m
else:
if m != pos:
if lo... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR ASSIGN VAR VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | mod = 10**9 + 7
n, x, pos = map(int, input().split())
ans = 1
a, b, c = list(range(1, n + 1)), 0, 0
l, r = 0, n
while l < r:
m = (l + r) // 2
if a[m] <= pos + 1:
if a[m] != pos + 1:
b += 1
l = m + 1
else:
r = m
c += 1
for i in range(x - 1, max(x - 1 - b, -1), -1):... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER ... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | from sys import stdin
n, x, pos = map(int, stdin.readline().strip().split())
def bin(a, x):
l = 0
r = n
aux = [(0) for i in range(n)]
while l < r:
mid = (l + r) // 2
if mid < pos:
aux[mid] = 1
l = mid + 1
elif pos == mid:
l = mid + 1
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR ... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | MOD = 1000000007
n, x, pos = map(int, input().split())
L = [-1] * n
L[pos] = 1
c0 = 0
c1 = 0
low = 0
high = n
ans = 1
while low < high:
mid = low + high >> 1
if mid < pos:
c0 += 1
low = mid + 1
elif mid > pos:
c1 += 1
high = mid
else:
low = mid + 1
if c0 >= x or c... | ASSIGN VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR ... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | n, x, pos = map(int, input().split())
fact, inv, invf = [0] * (n + 5), [0] * (n + 5), [0] * (n + 5)
MOD = 10**9 + 7
def mod(x):
return (x % MOD + x) % MOD
def init(n):
fact[0] = fact[1] = 1
inv[0] = inv[1] = 1
invf[0] = invf[1] = 1
for i in range(2, n + 1):
fact[i] = fact[i - 1] * i
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR FUNC_DEF ASSIGN VAR NUMBER VAR... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | n, x, pos = map(int, input().split())
mod = 10**9 + 7
factorials = [1]
for i in range(1, n + 1):
factorials.append(factorials[-1] * i % mod)
inverses = [pow(v, mod - 2, mod) for v in factorials]
def cnk(n, k):
return factorials[n] * inverses[n - k] * inverses[k]
def split(pos, n):
left = 0
right = n... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER 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 FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP VA... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.