description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
An atom of element X can exist in n distinct states with energies E_1 < E_2 < ... < E_{n}. Arkady wants to build a laser on this element, using a three-level scheme. Here is a simplified description of the scheme.
Three distinct states i, j and k are selected, where i < j < k. After that the following process happens... | n, U = [int(i) for i in input().split()]
E = [int(i) for i in input().split()]
k = 0
ans = 0.0
haveAns = False
for i in range(n):
while k < n and E[k] - E[i] <= U:
k += 1
k -= 1
if i + 2 <= k:
rate = E[k] - E[i + 1]
rate /= E[k] - E[i]
if rate > ans:
ans = rate
... | 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 NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR WHILE VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR VAR BIN_... |
An atom of element X can exist in n distinct states with energies E_1 < E_2 < ... < E_{n}. Arkady wants to build a laser on this element, using a three-level scheme. Here is a simplified description of the scheme.
Three distinct states i, j and k are selected, where i < j < k. After that the following process happens... | import sys
def run():
inp = sys.stdin.readlines()
n, u = (int(x) for x in inp[0].strip().split())
data = [int(x) for x in inp[1].strip().split()]
ans = None
for i in range(n - 2):
first = data[i]
second = data[i + 1]
trgt = u + first
if data[i + 2] > trgt:
... | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR NONE FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR BIN_OP... |
An atom of element X can exist in n distinct states with energies E_1 < E_2 < ... < E_{n}. Arkady wants to build a laser on this element, using a three-level scheme. Here is a simplified description of the scheme.
Three distinct states i, j and k are selected, where i < j < k. After that the following process happens... | pairs = [int(s) for s in input().split(" ")]
n = int(pairs[0])
U = int(pairs[1])
levels = [int(s) for s in input().split(" ")]
levels.sort()
def find_nearest(levels, start, finish, max_level):
if start > finish:
return -1
if start > n - 1:
return -1
if levels[start] > max_level:
re... | ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR BIN_OP VAR NUMBER RETURN NUMBER IF VAR VAR VAR RETURN NUMBER... |
An atom of element X can exist in n distinct states with energies E_1 < E_2 < ... < E_{n}. Arkady wants to build a laser on this element, using a three-level scheme. Here is a simplified description of the scheme.
Three distinct states i, j and k are selected, where i < j < k. After that the following process happens... | def run():
n, u = (int(x) for x in input().split())
data = [int(x) for x in input().split()]
uu = 2
ans = None
for i in range(n - 2):
first = data[i]
second = data[i + 1]
trgt = u + first
if data[i + 2] > trgt:
continue
while uu < n - 1 and data[uu... | FUNC_DEF 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 NUMBER ASSIGN VAR NONE FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR BIN_OP VAR NUMBER VAR WHILE VAR BI... |
An atom of element X can exist in n distinct states with energies E_1 < E_2 < ... < E_{n}. Arkady wants to build a laser on this element, using a three-level scheme. Here is a simplified description of the scheme.
Three distinct states i, j and k are selected, where i < j < k. After that the following process happens... | from sys import stdin, stdout
n, U = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
k = 0
ans = -1
for i in range(n):
while k + 1 < n and a[k + 1] - a[i] <= U:
k += 1
if k - i < 2:
continue
j = i + 1
cur = (a[k] - a[j]) / (a[k] - a[i])
ans = max(ans, cur)
pr... | 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 NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR WHILE BIN_OP VAR NUMBER VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN... |
A lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some stones in the river to help them.
The stones are located at integer distances from the banks. There ... | w, l = [int(i) for i in input().split()]
arr = [int(i) for i in input().split()]
o = sum(arr[:l])
O = o
for i in range(1, w - l):
o = o - arr[i - 1]
o += arr[i + l - 1]
O = min(O, o)
print(O) | 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 FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ... |
A lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some stones in the river to help them.
The stones are located at integer distances from the banks. There ... | I = lambda: map(int, input().split())
w, l = I()
a = list(I())
c = s = sum(a[:l])
for i in range(w - l - 1):
s = s - a[i] + a[i + l]
c = min(c, s)
print(c) | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR |
A lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some stones in the river to help them.
The stones are located at integer distances from the banks. There ... | w, l = list(map(int, input().split()))
a = list(map(int, input().split()))
r = 1e18
s = sum(a[:l])
for i in range(l, w - 1):
r = min(s, r)
s += a[i]
s -= a[i - l]
r = min(s, r)
print(r) | ASSIGN 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 ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CAL... |
A lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some stones in the river to help them.
The stones are located at integer distances from the banks. There ... | Q = [int(x) for x in input().split(" ")]
w = Q[0]
l = Q[1]
A = [int(x) for x in input().split(" ")]
B = [(0) for i in range(w - 1)]
i = 0
j = 0
for i in range(w - 1):
if i < l:
B[i] = A[i]
else:
while j < i:
if j < i - l:
j = i - l
t = min(A[i] - B[i], B[j... | ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN ... |
A lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some stones in the river to help them.
The stones are located at integer distances from the banks. There ... | [w, l] = list(map(int, input().strip().split()))
ais = list(map(int, input().strip().split()))
winais = [(0) for _ in range(w - l)]
s = sum(ais[:l])
winais[0] = s
for i in range(w - l - 1):
s += ais[i + l] - ais[i]
winais[i + 1] = s
print(min(winais)) | ASSIGN LIST VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ... |
A lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some stones in the river to help them.
The stones are located at integer distances from the banks. There ... | n, k = map(int, input().split())
a = list(map(int, input().split()))
s = sum(a[:k])
b = []
c = 0
b.append(s)
for i in range(n - k - 1):
s = s - a[i] + a[i + k]
b.append(s)
print(min(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 VAR ASSIGN VAR LIST ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR... |
A lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some stones in the river to help them.
The stones are located at integer distances from the banks. There ... | inf = 2000000000
w, l = map(int, input().split())
aa = input().split()
a = [(0) for i in range(w)]
dp = [(0) for i in range(w + 1)]
su = [(0) for i in range(w + 1)]
for i in range(1, w):
a[i] = int(aa[i - 1])
for i in range(1, w):
if i <= l:
dp[i] = a[i]
else:
dp[i] = min(a[i], su[i - 1] - s... | ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR ... |
A lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some stones in the river to help them.
The stones are located at integer distances from the banks. There ... | w, l = map(int, input().split())
a = list(map(int, input().split()))
f = s = sum(i for i in a[:l])
for i, b in enumerate(a[l:]):
s += b - a[i]
f = min(s, f)
print(f) | 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 VAR FUNC_CALL VAR VAR VAR VAR VAR FOR VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR |
A lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some stones in the river to help them.
The stones are located at integer distances from the banks. There ... | def main():
w, l = map(int, input().split())
a = list(map(int, input().split()))
dist = 0
mdist = float("inf")
for i in range(l):
dist += a[i]
mdist = min(mdist, dist)
for i in range(l, w - 1):
dist += a[i]
dist -= a[i - l]
mdist = min(mdist, dist)
print(m... | FUNC_DEF 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 NUMBER ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR BI... |
A lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some stones in the river to help them.
The stones are located at integer distances from the banks. There ... | w, l = list(map(int, input().split()))
a = list(map(int, input().split()))
s = 0
for i in range(l):
s += a[i]
c = 10**20 + 1
for i in range(l, w - 1):
c = min(c, s)
s = max(0, s + a[i] - a[i - l])
c = min(c, s)
print(c) | ASSIGN 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 FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASS... |
A lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some stones in the river to help them.
The stones are located at integer distances from the banks. There ... | import sys
def findMinSubSum(a, l):
minim = sum(a[:l])
current = minim
for i in range(l, len(a)):
current += a[i] - a[i - l]
minim = min(current, minim)
return minim
w, l = map(int, input().split())
a = list(map(int, input().split()))
print(findMinSubSum(a, l)) | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN VAR 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 F... |
A lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some stones in the river to help them.
The stones are located at integer distances from the banks. There ... | w, l = [int(i) for i in input().split(" ")]
a = [1000000000.0] * (w + 1)
entrada = [int(i) for i in input().split(" ")]
for i in range(1, w):
a[i] = entrada[i - 1]
aux = [0] * len(a)
num = 0
for j in range(1, w + 1):
if a[j] <= 0:
continue
if j <= l:
aux[j] = a[j]
continue
d = j
... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR ... |
A lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some stones in the river to help them.
The stones are located at integer distances from the banks. There ... | w, l = map(int, input().split())
A = list(map(int, input().split()))
A = [0] + A + [0]
dp = [0] * (w + 1)
for i in range(w):
if i == 0:
for j in reversed(range(1, l + 1)):
dp[j] += A[j]
else:
for j in reversed(range(i + 1, min(i + l + 1, w + 1))):
if j == w:
... | 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 BIN_OP BIN_OP LIST NUMBER VAR LIST NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR N... |
A lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some stones in the river to help them.
The stones are located at integer distances from the banks. There ... | w, l = (int(x) for x in input().split())
dist___rocks_nr = [int(x) for x in input().split()]
curr_l = 0
start_sum = sum(dist___rocks_nr[:l])
min_sum = start_sum
while True:
if curr_l + l >= w - 1:
break
start_sum -= dist___rocks_nr[curr_l]
start_sum += dist___rocks_nr[curr_l + l]
curr_l += 1
... | 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 NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR WHILE NUMBER IF BIN_OP VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUN... |
A lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some stones in the river to help them.
The stones are located at integer distances from the banks. There ... | river_width, jump_len = [int(x) for x in input().split(" ")]
stones = [int(x) for x in input().split(" ")]
ans, current = -1, 0
for i, stone in enumerate(stones):
current += stone
if i + 1 >= jump_len:
ans = min(ans, current) if ans != -1 else current
current -= stones[i + 1 - jump_len]
print(an... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR VAR IF BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER FUNC_CALL VAR VAR VAR VAR VAR VAR BIN_OP BIN_OP VAR NUMBER VAR EXPR FUNC_C... |
A lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some stones in the river to help them.
The stones are located at integer distances from the banks. There ... | w, l = list(map(int, input().split()))
a = list(map(int, input().split()))
for i in range(1, w - 1):
a[i] = a[i] + a[i - 1]
ans = a[l - 1]
for i in range(l, w - 1):
ans = min(ans, a[i] - a[i - l])
print(ans) | ASSIGN 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 FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN... |
A lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some stones in the river to help them.
The stones are located at integer distances from the banks. There ... | import sys
def getAns(river, w, l):
t_sum = 0
for i in range(0, l):
t_sum += river[i]
min_val = t_sum
for i in range(l, w - 1):
t_sum = t_sum - river[i - l] + river[i]
min_val = min(min_val, t_sum)
return min_val
w, l = [int(x) for x in input().split()]
f_list = [int(x) f... | IMPORT FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL ... |
A lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some stones in the river to help them.
The stones are located at integer distances from the banks. There ... | from sys import stdin
w, l = map(int, stdin.readline().split())
a = [0] + list(map(int, stdin.readline().split()))
c = [(0) for _ in range(w)]
i, j = 1, 1
C = 0
while j <= l:
c[j] = a[j]
a[j] = 0
j += 1
while i < w:
while j < w and a[j] == 0:
j += 1
if j - i > l:
i += 1
cont... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR NUMBER VAR NUMBER WHILE VAR VAR WHILE ... |
A lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some stones in the river to help them.
The stones are located at integer distances from the banks. There ... | import sys
wl = input().split()
w = int(wl.pop(0))
l = int(wl.pop(0))
a = [int(i) for i in input().split()]
a = [0] + a
sun = 0
ans = 10**9
for i in range(1, w):
sun += a[i]
if i >= l:
ans = min(ans, sun)
sun -= a[i - l + 1]
print(ans) | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR ... |
A lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some stones in the river to help them.
The stones are located at integer distances from the banks. There ... | import sys
read = lambda: map(int, sys.stdin.buffer.readline().split())
w, l = read()
a = list(read())
b = [0] * (w - 1)
ans = 0
j = 0
for i in range(l):
a[i], b[i] = 0, a[i]
for i in range(w - 1):
if b[i] == 0:
continue
if i + l >= w - 1:
ans += b[i]
else:
j = max(i + 1, j)
... | IMPORT ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF V... |
A lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some stones in the river to help them.
The stones are located at integer distances from the banks. There ... | n, jump = map(int, input().split())
arr = list(map(int, input().split()))
pt1, pt2 = 0, jump
while pt2 < n - 1:
count = 0
flag = 0
while pt1 < pt2:
if count + arr[pt1] <= arr[pt2]:
count += arr[pt1]
arr[pt1] = 0
pt1 += 1
else:
arr[pt1] -= max(0... | 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 VAR NUMBER VAR WHILE VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR NUMBER VAR NUMBER VAR VAR FUNC_CALL... |
A lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some stones in the river to help them.
The stones are located at integer distances from the banks. There ... | def f(n, l):
m = len(l)
if n == 1:
return min(l)
if n == m:
return sum(l)
ans = sum(l[:n])
new = ans
for i in range(1, m - n):
new = new + l[i - 1 + n] - l[i - 1]
if new < ans:
ans = new
return ans
w, n = list(map(int, input().split()))
l = list(... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER RETURN FUNC_CALL VAR VAR IF VAR VAR RETURN FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR VAR RETUR... |
A lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some stones in the river to help them.
The stones are located at integer distances from the banks. There ... | n, l = list(map(int, input().split()))
stones = list(map(int, input().split()))
summ = sum(stones[:l])
minn = summ
for i in range(n - l - 1):
summ = summ + stones[l + i] - stones[i]
if summ < minn:
minn = summ
print(minn) | ASSIGN 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 FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR E... |
A lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some stones in the river to help them.
The stones are located at integer distances from the banks. There ... | import sys
input = sys.stdin.readline
w, l = map(int, input().split())
a = [int(i) for i in input().split() if i != "\n"]
ans = [sum(a[:l])]
for i in range(w - 1 - l):
pq = ans[-1] + a[i + l] - a[i]
ans.append(pq)
sys.stdout.write(str(min(ans)) + "\n") | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR STRING ASSIGN VAR LIST FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR VA... |
A lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some stones in the river to help them.
The stones are located at integer distances from the banks. There ... | l, w = list(map(int, input().split()))
li = list(map(int, input().split()))
aa = []
tot = 0
for i in range(l - 1):
tot += li[i]
if i >= w:
tot = tot - li[i - w]
if i >= w - 1:
aa.append(tot)
print(min(aa)) | ASSIGN 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 ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR VAR BIN_OP VAR VAR IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ... |
A lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some stones in the river to help them.
The stones are located at integer distances from the banks. There ... | w, l = [int(i) for i in input().split(" ")]
arr = [int(i) for i in input().split(" ")]
cummulative = [(0) for i in range(len(arr) + 1)]
for i in range(len(arr)):
cummulative[i + 1] = cummulative[i] + arr[i]
min_cut = 1000000009
for i in range(w - l):
cut = cummulative[i + l] - cummulative[i]
if cut < min_cu... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FU... |
A lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some stones in the river to help them.
The stones are located at integer distances from the banks. There ... | def read_nums():
return list(map(int, input().split()))
w, l = read_nums()
rocks = read_nums()
cur_sum = sum(rocks[0:l])
min_sum = cur_sum
for i in range(l, len(rocks)):
cur_sum -= rocks[i - l]
cur_sum += rocks[i]
min_sum = min(min_sum, cur_sum)
print(min_sum) | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR |
A lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some stones in the river to help them.
The stones are located at integer distances from the banks. There ... | from itertools import *
r = lambda: map(int, input().split())
w, l = r()
v = [0, *accumulate(r())]
print(min(v[i] - v[i - l] for i in range(l, w))) | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR FUNC_CALL VAR VAR VAR |
A lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some stones in the river to help them.
The stones are located at integer distances from the banks. There ... | w, l = map(int, input().split())
a = list(map(int, input().split()))
prefix = [0] * (w - l)
prefix[0] = sum(a[:l])
for i in range(w - 1 - l):
prefix[i + 1] += prefix[i] + a[i + l] - a[i]
print(min(prefix)) | 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 BIN_OP LIST NUMBER BIN_OP VAR VAR ASSIGN VAR NUMBER FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR V... |
A lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some stones in the river to help them.
The stones are located at integer distances from the banks. There ... | import sys
while True:
try:
W, L = [int(i) for i in input().split()]
river = [int(i) for i in input().split()]
sum_seq = sum(river[:L])
frogs = sum_seq
for i in range(L, W - 1):
sum_seq = sum_seq + river[i] - river[i - L]
frogs = min(sum_seq, frogs)
... | IMPORT WHILE NUMBER 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 FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR E... |
A lot of frogs want to cross a river. A river is $w$ units width, but frogs can only jump $l$ units long, where $l < w$. Frogs can also jump on lengths shorter than $l$. but can't jump longer. Hopefully, there are some stones in the river to help them.
The stones are located at integer distances from the banks. There ... | input_string = input().split()
n = int(input_string[0])
l = int(input_string[1])
input_string = input().split()
v = []
for i in range(0, len(input_string)):
v.append(int(input_string[i]))
dp = [0]
for i in range(1, len(v) + 1):
dp.append(dp[i - 1] + v[i - 1])
ans = 1000000000000000000000000000
for i in range(l,... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR V... |
You are given a sequence $a_1, a_2, \dots, a_n$ consisting of $n$ integers.
You may perform the following operation on this sequence: choose any element and either increase or decrease it by one.
Calculate the minimum possible difference between the maximum element and the minimum element in the sequence, if you can ... | n, k = map(int, input().split(" "))
arr = list(map(int, input().split(" ")))
arr.sort()
dif = [0] * n
for i in range(n - 1):
dif[i] = arr[i + 1] - arr[i]
i = 0
j = n - 2
left = 1
right = 1
last = -1
while k > 0 and i <= j:
if dif[i] == 0:
left += 1
i += 1
continue
if dif[j] == 0:
... | 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 EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP V... |
You are given a sequence $a_1, a_2, \dots, a_n$ consisting of $n$ integers.
You may perform the following operation on this sequence: choose any element and either increase or decrease it by one.
Calculate the minimum possible difference between the maximum element and the minimum element in the sequence, if you can ... | n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
c = [a[i] for i in range(n)]
for i in range(1, n):
c[i] += c[i - 1]
c.append(0)
lnum, rnum = 0, 0
left = 0
right = n - 1
for i in range(n // 2 + n % 2):
left = i
lnum = i * a[i] - c[i - 1]
if lnum + rnum >= k:
break
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIG... |
You are given a sequence $a_1, a_2, \dots, a_n$ consisting of $n$ integers.
You may perform the following operation on this sequence: choose any element and either increase or decrease it by one.
Calculate the minimum possible difference between the maximum element and the minimum element in the sequence, if you can ... | n, k = list(map(int, input().split()))
l = list(map(int, input().split()))
l.sort()
s = 0
for i in range(n):
s += abs(l[i] - l[n // 2])
if s <= k:
print(0)
else:
i = 0
while True:
if i == n - 1:
break
if l[i + 1] != l[i]:
break
i += 1
p = i
left = ... | ASSIGN 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 EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE NUM... |
You are given a sequence $a_1, a_2, \dots, a_n$ consisting of $n$ integers.
You may perform the following operation on this sequence: choose any element and either increase or decrease it by one.
Calculate the minimum possible difference between the maximum element and the minimum element in the sequence, if you can ... | import sys
def main():
n, k = readIntArr()
a = readIntArr()
a.sort()
l = 0
r = n - 1
leftCnt = 1
rightCnt = 1
leftVal = a[0]
rightVal = a[n - 1]
while l < r:
if leftCnt < rightCnt:
if k >= leftCnt * (a[l + 1] - a[l]):
k -= leftCnt * (a[l + 1]... | IMPORT FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER WHILE VAR VAR IF VAR VAR IF VAR BIN_OP VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VA... |
You are given a sequence $a_1, a_2, \dots, a_n$ consisting of $n$ integers.
You may perform the following operation on this sequence: choose any element and either increase or decrease it by one.
Calculate the minimum possible difference between the maximum element and the minimum element in the sequence, if you can ... | n, k = map(int, input().split())
a = input().split()
for i in range(n):
a[i] = int(a[i])
a.sort()
b = []
count = 0
for i in range(n):
if i == 0:
count += 1
if i == n - 1:
b.append([a[i], count])
elif a[i] == a[i - 1]:
count += 1
if i == n - 1:
b.append... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR LIST VAR VAR VAR ... |
You are given a sequence $a_1, a_2, \dots, a_n$ consisting of $n$ integers.
You may perform the following operation on this sequence: choose any element and either increase or decrease it by one.
Calculate the minimum possible difference between the maximum element and the minimum element in the sequence, if you can ... | n, k = map(int, input().split())
l1 = list(map(int, input().split()))
l1.sort()
i = 0
j = n - 1
left = 1
right = 1
while i < j and k > 0:
x = l1[i + 1] - l1[i]
y = l1[j] - l1[j - 1]
if left == right:
if k >= left * x:
k -= left * x
i += 1
left += 1
else:
... | 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 ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR... |
You are given a sequence $a_1, a_2, \dots, a_n$ consisting of $n$ integers.
You may perform the following operation on this sequence: choose any element and either increase or decrease it by one.
Calculate the minimum possible difference between the maximum element and the minimum element in the sequence, if you can ... | n, k = map(int, input().split())
a = [int(x) for x in input().split()]
a.sort()
L1 = []
L2 = []
for i in range(0, n - 1):
L1.append(a[i + 1] - a[i])
for i in range(len(a) - 1, 0, -1):
L2.append(a[i] - a[i - 1])
L2 = L2 + [0]
L2 = L2[::-1]
L1 = L1 + [0]
low = 0
high = len(a) - 1
c1 = 1
c2 = 1
while low < high:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBE... |
You are given a sequence $a_1, a_2, \dots, a_n$ consisting of $n$ integers.
You may perform the following operation on this sequence: choose any element and either increase or decrease it by one.
Calculate the minimum possible difference between the maximum element and the minimum element in the sequence, if you can ... | n, k = map(int, input().split())
b = list(map(int, input().split()))
a = []
dic = {}
for i in b:
try:
if dic[i]:
dic[i] += 1
except KeyError:
dic[i] = 1
a.append(i)
a.sort()
i = 0
j = len(a) - 1
while 1:
frst = a[i]
last = a[j]
if frst == last:
break
f... | 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 LIST ASSIGN VAR DICT FOR VAR VAR IF VAR VAR VAR VAR NUMBER VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMB... |
You are given a sequence $a_1, a_2, \dots, a_n$ consisting of $n$ integers.
You may perform the following operation on this sequence: choose any element and either increase or decrease it by one.
Calculate the minimum possible difference between the maximum element and the minimum element in the sequence, if you can ... | n, k = [int(i) for i in input().split()]
d = [int(i) for i in input().split()]
mn = min(d)
mx = max(d)
dic = {}
for dd in d:
if dd in dic:
dic[dd] += 1
else:
dic[dd] = 1
ans = 0
vals = list(dic.keys())
vals.sort()
loi = 0
hii = len(vals) - 1
while loi < hii:
locl = vals[loi]
hicl = vals[... | 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 FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_C... |
You are given a sequence $a_1, a_2, \dots, a_n$ consisting of $n$ integers.
You may perform the following operation on this sequence: choose any element and either increase or decrease it by one.
Calculate the minimum possible difference between the maximum element and the minimum element in the sequence, if you can ... | n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
left = 1
right = 1
while 1:
if left * (a[left] - a[left - 1]) <= k:
k -= left * (a[left] - a[left - 1])
left += 1
else:
print(a[n - right] - a[left - 1] - int(k / left))
return
if left + right... | ASSIGN 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 EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR NUM... |
You are given a sequence $a_1, a_2, \dots, a_n$ consisting of $n$ integers.
You may perform the following operation on this sequence: choose any element and either increase or decrease it by one.
Calculate the minimum possible difference between the maximum element and the minimum element in the sequence, if you can ... | n, k = map(int, input().split())
a = sorted(map(int, input().split()))
l, r = 0, n - 1
b = False
while r - l > 0 and k > 0:
x = (a[l + 1] - a[l]) * (l + 1) + (a[r] - a[r - 1]) * (n - r)
if x >= k:
ans = max(a[r] - a[l] - k // (l + 1), 0)
print(ans)
b = True
k -= x
l += 1
r -=... | 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 VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR V... |
You are given a sequence $a_1, a_2, \dots, a_n$ consisting of $n$ integers.
You may perform the following operation on this sequence: choose any element and either increase or decrease it by one.
Calculate the minimum possible difference between the maximum element and the minimum element in the sequence, if you can ... | n, k = list(map(int, input().split()))
a = sorted(map(int, input().split()))
i = 1
while True:
ans = a[-i] - a[i - 1]
if (a[i] - a[i - 1]) * i >= k:
ans -= k // i
break
ans = a[-i] - a[i]
k += a[i - 1] * i
k -= a[i] * i
if (a[-i] - a[-i - 1]) * i >= k:
ans -= k // i
... | ASSIGN 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 WHILE NUMBER ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR... |
You are given a sequence $a_1, a_2, \dots, a_n$ consisting of $n$ integers.
You may perform the following operation on this sequence: choose any element and either increase or decrease it by one.
Calculate the minimum possible difference between the maximum element and the minimum element in the sequence, if you can ... | n, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
i, j = 0, n - 1
cnt0, cnt1 = 1, 1
left, right = l[0], l[-1]
while i < j:
if cnt0 < cnt1:
x = l[i + 1] - l[i]
if cnt0 * x <= k:
k -= cnt0 * x
cnt0 += 1
i += 1
left = l[i]
... | 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 ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR NUMBER VAR NUMBER WHILE VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VA... |
You are given a sequence $a_1, a_2, \dots, a_n$ consisting of $n$ integers.
You may perform the following operation on this sequence: choose any element and either increase or decrease it by one.
Calculate the minimum possible difference between the maximum element and the minimum element in the sequence, if you can ... | n, k = [int(i) for i in input().split(" ")]
a = sorted([int(i) for i in input().split(" ")])
if n == 1:
print(0)
exit()
tot = 0
i, j = 1, n - 2
while j - i >= -1:
do = i > n - j - 1
last = tot
tot += i * (a[i] - a[i - 1]) if not do else (n - j - 1) * (a[j + 1] - a[j])
if tot >= k:
if do:... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP ... |
You are given a sequence $a_1, a_2, \dots, a_n$ consisting of $n$ integers.
You may perform the following operation on this sequence: choose any element and either increase or decrease it by one.
Calculate the minimum possible difference between the maximum element and the minimum element in the sequence, if you can ... | n, k = [int(x) for x in input().split()]
d = {}
b = []
for i in map(int, input().split()):
if i not in d:
b.append(i)
d[i] = 1
else:
d[i] += 1
b.sort()
mi, ma = 0, len(b) - 1
left, right = b[mi], b[ma]
am_left, am_right = d[b[mi]], d[b[ma]]
mi, ma = 1, len(b) - 2
while right - left > 0:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR AS... |
You are given a sequence $a_1, a_2, \dots, a_n$ consisting of $n$ integers.
You may perform the following operation on this sequence: choose any element and either increase or decrease it by one.
Calculate the minimum possible difference between the maximum element and the minimum element in the sequence, if you can ... | n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
i = 0
j = n - 1
while i < j and k != 0:
if i + 1 <= n - j:
delta = a[i + 1] - a[i]
if k >= (i + 1) * delta:
up = delta
k -= up * (i + 1)
i += 1
else:
up = k // ... | ASSIGN 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 EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR IF VAR ... |
You are given a sequence $a_1, a_2, \dots, a_n$ consisting of $n$ integers.
You may perform the following operation on this sequence: choose any element and either increase or decrease it by one.
Calculate the minimum possible difference between the maximum element and the minimum element in the sequence, if you can ... | import sys
n, k = list(map(int, input().split()))
num = [int(x) for x in input().split()]
num.sort()
if n == 1:
print(0)
return
pre = 0
pree = num[0]
lat = n - 1
latt = num[n - 1]
pren = 1
latn = 1
while k > 0:
while num[pre + 1] == pree and pre + 1 < lat:
pre += 1
pren += 1
while num[l... | IMPORT ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER... |
You are given a sequence $a_1, a_2, \dots, a_n$ consisting of $n$ integers.
You may perform the following operation on this sequence: choose any element and either increase or decrease it by one.
Calculate the minimum possible difference between the maximum element and the minimum element in the sequence, if you can ... | class Solve:
def __init__(self):
self.n, self.k = map(int, input().split())
self.fuad = list(map(int, input().split()))
self.fuad.sort()
def FuckCase(self):
for i in range(int(self.n / 2)):
s = (self.fuad[i + 1] - self.fuad[i]) * (i + 1) + (
self.fua... | CLASS_DEF FUNC_DEF 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 FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER BIN_OP BIN_OP V... |
You are given a sequence $a_1, a_2, \dots, a_n$ consisting of $n$ integers.
You may perform the following operation on this sequence: choose any element and either increase or decrease it by one.
Calculate the minimum possible difference between the maximum element and the minimum element in the sequence, if you can ... | n, k = map(int, input().split())
a = list(map(int, input().split()))
cnt = {}
for elem in a:
if elem in cnt:
cnt[elem] += 1
else:
cnt[elem] = 1
cnt = sorted(list(cnt.items()))
for i in range(len(cnt)):
cnt[i] = list(cnt[i])
left = 0
right = len(cnt) - 1
while k > 0:
if k < cnt[left][1] a... | 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 DICT FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VA... |
You are given a sequence $a_1, a_2, \dots, a_n$ consisting of $n$ integers.
You may perform the following operation on this sequence: choose any element and either increase or decrease it by one.
Calculate the minimum possible difference between the maximum element and the minimum element in the sequence, if you can ... | import sys
def minp():
return sys.stdin.readline().strip()
def mint():
return int(minp())
def mints():
return map(int, minp().split())
def solve():
n, k = mints()
a = list(mints())
a.sort()
b = []
c = []
i = 0
while i < n:
j = i + 1
while j < n and a[j] ==... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR ... |
You are given a sequence $a_1, a_2, \dots, a_n$ consisting of $n$ integers.
You may perform the following operation on this sequence: choose any element and either increase or decrease it by one.
Calculate the minimum possible difference between the maximum element and the minimum element in the sequence, if you can ... | n, k = list(map(int, input().split()))
li = list(map(int, input().split()))
d = {}
l = []
for i in li:
try:
d[i] += 1
except KeyError:
d[i] = 1
l.append(i)
l.sort()
z = 1
a = 0
b = len(l) - 1
while k > 0:
if a == b:
z = 0
break
if d[l[a]] > d[l[b]]:
s = d[... | ASSIGN 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 DICT ASSIGN VAR LIST FOR VAR VAR VAR VAR NUMBER VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP F... |
You are given a sequence $a_1, a_2, \dots, a_n$ consisting of $n$ integers.
You may perform the following operation on this sequence: choose any element and either increase or decrease it by one.
Calculate the minimum possible difference between the maximum element and the minimum element in the sequence, if you can ... | from sys import stdin, stdout
def getmindifference(n, k, a):
a.sort()
lcnt = 1
rcnt = 1
lmin = a[0]
rmax = a[len(a) - 1]
lidx = 0
ridx = len(a) - 1
while k > 0 and lidx < ridx:
if lcnt <= rcnt:
needk = min(k, (a[lidx + 1] - a[lidx]) * lcnt)
lmin += needk... | FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR NUMBER VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR VAR BIN_OP VA... |
You are given a sequence $a_1, a_2, \dots, a_n$ consisting of $n$ integers.
You may perform the following operation on this sequence: choose any element and either increase or decrease it by one.
Calculate the minimum possible difference between the maximum element and the minimum element in the sequence, if you can ... | import sys
def minp():
return sys.stdin.readline().strip()
def mint():
return int(minp())
def mints():
return map(int, minp().split())
def solve1(b, n, k):
sl = 0
sr = 0
for i in b:
sr += i[0] * i[1]
i = 0
j = 0
m = len(b)
nl = 0
nr = n
r = int(2 * 1000000... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBE... |
You are given a sequence $a_1, a_2, \dots, a_n$ consisting of $n$ integers.
You may perform the following operation on this sequence: choose any element and either increase or decrease it by one.
Calculate the minimum possible difference between the maximum element and the minimum element in the sequence, if you can ... | n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
a.append(-1)
count = 1
b = []
add = 0
for i in range(n):
if a[i] == a[i + 1]:
count += 1
else:
b.append([a[i], count])
count = 1
add += 1
i = 0
j = add - 1
e, f = b[i][1], b[j][1]
plus = 0
flag = 0
whil... | 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 EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR LIST VAR V... |
You are given a sequence $a_1, a_2, \dots, a_n$ consisting of $n$ integers.
You may perform the following operation on this sequence: choose any element and either increase or decrease it by one.
Calculate the minimum possible difference between the maximum element and the minimum element in the sequence, if you can ... | from sys import stdin
n, k = [int(i) for i in stdin.readline().strip().split()]
a = [int(i) for i in stdin.readline().strip().split()]
a.sort()
i = 0
j = n - 1
a_min = a[i]
a_max = a[j]
while i < j:
if a[i] == a[i + 1]:
i += 1
a_min = a[i]
elif a[j] == a[j - 1]:
j -= 1
a_max = a... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR WHILE VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR I... |
You are given a sequence $a_1, a_2, \dots, a_n$ consisting of $n$ integers.
You may perform the following operation on this sequence: choose any element and either increase or decrease it by one.
Calculate the minimum possible difference between the maximum element and the minimum element in the sequence, if you can ... | def solve(k, a):
a.sort()
ans = a[-1] - a[0]
if ans == 0:
return 0
q1 = []
q2 = []
for i in range(1, len(a)):
if a[i] != a[i - 1]:
q1.append([i, a[i] - a[i - 1]])
a = a[::-1]
for i in range(1, len(a)):
if a[i] != a[i - 1]:
q2.append([i, a[i... | FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER RETURN NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR LIST VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUM... |
You are given a sequence $a_1, a_2, \dots, a_n$ consisting of $n$ integers.
You may perform the following operation on this sequence: choose any element and either increase or decrease it by one.
Calculate the minimum possible difference between the maximum element and the minimum element in the sequence, if you can ... | n, k = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
d = {}
for x in a:
if x not in d:
d[x] = 0
d[x] += 1
nums = list(d.keys())
nums.sort()
l = 0
r = len(nums) - 1
while l < r:
if d[nums[l]] < d[nums[r]]:
cur = nums[l]
nxt = nums[l + 1]
full_cost = (... | 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 DICT FOR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE V... |
You are given a sequence $a_1, a_2, \dots, a_n$ consisting of $n$ integers.
You may perform the following operation on this sequence: choose any element and either increase or decrease it by one.
Calculate the minimum possible difference between the maximum element and the minimum element in the sequence, if you can ... | from sys import stdin
n, k = [int(i) for i in stdin.readline().strip().split()]
a = [int(i) for i in stdin.readline().strip().split()]
a.sort()
ups = n * [0]
downs = n * [0]
for i in range(0, n - 1):
ups[i + 1] = ups[i] + (i + 1) * (a[i + 1] - a[i])
for i in range(n - 1, 0, -1):
downs[i - 1] = downs[i] + (n - ... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR LIST NUMBER ASSIGN VAR BIN_OP VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR VAR BIN_... |
You are given a sequence $a_1, a_2, \dots, a_n$ consisting of $n$ integers.
You may perform the following operation on this sequence: choose any element and either increase or decrease it by one.
Calculate the minimum possible difference between the maximum element and the minimum element in the sequence, if you can ... | n, k = map(int, input().split())
s = sorted(map(int, input().split()))
i = 0
j = n - 1
while i < j:
f = (s[i + 1] - s[i]) * (i + 1) + (s[j] - s[j - 1]) * (n - j)
if f >= k:
exit(print(max(0, s[j] - s[i] - k // (i + 1))))
k -= f
i += 1
j -= 1
print(0) | 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 NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR ... |
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!
The computers bought for the room were different. Some of them had only USB ... | a, b, c = map(int, input().split())
m = int(input())
z = 0
A = []
B = []
su = 0
for i in range(m):
s = input().split()
if s[1] == "USB":
A.append(int(s[0]))
else:
B.append(int(s[0]))
A.sort()
B.sort()
if a < len(A):
su += sum(A[:a])
A = A[a:]
z += a
a = 0
else:
su += sum(... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CA... |
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!
The computers bought for the room were different. Some of them had only USB ... | info = input()
infos = info.split(" ")
unb = int(infos[0])
pnb = int(infos[1])
bnb = int(infos[2])
mnums = int(input())
usbs = []
ps2s = []
for i in range(mnums):
ls = input().split(" ")
if ls[1] == "USB":
usbs.append(int(ls[0]))
else:
ps2s.append(int(ls[0]))
usbs.sort()
ps2s.sort()
buyed = ... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR NUMBER ST... |
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!
The computers bought for the room were different. Some of them had only USB ... | a, b, c = list(map(int, input().split()))
m = int(input())
USB, PS = [], []
for _ in range(m):
s = input().split()
l, r = int(s[0]), s[1]
if r == "USB":
USB.append(l)
else:
PS.append(l)
USB.sort()
PS.sort()
a = min(a, len(USB))
res = sum(USB[:a])
USB = USB[a:]
b = min(b, len(PS))
res += ... | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER IF VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC... |
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!
The computers bought for the room were different. Some of them had only USB ... | a, b, c = map(int, input().split())
m = int(input())
PS = []
USB = []
res = 0
for i in range(m):
q = input().split()
if q[1] == "USB":
USB.append(int(q[0]))
else:
PS.append(int(q[0]))
PS.sort()
USB.sort()
a = min(a, len(USB))
b = min(b, len(PS))
res += sum(USB[:a])
res += sum(PS[:b])
UN = US... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR 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 FUNC_CALL FUNC_CALL VAR IF VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ... |
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!
The computers bought for the room were different. Some of them had only USB ... | u, p, b = map(int, input().split())
n = int(input())
arr = []
cnt = 0
m = 0
for i in range(n):
a, bb = input().split()
arr.append([int(a), bb])
arr = sorted(arr)
for i in range(n):
if arr[i][1] == "USB" and u != 0:
u -= 1
cnt += arr[i][0]
m += 1
elif arr[i][1] == "PS/2" and p != ... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF... |
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!
The computers bought for the room were different. Some of them had only USB ... | usb = []
ps = []
nc = 0
pr = 0
s = input()
s = s.split()
u = int(s[0])
p = int(s[1])
up = int(s[2])
m = int(input())
for i in range(m):
b = input()
b = b.split()
pri = int(b[0])
ty = b[1]
if ty == "USB":
usb.append(pri)
else:
ps.append(pri)
usb.sort()
ps.sort()
if len(usb) <= u:
... | ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER 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 FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSI... |
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!
The computers bought for the room were different. Some of them had only USB ... | a, b, c = [int(i) for i in input().split()]
n = int(input())
A = []
ps = []
usb = []
for i in range(n):
s = input().split()
s[0] = int(s[0])
if s[1] == "USB":
usb.append(s[0])
else:
ps.append(s[0])
ps.sort()
usb.sort()
usbptr = 0
psptr = 0
totalnum = 0
totalcost = 0
for i in range(a):
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER IF VAR NUMBER STRING EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CAL... |
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!
The computers bought for the room were different. Some of them had only USB ... | from itertools import accumulate
a, b, c = map(int, input().split())
m = int(input())
ms = [[] for _ in range(2)]
for i in range(m):
ct, t = input().split()
ct = int(ct)
ms[int(t != "USB")].append(ct)
for i in range(2):
ms[i].sort()
ms[i] = list(accumulate(ms[i]))
ans = 0, 0
cost = lambda x, a: (
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR STRING VAR FOR VAR FUNC_CALL VAR NUMBER EXPR FUN... |
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!
The computers bought for the room were different. Some of them had only USB ... | a, b, c = input().strip().split()
a, b, c = int(a), int(b), int(c)
m = int(input())
usb = []
ps = []
cnt = 0
sum = 0
up = []
for a0 in range(m):
l = input().strip().split()
if l[1] == "USB":
usb.append(l[0])
else:
ps.append(l[0])
usb = [int(i) for i in usb]
ps = [int(j) for j in ps]
usb.sort... | ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ... |
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!
The computers bought for the room were different. Some of them had only USB ... | a, b, c = map(int, input().split())
m = int(input())
def merge(arr1, arr2):
result = []
ptr1 = ptr2 = 0
while ptr1 < len(arr1) or ptr2 < len(arr2):
if ptr1 >= len(arr1):
result.append(arr2[ptr2])
ptr2 += 1
elif ptr2 >= len(arr2):
result.append(arr1[ptr1]... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR LIST ASSIGN VAR VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMB... |
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!
The computers bought for the room were different. Some of them had only USB ... | a, b, c = map(int, input().split())
m = int(input())
usb = []
ps = []
for i in range(m):
val, name = input().split()
if name == "USB":
usb.append(int(val))
else:
ps.append(int(val))
usb.sort()
ps.sort()
sum1 = sum(usb[: min(len(usb), a)])
sum2 = sum(ps[: min(len(ps), b)])
u1 = min(len(usb), ... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL V... |
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!
The computers bought for the room were different. Some of them had only USB ... | import sys
input = sys.stdin.readline
num_usb, num_ps, num_both = map(int, input().split())
m = int(input())
usb = []
ps = []
for _ in range(m):
c, con = input().rstrip().split()
c = int(c)
if con == "USB":
usb.append(c)
else:
ps.append(c)
usb.sort(reverse=True)
ps.sort(reverse=True)
co... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EX... |
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!
The computers bought for the room were different. Some of them had only USB ... | import sys
usb, ps, pc = map(int, sys.stdin.readline().split())
n = int(sys.stdin.readline())
def find(usb, ps, pc, n):
buy = 0
price = 0
usbs = []
pss = []
for req_num in range(n):
req = sys.stdin.readline().strip().split()
req[0] = int(req[0])
if req[1] == "USB":
... | IMPORT ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER IF VAR NUMBER STRING E... |
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!
The computers bought for the room were different. Some of them had only USB ... | a, b, c = list(map(int, input().split()))
n = int(input())
usb = list()
pc2 = list()
for i in range(n):
kl = input().split()
if kl[1] == "USB":
usb.append(int(kl[0]))
else:
pc2.append(int(kl[0]))
usb = sorted(usb)
pc2 = sorted(pc2)
summ = 0
num = 0
i = 0
j = 0
can = True
if len(usb) <= a:
... | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL V... |
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!
The computers bought for the room were different. Some of them had only USB ... | a, b, c = map(int, input().split())
g = [input().split() for i in range(int(input()))]
v, vc = 0, 0
for x, y in sorted((int(x), y == "USB") for x, y in g):
if a and y or b and not y or c:
v += 1
vc += x
if y:
if a:
a -= 1
elif c:
c -= 1
elif b:
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR STRING VAR VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER VAR VAR IF VAR IF VAR VAR NUMBER IF VAR VAR NUMB... |
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!
The computers bought for the room were different. Some of them had only USB ... | un, pn, n = map(int, input().split())
m = int(input())
lu, lp = [], []
lui, lpi = 0, 0
for i in range(m):
v, t = input().split()
if t == "USB":
lu.append(int(v))
else:
lp.append(int(v))
list.sort(lu)
list.sort(lp)
lui, lpi = 0, 0
mxu = len(lu)
mxp = len(lp)
rc = 0
rv = 0
while un > 0 and lui... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR LIST LIST ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CAL... |
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!
The computers bought for the room were different. Some of them had only USB ... | a, b, c = map(int, input().split())
m = int(input())
m1 = []
m2 = []
for i in range(m):
s = input().split(" ")
if s[1] == "USB":
m1.append(int(s[0]))
else:
m2.append(int(s[0]))
m1 = sorted(m1)
m2 = sorted(m2)
m3 = []
ans1 = 0
ans2 = 0
for i in range(len(m1)):
if a == 0:
for j in ... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL 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 FUNC_CALL VAR STRING IF VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR ... |
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!
The computers bought for the room were different. Some of them had only USB ... | a, b, k = map(int, input().split())
A = []
B = []
for _ in range(int(input())):
s = input().split()
if s[len(s) - 1][len(s[len(s) - 1]) - 1] == "2":
B.append(int(s[0]))
else:
A.append(int(s[0]))
B.sort()
A.sort()
c = 0
ans = 0
T = []
if len(A) <= a:
c += len(A)
ans += sum(A)
else:
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR... |
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!
The computers bought for the room were different. Some of them had only USB ... | usb, ps2, both = map(int, input().split())
total = usb + ps2 + both
tests = int(input())
mouses = []
for _ in range(tests):
a, b = input().split()
if b == "USB":
mouses.append([int(a), 0])
else:
mouses.append([int(a), 1])
mouses.sort(key=lambda x: x[0])
i = 0
remaining = usb + ps2 + both
cos... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR STRING EXPR FUNC_CALL VAR LIST FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR LIST FUNC_CALL VAR V... |
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!
The computers bought for the room were different. Some of them had only USB ... | a, b, c = map(int, input().split())
n = int(input())
cop = []
for i in range(n):
x, y = input().split()
z = 0
if y == "USB":
z = 1
if y == "PS/2":
z = 2
cop.append((int(x), z))
ans = 0
num = 0
cop.sort(key=lambda x: x[0])
for terms in cop:
if terms[1] == 1:
if a > 0:
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR STRING ASSIGN VAR NUMBER IF VAR STRING ASSIGN VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBE... |
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!
The computers bought for the room were different. Some of them had only USB ... | import sys
a, b, c = map(int, input().split())
m = int(input())
usb, ps2 = [], []
for v, t in (line.split() for line in sys.stdin):
if t == "USB":
usb.append(int(v))
else:
ps2.append(int(v))
usb.sort()
ps2.sort()
i, j = min(a, len(usb)), min(b, len(ps2))
for _ in range(c):
if i < len(usb) a... | IMPORT ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR LIST LIST FOR VAR VAR FUNC_CALL VAR VAR VAR IF VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR... |
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!
The computers bought for the room were different. Some of them had only USB ... | def ri():
return map(int, input().split())
a, b, c = ri()
m = int(input())
u = []
p = []
for i in range(m):
cost, t = input().split()
cost = int(cost)
if t == "USB":
u.append(cost)
else:
p.append(cost)
u.sort(reverse=True)
p.sort(reverse=True)
count = 0
totcost = 0
for i in range(a... | 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 ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR... |
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!
The computers bought for the room were different. Some of them had only USB ... | a, b, c = map(int, input().split())
n = int(input())
usb = []
ps = []
for i in range(n):
k, t = input().strip().split()
if t == "USB":
usb.append(int(k))
else:
ps.append(int(k))
usb = sorted(usb)
ps = sorted(ps)
eq, tot = 0, 0
if len(usb) < a:
eq += len(usb)
tot += sum(usb)
usb =... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR IF VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ... |
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!
The computers bought for the room were different. Some of them had only USB ... | from sys import stdin as fin
u, p, pu = map(int, fin.readline().split())
m = int(fin.readline())
ps2, usb = [], []
for i in range(m):
cost, typ = fin.readline().strip().split()
cost = int(cost)
if typ == "PS/2":
ps2.append(cost)
else:
usb.append(cost)
ps2.sort()
usb.sort()
sumcost = 0
c... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CA... |
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!
The computers bought for the room were different. Some of them had only USB ... | from sys import stdin, stdout
a, b, c = stdin.readline().split()
a = int(a)
b = int(b)
c = int(c)
m = int(stdin.readline())
vals = []
for _ in range(m):
cost, type = stdin.readline().split()
cost = int(cost)
vals.append((cost, type))
vals.sort(key=lambda x: x[0])
cost = 0
total = 0
for i, val in enumerate(... | 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 FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL... |
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!
The computers bought for the room were different. Some of them had only USB ... | Upc, Ppc, UPpc = map(int, input().split())
m = int(input())
usb = []
ps2 = []
for i in range(m):
value = input().split()
if value[1] == "PS/2":
ps2 += [int(value[0])]
else:
usb += [int(value[0])]
usb = sorted(usb)
ps2 = sorted(ps2)
res1 = 0
res2 = 0
Ulength = len(usb)
Plength = len(ps2)
for ... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL 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 FUNC_CALL VAR IF VAR NUMBER STRING VAR LIST FUNC_CALL VAR VAR NUMBER VAR LIST FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VA... |
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!
The computers bought for the room were different. Some of them had only USB ... | a, b, c = map(int, input().split())
m = int(input())
usb = []
ps2 = []
for i in range(m):
s = input().split()
if s[1] == "USB":
usb.append(int(s[0]))
else:
ps2.append(int(s[0]))
usb.sort()
if a > len(usb):
sum1 = sum(usb)
p1 = len(usb)
usb = []
else:
sum1 = sum(usb[:a])
p... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL 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 FUNC_CALL VAR IF VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR... |
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!
The computers bought for the room were different. Some of them had only USB ... | a, b, c = map(int, input().split())
m = int(input())
x = list()
y = list()
for _ in range(m):
cost, mouse = input().split()
cost = int(cost)
if mouse == "USB":
x.append(cost)
else:
y.append(cost)
x.sort(reverse=True)
y.sort(reverse=True)
total = 0
amount = 0
while x and (a > 0 or c > 0) ... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL V... |
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!
The computers bought for the room were different. Some of them had only USB ... | a, b, c = map(int, input().split())
arr = [[], []]
for i in range(int(input())):
p, s = input().split()
pr = int(p)
if s == "USB":
arr[0].append(pr)
else:
arr[1].append(pr)
arr[0].sort()
arr[1].sort()
pr = 0
n = 0
d = []
for j in range(min(a, len(arr[0]))):
n += 1
pr += arr[0][j]... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST LIST LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR STRING EXPR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL ... |
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!
The computers bought for the room were different. Some of them had only USB ... | from sys import stdin as fin
a, b, c = input().split()
a = int(a)
b = int(b)
c = int(c)
n = int(input())
mouses = []
for i in range(0, n):
l, r = fin.readline().strip().split()
mouses.append((int(l), r))
mouses.sort()
money_count = 0
comp_count = 0
for t in mouses:
if t[1] == "USB" and a + c or t[1] == "PS... | 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 FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CA... |
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!
The computers bought for the room were different. Some of them had only USB ... | a, b, c = map(int, input().split())
n = int(input())
USB = []
PS2 = []
for i in range(n):
s1, s2 = map(str, input().split())
s1 = int(s1)
if s2 == "USB":
USB.append(s1)
else:
PS2.append(s1)
USB.sort()
PS2.sort()
count = 0
s = 0
if a > len(USB):
count += len(USB)
for i in USB:
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL V... |
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!
The computers bought for the room were different. Some of them had only USB ... | [a, b, c] = list(map(int, input().split()))
m = int(input())
usb = []
ps2 = []
for i in range(m):
[x, y] = list(map(str, input().split()))
if y == "USB":
usb.append(int(x))
else:
ps2.append(int(x))
usb.sort()
ps2.sort()
cnt = 0
cost = 0
p = min(a, len(usb))
cnt += p
for i in range(p):
co... | ASSIGN LIST VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN LIST VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL V... |
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!
The computers bought for the room were different. Some of them had only USB ... | a, b, c = map(int, input().split())
n = int(input())
u = []
p = []
ans = 0
if n == 0:
print(0, 0)
else:
for i in range(n):
x, y = map(str, input().split())
x = int(x)
if y == "USB":
u.append(x)
else:
p.append(x)
u.sort()
p.sort()
l = min(a, len... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR STRI... |
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!
The computers bought for the room were different. Some of them had only USB ... | a, b, c = input().split()
a, b, c = int(a), int(b), int(c)
n = int(input())
usb = []
ps = []
for i in range(n):
x = input().split()
if x[1] == "USB":
usb.append(int(x[0]))
else:
ps.append(int(x[0]))
usb.sort()
usb.reverse()
ps.sort()
ps.reverse()
usb_k = min(a, len(usb))
ps_k = min(b, len(ps... | 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 FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FU... |
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis!
The computers bought for the room were different. Some of them had only USB ... | a, b, c = map(int, input().split())
m = int(input())
usb = []
ps2 = []
for i in range(m):
aa, bb = input().split()
if bb == "USB":
usb.append(int(aa))
else:
ps2.append(int(aa))
usb.sort()
ps2.sort()
equip = 0
cost = 0
t = min(a, len(usb))
equip += t
for i in range(t):
cost += usb[i]
p = ... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL V... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.