description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
A string is binary, if it consists only of characters "0" and "1".
String v is a substring of string w if it has a non-zero length and can be read starting from some position in string w. For example, string "010" has six substrings: "0", "1", "0", "01", "10", "010". Two substrings are considered different if their po... | k = int(input())
s = input()
c = 0
d = {}
res = 0
d[0] = 1
for i in s:
if i == "1":
c += 1
res += d.get(c - k, 0)
d[c] = d.get(c, 0) + 1
print(res) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR |
A string is binary, if it consists only of characters "0" and "1".
String v is a substring of string w if it has a non-zero length and can be read starting from some position in string w. For example, string "010" has six substrings: "0", "1", "0", "01", "10", "010". Two substrings are considered different if their po... | k = int(input())
l = input()
if k == 0:
c = 0
ans = 0
for i in range(len(l)):
if l[i] == "0":
c += 1
else:
temp = c * (c + 1) // 2
ans += temp
c = 0
ans += c * (c + 1) // 2
print(ans)
else:
ans = 0
ar = []
a = -1
for i i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR VAR ASSIGN VAR NUMBER VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_... |
A string is binary, if it consists only of characters "0" and "1".
String v is a substring of string w if it has a non-zero length and can be read starting from some position in string w. For example, string "010" has six substrings: "0", "1", "0", "01", "10", "010". Two substrings are considered different if their po... | k = int(input())
string = input().strip()
dp = [(0) for a in range(0, len(string))]
if string[0] == "0":
dp[0] = 0
else:
dp[0] = 1
for a in range(1, len(string)):
if string[a] == "0":
dp[a] = dp[a - 1]
else:
dp[a] = dp[a - 1] + 1
hashmap = [(0) for a in range(0, max(dp) + 1)]
for a in ra... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR NUMBER STRING ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR V... |
A string is binary, if it consists only of characters "0" and "1".
String v is a substring of string w if it has a non-zero length and can be read starting from some position in string w. For example, string "010" has six substrings: "0", "1", "0", "01", "10", "010". Two substrings are considered different if their po... | k = int(input())
s = input().strip()
s = list(s)
dp = [(0) for i in range(len(s))]
cnt = 0
for i in range(len(s)):
if s[i] == "1":
cnt += 1
dp[i] = cnt
ans = 0
m = {}
lb = 0
for i in range(len(s)):
if dp[i] >= k:
lb = i
break
m[dp[i]] = m.get(dp[i], 0) + 1
for i in range(lb, len(... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR DICT ASSIGN VAR NUMBER FOR V... |
A string is binary, if it consists only of characters "0" and "1".
String v is a substring of string w if it has a non-zero length and can be read starting from some position in string w. For example, string "010" has six substrings: "0", "1", "0", "01", "10", "010". Two substrings are considered different if their po... | from itertools import accumulate
k = int(input())
pre_sum = list(accumulate([int(i) for i in input()]))
seen = {(0): 1}
ans = 0
for i in pre_sum:
a = i - k
if a in seen:
ans += seen[a]
if i in seen:
seen[i] += 1
else:
seen[i] = 1
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR DICT NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR VAR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
A string is binary, if it consists only of characters "0" and "1".
String v is a substring of string w if it has a non-zero length and can be read starting from some position in string w. For example, string "010" has six substrings: "0", "1", "0", "01", "10", "010". Two substrings are considered different if their po... | k = int(input())
s = input()
t = list(map(len, s.split("1")))
ans = 0
if k >= len(t):
ans = 0
elif k == 0:
for i in t:
ans += i * (i + 1) // 2
else:
for i in range(len(t) - k):
ans += (t[i] + 1) * (t[k + i] + 1)
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER FOR VAR VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR VAR BIN... |
A string is binary, if it consists only of characters "0" and "1".
String v is a substring of string w if it has a non-zero length and can be read starting from some position in string w. For example, string "010" has six substrings: "0", "1", "0", "01", "10", "010". Two substrings are considered different if their po... | k = int(input())
l = [0] * (k + 1)
l[0] = 1
s = input()
u = 1
if s.count("1") < k:
print(0)
exit()
else:
x = []
z, y = 0, 0
ans = 0
t = 0
g = 0
r = 0
for i in s:
if i == "0":
z += 1
if r == 1:
ans += 1
if i == "1" and k != 0:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF FUNC_CALL VAR STRING VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR ... |
A string is binary, if it consists only of characters "0" and "1".
String v is a substring of string w if it has a non-zero length and can be read starting from some position in string w. For example, string "010" has six substrings: "0", "1", "0", "01", "10", "010". Two substrings are considered different if their po... | k = int(input())
s = input()
n = len(s)
one_idx = []
for i in range(n):
if s[i] == "1":
one_idx.append(i)
m = len(one_idx)
if k == 0:
if one_idx:
sol = one_idx[0] * (one_idx[0] + 1) // 2
for i in range(m - 1):
zero_len = one_idx[i + 1] - one_idx[i] - 1
sol += zero... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_... |
A string is binary, if it consists only of characters "0" and "1".
String v is a substring of string w if it has a non-zero length and can be read starting from some position in string w. For example, string "010" has six substrings: "0", "1", "0", "01", "10", "010". Two substrings are considered different if their po... | def fun(s):
aa = c = 0
for i in range(len(s)):
if s[i] == "0":
c += 1
else:
aa += c * (c + 1) // 2
c = 0
aa += c * (c + 1) // 2
return aa
def check(mid):
one = pre[mid] - pre[i - 1]
return one > k
def check1(r):
return pre[r] - pre[i - ... | FUNC_DEF ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER RETURN VAR FUNC_DEF ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER RETURN VAR VAR FUNC_DEF RETURN BIN_OP VA... |
A string is binary, if it consists only of characters "0" and "1".
String v is a substring of string w if it has a non-zero length and can be read starting from some position in string w. For example, string "010" has six substrings: "0", "1", "0", "01", "10", "010". Two substrings are considered different if their po... | n = int(input())
s = input()
i, j, pre, aft = 0, 0, 0, 0
num, ans = 0, 0
while i < len(s) and s[i] != "1":
i += 1
pre += 1
j = i
while num != n and j < len(s):
if s[j] == "1":
num += 1
j += 1
while j < len(s) and s[j] != "1":
j += 1
aft += 1
if i != j:
ans += (pre + 1) * (aft + 1)
el... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER WHILE VAR FUNC_CALL ... |
A string is binary, if it consists only of characters "0" and "1".
String v is a substring of string w if it has a non-zero length and can be read starting from some position in string w. For example, string "010" has six substrings: "0", "1", "0", "01", "10", "010". Two substrings are considered different if their po... | k = int(input())
s = input()
ones = [i for i in range(len(s)) if s[i] == "1"]
start = 0
end = k - 1
ans = 0
if k == 0:
ones.insert(0, -1)
ones.append(len(s))
for i in range(1, len(ones)):
n = ones[i] - ones[i - 1] - 1
ans += n * (n + 1) // 2
else:
while end < len(ones):
left = 0
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR STRING ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VA... |
A string is binary, if it consists only of characters "0" and "1".
String v is a substring of string w if it has a non-zero length and can be read starting from some position in string w. For example, string "010" has six substrings: "0", "1", "0", "01", "10", "010". Two substrings are considered different if their po... | k = int(input())
cnt = 0
current = 0
d = {(0): 1}
for char in input():
current += int(char)
cnt += d.get(current - k, 0)
d[current] = 1 + d.get(current, 0)
print(cnt) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR DICT NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR VAR BIN_OP NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
A string is binary, if it consists only of characters "0" and "1".
String v is a substring of string w if it has a non-zero length and can be read starting from some position in string w. For example, string "010" has six substrings: "0", "1", "0", "01", "10", "010". Two substrings are considered different if their po... | import sys
def sumofn(n):
if n % 2 == 0:
return (n + 1) * (n // 2)
else:
return n * (n // 2) + n
def answer(k, s):
n1 = s.count("1")
if k > n1:
return 0
addr = [-1]
for i, char in enumerate(s):
if char == "1":
addr.append(i)
addr.append(len(s))... | IMPORT FUNC_DEF IF BIN_OP VAR NUMBER NUMBER RETURN BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING IF VAR VAR RETURN NUMBER ASSIGN VAR LIST NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC... |
A string is binary, if it consists only of characters "0" and "1".
String v is a substring of string w if it has a non-zero length and can be read starting from some position in string w. For example, string "010" has six substrings: "0", "1", "0", "01", "10", "010". Two substrings are considered different if their po... | k = int(input())
s = input()
n = len(s)
dp = [0] * n
cnt = 0
for i in range(n):
cnt += int(s[i])
dp[i] = cnt
d = {(0): 1}
ans = 0
for i in dp:
a = i - k
ans += d.get(a, 0)
d[i] = d.get(i, 0) + 1
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR DICT NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR FUNC_CALL VAR ... |
A string is binary, if it consists only of characters "0" and "1".
String v is a substring of string w if it has a non-zero length and can be read starting from some position in string w. For example, string "010" has six substrings: "0", "1", "0", "01", "10", "010". Two substrings are considered different if their po... | k = int(input())
d, c, r = {(0): 1}, 0, 0
for x in input():
c += x == "1"
r += d.get(c - k, 0)
d[c] = d.get(c, 0) + 1
print(r) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR DICT NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR STRING VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR |
A string is binary, if it consists only of characters "0" and "1".
String v is a substring of string w if it has a non-zero length and can be read starting from some position in string w. For example, string "010" has six substrings: "0", "1", "0", "01", "10", "010". Two substrings are considered different if their po... | def main():
k = int(input())
s = "1" + input() + "1"
ans = 0
q = []
for i in range(len(s)):
if s[i] == "1":
q.append(i)
for i in range(len(q) - k - 1):
x, y = q[i], q[i + k + 1]
l, r = q[i + 1], q[i + k]
if k == 0:
a = y - x
ans... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP STRING FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR VAR BIN_OP BIN_O... |
A string is binary, if it consists only of characters "0" and "1".
String v is a substring of string w if it has a non-zero length and can be read starting from some position in string w. For example, string "010" has six substrings: "0", "1", "0", "01", "10", "010". Two substrings are considered different if their po... | def _bs(e, arr, le):
high = l
low = le
mid = (high + low) // 2
while high - low > 1:
if e >= arr[mid]:
low = mid
elif e < arr[mid]:
high = mid
mid = (low + high) // 2
if arr[high] == e:
return high
return low
def bs(e, arr):
low = 0
... | FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER WHILE BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR IF VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR RETURN VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE... |
A string is binary, if it consists only of characters "0" and "1".
String v is a substring of string w if it has a non-zero length and can be read starting from some position in string w. For example, string "010" has six substrings: "0", "1", "0", "01", "10", "010". Two substrings are considered different if their po... | import itertools
k = int(input())
s = "1" + input() + "1"
if k == 0:
ans = 0
for k, v in itertools.groupby(s):
if k == "0":
l = len(list(v))
ans += l * (l + 1) // 2
print(ans)
exit()
cnt = 0
d = []
for i, c in enumerate(s, start=1):
if c == "1":
d.append(i)
a... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP STRING FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NU... |
A string is binary, if it consists only of characters "0" and "1".
String v is a substring of string w if it has a non-zero length and can be read starting from some position in string w. For example, string "010" has six substrings: "0", "1", "0", "01", "10", "010". Two substrings are considered different if their po... | j, k, t = 0, int(input()), input()
p = [1] + [0] * t.count("1")
for i in t:
if i == "1":
j += 1
p[j] += 1
print(
sum(p[i] * p[i + k] if p[i] > 1 else p[i + k] for i in range(len(p) - k))
if k
else sum(i * (i - 1) for i in p if i > 1) // 2
) | ASSIGN VAR VAR VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP LIST NUMBER FUNC_CALL VAR STRING FOR VAR VAR IF VAR STRING VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR NUMBER BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR FUNC_CALL VAR BIN_OP ... |
A string is binary, if it consists only of characters "0" and "1".
String v is a substring of string w if it has a non-zero length and can be read starting from some position in string w. For example, string "010" has six substrings: "0", "1", "0", "01", "10", "010". Two substrings are considered different if their po... | from sys import stdin, stdout
k = int(stdin.readline())
s = stdin.readline().strip()
values = list(map(int, list(s)))
cnt = [values[0]]
for i in range(1, len(s)):
cnt.append(cnt[-1] + values[i])
cnt.append(0)
ans = 0
for i in range(len(s) - k + 1):
if cnt[-2] - cnt[i - 1] < k:
continue
l, r = i - 1... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR ... |
A string is binary, if it consists only of characters "0" and "1".
String v is a substring of string w if it has a non-zero length and can be read starting from some position in string w. For example, string "010" has six substrings: "0", "1", "0", "01", "10", "010". Two substrings are considered different if their po... | n = int(input())
s = str(input())
c = s.count("1")
l = []
if n > c:
print(0)
elif n == 0:
f = 0
count = 0
for i in range(len(s)):
if s[i] == "1":
l.append(i)
if len(l) == 0:
count += len(s) * (len(s) + 1) // 2
else:
for i in range(len(l)):
if i == ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR LIST IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBE... |
A string is binary, if it consists only of characters "0" and "1".
String v is a substring of string w if it has a non-zero length and can be read starting from some position in string w. For example, string "010" has six substrings: "0", "1", "0", "01", "10", "010". Two substrings are considered different if their po... | I = lambda: int(input())
IL = lambda: list(map(int, input().split()))
k = I()
s = [len(i) for i in input().split("1")]
if k:
print(sum((i + 1) * (j + 1) for i, j in zip(s[:-k], s[k:])))
else:
print(sum(i * (i + 1) // 2 for i in s)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR VAR VAR VAR VAR EXPR... |
A string is binary, if it consists only of characters "0" and "1".
String v is a substring of string w if it has a non-zero length and can be read starting from some position in string w. For example, string "010" has six substrings: "0", "1", "0", "01", "10", "010". Two substrings are considered different if their po... | k = int(input())
s = input()
n = len(s)
i1 = 0
dp = [0] * n
cnt = 0
ind = [0]
if k == 0:
ocnt = 0
ans = 0
for i in range(n):
if s[i] == "0":
ocnt += 1
else:
ans += max(ocnt * (ocnt + 1) // 2, 0)
ocnt = 0
ans += max(ocnt * (ocnt + 1) // 2, 0)
print(... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR BIN_OP BIN_... |
A string is binary, if it consists only of characters "0" and "1".
String v is a substring of string w if it has a non-zero length and can be read starting from some position in string w. For example, string "010" has six substrings: "0", "1", "0", "01", "10", "010". Two substrings are considered different if their po... | n = int(input())
s = input()
l, q, w = [], 0, 0
for i in s:
if i == "0":
w += 1
else:
l.append(w)
w = 0
l += [w]
if n > 0:
for i in range(n, len(l)):
q += (l[i] + 1) * (l[i - n] + 1)
else:
for i in l:
q += i * (i + 1) // 2
print(q) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR LIST NUMBER NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR LIST VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR BIN_OP VAR VAR NUMBER FOR... |
Vasya's telephone contains n photos. Photo number 1 is currently opened on the phone. It is allowed to move left and right to the adjacent photo by swiping finger over the screen. If you swipe left from the first photo, you reach photo n. Similarly, by swiping right from the last photo you reach photo 1. It takes a sec... | def main():
n, a, b, t = list(map(int, input().split()))
b += 1
l = [(b if char == "w" else 1) for char in input()]
t -= sum(l) - a * (n + 2)
hi, n2 = n, n * 2
n3 = n2 + 1
lo = res = 0
l *= 2
while lo <= n and hi < n2:
t -= l[hi]
hi += 1
while (hi - lo + (hi i... | FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER WHILE VAR VAR... |
Vasya's telephone contains n photos. Photo number 1 is currently opened on the phone. It is allowed to move left and right to the adjacent photo by swiping finger over the screen. If you swipe left from the first photo, you reach photo n. Similarly, by swiping right from the last photo you reach photo 1. It takes a sec... | read = lambda: list(map(int, input().split()))
per = lambda L, R: R - L - 1 + min(R - n - 1, n - L)
n, a, b, T = read()
f = [(1 + (i == "w") * b) for i in input()] * 2
L, R = 0, n
ans = 0
cur = sum(f) // 2
while L <= n and R < n * 2:
cur += f[R]
R += 1
while R - L > n or cur + per(L, R) * a > T:
cur... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP VAR STRING VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER VAR ASSIGN... |
Vasya's telephone contains n photos. Photo number 1 is currently opened on the phone. It is allowed to move left and right to the adjacent photo by swiping finger over the screen. If you swipe left from the first photo, you reach photo n. Similarly, by swiping right from the last photo you reach photo 1. It takes a sec... | def main():
n, a, b, t = list(map(int, input().split()))
a1 = a + 1
b += a1
l, res = [(b if c == "w" else a1) for c in input()], []
l[0] = x = l[0] - a
if t <= x:
print(int(t == x))
return
f = res.append
for dr in (0, 1):
if dr:
l[1:] = l[-1:-n:-1]
... | FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR VAR VAR STRING VAR VAR VAR FUNC_CALL VAR LIST ASSIGN VAR NUMBER VAR BIN_OP VAR NUMBER VAR IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR RETURN ASSIGN VAR VAR FOR VAR NUMBER NUMBE... |
Vasya's telephone contains n photos. Photo number 1 is currently opened on the phone. It is allowed to move left and right to the adjacent photo by swiping finger over the screen. If you swipe left from the first photo, you reach photo n. Similarly, by swiping right from the last photo you reach photo 1. It takes a sec... | n, a, b, t = map(int, input().split())
b += 1
l = [(b if char == "w" else 1) for char in input()]
t -= sum(l) - a * (n + 2)
hi = n
n2 = n * 2
n3 = n2 + 1
lo = 0
res = 0
l *= 2
while lo <= n and hi < n2:
t -= l[hi]
hi += 1
while (hi - lo + (hi if hi < n3 else n3)) * a > t or lo < hi - n:
t += l[lo]
... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR STRING VAR NUMBER VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER WHILE VAR VAR V... |
Vasya's telephone contains n photos. Photo number 1 is currently opened on the phone. It is allowed to move left and right to the adjacent photo by swiping finger over the screen. If you swipe left from the first photo, you reach photo n. Similarly, by swiping right from the last photo you reach photo 1. It takes a sec... | n, a, b, T = map(int, input().split())
s = input()
prefsum = [0] * n
suffsum = [0] * n
for i in range(n):
prefsum[i] = 1 if s[i] == "h" else b + 1
if i > 0:
prefsum[i] += a + prefsum[i - 1]
suffsum[-1] = a
for i in range(n - 1, -1, -1):
suffsum[i] += 1 if s[i] == "h" else b + 1
if i + 1 < n:
... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN 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 STRING NUMBER BIN_OP VAR NUMBER IF VAR NUMBER VAR VAR BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FOR ... |
Vasya's telephone contains n photos. Photo number 1 is currently opened on the phone. It is allowed to move left and right to the adjacent photo by swiping finger over the screen. If you swipe left from the first photo, you reach photo n. Similarly, by swiping right from the last photo you reach photo 1. It takes a sec... | from sys import stdin, stdout
nmbr = lambda: int(stdin.readline())
lst = lambda: list(map(int, stdin.readline().split()))
for _ in range(1):
n, swipe, rotate, t = lst()
s = input()
ans = 0
pre = [0] * n
if s[0] == "w":
pre[0] = rotate + 1
else:
pre[0] = 1
for i in range(1, n... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR IF VAR NUMBER STRING ASSIGN VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUM... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
mod = 998244353
sol = 1
i = n - 1
j = m - 1
while sol > 0 and j >= 0:
goal = b[j]
s = 0
r = False
while i >= 0 and a[i] >= goal:
if r:
s += 1
elif a[i] == goal:
... | 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 VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR NUMBER ASSIGN ... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | import sys
mod = 998244353
eps = 10**-9
def main():
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A_unique = sorted(list(set(A)))
A_set = set(A)
B_set = set(B)
if A_unique[0] not in B... | IMPORT ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FUNC_DEF IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FU... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | mod = 998244353
n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
s = []
d = {}
for i, x in enumerate(a):
if x not in d:
d[x] = []
d[x].append(i)
while len(s) > 0 and x <= a[s[-1]]:
s.pop()
s.append(i)
idx = []
i, j = 0, 0
while j < ... | ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR DICT FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR LIST EXPR FUNC_CALL VAR... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | a, b = map(int, input().split())
answer = 1
mod = 998244353
z = list(map(int, input().split()))
x = list(map(int, input().split()))
i = a - 1
j = b - 1
while answer and j >= 0:
c = 0
while i >= 0 and z[i] >= x[j]:
if c:
c += 1
elif z[i] == x[j]:
c = 1
i -= 1
i... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER 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 ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR NUMBER ASSIGN VAR NUM... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
MOD = 998244353
out = 1
first = -1
curr = m - 1
for i in range(n - 1, -1, -1):
while a[i] < b[curr]:
if first > -1:
out *= first - i
out %= MOD
else:
out... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | import sys
input = sys.stdin.readline
n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
mod = 998244353
a = a[::-1]
b = b[::-1]
i, j = 0, 0
ans = 1
while ans and j < m:
cnt = 0
while i < n and a[i] >= b[j]:
if cnt:
cnt += 1
elif... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBE... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | def main():
n, m = map(int, input().split())
aa, bb = (list(map(int, input().split())) for _ in "ab")
res, term, i, start = 1, bb[0], n - 1, 0
for b in reversed(bb):
while i >= 0 and aa[i] > b:
i -= 1
if i >= 0 and aa[i] == b:
start = i
else:
r... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR STRING ASSIGN VAR VAR VAR VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR WHILE VAR NUMBER VAR VAR VAR VAR NUMBER IF VAR NUMBER VAR VAR VAR ASSIGN VAR VAR... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | alen, blen = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
minIndex = [-1] * blen
curMinIndex = blen - 1
failCount = 0
MOD = 998244353
for i in range(alen - 1, -1, -1):
if curMinIndex >= 0 and a[i] == b[curMinIndex]:
minIndex[curMinIndex] = i
curMi... | 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 VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP V... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
n -= 1
m -= 1
while n >= 0 and b[m] != a[n]:
if b[m] > a[n]:
print(0)
exit(0)
n -= 1
if n < 0 < m:
print(0)
exit(0)
ans = 1
mod = 998244353
while m >= 0 and n >= 0:
sana = 0
w... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR NUMBER WHILE VAR NUMBER VAR VAR VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | from sys import gettrace, stdin
if gettrace():
inputi = input
else:
def input():
return next(stdin)[:-1]
def inputi():
return stdin.buffer.readline()
def modInt(mod):
class ModInt:
def __init__(self, value):
self.value = value % mod
def __int__(self):
... | IF FUNC_CALL VAR ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP VAR VAR FUNC_DEF RETURN VAR FUNC_DEF RETURN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_DEF RETURN FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR FUNC_DEF RETURN FUNC_CALL ... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | inp = lambda: map(int, input().split(" "))
m, n = inp()
arr1 = tuple(inp())
arr2 = tuple(inp())
ans = 1
i = m - 1
j = n - 1
while j >= 0 and ans:
cnt = 0
seen = 0
if j == 0:
if i >= 0 and min(arr1[0 : i + 1]) == arr2[j]:
cnt = 1
else:
while arr1[i] >= arr2[j] and i >= 0:
... | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF VAR... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | import sys
input = lambda: sys.stdin.readline().rstrip()
n, m = map(int, input().split())
A = [int(i) for i in input().split()][::-1]
B = [int(i) for i in input().split()][::-1]
mod = 998244353
cur = 0
ct = 0
Chk = False
Ans = [0] * (m - 1)
ans = 1
for i in range(n):
if A[i] > B[cur] and Chk == False:
cont... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIS... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | MOD = 998244353
n, m = map(int, input().split())
d = dict()
a = [0] + list(map(int, input().split()))
b = list(map(int, input().split()))
for i in range(m):
d[b[i]] = i
c = [-1] * m
for i, x in enumerate(a):
if x in d:
c[d[x]] = i
idx = n
ans = 1
for i in range(m - 1, -1, -1):
while b[i] <= a[idx]:
... | ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_OP ... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | import sys
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II():
return int(sys.stdin.readline())
def MI():
return map(int, sys.stdin.readline().split())
def LI():
return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number):
return [LI() for _ in range(rows_numb... | IMPORT ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 1
m = a[-1]
mod = 998244353
ml = [0] * n
for i in range(n - 1, -1, -1):
m = min(m, a[i])
ml[i] = m
r = n
l = 0
for temp in b[::-1]:
while r - 1 >= 0 and ml[r - 1] > temp:
r -= 1
if 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 FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMB... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | mod = 998244353
def solve(a, b):
j = len(a) - 1
pos = 1
for i in reversed(range(1, len(b))):
while j >= 0 and a[j] != b[i]:
if a[j] < b[i]:
return 0
j -= 1
if j < 0:
return 0
x = j
small = None
y = None
whi... | ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR WHILE VAR NUMBER VAR VAR VAR VAR IF VAR VAR VAR VAR RETURN NUMBER VAR NUMBER IF VAR NUMBER RETURN NUMBER ASSIGN VAR VAR ASSIGN VAR NONE ASSIGN VAR NONE WHILE VAR NUMBER VA... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | import sys
input = sys.stdin.readline
t = 1
while t > 0:
t -= 1
n, m = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
if min(a) != b[0]:
print(0)
exit(0)
ff = {}
for i in range(n - 1, -1, -1):
if a[i] not in ff:
... | IMPORT ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMB... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
M = [a[i] for i in range(n)]
for i in range(n - 2, -1, -1):
M[i] = min(M[i], M[i + 1])
res = 1
mod = 998244353
val = b[m - 1]
id = n - 1
count = m - 1
l, r = -1, -1
while count and id > -1:
if M[id] > val:
... | 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 VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR V... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | mod = 998244353
def solv(A, B):
ans = 1
ai, bi = len(A) - 1, len(B) - 1
cnt = 0
match = False
while ai >= 0 and bi >= 0:
if match:
if A[ai] >= B[bi]:
cnt += 1
ai -= 1
else:
ans = ans * cnt % mod
match =... | ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER IF VAR IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | def binaryfun(x, arr):
low = 0
high = len(arr) - 1
mid = 0
while low <= high:
mid = (high + low) // 2
if arr[mid] < x:
low = mid + 1
elif arr[mid] > x:
high = mid - 1
else:
return mid
return -1
inp = list(map(int, input().split())... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VA... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
mod = 998244353
indexOf = {}
for i in range(n):
indexOf[a[i]] = i
for elem in b:
if elem not in indexOf:
print(0)
exit()
for i in range(m - 1):
if indexOf[b[i]] > indexOf[b[i + 1]]:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMB... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | import sys
input = sys.stdin.buffer.readline
def getAnswer(a, b):
a = list(reversed(a))
b = list(reversed(b))
if len(b) == 1:
if min(a) == b[0]:
return 1
else:
return 0
res = 1
x = 0
y = 0
j = 0
while True:
found = False
for x in... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR NUMBER FOR VAR FUNC... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | import sys
input = sys.stdin.buffer.readline
def prog():
n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
R = [(0) for i in range(m - 1)]
L = [(0) for i in range(m - 1)]
idx = n - 1
fail = False
i = 1
for i in range(m - 1, 0,... | IMPORT ASSIGN VAR VAR 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 FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP V... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | import sys
pprint = lambda s: print(" ".join(map(str, s)))
input = lambda: sys.stdin.readline().strip()
ipnut = input
n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
mod = 998244353
suf_min = [(10000000000, -1)]
a_r = list(reversed(a))
for i in range(n):
if ... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN V... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | from sys import stdin
input = stdin.buffer.readline
n, m = map(int, input().split())
(*a,) = map(int, input().split())
(*b,) = map(int, input().split())
p = n - 1
mn = 10**9 + 7
ans = 1
for i in range(m - 1, 0, -1):
if mn < b[i]:
exit(print(0))
idx = -1
while p >= 0:
if idx == -1 and a[p] =... | ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NU... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | n, m = map(int, input().split())
ai = list(map(int, input().split()))
maxn = 10**9 + 1
bi = list(map(int, input().split())) + [maxn]
mod = 998244353
bi2 = [0] * m
bi3 = [0] * m
j = m - 1
temp = 0
for i in range(n - 1, -1, -1):
if ai[i] == bi[j]:
temp = 1
bi2[j] = i
j -= 1
if 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 BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR LIST VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | from sys import stdin
input = stdin.readline
n, m = [int(x) for x in input().strip().split()]
a = [int(x) for x in input().strip().split()]
b = [int(x) for x in input().strip().split()]
MOD = 998244353
ans = 1
ai, bi = n - 1, m - 1
while bi >= 0:
while ai >= 0 and a[ai] != b[bi]:
if a[ai] < b[bi]:
... | ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER WHILE VAR NUM... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | def getint():
return int(input())
def getint2():
return map(int, input().split())
def getintlist():
return map(int, input().split())
def getstring():
return input()
n, m = getint2()
a = list(getintlist())
b = list(getintlist())
for i in range(n - 2, -1, -1):
if a[i] > a[i + 1]:
a[i] ... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR B... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | import sys
input = sys.stdin.readline
I = lambda: list(map(int, input().split()))
n, m = I()
a = I()
b = I()
an = 1
md = 998244353
suf = [0] * n
suf[-1] = a[n - 1]
for i in range(n - 2, -1, -1):
suf[i] = min(suf[i + 1], a[i])
suf = [0] + suf
cr = m - 1
ct = 0
for i in range(n, -1, -1):
if suf[i] < b[cr]:
... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NU... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | n, m = map(int, input().split())
lstn = list(map(int, input().split()))
b = list(map(int, input().split()))
hr = [(0) for i in range(m)]
hhr = [(-1) for i in range(m)]
hhl = [(-1) for i in range(m)]
def bnp(lst, elem, pos):
l = -1
r = len(lst)
while r - l > 1:
h = (r + l) // 2
if lst[h] > ... | 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 VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FUNC_DEF ... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | import sys
input = sys.stdin.readline
mod = 998244353
N, M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
bind = M - 1
defined = [-1] * M
ans = 1
for i in reversed(range(N)):
a = A[i]
if defined[bind] == -1:
if B[bind] > a:
ans = 0
... | IMPORT ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR ... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
it, ans, c, d, M = m - 1, 0, [0] * m, [[0, 0] for i in range(m)], 998244353
for i in range(n - 1, -1, -1):
if it <= 0:
break
if a[i] < b[it]:
if c[it]:
d[it][0], d[it - 1][1] = i ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR BIN_OP VAR NUMBER NUMBER BIN_OP LIST NUMBER VAR LIST NUMBER NUMBER VAR FUNC_CALL VAR VAR NUMBER FOR VA... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | n, m = input().split()
n = int(n)
m = int(m)
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
MOD = 998244353
a.reverse()
b.reverse()
def Solve(a, b, n, m):
if m > n:
return 0
men = a[0]
pos = 0
while pos < n and men > b[0]:
pos += 1
if pos >= n:
... | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR VAR NUMB... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | from sys import stdin, stdout
def two_arrasy(n, m, a, b):
r = n - 1
res = 1
for i in range(m - 1, -1, -1):
while r >= 0 and a[r] > b[i]:
r -= 1
if r < 0 or b[i] != a[r]:
return 0
l = r
while l >= 0 and a[l] >= b[i]:
l -= 1
if l < ... | FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER WHILE VAR NUMBER VAR VAR VAR VAR VAR NUMBER IF VAR NUMBER VAR VAR VAR VAR RETURN NUMBER ASSIGN VAR VAR WHILE VAR NUMBER VAR VAR VAR VAR VAR NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER IF VAR NUM... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | import sys
n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
last = []
i = n - 1
j = m - 1
MOD = 998244353
failflag = 0
while j >= 0 and i >= 0:
r = b[j]
while i >= 0:
if a[i] == r:
last.append(i)
break
if a[i] < r:
... | IMPORT 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 VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NU... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | n, m = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [(0) for _ in range(n)]
mn = a[-1]
for i in range(n - 1, -1, -1):
mn = min(mn, a[i])
c[i] = mn
j = n - 1
r = 1
for i in range(m - 1, -1, -1):
k = 0
while j >= 0 and c[j] > b[i]:
j -= ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | mod = 998244353
n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 1
i = n - 1
for j in range(m - 1, -1, -1):
l, r = -1, -1
while i != -1:
if a[i] < b[j]:
print(0)
exit()
if a[i] == b[j]:
r = i
... | ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
def solve():
M = 998244353
res = 1
i = n - 1
j = m - 1
while j >= 0 and res:
count = 0
while i >= 0 and a[i] >= b[j]:
if count > 0:
count += 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 FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NU... |
You are given two arrays $a_1, a_2, \dots , a_n$ and $b_1, b_2, \dots , b_m$. Array $b$ is sorted in ascending order ($b_i < b_{i + 1}$ for each $i$ from $1$ to $m - 1$).
You have to divide the array $a$ into $m$ consecutive subarrays so that, for each $i$ from $1$ to $m$, the minimum on the $i$-th subarray is equal t... | import sys
def rs():
return sys.stdin.readline().rstrip()
def ri():
return int(sys.stdin.readline())
def ria():
return list(map(int, sys.stdin.readline().split()))
def ws(s):
sys.stdout.write(s + "\n")
def wi(n):
sys.stdout.write(str(n) + "\n")
def wia(a):
sys.stdout.write(" ".join([... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR BIN_OP VAR STRING FUNC_DEF EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR STRING FUNC_DEF EXPR FUNC_CALL VAR BIN_OP FUNC_CALL STRING... |
You are given a sequence $a$ of length $n$ consisting of $0$s and $1$s.
You can perform the following operation on this sequence:
Pick an index $i$ from $1$ to $n-2$ (inclusive).
Change all of $a_{i}$, $a_{i+1}$, $a_{i+2}$ to $a_{i} \oplus a_{i+1} \oplus a_{i+2}$ simultaneously, where $\oplus$ denotes the bitwise XO... | for t in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
AA = now = 0
for i in range(n):
now ^= a[i]
if not now and not i % 2:
AA = i + 1
if not AA or now:
print("NO")
else:
print("YES")
an = []
for i in range(... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CAL... |
You are given a sequence $a$ of length $n$ consisting of $0$s and $1$s.
You can perform the following operation on this sequence:
Pick an index $i$ from $1$ to $n-2$ (inclusive).
Change all of $a_{i}$, $a_{i+1}$, $a_{i+2}$ to $a_{i} \oplus a_{i+1} \oplus a_{i+2}$ simultaneously, where $\oplus$ denotes the bitwise XO... | t = int(input())
for _ in range(t):
n = int(input())
arr = list(map(int, input().split()))
r = 0
mid = -1
for i, c in enumerate(arr):
r ^= c
if r == 0 and i % 2 == 0:
mid = i
if r:
print("NO")
elif n % 2 == 1:
print("YES")
ans = []
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR VAR IF VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR IF VAR EXPR FUNC_CALL... |
This is the hard version of the problem. The only difference between the two versions is the constraint on n. You can make hacks only if all versions of the problem are solved.
A forest is an undirected graph without cycles (not necessarily connected).
Mocha and Diana are friends in Zhijiang, both of them have a fore... | n, m1, m2 = map(int, input().split())
def getfa(fa, x):
if fa[x] == x:
return x
else:
fa[x] = getfa(fa, fa[x])
return fa[x]
fa1 = [i for i in range(n + 1)]
fa2 = [i for i in range(n + 1)]
for i in range(m1):
u, v = map(int, input().split())
t1 = getfa(fa1, u)
t2 = getfa(f... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR RETURN VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CA... |
This is the hard version of the problem. The only difference between the two versions is the constraint on n. You can make hacks only if all versions of the problem are solved.
A forest is an undirected graph without cycles (not necessarily connected).
Mocha and Diana are friends in Zhijiang, both of them have a fore... | class DisjointSet:
def __init__(self, size):
self.U = [[i, 1] for i in range(size)]
def root(self, e):
u = self.U[e]
if u[0] != e:
r = self.U[e] = self.root(u[0])
return r
return u
def union(self, first, second):
uFirst, uSecond = self.root(... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST VAR NUMBER VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR VAR VAR IF VAR NUMBER VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR NUMBER RETURN VAR RETURN VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER VAR NUMBER VAR... |
This is the hard version of the problem. The only difference between the two versions is the constraint on n. You can make hacks only if all versions of the problem are solved.
A forest is an undirected graph without cycles (not necessarily connected).
Mocha and Diana are friends in Zhijiang, both of them have a fore... | import sys
input = sys.stdin.readline
class Node:
def __init__(self, index, p=None, rank=None):
self.index = index
self.p = p
self.rank = rank
def make_set(self):
self.p = self
self.rank = 0
def find_set(self):
if self != self.p:
self.p = sel... | IMPORT ASSIGN VAR VAR CLASS_DEF FUNC_DEF NONE NONE ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER FUNC_DEF IF VAR VAR ASSIGN VAR FUNC_CALL VAR RETURN VAR FUNC_DEF IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR IF VAR VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR ... |
This is the hard version of the problem. The only difference between the two versions is the constraint on n. You can make hacks only if all versions of the problem are solved.
A forest is an undirected graph without cycles (not necessarily connected).
Mocha and Diana are friends in Zhijiang, both of them have a fore... | import sys
class UnionFind:
def __init__(self, n):
self.parent = list(range(n))
def find(self, a):
acopy = a
while a != self.parent[a]:
a = self.parent[a]
while acopy != a:
self.parent[acopy], acopy = a, self.parent[acopy]
return a
def uni... | IMPORT CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR VAR WHILE VAR VAR VAR ASSIGN VAR VAR VAR WHILE VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR AS... |
This is the hard version of the problem. The only difference between the two versions is the constraint on n. You can make hacks only if all versions of the problem are solved.
A forest is an undirected graph without cycles (not necessarily connected).
Mocha and Diana are friends in Zhijiang, both of them have a fore... | import sys
input = sys.stdin.buffer.readline
On, Pig, Cow = map(int, input().split())
class Farm:
def __init__(self):
self.Fa = [i for i in range(On)]
def fa(self, x):
if self.Fa[x] == x:
return x
self.Fa[x] = self.fa(self.Fa[x])
return self.Fa[x]
def merge(... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR CLASS_DEF FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF IF VAR VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR RETURN VAR VAR FUNC_DEF IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VA... |
This is the hard version of the problem. The only difference between the two versions is the constraint on n. You can make hacks only if all versions of the problem are solved.
A forest is an undirected graph without cycles (not necessarily connected).
Mocha and Diana are friends in Zhijiang, both of them have a fore... | class UnoinFind(object):
def __init__(self, n):
self.__findset = [i for i in range(n + 1)]
self.__rank = [(1) for i in range(n + 1)]
def find(self, x):
if self.__findset[x] != x:
self.__findset[x] = self.find(self.__findset[x])
return self.__findset[x]
def unio... | CLASS_DEF VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_DEF IF VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR RETURN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR VAR IF VAR VAR ... |
This is the hard version of the problem. The only difference between the two versions is the constraint on n. You can make hacks only if all versions of the problem are solved.
A forest is an undirected graph without cycles (not necessarily connected).
Mocha and Diana are friends in Zhijiang, both of them have a fore... | from sys import stdin, stdout
def get_list():
return list(map(int, stdin.readline().strip().split()))
def get_int():
return int(stdin.readline())
def get_ints():
return map(int, stdin.readline().strip().split())
def get_string():
return stdin.readline()
def printn(n):
stdout.write(str(n) +... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR STRING CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_C... |
ChthollyNotaSeniorious received a special gift from AquaMoon: $n$ binary arrays of length $m$. AquaMoon tells him that in one operation, he can choose any two arrays and any position $pos$ from $1$ to $m$, and swap the elements at positions $pos$ in these arrays.
He is fascinated with this game, and he wants to find t... | t = int(input())
for i in range(t):
n, m = [int(j) for j in input().split()]
lst = [[int(k) for k in input().split()] for j in range(n)]
sums = []
for l in lst:
sums.append(sum(l))
if sum(sums) % n != 0:
print(-1)
continue
even_sum = sum(sums) // n
ops = []
for j ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR 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 VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_C... |
ChthollyNotaSeniorious received a special gift from AquaMoon: $n$ binary arrays of length $m$. AquaMoon tells him that in one operation, he can choose any two arrays and any position $pos$ from $1$ to $m$, and swap the elements at positions $pos$ in these arrays.
He is fascinated with this game, and he wants to find t... | t = int(input())
for _ in range(t):
n, m = map(int, input().split())
a = []
d = {}
ts = 0
for i in range(n):
a.append(list(map(int, input().split())))
d[i] = sum(a[i])
ts += d[i]
if ts % n != 0:
print(-1)
continue
am = ts // n
ans = []
for i in... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VA... |
ChthollyNotaSeniorious received a special gift from AquaMoon: $n$ binary arrays of length $m$. AquaMoon tells him that in one operation, he can choose any two arrays and any position $pos$ from $1$ to $m$, and swap the elements at positions $pos$ in these arrays.
He is fascinated with this game, and he wants to find t... | for jj in range(int(input())):
n, m = [int(i) for i in input().split()]
tm = []
tot = 0
for i in range(n):
arr = input().split()
a = arr.count("1")
arr = [a] + arr + [i + 1]
tm.append(arr)
tot += a
if tot % n != 0:
print(-1)
continue
tm.sor... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP LIST VAR VAR LIST BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VA... |
ChthollyNotaSeniorious received a special gift from AquaMoon: $n$ binary arrays of length $m$. AquaMoon tells him that in one operation, he can choose any two arrays and any position $pos$ from $1$ to $m$, and swap the elements at positions $pos$ in these arrays.
He is fascinated with this game, and he wants to find t... | t = int(input())
for k in range(t):
n, m = map(int, input().split())
a = []
aux = []
up = []
down = []
ss = 0
for i in range(n):
c = 0
l = list(map(int, input().split()))
a.append(l)
for i in range(m):
if l[i] == 1:
c += 1
a... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR ... |
ChthollyNotaSeniorious received a special gift from AquaMoon: $n$ binary arrays of length $m$. AquaMoon tells him that in one operation, he can choose any two arrays and any position $pos$ from $1$ to $m$, and swap the elements at positions $pos$ in these arrays.
He is fascinated with this game, and he wants to find t... | t = int(input())
for _ in range(t):
n, m = [int(i) for i in input().strip().split()]
a = []
count = 0
stri_1 = [[0, i] for i in range(n)]
for i in range(n):
temp = [int(i) for i in input().strip().split()]
a.append(temp)
for j in range(m):
if temp[j] == 1:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUN... |
ChthollyNotaSeniorious received a special gift from AquaMoon: $n$ binary arrays of length $m$. AquaMoon tells him that in one operation, he can choose any two arrays and any position $pos$ from $1$ to $m$, and swap the elements at positions $pos$ in these arrays.
He is fascinated with this game, and he wants to find t... | for tc in range(int(input())):
n, m = map(int, input().split())
l = []
for i in range(n):
l.append(list(map(int, input().split())))
c1 = []
for i in range(n):
c1.append(l[i].count(1))
exp1 = sum(c1) // n
exp0 = m - exp1
if sum(c1) % n != 0:
print(-1)
conti... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN 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 FUNC_CALL VAR VAR NUMBER ASSIGN VAR... |
ChthollyNotaSeniorious received a special gift from AquaMoon: $n$ binary arrays of length $m$. AquaMoon tells him that in one operation, he can choose any two arrays and any position $pos$ from $1$ to $m$, and swap the elements at positions $pos$ in these arrays.
He is fascinated with this game, and he wants to find t... | t = int(input())
for _ in range(t):
n, m = map(int, input().split())
nums = []
cnt = []
for _ in range(n):
lin = list(map(int, input().split()))
cnt.append(lin.count(1))
nums.append(lin)
sums = sum(cnt)
h = sums // n
if sums % n != 0:
print(-1)
continu... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR... |
ChthollyNotaSeniorious received a special gift from AquaMoon: $n$ binary arrays of length $m$. AquaMoon tells him that in one operation, he can choose any two arrays and any position $pos$ from $1$ to $m$, and swap the elements at positions $pos$ in these arrays.
He is fascinated with this game, and he wants to find t... | import sys
def parse():
t = int(sys.stdin.readline())
for i in range(t):
n, m = list(map(int, sys.stdin.readline().split()))
matrix = []
count_rows = [0] * n
actions_count = 0
actions = []
for j in range(n):
arr = list(map(int, sys.stdin.readline().s... | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_... |
ChthollyNotaSeniorious received a special gift from AquaMoon: $n$ binary arrays of length $m$. AquaMoon tells him that in one operation, he can choose any two arrays and any position $pos$ from $1$ to $m$, and swap the elements at positions $pos$ in these arrays.
He is fascinated with this game, and he wants to find t... | for i in range(int(input())):
rows, cols = map(int, input().split())
mat = []
ones_arr = []
total_ones = 0
for i in range(rows):
arr = list(map(int, input().split()))
mat.append(arr)
ones_count = arr.count(1)
ones_arr.append(ones_count)
total_ones += ones_coun... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL ... |
ChthollyNotaSeniorious received a special gift from AquaMoon: $n$ binary arrays of length $m$. AquaMoon tells him that in one operation, he can choose any two arrays and any position $pos$ from $1$ to $m$, and swap the elements at positions $pos$ in these arrays.
He is fascinated with this game, and he wants to find t... | for _ in range(int(input())):
n, m = [int(i) for i in input().split()]
a = []
num = [0] * n
for i in range(n):
a.append([int(i) for i in input().split()])
num[i] = a[i].count(1)
count = sum(num)
if count % n:
print(-1)
continue
count //= n
mm = 0
for i... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR... |
ChthollyNotaSeniorious received a special gift from AquaMoon: $n$ binary arrays of length $m$. AquaMoon tells him that in one operation, he can choose any two arrays and any position $pos$ from $1$ to $m$, and swap the elements at positions $pos$ in these arrays.
He is fascinated with this game, and he wants to find t... | import sys
input = sys.stdin.readline
for _ in range(int(input())):
n, m = list(map(int, input().split()))
l = []
ct = []
for x in range(n):
a = list(map(int, input().split()))
l.append(a)
cnt = 0
for y in a:
if y == 1:
cnt += 1
ct.app... | IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR... |
Edo has got a collection of n refrigerator magnets!
He decided to buy a refrigerator and hang the magnets on the door. The shop can make the refrigerator with any size of the door that meets the following restrictions: the refrigerator door must be rectangle, and both the length and the width of the door must be posit... | from sys import *
def check(u, d, l, r):
used = [pointsx[i][1] for i in range(l)]
used += [pointsx[-1 - i][1] for i in range(r)]
used += [pointsy[i][1] for i in range(u)]
used += [pointsy[-1 - i][1] for i in range(d)]
if len(set(used)) > k:
return DOHERA
dx = pointsx[-1 - r][0] - point... | FUNC_DEF ASSIGN VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR BIN_OP NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR BIN_OP NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR VAR RETURN VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR NUMBER VAR VAR NUMBER ... |
This is the hard version of the problem. The difference between the versions is that in the easy version all prices $a_i$ are different. You can make hacks if and only if you solved both versions of the problem.
Today is Sage's birthday, and she will go shopping to buy ice spheres. All $n$ ice spheres are placed in a ... | import sys
def answer(n, a):
a.sort()
ah = a[n // 2 :]
al = a[: n // 2]
ans = []
for i in range(len(ah)):
if i < len(ah):
ans.append(ah[i])
if i < len(al):
ans.append(al[i])
num_spheres = 0
for i in range(1, n - 1):
if ans[i] < ans[i - 1] and... | IMPORT FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR N... |
This is the hard version of the problem. The difference between the versions is that in the easy version all prices $a_i$ are different. You can make hacks if and only if you solved both versions of the problem.
Today is Sage's birthday, and she will go shopping to buy ice spheres. All $n$ ice spheres are placed in a ... | import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().rstrip().split())
inl = lambda: list(map(int, input().split()))
out = lambda x, s="\n": print(s.join(map(str, x)))
n = ini()
a = sorted(inl())
ans = []
count = 0
for i in range(n // 2... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN 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 VAR ASSIGN VAR STRING FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_... |
This is the hard version of the problem. The difference between the versions is that in the easy version all prices $a_i$ are different. You can make hacks if and only if you solved both versions of the problem.
Today is Sage's birthday, and she will go shopping to buy ice spheres. All $n$ ice spheres are placed in a ... | n = int(input())
a = input().split(" ")
if n <= 2:
print(0)
print(" ".join(a))
exit(0)
a = [int(s) for s in a]
a = sorted(a)
b = [0] * n
stepb = 1
for i in range(0, n):
b[stepb] = a[i]
stepb += 2
if stepb >= n:
stepb = 0
cnt = 0
for i in range(1, n - 1):
if b[i] < b[i - 1] and b[i] <... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CA... |
This is the hard version of the problem. The difference between the versions is that in the easy version all prices $a_i$ are different. You can make hacks if and only if you solved both versions of the problem.
Today is Sage's birthday, and she will go shopping to buy ice spheres. All $n$ ice spheres are placed in a ... | from sys import *
input = stdin.readline
listInput = lambda: list(map(int, input().strip().split()))
lineInput = lambda: map(int, input().strip().split())
sJoin = lambda a, sep: f"{sep}".join(a)
arrJoin = lambda a, sep: f"{sep}".join(map(str, a))
def main():
n = int(input())
arr = sorted(listInput())
k =... | ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR AS... |
This is the hard version of the problem. The difference between the versions is that in the easy version all prices $a_i$ are different. You can make hacks if and only if you solved both versions of the problem.
Today is Sage's birthday, and she will go shopping to buy ice spheres. All $n$ ice spheres are placed in a ... | n = int(input())
(*arr,) = map(int, input().split())
arr.sort()
half = n // 2
res = [-1] * n
if n % 2 == 0:
res[::2] = arr[-half:]
res[1::2] = arr[:-half]
else:
res[::2] = arr[-half - 1 :]
res[1::2] = arr[: -half - 1]
ans = 0
for i in range(1, n - 1):
if res[i - 1] > res[i] < res[i + 1]:
ans... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR VAR ASSIGN VAR NUMBER NUMBER VAR VAR ASSIGN VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER N... |
This is the hard version of the problem. The difference between the versions is that in the easy version all prices $a_i$ are different. You can make hacks if and only if you solved both versions of the problem.
Today is Sage's birthday, and she will go shopping to buy ice spheres. All $n$ ice spheres are placed in a ... | def reOrder(arr):
resArray = []
arr = sorted(arr)
mid = len(arr) // 2
i = 0
j = mid
while i < mid and j < len(arr):
resArray.append(arr[j])
resArray.append(arr[i])
i += 1
j += 1
while j < len(arr):
resArray.append(arr[j])
j += 1
return resA... | FUNC_DEF ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER WHILE VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMBER RETURN VAR F... |
This is the hard version of the problem. The difference between the versions is that in the easy version all prices $a_i$ are different. You can make hacks if and only if you solved both versions of the problem.
Today is Sage's birthday, and she will go shopping to buy ice spheres. All $n$ ice spheres are placed in a ... | n = int(input())
A = list(map(int, input().split()))
A = sorted(A)
B = A[0 : n // 2]
C = A[n // 2 :]
a = []
for i in range(len(B)):
a.append(C[i])
a.append(B[i])
if n % 2 != 0:
a.append(C[-1])
ans = 0
for i in range(1, n - 1):
if a[i] < a[i - 1] and a[i] < a[i + 1]:
ans += 1
print(ans)
for x in ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR IF... |
This is the hard version of the problem. The difference between the versions is that in the easy version all prices $a_i$ are different. You can make hacks if and only if you solved both versions of the problem.
Today is Sage's birthday, and she will go shopping to buy ice spheres. All $n$ ice spheres are placed in a ... | for _ in range(1):
n = int(input())
l = list(map(int, input().split()))
if len(l) == 1:
print(0)
print(l[0])
else:
l.sort()
m = [0] * n
ind = 0
for i in range(1, n, 2):
m[i] = l[ind]
ind += 1
for i in range(0, n, 2):
... | FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER V... |
This is the hard version of the problem. The difference between the versions is that in the easy version all prices $a_i$ are different. You can make hacks if and only if you solved both versions of the problem.
Today is Sage's birthday, and she will go shopping to buy ice spheres. All $n$ ice spheres are placed in a ... | import sys
input = sys.stdin.buffer.readline
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
ans = [0] * n
for i in range(0, n, 2):
ans[i] = a.pop()
for i in range(1, n, 2):
ans[i] = a.pop()
v = 0
flag = 0
for i in range(1, n - int(n & 1 == 0), 2):
if ans[i] < ans[i - 1] and ans[i] < ans[i ... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR ... |
This is the hard version of the problem. The difference between the versions is that in the easy version all prices $a_i$ are different. You can make hacks if and only if you solved both versions of the problem.
Today is Sage's birthday, and she will go shopping to buy ice spheres. All $n$ ice spheres are placed in a ... | n = int(input())
a = [int(i) for i in input().split()]
a.sort()
a1 = [0] * n
cnt = 0
a1[0] = a[n // 2]
if n % 2 != 0:
for i in range(0, n // 2):
a1[i * 2 + 1] = a[i]
a1[i * 2 + 2] = a[n // 2 + i + 1]
else:
for i in range(0, n // 2 - 1):
a1[1 + i * 2] = a[i]
a1[i * 2 + 2] = a[n //... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NU... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.