description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = [int(x) for x in input().split(" ")]
a = [int(x) for x in input().split(" ")]
poss, lamp, left, right = True, 0, -1, min(r - 1, n - 1)
while right > left:
while right > left and a[right] != 1:
right -= 1
if left == right:
poss = False
break
else:
lamp += 1
left... | 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 VAR VAR NUMBER NUMBER NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER WHILE VAR VAR WHILE VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER VAR NUMBER ... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
l = list(map(int, input().split()))
c = [0] * n
ans = 0
for i in range(n):
if l[i] == 1:
b = False
for j in range(i - (r - 1), i + r):
if j < 0 or j >= n:
continue
if c[j] != 1:
b = True
c[j] = 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 BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR VAR IF VAR NUMBER VA... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | import sys
class Input(object):
def __init__(self):
self.fh = sys.stdin
def next_line(self):
return sys.stdin.readline()
def next_line_ints(self):
line = self.next_line()
return [int(x) for x in line.split()]
def get_min_heaters(n, r, valid_array):
count = 0
un... | IMPORT CLASS_DEF VAR FUNC_DEF ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR RETURN FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VA... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | [n, r] = [int(x) for x in input().split(" ")]
a = [int(x) for x in input().split(" ")]
last_heater = None
heaters = n * [0]
last_looked = None
ok = False
r = r - 1
last_looked = min(r + 1, n)
for i in reversed(range(0, min(r + 1, n))):
if a[i] == 1:
heaters[i] = 1
last_heater = i
ok = True
... | 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 ASSIGN VAR NONE ASSIGN VAR BIN_OP VAR LIST NUMBER ASSIGN VAR NONE ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR F... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
str = "0" + "".join(input().split())
flag = 1
heaters = 0
last = 0
while last < n:
pos = -1
a = max(1, last - r + 2)
test_str = str[a : last + r + 1]
for i in range(len(test_str)):
if test_str[i] == "1":
pos = i
if pos == -1:
flag = 0
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP STRING FUNC_CALL STRING FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER FO... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().strip().split())
a = list(map(int, input().strip().split()))
count = 0
i = 0
while i < n:
right = min(n - 1, i + r - 1)
left = max(0, i - r + 1)
flag = 0
for j in range(right, left - 1, -1):
if a[j] == 1:
start = j
flag = 1
break
if... | 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 NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR ... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
L = list(map(int, input().split()))
c = [0] * n
res = 0
for i in range(n):
if L[i]:
res += 1
for j in range(max(0, i - r + 1), min(n, i + r)):
c[j] += 1
for i in range(n):
if c[i] == 0:
print(-1)
quit()
for i in range(n):
f = 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 BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER FUNC_CALL VAR VAR BIN_OP... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = [int(el) for el in input().split()]
a = [int(el) for el in input().split()]
if n == 1 and a[0] == 0:
print(-1)
raise SystemExit
if n == 1 and a[0] == 1:
print(1)
raise SystemExit
out = 0
i = r - 1
mx = 0
j = -1
while mx < n - 1:
q = 0
if i > n - 1:
start = n - 1
else:
... | 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 IF VAR NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER VAR IF VAR NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NU... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
a = list(map(int, input().split()))
def searchr(st):
loop = 2 * r - 2
while loop >= 0:
if a[st + loop] == 1:
break
loop = loop - 1
return loop
if r >= n:
C = sorted(a, reverse=True)
if C[0] == 0:
print(-1)
else:
pri... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER WHILE VAR NUMBER IF VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMB... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | p = list(map(int, input().split()))
n = p[0]
m = p[1]
a = list(map(int, input().split()))
c = {}
l = int(0)
r = int(0)
ans = int(0)
flag = int(0)
for i in range(0, n):
c[i] = 0
while l < n:
if c[l] == 1:
l = l + 1
continue
ff = int(0)
ans = ans + 1
for i in range(l, min(n, l + m)):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBE... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | from itertools import accumulate
n, r = map(int, input().split())
a = list(map(int, input().split()))
dom = list(map(lambda x: 0, range(n + 1)))
for i, el in enumerate(a):
if el:
dom[max(0, i - r + 1)] += 1
dom[min(n, i + r)] -= 1
acc_d = list(accumulate(dom[:-1]))
if 0 in acc_d:
print(-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 FUNC_CALL VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR FUNC_CALL VAR VA... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
idx = 0
cb = -100000
ptr = 0
count = 0
flag = True
while idx < n:
ptr = max(0, idx - r + 1)
while ptr < min(n, idx + r):
if a[ptr] == 1:
cb = ptr
ptr += 1
if abs(idx - cb) >= r:
print(-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 NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER WHILE VAR FUNC_CALL VAR VAR BIN_OP VA... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | import sys
def rint():
return map(int, sys.stdin.readline().split())
n, r = rint()
a = list(rint())
cnt = 0
for i in range(n):
if a[i] == 0 or a[i] == 1:
for j in range(r - 1, -1, -1):
if i + j < 0 or i + j >= n:
continue
if a[i + j] == 1 or a[i + j] == 3:
... | IMPORT FUNC_DEF RETURN 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 NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP VAR VAR NUMBER BIN_OP VAR VAR VAR IF VAR BIN_O... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
a = list(map(int, input().split()))
if 1 not in a:
print(-1)
else:
s = [False] * n
current = [False] * n
for i in range(n):
if a[i] == 1:
q1 = max(0, i - r + 1)
q2 = min(i + r, n)
for j in range(q1, q2):
current... | 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 NUMBER VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_O... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().strip().split())
arr1 = list(map(int, input().strip().split()))
arr = [0] * n
ans = 0
f = 0
for i in range(n):
f1 = 0
f2 = 0
ind = -1
if arr[i] == 0:
for j in range(min(n - 1, i + r - 1), i - 1, -1):
if arr1[j] == 1 and f1 == 0:
ans += 1
... | 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 BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR NUMBER FOR VAR ... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
arr = list(map(int, input().split()))
covered = [set() for _ in range(n)]
for i in range(n):
if arr[i] == 1:
for j in range(max(0, i - r + 1), min(n, i + r)):
covered[j].add(i)
visited = set()
for i in range(n):
if covered[i] == set():
print(-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 FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR VAR ... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
arr = list(map(int, input().split()))
ans = 0
i = min(n - 1, r - 1)
prev = -1
while i > prev:
while i > prev and arr[i] == 0:
i -= 1
if i == prev:
ans = -1
break
prev = i
ans += 1
if prev + r >= n:
break
i = min(n - 1, i + 2 * 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 NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR WHILE VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR V... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = list(map(int, input().split(" ")))
r, pointer, count, heaters = r - 1, 0, 0, list(map(int, input().split(" ")))
while pointer < n:
offset = r
while (
pointer + offset >= n
or pointer + offset >= 0
and heaters[pointer + offset] == 0
and offset != -r - 1
):
offse... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR VAR BIN_OP VAR NUMBER NUMBER NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING WHILE VAR VAR ASSIGN VAR VAR WHILE BIN_OP VAR VAR VAR BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR NUMBER VAR BIN_OP VAR NUMBER ... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
a = list(map(int, input().split()))
i = 0
x = [0] * n
for i in range(n):
if a[i] == 1:
for j in range(i - r + 1, i + r):
if j > -1 and j < n:
x[j] = max(a[j], i + 1)
ans = 0
i = 0
while i < n:
if x[i] == 0:
ans = -1
break
e... | 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 LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR IF VAR NUMBER VAR VAR ASSIGN VAR V... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
a = list(map(int, input().split()))
b = [True] * n
count = 0
for i in range(n):
if b[i]:
f = -1
for j in range(r):
if j + i == n:
break
if a[i + j] == 1:
f = i + j
if f == -1:
for j in range(... | 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 VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR IF VAR BIN_OP VAR VAR NUMBER ASSIGN VAR B... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
arr = list(map(int, input().split()))
ptr = 0
total = 0
while ptr < n:
good = False
for i in range(min(ptr + r - 1, n - 1), max(ptr - r, -1), -1):
if arr[i] == 1:
good = True
ptr = i + r
total += 1
break
if not good:
... | 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 WHILE VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR VAR NUMBER NUMBER IF... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
ar = [0] * r + list(map(int, input().split())) + [0] * (r + 2)
L = R = -1
f = 0
bn = 5
for i in range(2 * r - 1, r - 1, -1):
if ar[i] == 1:
L = i
break
for i in range(n, n + r):
if ar[i] == 1:
R = i
break
if L == -1 or R == -1:
print("-1")
eli... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP LIST NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER BIN_OP VAR... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = list(map(int, input().split()))
a = list(map(int, input().split()))
res = 0
last_heater_pos = -r
while n - last_heater_pos > r or last_heater_pos < 0:
next_heaters_pos = [
i
for i in range(max(0, last_heater_pos + 1), min(last_heater_pos + 2 * r, n))
if a[i] == 1
]
if next_hea... | 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 VAR WHILE BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER VA... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | def main():
n, r = map(int, input().split())
arr = list(map(int, input().split()))
times = [0] * len(arr)
for i in range(len(arr)):
if arr[i] == 1:
for j in range(max(i - r + 1, 0), min(i + r, len(arr))):
times[j] += 1
for v in times:
if v == 0:
... | 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 BIN_OP LIST NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER FUNC_CALL... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, k = map(int, input().split())
lis = list(map(int, input().split()))
ans = [0] * (n + 2)
cou = 0
for i in range(n):
if lis[i] == 1:
cou += 1
l = max(0, i - k + 1)
r = min(n - 1, i + k - 1)
for j in range(l, r + 1):
ans[j] += 1
if min(ans[:n]) == 0:
print("-1")
e... | 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 NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUN... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = list(map(int, input().split()))
mas = list(map(int, input().split()))
masn = [(0) for i in range(n)]
for i in range(n):
if mas[i] == 1:
for j in range(max(0, i - r + 1), min(n, i + r)):
masn[j] = i + 1
ind = 0
otv = 0
br = False
while ind < n:
if masn[ind] > 0:
otv += 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 ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER FUNC_CALL VAR VAR BIN_OP V... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
t = list(map(int, input().split()))
arr = [0] * (n + 1)
for i in range(n):
if t[i] == 1:
arr[max(i - r + 1, 0)] += 1
arr[min(n, i + r)] -= 1
for j in range(1, n + 1):
arr[j] += arr[j - 1]
if 0 in arr[:n]:
print(-1)
else:
ans = 0
for i in range(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 BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER NUMBER VAR FUNC_CALL VAR VAR BIN_OP VAR VAR NUMBER... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split())
arr = list(map(int, input().split()))
arr1 = [0] * n
for i in range(n):
if arr[i] == 1:
for j in range(i, max(i - r, -1), -1):
arr1[j] += 1
for j in range(i + 1, min(i + r, n)):
arr1[j] += 1
if 0 in arr1:
print(-1)
else:
count = arr.co... | 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 VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER NUMBER VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR N... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
p = -1
ans = 0
while p < n - 1:
found = False
for i in range(n - 1, -1, -1):
if a[i] == 1 and i - r + 1 <= p + 1 and i + r - 1 > p:
found = True
p = i + r - 1
break
if not found:
br... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = (int(i) for i in input().split())
count = 0
arr = []
br = 0
for i in input().split():
arr.append([0, int(i)])
for i in range(n):
cur = arr[i]
if cur[0] == 0:
maxind = -1
for j in range(max(i - r, 0), min(i + r, n)):
if arr[j][1] == 1:
maxind = j
if ... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | def mini(arr, n, k):
lo = [(0) for i in range(n + 1)]
o = -1
for i in range(n):
if arr[i] == 1:
o = i
lo[i] = o
a = 0
i = 0
while i < n:
pos = lo[min(i + k - 1, n - 1)]
if pos == -1 or pos + k <= i:
return -1
i = pos + k
a +... | FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER IF VAR NUMBER BIN_OP VAR VAR VAR RE... |
Vova's house is an array consisting of $n$ elements (yeah, this is the first problem, I think, where someone lives in the array). There are heaters in some positions of the array. The $i$-th element of the array is $1$ if there is a heater in the position $i$, otherwise the $i$-th element of the array is $0$.
Each hea... | n, r = list(map(int, input().split()))
a = list(map(int, input().split()))
r -= 1
def f():
prev = [0] * n
last = -1
for i in range(n):
if a[i]:
last = i
prev[i] = last
nb = 0
i = 0
while i < n:
j = prev[min(i + r, n - 1)]
if j < 0 or j + r < 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 VAR NUMBER FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHI... |
Ivan is playing a strange game.
He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:
Initially Ivan's score i... | n, m, k = [int(i) for i in input().split()]
s = []
o = 0
for i in range(m):
s.append([])
for i in range(n):
l = [int(i) for i in input().split(" ")]
for i in range(m):
s[i].append(l[i])
result = 0
c = 0
for x in s:
count = 0
for i in range(n - k + 1):
count = max(count, sum(x[i : i +... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN... |
Ivan is playing a strange game.
He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:
Initially Ivan's score i... | def find(li, k):
li = li
mm = len(li)
x, y, c, an = 0, 0, 0, 0
while x < mm and y < mm:
while y < mm and li[y] - li[x] < k:
y += 1
if y - x > an:
an = y - x
c = x
x += 1
return [an, c]
n, m, k = map(int, input().split())
lis = []
fin = an... | FUNC_DEF ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER WHILE VAR VAR VAR VAR WHILE VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR NUMBER RETURN LIST VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL F... |
Ivan is playing a strange game.
He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:
Initially Ivan's score i... | n, m, k = [int(x) for x in input().split()]
matrix = []
for _ in range(n):
matrix.append([int(x) for x in input().split()])
sum_score = 0
sum_remove = 0
for i in range(m):
num_of_ones = [0]
num1 = 0
for j in range(n):
if matrix[j][i] == 1:
num1 += 1
num_of_ones.append(num1)
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMB... |
Ivan is playing a strange game.
He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:
Initially Ivan's score i... | n, m, k = [int(i) for i in input().split()]
a = []
for i in range(n):
b = [int(i) for i in input().split()]
a.append(b)
b = [0] * m
for i in range(k + 2):
a.append(b)
score = 0
repl = 0
for j in range(m):
cur_sum = 0
cur_max = 0
cur_best_repl = 0
cur_repl = 0
for i in range(k):
c... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ... |
Ivan is playing a strange game.
He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:
Initially Ivan's score i... | n, m, k = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
out = 0
mxout = 0
x = 0
for j in range(m):
kol = 0
mx = -1
for i in range(n):
if a[i][j] == 1:
t = 0
for l in range(i, min(i + k, n)):
if a[l][j] == 1:
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER ASSIGN... |
Ivan is playing a strange game.
He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:
Initially Ivan's score i... | n, m, k = map(int, input().split())
q = [map(int, input().split()) for i in range(n)]
x, y = 0, 0
for i in zip(*q):
z, f = 0, 0
for j in range(n - k + 1):
g, h = sum(i[j : j + k]), sum(i[:j])
if g > z:
z = g
f = h
x += z
y += f
print(x, y) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR V... |
Ivan is playing a strange game.
He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:
Initially Ivan's score i... | n, m, k = map(int, input().split())
a = [[] for i in range(m)]
for i in range(n):
s = list(map(int, input().split()))
for i in range(m):
a[i].append(s[i])
s, t = 0, 0
for i in a:
p, q, r = 0, 0, -1
l = [(0) for y in range(n)]
for j in range(n):
if i[j] == 1:
for e in rang... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR ASSIGN VAR VAR VAR NUMBER NUMB... |
Ivan is playing a strange game.
He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:
Initially Ivan's score i... | def main():
n, m, k = [int(x) for x in input().split()]
matr = []
for i in range(n):
matr.append(input().split())
matr = list(zip(*matr))
score = 0
repl = 0
for i in range(m):
window = count1(matr[i][:k])
row_scores = []
for j in range(k, n + k):
i... | FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR LIST FOR... |
Ivan is playing a strange game.
He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:
Initially Ivan's score i... | n, m, k = map(int, input().split())
a = []
for i in range(n):
a.append(list(map(int, input().split())))
ans = 0
ans1 = 0
for j in range(m):
mv = 0
td = 0
cc = 0
no = 0
for i in range(n):
if a[i][j]:
v = 0
for z in range(i, min(i + k, n)):
v += a[z]... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR ... |
Ivan is playing a strange game.
He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:
Initially Ivan's score i... | n, m, k = map(int, input().split())
arr = []
for _ in range(n):
arr.append(list(map(int, input().split())))
delete = ans = 0
for i in range(m):
mx = 0
ind = -1
j = 0
while j < n:
if arr[j][i] == 1:
cur = 0
q = 0
while j + q < n and q < k:
c... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR NUMBER ASSI... |
Ivan is playing a strange game.
He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:
Initially Ivan's score i... | n, m, k = map(int, input().split())
l = []
for i in range(n):
l.append(list(map(int, input().split())))
l = map(list, zip(*l))
score, chx = 0, 0
for row in l:
sumx = sum(row[:k])
val, idx = sumx, 0
for i, j in enumerate(row[k:]):
sumx += j - row[i]
if sumx > val:
val = sumx
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR NU... |
Ivan is playing a strange game.
He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:
Initially Ivan's score i... | def main():
rows, cols, k = map(int, input().split())
mat = [[(0) for j in range(cols)] for i in range(rows)]
is_one = [[(False) for j in range(cols)] for i in range(rows)]
for i in range(rows):
vals = list(map(int, input().split()))
for j in range(cols):
is_one[i][j] = vals[... | FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN ... |
Ivan is playing a strange game.
He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:
Initially Ivan's score i... | n, m, k = [int(x) for x in input().split()]
mat = []
r = 0
ps = 0
for i in range(n):
mat.append([int(x) for x in input().split()])
matrix = [[mat[i][j] for i in range(n)] for j in range(m)]
for i in range(m):
tm = 0
s = 0
for j in range(n):
if matrix[i][j] == 1:
end = j + k - 1 if j ... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER A... |
Ivan is playing a strange game.
He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:
Initially Ivan's score i... | nmk = list(map(int, input().split()))
n = nmk[0]
m = nmk[1]
k = nmk[2]
a = []
for i in range(n):
a.append(list(map(int, input().split())))
sum = 0
z = 0
for i in range(m):
sums = [a[0][i]]
for j in range(1, n):
sums.append(sums[-1] + a[j][i])
max_sum = 0
max_ones = 0
cur_ones = 0
for... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN V... |
Ivan is playing a strange game.
He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:
Initially Ivan's score i... | n, m, k = map(int, input().split())
k -= 1
arr = [[] for _ in range(n)]
for i in range(n):
arr[i] = list(map(int, input().split()))
prefix = [([0] * m) for _ in range(n)]
for i in range(m):
for j in range(n):
if not j:
prefix[j][i] = arr[j][i]
else:
prefix[j][i] = arr[j][... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VA... |
Ivan is playing a strange game.
He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:
Initially Ivan's score i... | n, m, k = map(int, input().split())
s = list()
for i in range(1, n + 1):
zc = list(map(int, input().split()))
s.append(zc)
sum = cs = 0
for j in range(0, m):
a = b = 0
for i in range(0, n):
if s[i][j] == 1:
for l in range(i, i + min(k, n - i)):
if s[l][j] == 1:
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VA... |
Ivan is playing a strange game.
He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:
Initially Ivan's score i... | n, m, k = [int(i) for i in input().split()]
l = []
for i in range(n):
l.append([int(j) for j in input().split()])
changes = 0
score = 0
for j in range(m):
max = 0
c1 = 0
for i in range(n):
l1 = []
if i <= n - k:
for z in range(k):
l1.append(l[i + z][j])
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST IF VAR B... |
Ivan is playing a strange game.
He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:
Initially Ivan's score i... | y, x, k = map(int, input().split())
h = [[int(i) for i in input().split()] for j in range(y)]
q, w = 0, 0
for i in range(x):
a = 0
s = 0
for j in range(y):
if h[j][i]:
g = sum([h[lp][i] for lp in range(j, min(j + k, y))])
if g > a:
s = sum([h[lp][i] for lp in ... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CA... |
Ivan is playing a strange game.
He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:
Initially Ivan's score i... | n, m, k = input().split()
n = int(n)
m = int(m)
k = int(k)
array = []
for x in range(n):
a = input().split()
fin = []
for i in a:
fin.append(int(i))
array.append(fin)
cumm = [[(0) for x in range(m)] for y in range(n)]
i = 0
while i < m:
j = n - 1
while j >= 0:
if j == n - 1:
... | 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 LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUN... |
Ivan is playing a strange game.
He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:
Initially Ivan's score i... | n, m, k = map(int, input().split())
a = []
b = []
score = []
ct = 0
for i in range(n):
a.append([int(x) for x in input().split()])
for i in range(m):
b.append([])
for i in range(m):
for j in range(n):
b[i].append(a[j][i])
for i in range(m):
maxsums = []
for j in range(n):
if b[i][j] ... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ... |
Ivan is playing a strange game.
He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:
Initially Ivan's score i... | n, m, k = map(int, input().split())
a = []
for i in range(n):
a.append(list(map(int, input().split())))
v = []
for i in range(m):
v.append([])
x = 0
for j in range(n):
if a[j][i] == 1:
s = 0
for o in range(min(k, n - j)):
s += a[j + o][i]
v[i].... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR... |
Ivan is playing a strange game.
He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:
Initially Ivan's score i... | import sys
n, m, k = map(int, input().split())
matrix = [[0] * m] + [list(map(int, input().split())) for _ in range(n)]
for j in range(m):
for i in range(1, n + 1):
matrix[i][j] += matrix[i - 1][j]
ans = [0, 0]
for j in range(m):
max_one, rem = 0, 0
for i in range(k, n + 1):
if max_one < ma... | IMPORT ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST BIN_OP LIST NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR LIST N... |
Ivan is playing a strange game.
He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:
Initially Ivan's score i... | n, m, k = [int(p) for p in input().split()]
matrix = []
for i in range(n):
matrix.append([int(p) for p in input().split()])
def best(col):
results = {}
for row in range(n):
if matrix[row][col] == 1:
results[row] = 1
for r2 in range(row + 1, min(row + k, n)):
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR... |
Ivan is playing a strange game.
He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:
Initially Ivan's score i... | n, m, k = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]
acc = [[0] for _ in range(m)]
for i in range(m):
for j in range(n):
acc[i].append(acc[i][-1] + (1 if a[j][i] == 1 else 0))
ans_0 = 0
ans_1 = 0
for i in range(m):
if acc[i][n] - acc[i][0] == 0:
continue
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR VAR NUMBER VAR VAR VAR NUMBER NUMBER NU... |
Ivan is playing a strange game.
He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:
Initially Ivan's score i... | while True:
try:
def read():
n, m, k = map(int, input().split())
mtrx = []
for i in range(n):
mtrx.append(list(map(int, input().split())))
solve(n, m, k, mtrx)
def solve(n, m, k, mtrx):
ans = rplc = cunt = 0
i,... | WHILE NUMBER FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR FUNC_DEF ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER WHILE VAR VAR ASSIGN ... |
Ivan is playing a strange game.
He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:
Initially Ivan's score i... | n, m, k = [int(x) for x in input().split()]
a = []
for i in range(m):
a.append([0] * n)
for i in range(n):
t = input().split()
for j in range(m):
a[j][i] = int(t[j])
maxs = 0
r = 0
for i in a:
maxframe = 0
mfp = -1
for j in range(n - k + 1):
if sum(i[j : j + k]) > maxframe:
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR... |
Ivan is playing a strange game.
He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:
Initially Ivan's score i... | m, n, k = list(map(int, input().split()))
a = []
res = [(0) for a in range(n)]
c = [(0) for a in range(n)]
for i in range(n + 1):
a.append([])
for i in range(m):
s = input()
for p in range(n):
a[p].append(int(s[p * 2]))
for i in range(n):
for j in range(m):
if a[i][j] == 1:
r... | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUN... |
Ivan is playing a strange game.
He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:
Initially Ivan's score i... | f = lambda: map(int, input().split())
n, m, k = f()
s = d = 0
for t in zip(*[f() for i in range(n)]):
p, q = x, y = sum(t[:k]), 0
for j in range(n - k):
p += t[j + k] - t[j]
q += t[j]
if p > x:
x, y = p, q
s += x
d += y
print(s, d) | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR VAR VAR VAR VAR IF VAR VAR ASSI... |
Ivan is playing a strange game.
He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:
Initially Ivan's score i... | n, m, k = map(int, input().split())
mat = []
for i in range(n):
mat.append([int(i) for i in input().split()])
ind = [-1] * m
sm = 0
for j in range(m):
curr = 0
maxi = 0
for i in range(0, k):
curr += mat[i][j]
if curr > maxi:
maxi = curr
ind[j] = 0
for i in range(k, n):
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR V... |
Ivan is playing a strange game.
He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:
Initially Ivan's score i... | h, w, k = map(int, input().split())
d = [[int(x) for x in input().split()] for _ in range(h)]
d = [[x for x in line] for line in zip(*d)]
totalScore = 0
totalCost = 0
for line in d:
max = 0
cost = 0
cur = 0
curCost = 0
for c1, c2 in zip(line, [0] * k + line):
cur += c1
cur -= c2
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUN... |
Ivan is playing a strange game.
He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:
Initially Ivan's score i... | n, m, k = map(int, input().split())
a = [[] for i in range(m)]
for i in range(n):
b = [int(x) for x in input().split()]
for j in range(m):
a[j].append(b[j])
s = 0
p = 0
for i in range(m):
a[i].append(0)
for i in a:
d = 0
ma = 0
ans = 0
cur = sum(i[: k - 1])
for j in range(k - 1, ... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ... |
Ivan is playing a strange game.
He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:
Initially Ivan's score i... | def cal(col, index, k):
one = 0
for i in range(index, len(col)):
if col[i] == 1:
for j in range(i, min(len(col), i + k)):
if col[j] == 1:
one += 1
break
return one
def solve(col, k):
change = 0
score = 0
n = len(col)
for i... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR VAR IF VAR VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ... |
Ivan is playing a strange game.
He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:
Initially Ivan's score i... | n, m, k = map(int, input().split())
sums = [[] for i in range(m)]
for i in range(n):
str = input().split()
for j in range(m):
if i == 0:
sums[j].append(int(str[j]))
else:
sums[j].append(sums[j][i - 1] + int(str[j]))
ans1 = 0
ans2 = 0
for j in range(m):
cans1 = 0
c... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR V... |
Ivan is playing a strange game.
He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:
Initially Ivan's score i... | from sys import stdin, stdout
n, m, k = map(int, stdin.readline().split())
values = []
for i in range(n):
values.append(list(map(int, stdin.readline().split())))
strings = []
for j in range(m):
counting = []
for i in range(n):
counting.append(values[i][j])
strings.append(counting)
ans, cnt = 0,... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSI... |
Ivan is playing a strange game.
He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:
Initially Ivan's score i... | def best_for_column(matrix, col) -> (int, int):
result_by_row = {}
for row in range(n):
if matrix[row][col] == 1:
result_by_row[row] = 1
upper_bound = min(row + k, n)
for r2 in range(row + 1, upper_bound):
if matrix[r2][col] == 1:
r... | FUNC_DEF ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NONE FOR VAR VAR IF VAR NONE VAR STR... |
Ivan is playing a strange game.
He has a matrix a with n rows and m columns. Each element of the matrix is equal to either 0 or 1. Rows and columns are 1-indexed. Ivan can replace any number of ones in this matrix with zeroes. After that, his score in the game will be calculated as follows:
Initially Ivan's score i... | n, m, k = map(int, input().split())
x, y = 0, 0
a = []
for i in range(n):
a.append(list(map(int, input().split())))
for i in zip(*a):
u, v = 0, 0
for j in range(n - k + 1):
p, q = sum(i[j : j + k]), sum(i[:j])
if p > u:
u = p
v = q
x += u
y += v
print(x, y) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN ... |
There are n stones arranged on an axis. Initially the i-th stone is located at the coordinate s_i. There may be more than one stone in a single place.
You can perform zero or more operations of the following type:
* take two stones with indices i and j so that s_i β€ s_j, choose an integer d (0 β€ 2 β
d β€ s_j - s_i)... | n = int(input())
s = sorted((v, i + 1) for i, v in enumerate(map(int, input().split())))
t = sorted(map(int, input().split()))
r = []
q = []
err = False
for x, y in zip(s, t):
d = x[0] - y
if d < 0:
q.append([-d, x[1]])
else:
while d > 0:
if not q:
err = True
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER 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 LIST ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP V... |
There are n stones arranged on an axis. Initially the i-th stone is located at the coordinate s_i. There may be more than one stone in a single place.
You can perform zero or more operations of the following type:
* take two stones with indices i and j so that s_i β€ s_j, choose an integer d (0 β€ 2 β
d β€ s_j - s_i)... | n = int(input())
s = list(map(int, input().split()))
t = list(map(int, input().split()))
if sum(s) != sum(t):
print("NO")
else:
s = [(s[i], i + 1) for i in range(n)]
s.sort()
t.sort()
diff = [0] * n
for i in range(n):
if s[i][0] == t[i]:
diff[i] = 0
elif s[i][0] < t[i... | 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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR... |
There are n stones arranged on an axis. Initially the i-th stone is located at the coordinate s_i. There may be more than one stone in a single place.
You can perform zero or more operations of the following type:
* take two stones with indices i and j so that s_i β€ s_j, choose an integer d (0 β€ 2 β
d β€ s_j - s_i)... | import sys
class cell:
def __init__(self, val, idx):
self.idx = idx
self.val = val
inp = [int(x) for x in sys.stdin.read().split()]
n = inp[0]
inp_idx = 1
s = [cell(inp[idx], idx) for idx in range(1, n + 1)]
t = [inp[idx] for idx in range(n + 1, n + n + 1)]
s.sort(key=lambda x: x.val)
t.sort()
... | IMPORT CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER EXP... |
There are n stones arranged on an axis. Initially the i-th stone is located at the coordinate s_i. There may be more than one stone in a single place.
You can perform zero or more operations of the following type:
* take two stones with indices i and j so that s_i β€ s_j, choose an integer d (0 β€ 2 β
d β€ s_j - s_i)... | input()
s = [(int(x), i) for i, x in enumerate(input().split())]
t = [int(x) for x in input().split()]
s.sort()
t.sort()
def no():
print("NO")
raise SystemExit(0)
end = 1
ans = []
for si, ti in zip(s, t):
si_pos, i = si
if si_pos > ti:
no()
jump = ti - si_pos
while jump:
for ... | EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR STRING FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR VAR ASS... |
Vasya plays the Geometry Horse.
The game goal is to destroy geometric figures of the game world. A certain number of points is given for destroying each figure depending on the figure type and the current factor value.
There are n types of geometric figures. The number of figures of type ki and figure cost ci is kno... | n = int(input())
a = [list(map(int, input().split()))[::-1] for i in range(n)]
t = int(input())
p = list(map(int, input().split()))
b = 0
i = 0
a.sort()
c = 0
for j in range(n):
while i < t and p[i] - b <= a[j][1]:
c += (p[i] - b) * (i + 1) * a[j][0]
a[j][1] -= p[i] - b
b = p[i]
i +=... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VA... |
Vasya plays the Geometry Horse.
The game goal is to destroy geometric figures of the game world. A certain number of points is given for destroying each figure depending on the figure type and the current factor value.
There are n types of geometric figures. The number of figures of type ki and figure cost ci is kno... | n = int(input())
pieces = [input() for _ in range(n)]
pieces = [_.split() for _ in pieces]
pieces = [tuple(_) for _ in pieces]
pieces = [[int(k), int(c)] for k, c in pieces]
t = int(input())
p = input().split()
p = [int(_) for _ in p]
pieces = sorted(pieces, key=lambda x: x[1])
values = []
count = 0
i = 0
j = 0
while i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR V... |
Vasya plays the Geometry Horse.
The game goal is to destroy geometric figures of the game world. A certain number of points is given for destroying each figure depending on the figure type and the current factor value.
There are n types of geometric figures. The number of figures of type ki and figure cost ci is kno... | n = int(input())
fig = [tuple(map(int, input().split()))[::-1] for _ in range(n)]
fig.sort()
t = int(input())
a = list(map(int, input().split()))
res, curr = 0, 0
i, j = 0, 0
while i < n:
if j < t and curr + fig[i][1] >= a[j]:
take = a[j] - curr
curr += take
fig[i] = fig[i][0], fig[i][1] - t... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER WH... |
Vasya plays the Geometry Horse.
The game goal is to destroy geometric figures of the game world. A certain number of points is given for destroying each figure depending on the figure type and the current factor value.
There are n types of geometric figures. The number of figures of type ki and figure cost ci is kno... | import sys
def solve():
(n,) = rv()
figures = list()
before = 0
for i in range(n):
number, cost = rv()
figures.append([cost, number, before, before + number])
figures.sort()
for i in range(n):
number = figures[i][1]
figures[i][2] = before
figures[i][3] =... | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR ASSIGN VAR VAR NUMBER BIN_OP VAR ... |
Lena is the most economical girl in Moscow. So, when her dad asks her to buy some food for a trip to the country, she goes to the best store β "PriceFixed". Here are some rules of that store:
The store has an infinite number of items of every product.
All products have the same price: $2$ rubles per item.
For every... | N = int(input())
A = [0] * N
B = [0] * N
for i in range(N):
A[i], B[i] = map(int, input().split())
indices = list(range(N))
indices.sort(key=lambda i: B[i])
low = 0
high = N - 1
bought = 0
cost = 0
while low <= high:
l = indices[low]
h = indices[high]
if bought >= B[l]:
bought += A[l]
co... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIG... |
Lena is the most economical girl in Moscow. So, when her dad asks her to buy some food for a trip to the country, she goes to the best store β "PriceFixed". Here are some rules of that store:
The store has an infinite number of items of every product.
All products have the same price: $2$ rubles per item.
For every... | def solve(n, items):
items.sort(key=lambda x: x[1])
ans = 0
cnt = 0
l = 0
r = n - 1
while l <= r:
if items[l][1] <= cnt:
cnt += items[l][0]
ans += items[l][0]
items[l][0] = 0
l += 1
else:
diff = min(items[l][1] - cnt, it... | FUNC_DEF EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR IF VAR VAR NUMBER VAR VAR VAR VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR VAR VAR NUMBER VAR VAR VAR BIN_OP... |
Lena is the most economical girl in Moscow. So, when her dad asks her to buy some food for a trip to the country, she goes to the best store β "PriceFixed". Here are some rules of that store:
The store has an infinite number of items of every product.
All products have the same price: $2$ rubles per item.
For every... | n = int(input())
s = 0
x = []
for _ in range(n):
a, b = map(int, input().split())
s += a
x.append([a, b])
x.sort(key=lambda x: x[1])
cnt = 0
cur = 0
for a, b in x:
if cur < b:
cur = b
if b >= s:
break
if s - cur >= a:
cnt += a
cur += a
else:
cnt += s -... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR IF VAR VAR IF BI... |
Lena is the most economical girl in Moscow. So, when her dad asks her to buy some food for a trip to the country, she goes to the best store β "PriceFixed". Here are some rules of that store:
The store has an infinite number of items of every product.
All products have the same price: $2$ rubles per item.
For every... | n = int(input())
items = []
for i in range(n):
a, b = map(int, input().split())
items.append([b, a])
items.sort()
head = 0
tail = len(items) - 1
count = 0
pay = 0
while head != tail:
head_need, head_left = items[head]
tail_need, tail_left = items[tail]
if count >= head_need:
count += head_le... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR VAR V... |
Lena is the most economical girl in Moscow. So, when her dad asks her to buy some food for a trip to the country, she goes to the best store β "PriceFixed". Here are some rules of that store:
The store has an infinite number of items of every product.
All products have the same price: $2$ rubles per item.
For every... | n = int(input())
lis = []
for i in range(n):
a, b = map(int, input().split())
lis.append([b, a])
lis.sort()
i = 0
j = n - 1
p_c = 0
price = 0
while i < j:
if lis[i][0] <= p_c:
price += lis[i][1]
p_c += lis[i][1]
i += 1
else:
pick = min(lis[j][1], lis[i][0] - p_c)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR NUMBER VAR VAR VAR VAR ... |
Lena is the most economical girl in Moscow. So, when her dad asks her to buy some food for a trip to the country, she goes to the best store β "PriceFixed". Here are some rules of that store:
The store has an infinite number of items of every product.
All products have the same price: $2$ rubles per item.
For every... | from sys import stdin
input = stdin.readline
def f(ar):
ar = sorted(ar, reverse=True, key=lambda s: s[1])
cost, cs, lo = 0, 0, 0
hi = len(ar) - 1
while lo <= hi:
if ar[hi][1] <= cs:
cost += ar[hi][0]
cs += ar[hi][0]
hi -= 1
elif ar[hi][1] - cs <= ar... | ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR IF VAR VAR NUMBER VAR VAR VAR VAR NUMBER VAR VAR VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR NUMBER VAR VAR VAR NUMBER VAR VAR NUMBER BIN_OP VAR VAR NUMBER ... |
Lena is the most economical girl in Moscow. So, when her dad asks her to buy some food for a trip to the country, she goes to the best store β "PriceFixed". Here are some rules of that store:
The store has an infinite number of items of every product.
All products have the same price: $2$ rubles per item.
For every... | n = int(input())
T = []
for _ in range(n):
a, b = map(int, input().split(" "))
T.append([a, b])
T.sort(key=lambda e: e[1])
price = 0
total = 0
l, r = 0, len(T) - 1
while l < r:
a, b = T[l]
if total >= b:
price += a
total += a
T[l][0] = 0
l += 1
else:
d = b - t... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR ASSIGN VA... |
Lena is the most economical girl in Moscow. So, when her dad asks her to buy some food for a trip to the country, she goes to the best store β "PriceFixed". Here are some rules of that store:
The store has an infinite number of items of every product.
All products have the same price: $2$ rubles per item.
For every... | n = int(input())
a = []
for i in range(n):
q, w = [int(i) for i in input().split()]
a.append([q, w])
a.sort(key=lambda x: x[1])
s = 0
for i in range(n):
s += a[i][0]
M = 0
N = 0
i = 0
while M + N < s:
if M + N < a[i][1]:
N += min(a[i][1] - N - M, s - N - M)
if M + N < s - a[i][0]:
M ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER... |
Lena is the most economical girl in Moscow. So, when her dad asks her to buy some food for a trip to the country, she goes to the best store β "PriceFixed". Here are some rules of that store:
The store has an infinite number of items of every product.
All products have the same price: $2$ rubles per item.
For every... | N = int(input())
A = [0] * N
for i in range(N):
A[i] = list(map(int, input().split()))
A.sort(key=lambda a: a[1])
low = 0
high = N - 1
bought = 0
cost = 0
while low <= high:
if bought >= A[low][1]:
bought += A[low][0]
cost += A[low][0]
A[low][0] = 0
low += 1
elif A[low][1] - ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR NUMBER V... |
Lena is the most economical girl in Moscow. So, when her dad asks her to buy some food for a trip to the country, she goes to the best store β "PriceFixed". Here are some rules of that store:
The store has an infinite number of items of every product.
All products have the same price: $2$ rubles per item.
For every... | arr = []
ans = 0
for _ in range(int(input())):
a, b = map(int, input().split())
arr.append([a, b])
arr.sort(key=lambda a: a[1])
start = 0
end = len(arr) - 1
curr = 0
ans = 0
while start <= end:
if arr[start][1] > curr:
temp = min(arr[start][1] - curr, arr[end][0])
curr += temp
ans +=... | ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR... |
Lena is the most economical girl in Moscow. So, when her dad asks her to buy some food for a trip to the country, she goes to the best store β "PriceFixed". Here are some rules of that store:
The store has an infinite number of items of every product.
All products have the same price: $2$ rubles per item.
For every... | import sys
def inpu():
return sys.stdin.readline()
lets = "abcdefghijklmnopqrstuvwxyz"
key = {lets[i]: i for i in range(26)}
n = int(input())
done = False
a = [0] * n
b = [0] * n
bb = 0
for i in range(n):
b[i], a[i] = map(int, input().split())
bb += b[i]
k = sorted(range(n), key=lambda i: a[i], reverse=... | IMPORT FUNC_DEF RETURN FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CA... |
Lena is the most economical girl in Moscow. So, when her dad asks her to buy some food for a trip to the country, she goes to the best store β "PriceFixed". Here are some rules of that store:
The store has an infinite number of items of every product.
All products have the same price: $2$ rubles per item.
For every... | n = int(input())
li = []
for i in range(n):
a, b = map(int, input().split())
temp = [b, a]
li.append(temp)
li.sort()
a = 0
b = n - 1
cost = 0
count = 0
while a <= b:
if count >= li[a][0]:
count += li[a][1]
cost += li[a][1]
a += 1
else:
c = li[a][0] - count
if ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR NUMB... |
Lena is the most economical girl in Moscow. So, when her dad asks her to buy some food for a trip to the country, she goes to the best store β "PriceFixed". Here are some rules of that store:
The store has an infinite number of items of every product.
All products have the same price: $2$ rubles per item.
For every... | n = int(input())
dp = []
cnt1 = 0
cnt2 = 0
for i in range(n):
a, b = list(map(int, input().split()))
dp.append((b, a))
cnt2 += a
dp.sort()
dp = dp[::-1]
for i in range(n):
cnt1 += min(cnt2 - cnt1 - min(dp[i][0], cnt2), dp[i][1])
print(cnt2 * 2 - cnt1) | 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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP BIN_O... |
Lena is the most economical girl in Moscow. So, when her dad asks her to buy some food for a trip to the country, she goes to the best store β "PriceFixed". Here are some rules of that store:
The store has an infinite number of items of every product.
All products have the same price: $2$ rubles per item.
For every... | import sys
t = int(sys.stdin.readline())
li = []
for _ in range(t):
a, b = map(int, sys.stdin.readline().split())
li.append([a, b])
li.sort(key=lambda x: x[1])
l, r = 0, len(li) - 1
n = 0
ans = 0
while l <= r:
if li[l][1] <= n:
n += li[l][0]
ans += li[l][0]
l += 1
else:
... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VA... |
Lena is the most economical girl in Moscow. So, when her dad asks her to buy some food for a trip to the country, she goes to the best store β "PriceFixed". Here are some rules of that store:
The store has an infinite number of items of every product.
All products have the same price: $2$ rubles per item.
For every... | import sys
input = sys.stdin.readline
I = lambda: list(map(int, input().split()))
(n,) = I()
l = []
for _ in range(n):
l.append(I())
l.sort(key=lambda x: x[1])
an = 0
mx = n - 1
tot = 0
for i in range(n):
a, b = l[i]
if a <= 0:
break
if b <= tot:
an += a
tot += a
continu... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR... |
Lena is the most economical girl in Moscow. So, when her dad asks her to buy some food for a trip to the country, she goes to the best store β "PriceFixed". Here are some rules of that store:
The store has an infinite number of items of every product.
All products have the same price: $2$ rubles per item.
For every... | n = int(input())
items = []
needed = 0
for i in range(n):
x = input().split()
items.append([int(x[1]), int(x[0])])
needed += int(x[0])
items.sort()
l = 0
r = n - 1
total = 0
spent = 0
while total < needed:
if items[l][0] <= total:
cur = items[l][1]
total += cur
spent += cur
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER... |
Lena is the most economical girl in Moscow. So, when her dad asks her to buy some food for a trip to the country, she goes to the best store β "PriceFixed". Here are some rules of that store:
The store has an infinite number of items of every product.
All products have the same price: $2$ rubles per item.
For every... | n = int(input())
product = []
for i in range(n):
product.append(list(map(int, input().split())))
product.sort(key=lambda x: x[1], reverse=True)
sum = 0
i = 0
j = n - 1
answer = 0
while j >= i:
if sum >= product[j][1]:
answer += product[j][0]
sum += product[j][0]
product[j][0] = 0
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR NUMBER VAR VAR ... |
Lena is the most economical girl in Moscow. So, when her dad asks her to buy some food for a trip to the country, she goes to the best store β "PriceFixed". Here are some rules of that store:
The store has an infinite number of items of every product.
All products have the same price: $2$ rubles per item.
For every... | n = int(input())
a, b = [], []
for _ in range(n):
ax, bx = input().split(" ")
a.append(int(ax))
b.append(int(bx))
shopping_list = dict()
for aa, bb in zip(a, b):
if bb in shopping_list:
shopping_list[bb] += aa
else:
shopping_list[bb] = aa
items_bought = 0
cost = 0
ind = sorted(shoppi... | 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 VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VA... |
Lena is the most economical girl in Moscow. So, when her dad asks her to buy some food for a trip to the country, she goes to the best store β "PriceFixed". Here are some rules of that store:
The store has an infinite number of items of every product.
All products have the same price: $2$ rubles per item.
For every... | import sys
input = sys.stdin.readline
prod, ones, twos = (
sorted(
[[int(i) for i in input().split()] for j in range(int(input()))],
key=lambda x: x[1],
),
0,
0,
)
for i in range(len(prod)):
twos += prod[i][0]
for i in range(len(prod) - 1, -1, -1):
left = max(twos - prod[i][1], ... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL ... |
Lena is the most economical girl in Moscow. So, when her dad asks her to buy some food for a trip to the country, she goes to the best store β "PriceFixed". Here are some rules of that store:
The store has an infinite number of items of every product.
All products have the same price: $2$ rubles per item.
For every... | import sys
input = sys.stdin.readline
def solve():
n = int(input())
arr = [list(map(int, input().split())) for _ in range(n)]
arr.sort(key=lambda x: (x[1], x[0]))
j = n - 1
cnt = ans = 0
for i in range(n):
a, b = arr[i]
if cnt >= b:
cnt += a
ans += a
... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR IF VAR VAR VAR VAR V... |
Lena is the most economical girl in Moscow. So, when her dad asks her to buy some food for a trip to the country, she goes to the best store β "PriceFixed". Here are some rules of that store:
The store has an infinite number of items of every product.
All products have the same price: $2$ rubles per item.
For every... | from sys import stdin
n = int(stdin.readline())
lst = list()
for i in range(n):
a, b = map(int, stdin.readline().split())
lst.append([b, a])
lst.sort(key=lambda x: tuple(x))
nzi = n - 1
cur = 0
ans = 0
for i in range(n):
while nzi >= 0 and cur < lst[i][0]:
w = min(lst[i][0] - cur, lst[nzi][1])
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR WHILE VAR NUM... |
Lena is the most economical girl in Moscow. So, when her dad asks her to buy some food for a trip to the country, she goes to the best store β "PriceFixed". Here are some rules of that store:
The store has an infinite number of items of every product.
All products have the same price: $2$ rubles per item.
For every... | from sys import stdin
input = stdin.readline
n = int(input())
c = []
for _ in range(n):
a, b = [int(x) for x in input().split()]
c.append([b, a])
c.sort()
l = 0
r = n - 1
buyed = 0
costs = 0
while l <= r:
needed_for_discount = c[l][0]
needed_to_buy = c[l][1]
if buyed >= needed_for_discount:
... | ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR ... |
Lena is the most economical girl in Moscow. So, when her dad asks her to buy some food for a trip to the country, she goes to the best store β "PriceFixed". Here are some rules of that store:
The store has an infinite number of items of every product.
All products have the same price: $2$ rubles per item.
For every... | n = int(input())
merch = []
for i in range(n):
m = list(map(int, input().split(" ")))
merch.append(m)
merch = sorted(merch, key=lambda x: x[1])
l = 0
r = len(merch) - 1
res = 0
num = 0
while l <= r:
if merch[l][1] <= num:
num += merch[l][0]
res += merch[l][0]
l += 1
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE... |
Lena is the most economical girl in Moscow. So, when her dad asks her to buy some food for a trip to the country, she goes to the best store β "PriceFixed". Here are some rules of that store:
The store has an infinite number of items of every product.
All products have the same price: $2$ rubles per item.
For every... | t = int(input())
a = []
for T in range(t):
b = list(map(int, input().split()))
a.append(b)
h = sorted(a, key=lambda x: x[1])
s = 0
j = 0
i = len(h) - 1
cost = 0
while j <= i:
k = h[i][0]
if k + s < h[j][1]:
s = s + k
i = i - 1
cost = cost + 2 * k
elif k + s == h[j][1]:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VA... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.