description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | hobs, pillows, frodo = input().split()
hobs, pillows, frodo = int(hobs), int(pillows), int(frodo)
turn = 0
left = frodo
right = frodo
pilCount = 1
pillows -= hobs
while True:
if left < 1 and right > hobs:
pilCount += pillows // hobs
break
elif left < 1:
pillows -= right
elif right > ... | ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER VAR VAR WHILE NUMBER IF VAR NUMBER VAR VAR VAR BIN_OP VAR VAR IF VAR NUMBER VAR VAR IF VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | n, m, k = list(map(int, input().split()))
s = 0
m -= n
s += 1
if m == 0:
print(1)
return
while m >= 0:
if k > s and n - k + 1 > s and m >= 2 * (s - 1) + 1:
m -= 2 * (s - 1) + 1
elif k > s and m >= n - k + s:
m -= n - k + s
elif n - k + 1 > s and m >= k + s - 1:
m -= k + s - 1... | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN WHILE VAR NUMBER IF VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER ... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | n, m, k = [int(f) for f in input().split()]
l, r = 0, m
t = True
for x in range(60):
i = (l + r) // 2
c = k - 1
b = n - k
s = (
i
- 1
+ n
+ [(i - 2 - b) * b if i - 2 - b > 0 else 0][0]
+ [(i - 2 - c) * c if i - 2 - c > 0 else 0][0]
+ min(i - 2, b) * (1 + m... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER VAR LIST BIN_OP BIN_OP ... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | def v(length, start):
W = start * (start + 1) // 2
t = max(0, start - length)
T = t * (t + 1) // 2
return W - T + max(0, length - start)
def check(p):
return p + v(k - 1, p - 1) + v(n - k, p - 1) <= m
n, m, k = map(int, input().split())
l = 0
r = 10**100
while r - l > 1:
mid = (l + r) // 2
... | FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER RETURN BIN_OP BIN_OP VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER FUNC_CA... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | def __starting_point():
n, m, k = map(int, input().split())
m -= n
res = 1
lvl = 0
while m > 0:
x = min(k, lvl + 1) + min(n - k, lvl)
if x == n:
res += m // n
break
elif m >= x:
m -= x
lvl += 1
res += 1
else:... | FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR VAR IF VAR VAR VAR BIN_OP VAR VAR IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUN... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | hobbits_nr, pillows_nr, frodos_place = (int(x) for x in input().split())
pillows_nr = pillows_nr - hobbits_nr
frodos_pillows = 1
left = frodos_place
right = frodos_place + 1
while pillows_nr >= right - left:
pillows_nr -= right - left
frodos_pillows += 1
right += 1
left += -1
if right > hobbits_nr +... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF V... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | n, m, kk = map(int, input().split())
def getleft(x, k):
res = 0
if x < k:
res = (1 + x) * x / 2
res += k - x
else:
res = (x - k + 1 + x) * k / 2
return res
def getright(x, k):
return getleft(x, n - k + 1)
lt = 1
rt = m
ans = 1
while lt <= rt:
mid = (lt + rt) // 2
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR VAR NUMBER RETURN VAR FUNC_DEF RETURN FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBE... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | def main():
n, hi, k = map(int, input().split())
m, l, lo = (hi - n) * 2, n - k + 1, 0
while lo < hi - 1:
mid = (lo + hi) // 2
x = mid * mid * 2
if mid > k:
x -= (mid - k) * (mid - k + 1)
if mid > l:
x -= (mid - l) * (mid - l + 1)
if x > m:
... | FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER NUMBER WHILE VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | n, m, k = input().split(" ")
n, m, k = int(n), int(m), int(k)
ans = 1
m -= n
a = 0
b = 0
c = a + b + 1
while m >= c:
ans += 1
m -= c
if a < k - 1:
a += 1
if b < n - k:
b += 1
if a == k - 1 and b == n - k:
break
c = a + b + 1
ans += m // n
print(ans) | ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER WHILE VAR VAR VAR NUMBER VAR VAR IF VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR VAR VAR ... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | def pillows_needed(height, width):
if height > width:
return height * (height + 1) // 2 - (height - width) * (height - width + 1) // 2
else:
return height * (height + 1) // 2 + (width - height)
n, m, k = list(map(int, input().split()))
a, b, c = 0, m, 0
while a < b:
c = (a + b + 1) // 2
... | FUNC_DEF IF VAR VAR RETURN BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER RETURN BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER 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 VAR N... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | q, w, e = list(map(int, input().split()))
w -= q
z = e - 1
x = q - e
z, x = min(z, x), max(z, x)
ans = 1
t = 1
while w - t >= 0:
w -= t
ans += 1
if z == x == 0:
ans += w // t
break
if z > 0:
z -= 1
t += 1
if x > 0:
x -= 1
t += 1
print(ans) | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR NUMBER VAR VAR VAR NUMBER IF VAR VAR NUMBER VAR BIN_OP VAR VAR IF ... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | def main():
n, m, k = map(int, input().split())
l = 1
r = 10**10
while l + 1 < r:
med = (l + r) // 2
cnt = n
left = max(0, med - 1 - (k - 1))
right = max(0, med - 1 - (n - k))
left_cord = max(1, k - med + 1)
right_cord = min(k + med - 1, n)
cnt += ... | FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER WHILE BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | n, m, k = [int(i) for i in input().split()]
def get_min_pillow(bed, x):
res = x * (x + 1) / 2
if bed >= x:
res += bed - x
else:
temp = x - bed
res -= temp * (temp + 1) / 2
return res
def get_min(s, x):
return x * (x + 1) / 2 + (s - x) if s >= x else s * (x + x - s + 1) / ... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER RETURN VAR FUNC_DEF RETURN VAR VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | n, m, k = map(int, input().split())
i, j = 1, m
def check(mid):
ans = mid * (mid + 1) // 2
if mid > k:
ans -= (mid - k) * (mid - k + 1) // 2
else:
ans += k - mid
ans += mid * (mid - 1) // 2
if n - k > mid - 1:
ans += 1 * (n - k - mid + 1)
else:
t = mid - 1 - n +... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR VAR BIN_OP... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | n, m, k = map(int, input().split())
a = 0
b = 0
a_lim = k - 1
b_lim = n - k
m = m - n
x = 1
while m - a - b - 1 >= 0:
m = m - a - b - 1
x += 1
if a == a_lim:
pass
else:
a += 1
if b == b_lim:
pass
else:
b += 1
if a == a_lim and b == b_lim:
x = x + m // ... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER VAR NUMBER IF VAR VA... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | n, m, k = map(int, input().split())
m -= n
d = 0
k -= 1
ans = 1
while m > 1 and d != max(k, n - k - 1):
ans += 1
m -= 1
l = min(d, k)
r = min(d, n - k - 1)
d += 1
m -= l
m -= r
ans += m // n
print(ans) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER VAR VAR VAR ... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | from sys import stdin, stdout
n, m, k = map(int, stdin.readline().split())
left = k - 1
right = n - k
l = 1
r = m + 1
while r - l > 1:
mid = (r + l) // 2
cnt = mid
if mid > left:
cnt += (2 * mid - 1 - left) * left // 2
else:
cnt += mid * (mid - 1) // 2 + left - (mid - 1)
if mid > ri... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR IF VAR VAR VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER VAR VA... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | n, m, k = map(int, input().split())
f = lambda k, s: (2 * s - k + 1) * k - s if k < s else (s - 2) * s + 2 * k
s, m = m // n + 1, 2 * m + 1
while f(k, s) + f(n - k + 1, s) < m:
s += 1
print(s - 1) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER VAR VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR BIN_OP NUMBER VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER WHILE BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL ... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | def just_sum(n):
return n * (n + 1) // 2
def get_sum(a, b):
return just_sum(b) - just_sum(a - 1)
def check(middle):
left = k - 1
right = n - k
if left < middle:
left_sum = get_sum(middle - left, middle - 1)
else:
left_sum = just_sum(middle - 1) + (left - (middle - 1))
if ... | FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER BIN_O... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | I = lambda: list(map(int, input().split()))
n, m, k = I()
l, r = 1, m + 1
onLeft, onRight = k - 1, n - k
while l < r - 1:
amount = l + r >> 1
s = amount
for neighbors in [onLeft, onRight]:
if neighbors > amount - 1:
s += (amount - 1) * amount // 2 + neighbors - amount + 1
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR WHILE VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR FOR VAR LIST VAR VAR IF VAR BIN_OP VAR NUMBER VAR... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | def check(n, m, k, r):
a = r - k
u = 0
if a > 0:
u += (a + r) * (k + 1) // 2
else:
u += r * (r + 1) // 2
b = r - (n - 1 - k)
v = 0
if b > 0:
v += (b + r) * (n - k) // 2
else:
v += r * (r + 1) // 2
t = u + v - r
return t <= m
n, m, k = map(int, in... | FUNC_DEF ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR NUMBER VAR BIN_OP... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | n, m, k = list(map(int, input().split()))
def g(a, b):
return (a + a - b + 1) * b >> 1
def f(x):
return g(x, min(x, k)) + g(x - 1, min(x - 1, n - k))
l, r, res = 1, m - n, 0
while l <= r:
mid = l + r >> 1
if f(mid) <= m - n:
res, l = mid, mid + 1
else:
r = mid - 1
print(res + 1... | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER VAR NUMBER FUNC_DEF RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR ASSIGN VAR VAR VAR NUM... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | n, m, k = list(map(int, input().split()))
min_delta = min(k - 1, n - k)
max_delta = max(k - 1, n - k)
top = (
((k - 1) * k + (n - k) * (n - k + 1)) // 2
+ (max_delta - min_delta) * min_delta
+ max_delta
+ 1
)
def get_level(n, k, level):
return 1 + min(level, k - 1) + min(level, n - k)
if top <= ... | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUM... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | def summ(t):
ans = t * (t + 1) // 2
return ans
n, m, k = map(int, input().split())
def res(p):
global n
tmp = n * p
l = k - 1
t = min(p - 1, l)
tmp -= summ(t)
tmp -= (p - 1) * (l - t)
r = n - k
t = min(p - 1, r)
tmp -= summ(t)
tmp -= (p - 1) * (r - t)
return tmp
... | FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR VAR ASSIGN V... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | n, m, k = map(int, input().split())
m -= n
def Sum(cnt, x):
return cnt * (x - 1 + (x - cnt)) // 2
def check(x):
l = min(k - 1, x - 1)
r = min(n - k, x - 1)
cur = Sum(l, x) + Sum(r, x) + x
return cur <= m
L = -1
R = 10**20
while R - L > 1:
M = L + R >> 1
if check(M):
L = M
e... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | import sys
def sum_(a):
return max(0, a * (a + 1) // 2)
def check(a):
if a * n <= m:
return 1
a -= 1
ans = n
t1 = a - k + 1
if t1 >= 0:
ans += sum_(a) - sum_(t1 - 1)
else:
ans += sum_(a)
z = n - k + 1
t2 = a - z + 1
if t2 >= 0:
ans += sum_(a - ... | IMPORT FUNC_DEF RETURN FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF IF BIN_OP VAR VAR VAR RETURN NUMBER VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP ... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | n, m, k = map(int, input().split())
l = 1
r = m + 1
left = k - 1
right = n - k
rs = right * (right - 1) // 2
ls = left * (left - 1) // 2
while r > l + 1:
md = (l + r) // 2
if md > right:
s = md - right
tr = s * right + rs
else:
tr = right - md + 1 + md * (md - 1) // 2
if md > lef... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER WHILE VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | n, m, k = map(int, input().split(" "))
m -= n
ans = 1
side1 = k - 1
side2 = n - k
prevadd = 1
while m >= prevadd:
m -= prevadd
ans += 1
if side1 + side2 == 0:
ans += m // n
break
if side1 > 0:
side1 -= 1
prevadd += 1
if side2 > 0:
side2 -= 1
prevadd +=... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER EXPR... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | n, m, k = map(int, input().split())
done = 0
for A in range(m // n, m + 1):
up = A
if k - 1 >= A - 1:
up = up + A * (A - 1) / 2
up = up + k - A
else:
s = A - k + 1
up = up + (s + (A - 1)) * (A - s) / 2
kk = n - k
if kk >= A - 1:
up = up + A * (A - 1) / 2
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR V... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | hob, pil, fro = map(int, input().split())
pil -= hob
ans = 1
rad = 0
x, y = fro - 1, hob - fro
while pil > 0:
if rad >= max(x, y):
ans += pil // hob
break
pil -= min(rad, x)
pil -= min(rad, y)
if pil < 1:
break
pil -= 1
ans += 1
rad += 1
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 VAR BIN_OP VAR NUMBER BIN_OP VAR VAR WHILE VAR NUMBER IF VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXP... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | def tri(x):
return x * (x + 1) // 2
def C(x, k, n):
ret = 0
if x == 0:
return x
if x <= k:
ret = ret + tri(x - 1) + (k - x)
else:
rem = x - k
ret = ret + tri(x - 1) - tri(rem)
r = n - k + 1
if x <= r:
ret = ret + tri(x) + (r - x)
else:
re... | FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR NUMBER IF VAR NUMBER RETURN VAR IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | def calc(y, x):
if y > x - 1:
return int(x * (x - 1) / 2) + y - x + 1
return int((x - 1 + x - y) * y / 2)
def main():
n, m, k = map(int, input().split())
low = 1
hi = m
beds_left = k - 1
beds_right = n - k
while low <= hi:
mid = low + hi >> 1
cant = calc(beds_le... | FUNC_DEF IF VAR BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER RETURN FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER VAR VAR VAR NUMBER FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR V... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | n, m, k = map(int, input().split())
kk1 = min(k - 1, n - k)
kk2 = n - kk1 - 1
mm = m - n
s1 = (kk1 + 1) ** 2
if s1 >= mm:
res = 1 + int(mm**0.5)
else:
res = 1 + (kk1 + 1)
mmm = mm - s1
a = 2 * (kk1 + 1)
b = kk2 - kk1 - 1
s2 = a * b + b * (b - 1) // 2
if s2 >= mmm:
res += int(-(2 * a ... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR VAR ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP NUMBER... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | beds, pillows, frodo = map(int, input().split())
flag = 0
if beds == pillows:
flag = 1
pillows = pillows - beds - 1
layer = 2
while pillows > 0:
if beds == 1:
layer = pillows + 2
pillows = 0
break
if frodo - 1 < layer - 1 and beds - frodo < layer - 1:
layer += int(pillows / b... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR VAR BIN_OP VAR NUMBER VAR ... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | def f(med):
left = k - 1
right = n - k
ans = 0
if med > left + 1:
d = med - left
ans += (med + d) * (med - d + 1) // 2
else:
ans += med * (med + 1) // 2
left -= med - 1
ans += left
if med > right + 1:
d = med - right
ans += (med + d) * (med... | FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER VAR VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_O... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | def pil_add(height, div):
add = height
if height > div:
add = div
return add
hobb, pillow, number = (int(i) for i in input().split())
div_first = number
div_last = hobb - number + 1
other_pillow = pillow - hobb
height = 0
heap_pil = 0
right_flag = False
left_flag = False
while heap_pil <= other_pi... | FUNC_DEF ASSIGN VAR VAR IF VAR VAR ASSIGN VAR VAR RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER IF VAR VAR ASSIG... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | def partSum(a, b):
if a > b:
return 0
supp = 0
if a <= 0:
supp = -a + 1
a = 1
return supp + b * (b + 1) // 2 - (a - 1) * (a - 1 + 1) // 2
def f(v, l, r):
return v + partSum(v - l, v - 1) + partSum(v - r, v - 1)
def valid(v, l, r):
return m - v - partSum(v - l, v - 1) ... | FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER RETURN BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER FUNC_DEF RETURN BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_O... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | def total_pillows(x, y):
if y > x - 1:
return y - (x - 1) + (x - 1) * x / 2
else:
return (x - 1 + x - y) * y / 2
n, m, k = list(map(int, input().split()))
y1 = n - k
y2 = k - 1
l, h = 0, m
ans = 1 if m == n else 0
if n == 1:
ans = m
if ans != 1 and ans != m:
while l <= h:
mid =... | FUNC_DEF IF VAR BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER RETURN BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBE... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | import sys
input = sys.stdin.readline
def f(x):
z = m - n
if x > k:
sumi = k * (2 * x - k + 1) // 2
else:
sumi = x * (x + 1) // 2
y = n - k
if x > y:
sumi += y * (2 * x - y - 1) // 2
else:
sumi += x * (x - 1) // 2
if sumi <= z:
return 1
return 0... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER NUMBER VAR BIN_OP... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | n, m, k = list(map(int, input().split()))
left = 0
right = 10000000000
while right - left > 1:
mid = (left + right) // 2
counter = mid
lh = k - 1
if lh >= mid - 1:
counter += (mid - 1) * mid // 2
counter += lh - (mid - 1)
else:
last_hobbit = mid - lh - 1
counter += (m... | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL 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 VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR BIN_OP VAR BIN_OP VAR... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | def ri():
return map(int, input().split())
n, m, k = ri()
def area(h, n, k):
s = n
if k >= h - 1:
s += h * (h - 1) // 2
else:
s += k * (k + 1) // 2 + k * (h - k - 1)
if n - k >= h - 1:
s += (h - 1) * (h - 2) // 2
else:
s += (n - k - 1) * (n - k) // 2 + (n - k)... | FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR IF VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR BIN_OP VAR NUMBER VAR... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | n, m, k = list(map(int, input().split()))
def __sum(n):
return n * (n + 1) // 2
def _sum(l, r):
if l > r:
return 0
delta = 0
if l <= 0:
delta = abs(l) + 1
l = 1
return __sum(r) - __sum(l - 1) + delta
left = 1
right = int(1000000000.0) + 2
while right - left > 1:
mid... | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER RETURN BIN_OP BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | def check(n, m, k, x):
s = x
if x <= k:
s += (x - 1) * x // 2
else:
s += (x - 1) * x // 2 - (x - k) * (x - k + 1) // 2
if x - 1 <= n - k:
s += (x - 1) * x // 2
else:
s += (x - 1) * x // 2 - (x - 1 - n + k) * (x - n + k) // 2
if s <= m:
return True
retu... | FUNC_DEF ASSIGN VAR VAR IF VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER IF BIN_OP VAR NUMBER BIN_OP VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR ... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | def distribute(target, n, k, m):
right = n - k
prev = target - 1
total = m - target
if right >= prev:
total -= prev * (prev + 1) // 2
total -= right - prev
else:
temp = prev - right
total -= prev * (prev + 1) // 2 - temp * (temp + 1) // 2
right = k - 1
prev = ... | FUNC_DEF ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER A... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | n, m, k = list(map(int, input().split()))
p = m - n
min_d, max_d = min(abs(n - k + 1), k), max(abs(n - k + 1), k)
i = 1
r = m + 1
l = 0
while r - l > 1:
i = (r + l) // 2
min_dist = min_d - i
max_dist = max_d - i
min_summ = 0
max_summ = 0
if min_dist < 0:
min_summ = abs(min_dist) * (abs(m... | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR ... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | n, m, k = map(int, input().split())
l = 1
r = m + 1
s = 0
f = 0
while r - l > 1:
x = (l + r) // 2
if x - 1 < k - 1:
f = x * (x - 1) // 2 + (k - 1 - (x - 1))
else:
f = (x - 1 - (k - 2) + (x - 1)) * (k - 1) // 2
if f + x > m:
s = 0
elif x - 1 >= n - k:
s = (n - k) * (x ... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP B... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | def I():
return list(map(int, input().split()))
def f(k):
s = 0
if k - idx > 1:
s -= (k - idx - 1) * (k - idx) // 2
if k - (n - idx - 1) > 1:
s -= (k - (n - idx - 1) - 1) * (k - (n - idx - 1)) // 2
s += k**2
return s
n, m, idx = I()
idx -= 1
m = m - n
l = 0
r = m
while l <= r... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER IF BIN_OP VAR VAR NUMBER VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER IF BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER BIN_O... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | places, pillow_num, frodo_place = map(int, input().split())
def calculate_sum(fp, p, length):
if fp == p:
left_sum_min = (p - 1) * p / 2
else:
if p < fp:
left_sum_min = (p - 1) * p / 2 + (fp - 1 - (p - 1))
if p > fp:
left_sum_min = (p - (fp - 1) + p - 1) * (fp -... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP VA... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | n, m, k = map(int, input().split())
a = m - n
if n == 1:
print(m)
elif n == 2:
print((m + 1) // 2)
elif a == 0:
print(1)
else:
l = 0
h = a
ans = 1
while l <= h:
m = (l + h) // 2
if m <= k:
x = m * (m + 1) // 2
else:
z = m - k
x = m ... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP V... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | inn = input()
data = inn.split()
n = int(data[0])
m = int(data[1])
k = int(data[2])
frodo = 1
pillows = m - n
left = k - 1
right = n - k
R, L = 0, 0
x = 0
while pillows > x:
pillows = pillows - (1 + L + R)
frodo += 1
if left > 0:
L += 1
left -= 1
x += 1
if right > 0:
R +=... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR 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 NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR AS... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | num_hobbits, num_pillows, frodo_pos = map(int, input().split())
num_pillows -= num_hobbits
if num_pillows == 0:
print(1)
elif num_pillows <= 2:
print(2)
else:
left, right = frodo_pos - 1, num_hobbits - frodo_pos
frodo_amt = 1
def f(x):
return 1 + min(x - 1, left) + min(x - 1, right)
la... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR ASSIGN VAR NUMBER FUNC_DEF RETURN BIN_OP BIN_OP NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | def check(x):
k1 = k - 1
k2 = n - k
p1 = min(k1, x - 1) * (2 * (x - 1) - (min(k1, x - 1) - 1)) // 2
p2 = min(k2, x - 1) * (2 * (x - 1) - (min(k2, x - 1) - 1)) // 2
f = p1 + x + p2
return f <= m - n
n, m, k = map(int, input().split())
l = 0
r = 10**9
while r - l > 1:
M = (l + r) // 2
if... | FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | n, m, k = [int(i) for i in input().strip().split(" ")]
def check(t):
a = t - k + 1
b = t - n + k
pillows = t
if a > 1:
pillows += (t - a) * (a + t - 1) // 2
else:
pillows += 1 - a + t * (t - 1) // 2
if b > 1:
pillows += (t - b) * (b + t - 1) // 2
else:
pillo... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR VAR IF VAR NUMBER VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR BIN_OP BIN_OP NUMBER VAR BIN_OP BIN_OP VAR BIN_OP ... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | n, m, k = [int(i) for i in input().split()]
res = 1
m = m - n
if m > 0:
m -= 1
res += 1
l = k - 1
r = k + 1
t1 = l
t2 = r
while m > 0:
if l <= 0 and r > n:
break
else:
if l == 0:
l += 1
if r > n:
r -= 1
temp = r - l + 1
m -= temp
if... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR WHILE VAR NUMBER IF VAR NUMBER VAR VAR IF VAR NUMBER VAR NUMBER IF VAR VAR VAR NUMBER A... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | import sys
n, m, k = map(int, input().split())
ans = 1
m -= n
l = min(k - 1, n - k)
step = 1
for i in range(l):
if m - step < 0:
print(ans)
sys.exit(0)
m -= step
step += 2
ans += 1
while step < n:
if m - step < 0:
print(ans)
sys.exit(0)
m -= step
step += 1
... | IMPORT ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER VAR VAR VAR NUMBER VAR NUMBER WHILE VAR VAR IF BIN... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | n, m, k = [int(i) for i in input().split()]
def one_sided(slots, x):
if slots >= x - 1:
return slots - x + 1 + (x - 1) * x // 2
else:
return slots * (2 * x - slots - 1) // 2
def pillows_used(x):
left_slot = k - 1
right_slot = n - k
return x + one_sided(left_slot, x) + one_sided(r... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER RETURN BIN_OP BIN_OP VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR ... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | def f(n, m, k, x):
if x - n + k > 0 and x - k + 1 > 0:
ans = (
(x - 1 + (x - (n - k))) * (n - k) // 2
+ (x - 1 + (x - (k - 1))) * (k - 1) // 2
+ x
)
elif x - n + k <= 0 and x - k + 1 > 0:
ans = (
(x - 1 + 1) * (n - k - (-(x - n + k) + 1)) /... | FUNC_DEF IF BIN_OP BIN_OP VAR VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR VAR BIN_OP VAR VAR NUMBER BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER VAR IF BIN_OP BIN_OP VAR VAR VAR N... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | n, m, k = map(int, input().split())
l = 1
r = m
ans = 0
while l <= r:
mid = (l + r) // 2
maxa = min(mid * n, m)
mini = 0
print
if mid < k:
mini += mid * (mid + 1) // 2 + (k - mid)
else:
mini += mid * (mid + 1) // 2
t = mid - k
mini -= t * (t + 1) // 2
spots = ... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR ASSIGN VAR NUMBER EXPR VAR IF VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR VAR VAR... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | def f(a):
sums1 = 0
sums2 = 0
if k >= a:
sums1 = a * (a + 1) // 2
sums1 += k - a
else:
sums1 = k * (a + a - k + 1) // 2
sums3 = 0
sums4 = 0
k1 = n - k + 1
if k1 >= a:
sums2 = a * (a + 1) // 2
sums2 += k1 - a
else:
sums2 = k1 * (a + a - ... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | n, m, k = map(int, input().split())
low = 1
high = m
ans = -1
while low <= high:
mid = low + (high - low) // 2
numReq = 0
if mid > k:
numReq += mid * (mid + 1) // 2 - (mid - k) * (mid - k + 1) // 2
elif mid <= k:
numReq += mid * (mid + 1) // 2 + (k - mid)
if mid == 1:
numReq ... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NU... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | def read(type=int):
return type(input())
def read_arr(type=int):
return [type(token) for token in input().split()]
def runB():
n, m, k = read_arr()
ans = 1
m -= n
l, r = k, k
while (r < n or l > 1) and m > 0:
ans += 1
m -= r - l + 1
if l > 1:
l -= 1
... | FUNC_DEF VAR RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF VAR RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR VAR ASSIGN VAR VAR VAR VAR WHILE VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR NUMBER VAR NUMBER IF VAR VAR... |
n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and at least one pillow to sleep, however, everyone wants as many pillows as possible. Of course, it's not always possible to share pillows equally, but any hobbit gets hurt if h... | def myf(n, m, k):
res = 1
m2 = m - n
left = k
right = k
i = 1
while (left != 1 or right != n) and m2 > 0:
res = res + 1
m2 = m2 - (right - left + 1)
if right < n:
if left > 1:
left -= 1
right += 1
else:
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VA... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | N = int(input())
maps = []
for i in range(N):
a, b = map(int, input().split())
diff = b - a
maps += [[diff, a, b]]
maps.sort()
ans = 0
for i, v in enumerate(maps):
a = v[1]
b = v[2]
j = i + 1
ans += a * (j - 1) + b * (N - j)
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR VAR LIST LIST VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP V... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | n = int(input())
nums = []
for i in range(n):
nums.append(list(map(int, input().split())))
nums.sort(key=lambda x: x[1] - x[0])
ans = 0
for idx, ele in enumerate(nums):
ans += idx * ele[0] + (n - idx - 1) * ele[1]
print(ans) | ASSIGN VAR FUNC_CALL VAR 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 BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP BIN_OP VAR VAR NUMBER... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | t = int(input())
ss = []
for _ in range(0, t):
a, b = map(int, input().split())
ss.append([b - a, a, b])
ss = sorted(ss)
s = 0
for i in range(1, t + 1):
s += ss[i - 1][1] * (i - 1) + ss[i - 1][2] * (t - i)
print(s) | ASSIGN VAR FUNC_CALL VAR 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 EXPR FUNC_CALL VAR LIST BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR BIN_OP BIN_OP VAR BIN_OP VAR N... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | n = int(input())
people = list()
for i in range(n):
people.append([int(el) for el in input().split()])
disbal = [(i, el[1] - el[0]) for i, el in enumerate(people)]
disbal = sorted(disbal, key=lambda x: x[1])
power = 0
for cur, el in enumerate(disbal):
power += people[el[0]][0] * cur + people[el[0]][1] * (n - cu... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR BIN... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | def argsort(seq):
return sorted(range(len(seq)), key=seq.__getitem__)
n = int(input())
sta = []
geb = []
for i in range(n):
a = list(map(int, input().split()))
sta.append(a[1] - a[0])
geb.append(a)
sor = argsort(sta)
left = 0
right = n - 1
ans = 0
for i in range(n):
g = sor[i]
ans += geb[g][0]... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR 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 BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CAL... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | n = int(input())
students = []
total = 0
for _ in range(n):
a, b = map(int, input().split())
total += b * n - a
students.append((a, b))
students.sort(key=lambda x: x[0] - x[1])
students.reverse()
for i in range(n):
total += (students[i][0] - students[i][1]) * (i + 1)
print(total) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR VAR BIN_OP BIN... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | from sys import stdin
input = stdin.readline
n = int(input())
ab = [list(map(int, input().split())) for i in range(n)]
ab.sort(key=lambda x: x[0] - x[1], reverse=True)
ans = 0
for i in range(n):
ans += ab[i][0] * i + ab[i][1] * (n - 1 - i)
print(ans) | ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR N... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | import sys
__version__ = "0.2"
__date__ = "2019-04-19"
def solve(n, ab):
ordered_students = sorted(ab, key=lambda x: x[1] - x[0])
return sum(a * j + b * (n - j - 1) for j, (a, b) in enumerate(ordered_students))
def main(argv=None):
n = int(input())
ab = [list(map(int, input().split())) for student ... | IMPORT ASSIGN VAR STRING ASSIGN VAR STRING FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR NUMBER RETURN FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF NONE ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR F... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | n = int(input())
values = []
for _ in range(n):
a, b = list(map(int, input().split()))
values.append((a, b))
values.sort(key=lambda x: x[0] - x[1], reverse=True)
diss = sum([(values[i][0] * i + values[i][1] * (n - i - 1)) for i in range(n)])
print(diss) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR NUMBER BIN_OP... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | n = int(input())
que = []
for i in range(n):
a, b = [int(x) for x in input().split()]
que.append((a - b, a, b))
que.sort(reverse=True)
counter = 0
for i in range(n):
counter += que[i][1] * i + que[i][2] * (n - i - 1)
print(counter) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR NUMBER BIN_OP ... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | n = int(input())
weights = []
nums = []
for i in range(n):
nums.append([int(x) for x in input().split()])
weights.append(nums[i][0] - nums[i][1])
nums = [x[0] for x in sorted(zip(nums, weights), reverse=True, key=lambda x: x[1])]
cost = 0
for j in range(n):
cost += nums[j][0] * j + nums[j][1] * (n - j - 1)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR ... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | intin = lambda: map(int, input().split())
n = int(input())
ans = 0
x = [0] * n
for i in range(n):
a, b = intin()
x[i] = a - b
ans += n * b - a
x.sort(reverse=True)
for i in range(n):
ans += (i + 1) * x[i]
print(ans) | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_O... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | def key(ab):
a, b = ab
return a - b
def main():
n = int(input())
nm = 0
m1 = n - 1
res = 0
for a, b in sorted((tuple(map(int, input().split())) for _ in range(n)), key=key):
res += a * m1 + b * nm
nm += 1
m1 -= 1
print(res)
main() | FUNC_DEF ASSIGN VAR VAR VAR RETURN BIN_OP VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR NUMB... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | n = int(input())
iparray = []
sumab = 0
for i in range(n):
ip = list(map(int, input().split()))
iparray.append(ip[0] - ip[1])
sumab += ip[1] * n - ip[0]
iparray.sort(reverse=True)
result = 0
for i in range(1, n + 1):
result = result + i * iparray[i - 1]
final = result + sumab
print(final) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL ... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | import sys
class Main:
def __init__(self):
self.buff = None
self.index = 0
def next(self):
if self.buff is None or self.index == len(self.buff):
self.buff = sys.stdin.readline().split()
self.index = 0
val = self.buff[self.index]
self.index += 1... | IMPORT CLASS_DEF FUNC_DEF ASSIGN VAR NONE ASSIGN VAR NUMBER FUNC_DEF IF VAR NONE VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER RETURN VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_C... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | import sys
n = int(sys.stdin.readline().strip())
Q = [0] * n
for i in range(0, n):
line = sys.stdin.readline().strip().split()
a = int(line[0])
b = int(line[1])
Q[i] = [a, b, b - a]
Q.sort(key=lambda x: x[2])
s = 0
for i in range(0, n):
s = s + Q[i][0] * i + Q[i][1] * (n - 1 - i)
print(s) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR LIST VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN ... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | row = int(input())
data = [([0] * 2) for _ in range(row)]
for i in range(row):
arr = input()
arr = [int(x) for x in arr.split(" ")]
for j in range(2):
data[i][j] = arr[j]
data = sorted(data, key=lambda e: e[1] - e[0])
res = 0
for i in range(row):
A = i
B = row - i - 1
res += data[i][0] *... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASS... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | n = int(input())
arr = []
ans = 0
for i in range(n):
a, b = map(int, input().split())
arr.append(a - b)
ans += b * n - a
arr = sorted(arr)[::-1]
for i in range(n):
ans += arr[i] * (i + 1)
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR BIN_OP VAR NUMBER E... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | n = int(input())
arr = [([0] + [int(i) for i in input().split()]) for i in range(n)]
for i in range(n):
arr[i][0] = arr[i][1] - arr[i][2]
arr = sorted(arr)[::-1]
ans = 0
for i in range(n):
ans += i * arr[i][1] + (n - i - 1) * arr[i][2]
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER BIN_OP VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP ... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | n = int(input())
ab = [tuple(map(int, input().split())) for i in range(n)]
a = [(k[0] - k[1]) for k in ab]
a.sort()
var = sum([(a[i] * (n - i)) for i in range(n)])
const = sum([(k[1] * n - k[0]) for k in ab])
print(var + const) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBE... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | n = int(input())
q1 = []
for i in range(n):
a1, b1 = map(int, input().split())
q1.append((10**8 - (a1 - b1), a1, b1))
q1.sort()
c = 0
for j in range(n):
a1, b1 = q1[j][1], q1[j][2]
c += a1 * j + b1 * (n - 1 - j)
print(c) | ASSIGN VAR FUNC_CALL VAR 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 BIN_OP BIN_OP NUMBER NUMBER BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR NUMBER VAR VAR NUMBER VAR ... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | import sys
def main():
count = int(sys.stdin.readline().rstrip("\r\n"))
items = []
summ = 0
i = 0
while i < count:
[l, r] = sys.stdin.readline().rstrip("\r\n").split()
l = int(l)
r = int(r)
items.append([r - l, l, r])
i += 1
items.sort()
i = 0
wh... | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN LIST VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST BIN_OP VAR VAR VAR VAR VAR NUMBER EXPR ... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | n = int(input())
chars = []
for i in range(n):
a, b = map(int, input().strip().split())
chars.append((i, a, b))
new_order = sorted(chars, key=lambda x: x[2] - x[1])
total_dis = 0
for i, e in enumerate(new_order):
total_dis += chars[e[0]][1] * i + chars[e[0]][2] * (n - i - 1)
print(total_dis)
def total_ord... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NU... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | n = int(input())
l = []
for i in range(n):
a, b = [int(x) for x in input().split()]
l += [(a, b, i)]
def keyf(ab):
a, b, i = ab
return -(a - b)
l.sort(key=keyf)
ans = 0
for i in range(n):
ans += (n - 1) * l[i][1] + i * (l[i][0] - l[i][1])
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR LIST VAR VAR VAR FUNC_DEF ASSIGN VAR VAR VAR VAR RETURN BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR NUMBER ... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | def main():
n = int(input())
ans = 0
vals = []
for i in range(n):
a, b = map(int, input().split())
ans += b * n
ans -= a
vals.append(a - b)
vals.sort()
k = n
for i in vals:
ans += i * k
k -= 1
print(ans)
main() | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR FOR VAR VAR VAR BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda x: x[1] - x[0])
ans = 0
for i in range(N):
a, b = AB[i]
ans += a * i + b * (N - i - 1)
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_C... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | import sys
N = int(input())
alu = 0
A = []
B = []
for _ in range(N):
a, b = map(int, sys.stdin.readline().split())
alu += min(a, b)
if a < b:
B.append(b - a)
else:
A.append(a - b)
alu *= N - 1
A.sort(reverse=True)
B.sort(reverse=True)
alu += sum([(i * j) for i, j in enumerate(A)]) + sum... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | def cmp(a):
return a[0] - a[1]
n = int(input())
v = []
for i in range(n):
v.append(list(map(int, input().split())))
v = list(sorted(v, key=cmp, reverse=True))
s = 0
for i in range(n):
s = s + v[i][0] * i + v[i][1] * (n - i - 1)
print(s) | FUNC_DEF RETURN BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR 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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | def in_int():
return int(input())
def in_list():
return [int(x) for x in input().split()]
n = int(input())
ns = []
ans = 0
for i in range(n):
x, y = in_list()
ns.append(x - y)
ans += -x + y * n
ns.sort(reverse=True)
for i in range(n):
c = ns[i]
ans += c * (i + 1)
print(ans) | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR NUM... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | n = int(input())
total = 0
arr = []
for i in range(n):
a, b = input().split()
a, b = int(a), int(b)
arr.append(a - b)
total += n * b - a
arr.sort(key=lambda P: -1 * P)
for i in range(n):
total += (i + 1) * arr[i]
print(total) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR VAR VAR ... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | n = int(input())
a, b = zip(*[map(int, input().split()) for _ in range(n)])
s = (n - 1) * sum(b)
d = sorted(a[i] - b[i] for i in range(n))[::-1]
for i in range(n):
s += d[i] * i
print(s) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR EXPR FUN... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | def solve():
n = int(input())
a = list()
b = list()
a_append = a.append
b_append = b.append
split = str.split
for i in range(n):
new_a, new_b = map(int, split(input()))
a_append(new_a)
b_append(new_b)
c = [(a[i] - b[i], i) for i in range(n)]
c = sorted(c, key=... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR VAR FU... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | n = int(input())
a = []
b = []
c = 0
d = 0
for i in range(n):
a.append(list(map(int, input().split())))
b.append(a[i][1] - a[i][0])
c = c + a[i][0]
d = d + a[i][1]
b.sort()
s = 0
for i in range(n):
s = s + b[i] * (i + 1)
s = -1 * s
print(s - c + d * n) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER 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 BIN_OP VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR BIN_OP V... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | n = int(input())
ans = 0
c = []
for i in range(n):
[a, b] = input().strip().split(" ")
a = int(a)
b = int(b)
ans = ans + b * n - a
c.append(b - a)
c = sorted(c)
tem = 0
for i in range(n):
tem = tem + c[i] * (i + 1)
ans = ans - tem
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN LIST VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | n = int(input())
s = []
bs = []
k = 0
for i in range(n):
a, b = map(int, input().split())
bs.append(b)
s.append(a - b)
z = sorted(zip(s, bs))
s = [x for x, y in z][::-1]
bs = [y for x, y in z][::-1]
for i in range(n):
k += s[i] * i + bs[i] * (n - 1)
print(k) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR NUMBER ASSIGN VAR... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | y = []
a = int(input())
for i in range(a):
temp = list(map(int, input().split()))
temp.append(temp[1] - temp[0])
y.append(temp)
final = sorted(y, key=lambda x: x[2])
ans = 0
for i in range(a):
ans += final[i][0] * i + final[i][1] * (a - 1 - i)
print(ans) | ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | import sys
sys.setrecursionlimit(20000000)
input = sys.stdin.readline
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
for i in range(n):
a[i].append(a[i][0] - a[i][1])
a.sort(key=lambda x: -x[2])
ans = 0
for i in range(n):
ans += a[i][0] * i + a[i][1] * (n - i - 1)
print(ans) | IMPORT EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FU... |
During a break in the buffet of the scientific lyceum of the Kingdom of Kremland, there was formed a queue of $n$ high school students numbered from $1$ to $n$. Initially, each student $i$ is on position $i$. Each student $i$ is characterized by two numbers — $a_i$ and $b_i$. Dissatisfaction of the person $i$ equals th... | N_ = 100010
n = int(input())
a = []
b = []
d = []
sum = 0
for i in range(n):
ai, bi = list(map(int, input().split()))
a.append(ai)
b.append(bi)
d.append(ai - bi)
sum += bi * n - ai
d.sort()
d = d[::-1]
for i in range(n):
sum += d[i] * (i + 1)
print(sum) | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR 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.