description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Mark has just purchased a rack of $n$ lightbulbs. The state of the lightbulbs can be described with binary string $s = s_1s_2\dots s_n$, where $s_i={1}$ means that the $i$-th lightbulb is turned on, while $s_i={0}$ means that the $i$-th lightbulb is turned off.
Unfortunately, the lightbulbs are broken, and the only op... | T = int(input())
while T:
T -= 1
n = int(input())
s = list(input())
t = list(input())
ls = []
lt = []
if s[0] != t[0] or s[-1] != t[-1]:
print("-1")
continue
for i in range(n - 1):
if s[i] != s[i + 1]:
ls.append(i)
if t[i] != t[i + 1]:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBE... |
Mark has just purchased a rack of $n$ lightbulbs. The state of the lightbulbs can be described with binary string $s = s_1s_2\dots s_n$, where $s_i={1}$ means that the $i$-th lightbulb is turned on, while $s_i={0}$ means that the $i$-th lightbulb is turned off.
Unfortunately, the lightbulbs are broken, and the only op... | for _ in range(int(input())):
n = int(input())
a = input()
b = input()
a_ = []
b_ = []
for i in range(n - 1):
if a[i] != a[i + 1]:
a_.append(i)
if b[i] != b[i + 1]:
b_.append(i)
if len(a_) != len(b_) or a[0] != b[0] or a[-1] != b[-1]:
print(-1)... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR V... |
Mark has just purchased a rack of $n$ lightbulbs. The state of the lightbulbs can be described with binary string $s = s_1s_2\dots s_n$, where $s_i={1}$ means that the $i$-th lightbulb is turned on, while $s_i={0}$ means that the $i$-th lightbulb is turned off.
Unfortunately, the lightbulbs are broken, and the only op... | for _ in range(int(input())):
n = int(input())
s = list(map(int, input()))
t = list(map(int, input()))
l1, l2 = [], []
if s[0] != t[0] or s[n - 1] != t[n - 1]:
print(-1)
else:
for j in range(n - 1):
if s[j] != s[j + 1]:
l1.append(j)
if t[j]... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR VAR LIST LIST IF VAR NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMB... |
Mark has just purchased a rack of $n$ lightbulbs. The state of the lightbulbs can be described with binary string $s = s_1s_2\dots s_n$, where $s_i={1}$ means that the $i$-th lightbulb is turned on, while $s_i={0}$ means that the $i$-th lightbulb is turned off.
Unfortunately, the lightbulbs are broken, and the only op... | t_ = int(input())
for _ in range(t_):
n = int(input())
s = input().strip()
t = input().strip()
if s[0] != t[0]:
print(-1)
continue
s_dist = []
for i in range(1, n):
if s[i] != s[i - 1]:
s_dist.append(i)
total = 0
t_seg = 0
for i in range(1, n):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CAL... |
Mark has just purchased a rack of $n$ lightbulbs. The state of the lightbulbs can be described with binary string $s = s_1s_2\dots s_n$, where $s_i={1}$ means that the $i$-th lightbulb is turned on, while $s_i={0}$ means that the $i$-th lightbulb is turned off.
Unfortunately, the lightbulbs are broken, and the only op... | for _ in range(int(input())):
n = int(input())
s1 = input()
s2 = input()
if s1[0] == s2[0] and s1[-1] == s2[-1]:
cur = s1[0]
num = 0
l1 = []
l2 = []
for i in s1 + "2":
if i == cur:
num += 1
else:
l1.append(nu... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR BIN_OP VAR STRING IF VAR VAR VAR NUMBER EXPR FUNC_CALL... |
Mark has just purchased a rack of $n$ lightbulbs. The state of the lightbulbs can be described with binary string $s = s_1s_2\dots s_n$, where $s_i={1}$ means that the $i$-th lightbulb is turned on, while $s_i={0}$ means that the $i$-th lightbulb is turned off.
Unfortunately, the lightbulbs are broken, and the only op... | t = eval(input())
for i in range(t):
n = eval(input())
s1 = input()
s2 = input()
k1, k2 = 1, 1
for i in range(0, len(s1) - 1):
if s1[i] != s1[i + 1]:
k1 += 1
for i in range(0, len(s2) - 1):
if s2[i] != s2[i + 1]:
k2 += 1
if k1 != k2 or s1[0] != s2[0] o... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN... |
Mark has just purchased a rack of $n$ lightbulbs. The state of the lightbulbs can be described with binary string $s = s_1s_2\dots s_n$, where $s_i={1}$ means that the $i$-th lightbulb is turned on, while $s_i={0}$ means that the $i$-th lightbulb is turned off.
Unfortunately, the lightbulbs are broken, and the only op... | for _ in range(int(input())):
n = int(input())
s = input()
t = input()
if s[0] != t[0] or s[-1] != t[-1]:
print(-1)
continue
s_seg = 0
s_fl = False
t_seg = 0
t_fl = False
for i in range(n):
if not s_fl and s[i] == "1":
s_fl = True
if s_fl a... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR... |
Mark has just purchased a rack of $n$ lightbulbs. The state of the lightbulbs can be described with binary string $s = s_1s_2\dots s_n$, where $s_i={1}$ means that the $i$-th lightbulb is turned on, while $s_i={0}$ means that the $i$-th lightbulb is turned off.
Unfortunately, the lightbulbs are broken, and the only op... | def miis():
return map(int, input().split())
for _ in range(int(input())):
n = int(input())
s = list(map(int, list(input())))
t = list(map(int, list(input())))
l = 0
cs = []
ct = []
for i in range(n):
if s[i]:
if l:
cs[-1][1] += 1
else:
... | FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LI... |
Mark has just purchased a rack of $n$ lightbulbs. The state of the lightbulbs can be described with binary string $s = s_1s_2\dots s_n$, where $s_i={1}$ means that the $i$-th lightbulb is turned on, while $s_i={0}$ means that the $i$-th lightbulb is turned off.
Unfortunately, the lightbulbs are broken, and the only op... | num_inp = lambda: int(input())
arr_inp = lambda: list(map(int, input().split()))
sp_inp = lambda: map(int, input().split())
str_inp = lambda: input()
for _ in range(int(input())):
N = int(input())
S = input()
T = input()
s, t = [], []
for i in range(N - 1):
if S[i] != S[i + 1]:
s... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL V... |
Mark has just purchased a rack of $n$ lightbulbs. The state of the lightbulbs can be described with binary string $s = s_1s_2\dots s_n$, where $s_i={1}$ means that the $i$-th lightbulb is turned on, while $s_i={0}$ means that the $i$-th lightbulb is turned off.
Unfortunately, the lightbulbs are broken, and the only op... | q = int(input())
for _ in range(q):
n = int(input())
s1 = input()
s2 = input()
if s1[0] != s2[0] or s1[-1] != s2[-1]:
print(-1)
else:
tmp1 = []
tmp = ""
start = -1
for idx, char in enumerate(s1):
if char != tmp:
if tmp == "1":
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR ... |
Mark has just purchased a rack of $n$ lightbulbs. The state of the lightbulbs can be described with binary string $s = s_1s_2\dots s_n$, where $s_i={1}$ means that the $i$-th lightbulb is turned on, while $s_i={0}$ means that the $i$-th lightbulb is turned off.
Unfortunately, the lightbulbs are broken, and the only op... | k = int(input())
while k:
p = int(input())
s = input()
t = input()
a = []
b = []
ac = 0
bc = 0
for i in range(1, p):
if s[i] != s[i - 1]:
a.append(i)
ac += 1
if t[i] != t[i - 1]:
b.append(i)
bc += 1
if s[0] != t[0] or ac... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR VAR... |
Mark has just purchased a rack of $n$ lightbulbs. The state of the lightbulbs can be described with binary string $s = s_1s_2\dots s_n$, where $s_i={1}$ means that the $i$-th lightbulb is turned on, while $s_i={0}$ means that the $i$-th lightbulb is turned off.
Unfortunately, the lightbulbs are broken, and the only op... | def f(s, t, n):
if s[0] != t[0] or s[n - 1] != t[n - 1]:
return -1
i, j, edits = 0, 0, 0
while True:
while i < n - 1 and s[i] == s[i + 1]:
i += 1
while j < n - 1 and t[j] == t[j + 1]:
j += 1
if i < n - 1 and j < n - 1:
edits += abs(i - j)
... | FUNC_DEF IF VAR NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER RETURN NUMBER ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER WHILE NUMBER WHILE VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER WHILE VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR BIN_OP V... |
Mark has just purchased a rack of $n$ lightbulbs. The state of the lightbulbs can be described with binary string $s = s_1s_2\dots s_n$, where $s_i={1}$ means that the $i$-th lightbulb is turned on, while $s_i={0}$ means that the $i$-th lightbulb is turned off.
Unfortunately, the lightbulbs are broken, and the only op... | def find(s):
st = s[0]
a = []
c = 0
for i in range(len(s)):
if s[i] == st:
c += 1
else:
a.append(c)
c = 1
st = s[i]
if c > 0:
a.append(c)
return a
for _ in range(int(input())):
n = input()
s = input()
t = input... | FUNC_DEF ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN... |
Mark has just purchased a rack of $n$ lightbulbs. The state of the lightbulbs can be described with binary string $s = s_1s_2\dots s_n$, where $s_i={1}$ means that the $i$-th lightbulb is turned on, while $s_i={0}$ means that the $i$-th lightbulb is turned off.
Unfortunately, the lightbulbs are broken, and the only op... | def p(s):
k = 0
q = 1
for i in s:
if i == "1":
if q:
k += 1
q = 0
else:
q = 1
return k
for i in range(int(input())):
n = int(input())
s1 = input()
s2 = input()
s = 0
if s1[0] != s2[0] or s1[-1] != s2[-1] or p(s... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING IF VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER VA... |
The New Vasjuki village is stretched along the motorway and that's why every house on it is characterized by its shift relative to some fixed point β the xi coordinate. The village consists of n houses, the i-th house is located in the point with coordinates of xi.
TELE3, a cellular communication provider planned to l... | import sys
n = int(input())
houses = sorted(set(map(int, input().split())))
if len(houses) <= 3:
print(0)
result = houses[:]
while len(result) < 3:
result.append(result[-1])
print("%.6f %.6f %.6f" % tuple(result))
import sys
sys.exit()
span = 0
left = 1
right = len(houses) - 2
while ho... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR WHILE FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR IMPORT EXPR ... |
The New Vasjuki village is stretched along the motorway and that's why every house on it is characterized by its shift relative to some fixed point β the xi coordinate. The village consists of n houses, the i-th house is located in the point with coordinates of xi.
TELE3, a cellular communication provider planned to l... | n = int(input())
a = sorted(map(int, input().split()))
i = 1 - n
j = n - 2
s = 0
n = a[j] - a[i]
while s < n:
l, r = a[i] - a[0], a[-1] - a[j]
if l < r:
if n <= l:
s = n
break
i += 1
s = l
else:
if n <= r:
s = n
break
j ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR VAR WHILE VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR NUMBER BIN_OP VAR NUMBER VAR VAR IF VAR VAR IF VAR VAR A... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, k = map(int, input().split())
a = [int(i) for i in input().split()]
a.sort()
h = a[-1]
height = 0
count = 0
for i in range(n - 1):
if a[i] > height:
height = height + 1
count = count + 1
if height < h:
print(sum(a) - (count + h - height))
else:
print(sum(a) - (count + 1)) | 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 VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR EXPR ... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = map(int, input().split())
a = [int(x) for x in input().split()]
c = sum(a)
if n == 1:
print(0)
exit(0)
a.sort()
res = 0
pocl = a[n - 1]
f = False
for i in range(n - 2, -1, -1):
if pocl > 1:
if a[i] >= pocl:
res += 1
pocl -= 1
res += a[i] - 1
else:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR B... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = map(int, input().split())
l = list(map(int, input().split()))
if n == 1:
print(0)
else:
l.sort()
k = 0
ans = 0
for i in range(n):
ans += 1
if l[i] > k:
k += 1
ans += l[n - 1] - k
print(sum(l) - ans) | 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 IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR VAR VAR NUMBER VAR BIN_OP VAR BIN_OP VAR NUMBER VAR E... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = map(int, input().split())
A = list(map(int, input().split()))
sum = 0
A.sort()
for i in A:
sum += i
choosen = 0
for i in range(n):
if A[i] > choosen:
choosen += 1
not_choosen = A[-1] - choosen
print(sum - not_choosen - n) | 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 EXPR FUNC_CALL VAR FOR VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | def main():
inl = input().strip().split()
n, m = int(inl[0]), int(inl[1])
stacks = []
total_blocks = 0
for i, h in enumerate(input().strip().split()):
stacks.append((i, int(h)))
total_blocks += int(h)
stacks.sort(key=lambda s: s[1], reverse=True)
blocks = 0
hmax = stacks[... | FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN ... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = map(int, input().split())
a = [int(o) for o in input().split()]
a = sorted(a)
b = []
u = 0
s = sum(a)
l = 0
k = 0
d = 0
for i in range(n):
l = a[i]
d += a[i] - u
if d <= i:
d += 1
u = a[i]
print(s - d) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR BIN_OP VAR ... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = list(map(int, input().split()))
in_list = list(map(int, input().split()))
in_list.sort()
prev = 0
min_block = 0
for i in range(n):
min_block = min_block + in_list[i] - prev
if min_block <= i:
min_block = min_block + 1
prev = in_list[i]
print(sum(in_list) - min_block) | 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 FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR E... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | def run():
n, mmm = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
ans = 0
for i in range(n):
if arr[i] > ans:
ans += 1
left = arr[n - 1] - ans
sol = sum(arr) - n - left
print(sol)
run() | 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 ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR VAR EXP... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = input().split()
a = [int(i) for i in input().split()]
a.sort()
if 1 in a:
c = 1
else:
c = 0
ans = cc = 0
for i in range(int(n)):
if a[i] == c and cc == 0 or a[i] == c + 1:
ans += a[i] - 1
elif a[i] == c and cc > 0:
ans += c
cc -= 1
else:
ans += c
cc += ... | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR IF NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR VAR NUMBER IF VAR VAR VAR ... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = map(int, input().split())
seq = sorted(map(int, input().split()))
ans = 0
for i in range(n):
ans += seq[i] - 1
wait = 0
last = seq[-1]
for i in range(n - 1, 0, -1):
wait += 1
if last - seq[i - 1] > wait:
ans -= last - seq[i - 1] - wait
wait = 0
last = seq[i - 1]
if last - 1 > ... | 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 FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER VAR NUMBER IF BIN_OP VAR VAR BIN... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
worst = 0
maxi = a[0]
a.append(0)
for i in range(n + 1):
bad = maxi - a[i] - i
worst = max(worst, bad)
print(sum(a) - n - worst) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VA... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | a = input()
n = int(a.split()[0])
m = int(a.split()[1])
b = input()
l = list(map(int, b.split()))
l.sort()
h = 0
k = 0
for i in range(n):
if h < l[n - 1] and l[i] >= h + 1:
h = h + 1
k = k + 1
else:
k = k + 1
k = k + l[n - 1] - h
print(sum(l) - k) | ASSIGN VAR 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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR NUMBER VAR VAR BIN... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = map(int, input().split())
a = [int(s) for s in input().split()]
a = sorted(a)
current = a[n - 1]
k = 0
if n == 1:
print(0)
exit()
for i in range(n - 1, -1, -1):
if i > 0 and a[i - 1] < current - 1:
a[i] -= current - 1 - a[i - 1]
k += a[i] - 1
current = a[i - 1]
elif a[i] >... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR NUMBER... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | [n, m] = [int(x) for x in input().split(" ")]
A = [int(x) for x in input().split(" ")]
A.sort()
maxRemove = 0
maxHeight = 0
for i in range(n):
if i == n - 1:
if A[i] > maxHeight:
maxRemove += maxHeight
else:
maxRemove += A[i] - 1
elif i == 0:
maxHeight = 1
... | ASSIGN LIST 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 EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR NUM... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
used = a[0]
f = a[0] - 1
for i in range(1, n):
if f > 0:
f = min(f - 1, a[i] - 1)
else:
used += 1
print(sum(a) - used) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER ... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | import sys
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
ma = a[n - 1]
yr = 1
g = 1
if n == 1:
print(0)
sys.exit()
for i in range(1, n):
if a[i] > yr:
yr += 1
g += 1
g += ma - yr
print(sum(a) - g) | IMPORT 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 BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | s = input().split()
n = int(s[0])
m = int(s[1])
stack = list(map(int, input().split()))
stack.sort()
h = 0
ans = 0
for i in stack:
ans += 1
if i > h:
h += 1
ans += stack[-1] - h
print(sum(stack) - ans) | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR B... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = map(int, input().split())
mas = list(map(int, input().split()))
mas.sort()
res, a = 0, mas[n - 1]
for i in range(n - 2, -1, -1):
q, w = mas[i + 1], mas[i]
if q == w:
res += q - 1
a -= 1
elif a - 1 <= w:
res += q - 1
a -= 1
else:
res += q - (a - w)
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 EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER V... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
s = sum(a)
need = 0
a.sort()
j = 1
flag = 0
k = max(a)
if n == 1:
print(0)
else:
for i in range(n):
if a[i] < j:
flag = 1
else:
flag = 0
if a[i] == 1:
need += 1
elif... | 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 NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VA... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = [int(x) for x in input().split()]
L = [int(x) for x in input().split()]
D = {}
for i in L:
if i in D:
D[i] += 1
else:
D[i] = 1
S = sorted(D.keys(), reverse=True) + [0]
height = S[0]
extra = 0
for i in range(0, len(S) - 1):
height -= max(D[S[i]], max(0, min(S[i], height) - S[i + 1]))
p... | 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 VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR NUMBER LIST NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
p = sum(a)
i = n - 1
while i > 0:
a[i - 1] = min(a[i] - 1, a[i - 1])
p -= a[i] - a[i - 1]
i -= 1
print(p - max(a[0], 1)) | 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 FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR VAR V... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = list(map(int, input().strip().split(" ")))
a = list(map(int, input().strip().split(" ")))
a.sort()
x = 0
y = 0
count = 0
for i in range(0, n):
count += a[i]
if a[i] > y:
y += 1
x += 1
if i == n - 1 and a[i] > y:
x += a[i] - y
print(count - x) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR IF VAR VAR VAR VAR NUMBER VAR ... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = map(int, input().split())
l = list(map(int, input().split()))
s = 0
l.sort()
k = 0
for i in range(n - 1, 0, -1):
if l[i] > l[i - 1]:
s += l[i - 1]
elif l[i] == l[i - 1] and l[i] > 1:
s += l[i]
l[i - 1] = l[i - 1] - 1
else:
s += l[i - 1] - l[i]
if l[i] > 1:
... | 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 EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NU... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | def main():
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
s = 0
for i in range(len(a)):
s += a[i]
for i in range(n - 2, -1, -1):
if a[i + 1] > a[i]:
s -= a[i + 1] - a[i]
else:
s -= 1
a[i] = max(a[i + 1] - 1, 1... | FUNC_DEF 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 NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR B... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | def solve(xs):
if len(xs) == 1:
return 0
heights = sorted(xs)[::-1]
used = 0
needed = heights[0]
for i in range(len(heights)):
current = heights[i]
if needed <= current:
used += 1
needed -= 1
else:
used += needed - current
... | FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR VAR VAR NUMBER VAR NUMBER VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR VAR RETURN BIN_OP FUNC_C... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort()
summ, minn = 0, 0
for i in range(n):
summ += arr[i] - 1
minn = min(minn + 1, arr[i])
print(summ - arr[-1] + minn) | 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 NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMB... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = [int(x) for x in input().split()]
hei = [int(x) for x in input().split()]
total_blocks = 0
for x in hei:
total_blocks += x
hei.sort(reverse=True)
if len(hei) == 1:
print(0)
exit()
used_blocks = 0
max_covered_hei = -1
for i in range(len(hei)):
if max_covered_hei == -1:
max_covered_hei = he... | 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 FOR VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CA... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | a, b = map(int, input().split())
list1 = [*map(int, input().split())]
list1.sort(reverse=True)
ans = 0
neededHeight = list1[0]
for i, j in enumerate(list1[1:]):
neededHeight = max(min(j, list1[i] - 1), 1)
ans += j - neededHeight
if list1[i] > 1:
ans += neededHeight
list1[i + 1] = neededHeight
pr... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR VAR NUMBER NUMBER VAR BIN_OP VAR VAR IF VAR VAR ... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = map(int, input().strip().split())
arr = list(map(int, input().strip().split()))
arr = sorted(arr, reverse=True)
ak = []
for i in range(n):
ak.append(arr[i])
for i in range(n - 1):
if arr[i] == min(arr[i], arr[i + 1]):
arr[i + 1] = max(1, arr[i] - 1)
ans = 0
for i in range(n):
ans += ak[i] - a... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR FUNC_CALL VAR VAR VA... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | R = lambda: list(map(int, input().split()))
n, m = R()
a = R()
a.sort()
i = n - 1
re = 0
now = a[i]
while i > 0:
if now > a[i - 1]:
now = a[i - 1]
re += now
elif now == a[i - 1] and now > 1:
now -= 1
re += now + 1
else:
if now > 1:
now -= 1
re ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR WHILE VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER VAR VAR IF VAR VAR BIN_OP VAR NUMBE... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | def exponat(lst):
result, count = 0, 1
for i in range(len(lst)):
if count > lst[len(lst) - 1] or count > lst[i]:
result += lst[i] - 1
continue
if i != len(lst) - 1:
result += lst[i] - 1
count += 1
else:
result += count - 1
r... | FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR VAR VAR BIN_OP VAR VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP VAR VAR NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = map(int, input().split())
A = list(map(int, input().split()))
k = max(A)
s = sum(A)
x = 0
a = 0
A.sort()
for i in range(0, n):
if A[i] > x:
x += 1
a += 1
else:
a += 1
if k > x:
a += k - x
print(s - 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 FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER IF... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse=True)
sa = sum(l)
t = 0
for i in range(len(l) - 1):
if l[i] != 1:
if l[i] > l[i + 1]:
t += l[i] - l[i + 1]
elif l[i] == l[i + 1]:
l[i + 1] -= 1
t += 1
else:
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 NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR VAR... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort(reverse=True)
right = arr[0]
c = 0
for i in range(n):
if arr[i] >= right:
c += 1
right -= 1
else:
c += 1
right = arr[i] - 1
if right == 0:
break
print(sum(arr) - (n - c) - arr[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 EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER IF VAR NUMBER EXPR FUNC... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, t = input().split()
t = int(t)
n = int(n)
l = list(map(int, input().split()))
m = max(l)
s = sum(l)
l.sort()
j = 1
c = 0
for i in l:
if i >= j:
j += 1
c += 1
c += m - j + 1
print(s - c) | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER VAR NUMBE... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
c = 0
d = 0
s = sum(a)
for i in range(n):
c += 1
if a[i] > d:
d += 1
c += a[n - 1] - d
print(s - c) | 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 NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR VAR VAR NUMBER VAR BIN_OP VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CA... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
t = 1
ans = 0
for i in range(n - 1):
if l[i] >= t and t < l[n - 1]:
t += 1
ans += l[i] - 1
ans += l[n - 1] - (l[n - 1] - t + 1)
print(ans) | 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 NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR BIN_OP VAR VAR NUMBER VAR BIN_OP VAR BIN_OP V... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
if n == 1:
print(0)
exit(0)
k = 0
for i in a:
if i > 0:
k += 1
a.sort()
a = a[::-1]
c = max(a)
d = 0
for i in a:
if c > i:
c = i
if c <= 1:
break
d += 1
c -= 1
ans = sum(a) - (max(a) + k - 1) +... | 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 IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | import sys
input = sys.stdin.readline
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
ans = 0
need = max(a)
for col in a:
if col == 1 and need == 1:
ans += 1
else:
ans += max(1, need - col + 1)
need = max(1, min(need - 1, col - 1))
if need != 1:... | IMPORT ASSIGN VAR 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 FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | import sys
readints = lambda: map(int, input().strip("\n").split())
n, m = readints()
a = list(readints())
a = list(reversed(sorted(a)))
if n == 1:
print(0)
sys.exit(0)
ans = sum(a)
need = a[0]
for x in a:
if x > need:
ans -= 1
need -= 1
elif x == need:
ans -= 1
need -= ... | IMPORT ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER F... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = map(int, input().split())
a = list(map(int, input().split()))
a.append(0)
a.sort()
mx = a[n]
ans = 0
for i in range(n, 0, -1):
cnt = max(1, mx - a[i - 1])
ans += a[i] - cnt
mx -= cnt
print(ans) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR BIN_OP VAR NUMBER VAR BIN_O... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = list(map(int, input().rstrip().split()))
data = list(map(int, input().rstrip().split()))
def mergesort(l):
if len(l) == 1:
return l
llower = []
lupper = []
for i in range(0, int(len(l) / 2)):
llower.append(l[i])
for i in range(int(len(l) / 2), len(l)):
lupper.append(... | ASSIGN 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 FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FU... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = map(int, input().split())
l = list(map(int, input().split()))
if n == 1 or m == 1:
print(0)
else:
ans = sum(l)
l.sort(reverse=True)
for i in range(n - 1):
if l[i] <= l[i + 1]:
l[i + 1] = l[i] - 1
l.append(0)
for i in range(n):
ans -= max(1, l[i] - l[i + 1])
... | 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 IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = map(int, input().split())
a = sorted([int(x) for x in input().split()])
total = 0
m = max(a)
for i in range(n):
if a[i] > total:
total += 1
print(sum(a) - n - m + total) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR VAR VAR VAR |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
mx = a[-1]
t = 0
ans = 0
for i in a:
if i > 0:
if i > t:
t += 1
ans += i - 1
ans -= mx - t
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 EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER IF VAR VAR VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR VAR EXPR FUNC_CALL V... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | def solve():
N, M = map(int, input().split())
A = [int(k) for k in input().split()]
A.sort()
height = 0
for i in range(1, N + 1):
if A[i - 1] > height:
height += 1
res = N + (A[-1] - height)
print(sum(A) - res)
solve() | FUNC_DEF 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 NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP FUN... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = map(int, input().split())
a = sorted(map(int, input().split()))
ans = 0
cur = 0
for b in a:
if b > cur:
ans += 1
cur += 1
else:
ans += 1
print(sum(a) - (ans + max(a) - cur)) | 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 NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR VAR |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
a = a[::-1]
sum = int(0)
mx = int(0)
for i in range(n):
sum += a[i]
mx = max(mx, a[i])
kol = int(0)
for i in range(n):
if i != n - 1:
a[i + 1] = min(a[i + 1], a[i])
if a[i] == a[i + 1] and a[i] != 1:
mx... | 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 ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
a.append(0)
j, s = a[0], 0
for i in range(n):
if j > 0:
if j - 1 <= a[i + 1] and j - 1 > 0:
j -= 1
s += 1
elif j - 1 > a[i + 1]:
s += j - a[i + 1]
j = a[i + 1]
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER IF BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER VAR... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = map(int, input().split())
a = [int(x) for x in input().split()]
a.sort()
c = 0
maxi = 0
for i in range(n):
if maxi + 1 > a[i]:
c += a[i] - 1
pass
else:
maxi += 1
c += a[i] - 1
print(c - a[-1] + maxi) | 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 NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR VAR NUMBER VAR NUMBER VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP ... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | input1 = [int(x) for x in input().split()]
n = input1[0]
m = input1[1]
_arr = [int(x) for x in input().split()]
arr = sorted(_arr)
result = 0
height = 0
for i in range(n - 1):
if arr[i] > height:
height += 1
result += 1
if arr[-1] == height:
result += 1
else:
result += arr[-1] - height
print(sum... | ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR NUMBER VAR VA... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | s = input()
s = s.split()
for j in range(len(s)):
s[j] = int(s[j])
n = s[0]
m = s[1]
s1 = input()
s1 = s1.split()
for j in range(n):
s1[j] = int(s1[j])
s1.sort()
s1.reverse()
pointer = s1[0]
res = 0
flag = 0
if n == 1:
print(0)
else:
for i in range(n - 1):
if s1[i] != 1:
if flag == 1... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VA... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | import sys
input_file = sys.stdin
[n, m] = list(int(x) for x in input_file.readline().split())
stacks = list(int(x) for x in input_file.readline().split())
stacks.sort()
ans = 0
cur_stack = 0
cur_h = 0
while cur_stack < n:
ans += 1
if stacks[cur_stack] >= cur_h + 1:
cur_h += 1
cur_stack += 1
ans +=... | IMPORT ASSIGN VAR VAR ASSIGN LIST VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBE... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = map(int, input().split())
a = list(map(int, input().split()))
a.append(0)
a.sort(reverse=True)
all_s = sum(a)
s = 0
for i in range(1, len(a)):
if a[i - 1] > a[i]:
s += a[i - 1] - a[i]
elif a[i - 1] == a[i]:
s += 1
a[i] -= 1
else:
s += 1
a[i] = a[i - 1] - 1
prin... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR BI... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
res = 0
same = 0
p = 1
for h in a:
if p <= h:
p += 1
else:
same += 1
res = a[-1] + same
print(sum(a) - res) | 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 NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR V... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = input().split()
a = [int(i) for i in input().split()]
a.sort()
c = 0
ans = cc = 0
for i in range(int(n)):
if cc > 1:
ans += cc - 1
cc += -1 + a[i] - c
ans += a[i] - cc
else:
cc = max(1, a[i] - c)
ans += a[i] - cc
c = a[i]
print(ans) | ASSIGN 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 NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP NUMBER VAR VAR VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR NUMB... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
c = max(l)
low = 0
ans = 0
for i in range(n - 1):
if l[i] > low:
ans += l[i] - 1
low += 1
else:
ans += l[i] - 1
if low == c:
ans += low - 1
else:
ans += low
print(ans) | 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 FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR BIN_OP VAR VAR NUMBER VAR NUMBER VAR BIN_OP VAR VAR N... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = map(int, input().split())
l = list(map(int, input().split()))
l.sort()
res = 0
pre = l[0] - 1
for i in range(len(l) - 1):
if l[i] < l[i + 1]:
res += l[i]
pre += l[i + 1] - l[i] - 1
else:
res += l[i] - 1
if pre > 0:
pre -= 1
res += 1
print(res) | 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 NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR BIN_OP BIN_OP VAR BI... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | line1 = input().split()
row, col = int(line1[0]), int(line1[1])
blocks = [int(x) for x in input().split()]
def count_removable(blocks):
rows = len(blocks)
cols = max(blocks)
blocks.sort()
can_replace = 1
for i in range(1, len(blocks)):
block = blocks[i]
if block > can_replace:
... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR V... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
temp = 1
top = 0
side = 0
total = sum(a)
for i in range(n):
if i == 0:
top += 1
side += 1
total -= 1
elif a[i] == temp:
top += 1
total -= 1
elif a[i] > temp:
side += 1
top +=... | 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 NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR NU... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = map(int, input().split())
A = list(map(int, input().split()))
s = sum(A)
if n == 1:
print(0)
else:
ans = 0
A.sort(reverse=True)
for i in range(n - 1):
A[i] = min(A[i], m)
if A[i] > A[i + 1]:
ans += A[i] - A[i + 1]
m = min(m, A[i + 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 ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR IF... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = map(int, input().split())
inp = list(map(int, input().split()))
inp.sort()
pos = 1
for i in inp[0 : n - 1]:
if pos == inp[n - 1]:
break
elif i >= pos:
pos += 1
print(sum(inp) - (n - 1) - (inp[n - 1] - pos + 1)) | 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 FOR VAR VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER BI... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = map(int, input().split())
A = sorted(map(int, input().split()))
cnt = 0
prev = 0
for a in A:
cnt += 1
if a > prev:
prev += 1
cnt += A[-1] - prev
print(sum(A) - cnt) | 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 NUMBER FOR VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | def main():
n, m = map(int, input().split())
a = list(reversed(sorted(map(int, input().split()))))
res = 0
h = a[0]
b = []
for x in a:
if x > h:
res += x - h
h = min(h, x)
b.append(h)
if h > 1:
h -= 1
for i in range(len(b) - 1):
... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR IF VA... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | ar1 = str(input()).split(" ")
ar2 = sorted(str(input()).split(" "))
ar3 = []
for el in ar2:
ar3.append(int(el))
ar4 = sorted(ar3)
n = int(ar1[0])
m = int(ar1[1])
summ1 = 0
for i in range(len(ar2)):
summ1 = summ1 + int(ar2[i])
summ = 0
num = 0
j = 1
for i in range(len(ar4)):
if j > int(ar4[i]):
num +... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FU... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | N, _ = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
keep = max(A)
up_to = 0
for i in range(N):
if A[i] > up_to:
up_to += 1
else:
keep += 1
print(sum(A) - keep) | 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 FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | R = lambda: map(int, input().rstrip().split())
n, m = R()
a = list(sorted(R()))
x = 0
prev = 0
for i in range(1, n + 1):
x += 1
if a[i - 1] > prev:
prev += 1
x += a[n - 1] - prev
print(sum(a) - x) | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR NUMBER VAR BIN_OP VAR BIN_OP VAR NUMBER VAR EXPR... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort(reverse=True)
m = a[0]
ct = 0
for i in range(n):
if m == 0:
ct += n - i
break
ct += 1
if a[i] < m:
ct += m - a[i]
m = a[i]
m -= 1
print(sum(a) - (m + ct)) | 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 NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR BIN_OP VAR VAR VAR NUMBER IF VAR VAR VAR VAR BIN_OP VAR VAR VAR ASSIGN V... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
sum1 = sum(a)
delete = n
possible_height = 0
max_height = a[n - 1]
for i in range(n):
if a[i] > possible_height:
possible_height += 1
print(sum1 - delete + possible_height - max_height) | 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 FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
l, p, k = a[n - 1], 0, 0
for i in range(n - 1):
if p < l:
if a[i] > p:
k += a[i] - 1
p += 1
else:
k += a[i] - 1
else:
k += a[i] - 1
if p >= l:
print(k + (a[n - 1] -... | 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 VAR VAR VAR BIN_OP VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR IF VAR VAR VAR VAR BIN_OP VAR VAR NUMBER VAR NUMBER VAR B... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = map(int, input().split())
a = [int(x) for x in input().split()]
a.sort()
j = 1
for i in a:
if i >= j:
j += 1
print(max(sum(a) - n - max(max(a) - j + 1, 0), 0)) | 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 NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER NU... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | import sys
def solve(io):
N = io.read_int()
M = io.read_int()
A = io.read_int_array(N)
A = list(sorted(A))
H = max(A)
S = sum(A)
want = 1
rem = 0
for v in A:
if want <= v:
want += 1
keep = H + N - (want - 1)
rem = S - keep
io.println(rem)
class IO:... | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER ASS... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | from sys import stdin
def myfunction(arr, n):
my_sum = 0
my_min = 0
if n == 1:
return 0
for i in range(n - 1):
if arr[i] > my_min:
my_min += 1
my_sum += arr[i] - 1
if arr[-1] == my_min:
my_sum += arr[i] - 1
else:
my_sum += my_min
return m... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR NUMBER VAR BIN_OP VAR VAR NUMBER IF VAR NUMBER VAR VAR BIN_OP VAR VAR NUMBER VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL ... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = map(int, input().split())
num = [int(i) for i in input().split()]
num.sort()
ans = n + num[-1]
c = 0
for i in num:
if c < i:
c += 1
print(sum(num) - ans + c) | 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 BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR VAR |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | [n, m] = [int(i) for i in input().split()]
a = sorted([int(i) for i in input().split()])
a = [i for i in a if i > 0]
needLeft = 1
j = 1
for i in range(n):
if i == n - 1:
needLeft += a[i] - j
elif a[i + 1] > j:
j += 1
needLeft += 1
else:
needLeft += 1
canDelete = sum(a) - need... | ASSIGN LIST VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR VAR VAR IF VAR BIN_OP VAR NUMBER VAR VAR NUMBER... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | R = lambda: map(int, input().split())
n, m = R()
i = 0
a = sorted(R())
for x in a:
i = min(x, i + 1)
print(sum(a) - n - a[-1] + i) | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR VAR VAR NUMBER VAR |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = map(int, input().split())
arr = [int(x) for x in input().split()]
tot = sum(arr)
ma = max(arr)
arr.sort()
for i in range(n):
if arr[i] == 0:
del arr[i]
l = len(arr)
if True:
h = 0
left = 0
for i in range(l - 1):
if arr[i] > h:
h += 1
left += 1
if h == ma:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FO... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | nos = list(map(int, input().split()))
n = nos[0]
data = list(map(int, input().split()))
suma = 0
for a in range(0, n):
suma += data[a]
data.sort()
data.reverse()
ans = 0
data.append(0)
for i in range(0, n):
if data[i] - data[i + 1] > 0:
ans += data[i] - data[i + 1]
else:
ans += 1
dat... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL V... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | class IO:
def get(reader=str):
return reader(input().strip())
def gets(reader=str, delim=None):
return [reader(x) for x in input().strip().split(delim)]
def tostr(raw, writer=str, delim=" "):
return delim.join(writer(x) for x in raw)
n, m = IO.gets(int)
a = IO.gets(int)
a.sort()... | CLASS_DEF FUNC_DEF VAR RETURN FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF VAR NONE RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR VAR FUNC_DEF VAR STRING RETURN FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER F... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | inp = input().split()
n = int(inp[0])
m = int(inp[1])
inp = input().split()
a = []
for i in inp:
a.append(int(i))
res = 0
a.sort(reverse=True)
tr = a[0]
for i in range(0, len(a) - 1):
if tr - 1 > a[i + 1]:
res += tr - a[i + 1]
tr = a[i + 1]
else:
res += 1
tr = max(1, tr - 1)
... | 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 VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL V... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | I = input
n, m = map(int, I().split())
a = list(map(int, I().split()))
a.sort()
l = 0
h = a[n - 1]
ans = 0
for i in range(n):
if l == h:
ans += a[i] - 1
elif a[i] < l + 1:
if a[i] > 1:
ans += a[i] - 1
elif a[i] >= l + 1:
if i != n - 1:
if a[i] > 1:
... | ASSIGN VAR 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 FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER I... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = map(int, input().split())
a = list(map(int, input().split()))
ans = sum(a)
a.sort()
lastlevel = 0
level = 0
got = 0
for i in a:
got = max(got, i)
level = min(level + 1, got)
if i > 0:
ans -= 1
lastlevel = level
ans -= got - level
print(ans) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
total = 0
req = 0
ans = 0
prev = 0
for i in a:
total += i
for i in a:
req += 1
if i > prev:
prev += 1
req += a[-1] - prev
ans = total - req
print(ans) | 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 NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR VAR FOR VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP V... |
You came to the exhibition and one exhibit has drawn your attention. It consists of $n$ stacks of blocks, where the $i$-th stack consists of $a_i$ blocks resting on the surface.
The height of the exhibit is equal to $m$. Consequently, the number of blocks in each stack is less than or equal to $m$.
There is a camera ... | input()
A = sorted(list(map(int, input().split())))
keep = max(A)
up_to = 0
for a in A:
if a > up_to:
up_to += 1
else:
keep += 1
print(sum(A) - keep) | EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.