description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | def solve(inp):
n = len(inp)
l = [0] * n
r = [0] * n
ans = 1
l[0] = 1
updateLeft(inp, l, n)
updateRight(inp, r, n)
for i in range(1, n - 1):
if inp[i + 1] - inp[i - 1] >= 2:
ans = max(ans, l[i - 1] + r[i + 1] + 1)
for i in range(n - 1):
ans = max(ans, r[i ... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER A... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
nums = list(map(int, input().split()))
left = [1] * n
right = [1] * n
res = 1
for i in range(1, n):
if nums[i - 1] < nums[i]:
left[i] = left[i - 1] + 1
res = max(res, left[i])
for i in range(n - 2, -1, -1):
if nums[i] < nums[i + 1]:
right[i] = right[i + 1] + 1
re... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR ... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | import sys
T = 1
for _ in range(T):
n = int(input())
l = list(map(int, input().split()))
p = []
i = 0
j = 1
kk = 0
while j < n:
if l[j] <= l[j - 1]:
p.append((i, j - 1))
if j - i > kk:
kk = j - i
i = j
j += 1
p.append((... | IMPORT ASSIGN VAR NUMBER 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 LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF BI... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
a = list(map(int, input().split()))
a = [-1] + a + [1000000007]
maxi = 0
up = [(0) for i in range(n + 2)]
down = [(0) for i in range(n + 2)]
for i in range(1, n + 1):
up[i] = up[i - 1] + 1 if a[i] > a[i - 1] else 1
for i in range(n, 0, -1):
down[i] = down[i + 1] + 1 if a[i] < a[i + 1] else 1
fo... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP LIST NUMBER VAR LIST NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | def canMerge(seq1, seq2):
if len(seq2) == 1:
return True
last = seq1[-1]
second = seq2[1]
if second - last > 1:
return True
if len(seq1) == 1:
return True
second_last = seq1[-2]
first = seq2[0]
if first - second_last > 1:
return True
return False
def... | FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER RETURN NUMBER IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
a = [int(x) for x in input().split()]
res = [[0], []]
cur = 1
for i in range(1, n):
res[0].append(cur)
if a[i - 1] < a[i]:
cur += 1
else:
cur = 1
cur = 1
for i in range(n - 2, -1, -1):
res[1].append(cur)
if a[i + 1] > a[i]:
cur += 1
else:
cur = 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST LIST NUMBER LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP V... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | def fast_dzy_loves_sequence(a):
a = [10**9] + a + [0]
lens = []
left = []
right = []
c_left = 0
c_right = 0
for i in range(0, len(a)):
if i > 0 and a[i - 1] < a[i]:
c_left += 1
else:
c_left = 1
left.append(c_left)
for j in range(len(a) - 1,... | FUNC_DEF ASSIGN VAR BIN_OP BIN_OP LIST BIN_OP NUMBER NUMBER VAR LIST NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
a = list(map(int, input().split()))
INF = 10**9
dp = [([-INF] * 3) for i in range(n)]
for i in range(n):
dp[i][0] = dp[i][2] = 1
if i > 0:
dp[i][1] = 2
def upd(i, cr, nx):
dp[i + 1][nx] = max(dp[i + 1][nx], dp[i][cr] + 1)
for i in range(n - 1):
for j in range(3):
cur... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP LIST VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER NUMBER IF VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FUNC_DEF ASSI... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
A = input()
A = A.split()
i = 0
while i < n:
A[i] = int(A[i])
i = i + 1
opt_solutions_0 = list()
opt_solutions_1 = list()
i = 0
while i < n:
opt_solutions_0.append(0)
opt_solutions_1.append(0)
i = i + 1
opt_solutions_0[0] = 1
opt_solutions_1[0] = 1
i = 1
while i < n:
if A[i] > A... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | from sys import stdin, stdout
nmbr = lambda: int(stdin.readline())
lst = lambda: list(map(int, input().split()))
for i in range(1):
n = nmbr()
a = lst()
if n == 1:
print(1)
continue
f = [1] * n
b = [1] * (1 + n)
for i in range(1, n):
if a[i] > a[i - 1]:
f[i] ... | 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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP NUMBER VAR FOR VAR FUNC_... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
a = input().split(" ")
a = [int(a) for a in a]
b = [(-1) for b in range(0, n)]
now = 0
while now < n:
start = now
while now < n - 1 and a[now] < a[now + 1]:
now += 1
while start <= now:
b[start] = now
start += 1
now += 1
start = now
ans = 0
for i in range(0, ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR WHILE VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR VAR VAR NU... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
c = [0] * (n + 2)
d = [1] * (n + 2)
a = [1] * (n + 2)
a[0] = 0
d[-1] = 0
for i, x in enumerate(map(int, input().split()), 1):
c[i] = x
if c[i] > c[i - 1]:
a[i] = a[i - 1] + 1
for i in range(n, 0, -1):
if c[i] < c[i + 1]:
d[i] = d[i + 1] + 1
m = 0
for i in range(1, n + 1):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR V... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
a = [int(x) for x in input().split()]
vcnt = 1
vpl = [0]
vpr = []
for i in range(1, n):
if a[i - 1] >= a[i]:
vcnt += 1
vpr.append(i - 1)
vpl.append(i)
if len(vpl) > len(vpr):
vpr.append(n - 1)
mmax = 0
for i in range(vcnt):
if vpr[i] - vpl[i] + 1 > mmax:
mmax... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
Ar = [int(0)] * (n + 5)
A = [int(0)] * (n + 5)
i = 1
res = 0
for x in input().split():
Ar[i] = int(x)
A[i] = 1
if Ar[i] > Ar[i - 1]:
A[i] = A[i - 1] + 1
i += 1
for i in range(1, n + 1):
res = max(res, min(A[i] + 1, n))
if Ar[i - A[i] + 1] > Ar[i - A[i] - 1] + 1:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER A... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
a = list(map(int, input().split()))
b = [1]
for i in range(1, n):
if a[i] > a[i - 1]:
b.append(b[-1] + 1)
else:
b.append(1)
ans = max(b)
if ans != n:
ans += 1
c = [0] * n
i = n - 1
val = b[-1]
while i >= 0:
for j in range(val):
c[i] = val
i -= 1
val =... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER ASSI... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
a = list(map(int, input().split()))
ans = 0
cnt = 1
q = []
for i in range(n - 1):
if a[i] < a[i + 1]:
cnt += 1
else:
q.append([cnt, i])
cnt = 1
q.append([cnt, n - 1])
for i in range(len(q) - 1):
c1, idx1 = q[i]
c2, idx2 = q[i + 1]
if idx1 + 2 < n and a[idx1] ... | 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 ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR LIST VAR ... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
a = list(map(int, input().split()))
a = [0] + a + [0]
pre = [(0) for i in range(n + 2)]
pre[1] = 1
for i in range(2, n + 1):
pre[i] = pre[i - 1] + 1 if a[i] > a[i - 1] else 1
suf = [(0) for i in range(n + 2)]
suf[n] = 1
for i in range(n - 1, 0, -1):
suf[i] = suf[i + 1] + 1 if a[i] < a[i + 1] el... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP LIST NUMBER VAR LIST NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR VAR BIN_OP V... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
arr = [int(var) for var in input().split()]
maxLeft = [(1) for _ in range(n)]
maxRight = [(1) for _ in range(n)]
ans = 1
for i in range(1, n):
if arr[i] > arr[i - 1]:
maxLeft[i] = maxLeft[i - 1] + 1
for i in reversed(range(n - 1)):
if arr[i] < arr[i + 1]:
maxRight[i] = maxRight[... | ASSIGN VAR FUNC_CALL VAR 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 NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER FOR VAR F... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
arr = list(map(int, input().split()))
pre = [(0) for i in range(n)]
pre[-1] = 1
for i in range(n - 2, -1, -1):
if arr[i + 1] > arr[i]:
pre[i] = pre[i + 1] + 1
else:
pre[i] = 1
ans = 0
for i in range(n):
last1 = arr[i + pre[i] - 1]
ans = max(ans, pre[i])
if pre[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 NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR ... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | def main():
n, l, res, a = int(input()), [], [], 0
aa = list(map(int, input().split()))
for i, b in enumerate(aa):
if a >= b:
l.append(i)
a = b
if not l:
print(n)
return
l.append(n)
rapp, a = res.append, 0
for b in l:
rapp(b - a)
a ... | FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR LIST LIST NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR IF VAR EXPR FUNC_CALL VAR VAR RETURN EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER FOR VAR VAR... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | import sys
n = int(input())
s = list(map(int, input().split()))
a = [0] * n
b = [0] * n
a[0] = 1
b[0] = 1
if n == 1:
print(1)
sys.exit()
for i in range(1, n):
if s[i] > s[i - 1]:
a[i] = a[i - 1] + 1
else:
a[i] = 1
s = s[::-1]
for i in range(1, n):
if s[i] < s[i - 1]:
b[i] = ... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER V... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
if n <= 2:
print(n)
exit()
a = list(map(int, input().split()))
lower = [(0) for _ in range(n)]
higher = [(0) for _ in range(n)]
current = 0
e = -1
for x in range(n):
if a[x] > e:
current += 1
else:
for y in range(current):
lower[x - 1 - y] = y + 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR 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 ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR V... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | a = int(input())
z = list(map(int, input().split()))
dp = [[(0) for i in range(len(z))] for i in range(2)]
ans = [1]
for i in range(1, len(z)):
if z[i] > z[i - 1]:
ans.append(ans[-1] + 1)
else:
ans.append(1)
dp[0][0] = 1
dp[1][0] = 0
maxa = 1
for i in range(1, len(z)):
if z[i] > z[i - 1]:
... | 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 VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NU... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | from sys import stdin, stdout
n = int(stdin.readline())
a = [int(s) for s in stdin.readline().split()]
left = [(0) for i in range(n)]
right = [(0) for i in range(n)]
left[0] = 1
for i in range(1, n):
if a[i] > a[i - 1]:
left[i] = left[i - 1] + 1
else:
left[i] = 1
right[n - 1] = 1
for i in range... | ASSIGN VAR FUNC_CALL VAR 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 NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER AS... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
seq = [int(n) for n in input().split()]
dp = [(0) for n in range(n + 1)]
for j in range(0, n):
if seq[j] > seq[j - 1]:
dp[j] = dp[j - 1] + 1
else:
dp[j] = 1
seq.append(0)
m = 0
x = 0
for i in range(n - 1, -1, -1):
m = max(m, dp[i - 1] + 1, x + 1)
if i == 0 or i == n - 1 ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIG... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | import sys
input = sys.stdin.buffer.readline
def solution():
n = int(input())
l = list(map(int, input().split()))
end = [1] * (n + 1)
start = [1] * (n + 1)
for i in range(1, n):
if l[i] > l[i - 1]:
end[i] += end[i - 1]
for i in range(n - 2, -1, -1):
if l[i] < l[i +... | 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 ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VA... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | def solve():
size = int(input())
ls = list(map(int, input().rstrip().split()))
dp0 = [(1) for i in range(size)]
dp1 = [(1) for i in range(size)]
for i in range(1, size):
dp0[i] = dp0[i - 1] + 1 if ls[i - 1] < ls[i] else 1
for i in range(0, size - 1)[::-1]:
dp1[i] = dp1[i + 1] + 1... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER N... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | elems = int(input())
data = list(map(int, input().split()))
data.append(float("-inf"))
def find_seq_breaks():
nonlocal elems
nonlocal data
seq_spans = []
sequence_idx = 0
longest_span = 0
for i in range(1, elems + 1):
if data[i] <= data[i - 1]:
seq_range = [sequence_idx, i ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR LIST VAR BIN_OP VAR NU... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
a = list(map(int, input().split()))
pre = [1] * n
suf = [1] * n
for i in range(1, n):
if a[i] > a[i - 1]:
pre[i] = pre[i - 1] + 1
for i in range(n - 2, 0, -1):
if a[i] < a[i + 1]:
suf[i] = suf[i + 1] + 1
ans = max(pre)
for i in range(0, n):
if i > 0:
ans = max(ans, p... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP ... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
a = list(map(int, input().split()))
start = [1] * n
for i in range(n - 2, -1, -1):
if a[i] < a[i + 1]:
start[i] += start[i + 1]
end = [1] * n
for i in range(1, n):
if a[i] > a[i - 1]:
end[i] += end[i - 1]
ret = max(start)
for i in range(n):
if i + 1 < n:
ret = max(re... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER ... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | def main():
n = int(input())
a = [10**10] + list(map(int, input().split())) + [-(10**10)]
if n == 1:
print(1)
return
b = [0] * (n + 10)
c = [0] * (n + 10)
i = 1
while i <= n:
for j in range(i, n + 1):
if a[j] >= a[j + 1]:
break
for ... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP LIST BIN_OP NUMBER NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR LIST BIN_OP NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUM... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
arr = list(map(int, input().split()))
pre, pre1 = [1], [1]
for i in range(1, n):
if arr[i] > arr[i - 1]:
pre.append(pre[-1] + 1)
else:
pre.append(1)
arr.reverse()
for i in range(1, n):
if arr[i] < arr[i - 1]:
pre1.append(pre1[-1] + 1)
else:
pre1.append(1)... | 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 LIST NUMBER LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VA... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
arr = list(map(int, input().split()))
l = [(1) for i in range(n)]
m = [(1) for i in range(n)]
f = 1
for i in range(n):
if i != n - 1:
if arr[i + 1] > arr[i]:
l[i + 1] += l[i]
for i in range(n - 2, -1, -1):
if arr[i + 1] > arr[i]:
m[i] += m[i + 1]
max1 = max(l)
z = ma... | 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 VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR VAR FO... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | dp_right, dp_left = [], []
def solve(n, a):
a.insert(0, 0)
a.append(0)
for i in range(1000005):
dp_right.append(0)
dp_left.append(0)
res = 0
for i in range(1, n + 1):
if a[i] > a[i - 1]:
dp_right[i] = dp_right[i - 1] + 1
else:
dp_right[i] = 1... | ASSIGN VAR VAR LIST LIST FUNC_DEF EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMB... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | from sys import stdin
input = stdin.readline
n = int(input())
a = [-100] + [*map(int, input().split())] + [10**9 + 100]
c = 0
ans = []
for i, j in enumerate(a):
if 1 <= i <= n:
if a[i - 1] < a[i]:
c += 1
else:
ans.append(c)
c = 1
if a[i + 1] - a[i - 1... | ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP LIST NUMBER LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR LIST BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR IF NUMBER VAR VAR IF VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL V... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | ints = int(input())
nums = list(map(int, input().split(" ")))
if ints == 1:
print(1)
elif ints == 2:
print(2)
else:
left = [1] * ints
right = [1] * ints
for i in range(ints - 1):
if nums[i + 1] > nums[i]:
left[i + 1] += left[i]
nums.reverse()
for i in range(ints - 1):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR N... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | def seq(arr):
l = [1] * len(arr)
r = [1] * len(arr)
for i in range(1, len(arr)):
if arr[i] > arr[i - 1]:
l[i] = l[i - 1] + 1
for i in range(len(arr) - 2, -1, -1):
if arr[i] < arr[i + 1]:
r[i] = r[i + 1] + 1
m = max(l)
if m < len(arr):
m += 1
fo... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR VAR VAR B... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
nums = list(map(int, str(input()).split(" ")))
increasing_subs = []
l = 0
r = 0
for i in range(n):
if i == 0:
continue
if nums[i - 1] < nums[i]:
r += 1
else:
increasing_subs.append((l, r))
l = i
r = i
if i == n - 1:
increasing_subs.append(... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
alist = [int(x) for x in input().split()]
maximum = 2
l = [1] * n
r = l[:]
if n < 3:
print(n)
quit()
for i in range(0, n - 1):
if alist[i] < alist[i + 1]:
l[i + 1] += l[i]
if alist[n - 1 - i] > alist[n - 2 - i]:
r[n - 2 - i] += r[n - 1 - i]
for i in range(1, n - 1):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | def find_inc_seq(n, nums):
max_found = 1 if n else 0
dp = [([1] * 2) for _ in range(n)]
dp[0][0] = 0
for i in range(2, n):
if nums[i - 1] > nums[i - 2]:
dp[i][0] = dp[i - 1][0] + 1
dp[n - 1][1] = 0
for i in range(n - 3, -1, -1):
if nums[i + 1] < nums[i + 2]:
... | FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER NUMBER FOR... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
a = list(map(int, input().split()))
b = []
b.append(1)
for i in range(1, len(a)):
if a[i] > a[i - 1]:
b.append(b[i - 1] + 1)
else:
b.append(1)
for i in range(len(a) - 2, -1, -1):
if a[i] < a[i + 1]:
b[i] = b[i + 1]
ans = max(b) + 1
if len(a) > 2:
for i in range(l... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUN... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
a = list(map(int, input().split()))
l = [1] * n
r = [1] * n
if n == 1:
print(1)
exit(0)
ans = 1
for i in range(1, len(a)):
if a[i] > a[i - 1]:
l[i] = l[i - 1] + 1
for i in range(len(a) - 2, -1, -1):
if a[i] < a[i + 1]:
r[i] = r[i + 1] + 1
ans = max(r[1], l[len(a) - 2]) +... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR ... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | import sys
def solve(n, a):
t = [0] * (n + 1)
a = [0] + a
for i in range(1, n + 1):
if a[i] > a[i - 1]:
t[i] = t[i - 1] + 1
else:
t[i] = 1
r = 0
for i in range(1, n + 1):
r = max(r, t[i])
cur_max = t[i]
if (
a[i - cur_max]... | IMPORT FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSI... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
a = list(map(int, input().split())) + [0]
s, sb, val = [], 0, 0
for i in range(1, n + 1):
if a[i] <= a[i - 1]:
s.append((sb, i - 1))
val = max(val, i - sb)
sb = i
val += len(s) > 1
for i in range(1, len(s)):
c = s[i][0]
if c in range(2, n - 1) and max(a[c] - a[c - 2]... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR LIST NUMBER ASSIGN VAR VAR VAR LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP ... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | from sys import stdin
inFile = stdin
tokens = []
tokens_next = 0
def next_str():
global tokens, tokens_next
while tokens_next >= len(tokens):
tokens = inFile.readline().split()
tokens_next = 0
tokens_next += 1
return tokens[tokens_next - 1]
def nextInt():
return int(next_str())
... | ASSIGN VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FUNC_DEF WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR NUMBER RETURN VAR BIN_OP VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF IF VAR FUNC_CALL VAR VAR RETURN NONE ASSIGN VAR VAR WHILE BIN_OP VAR NUMBER FUNC_CALL VA... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
vec = list(map(int, input().split()))
status = [1] * (n + 1)
for i in range(1, n):
if vec[i] > vec[i - 1]:
status[i] = status[i - 1] + 1
far = [1] * (n + 1)
cur = status[n - 1]
for i in range(n - 2, -1, -1):
if vec[i] < vec[i + 1]:
far[i] += cur - status[i]
else:
cur... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER A... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
l = list(map(int, input().split(" ")))
a = [1] * n
b = [1] * n
for i in range(1, n):
if l[i] > l[i - 1]:
a[i] = a[i - 1] + 1
i = n - 2
while i >= 0:
if l[i + 1] > l[i]:
b[i] = b[i + 1] + 1
i = i - 1
total = max(a)
if total < n:
total = total + 1
for i in range(1, n - 1):... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR ... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
a = list(map(int, input().split()))
ls = []
temp = [a[0]]
for i in range(1, n):
if a[i] > a[i - 1]:
temp.append(a[i])
else:
ls.append(temp)
temp = [a[i]]
if len(temp):
ls.append(temp)
ans = 0
for i in range(len(ls) - 1):
ans = max(ans, len(ls[i]) + 1)
if len(... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR VAR IF FUNC_CALL VAR VAR EXPR FUNC_... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
a = list(map(int, input().split()))
if n == 1:
print(1)
else:
right = [1] * n
left = [1] * n
for i in range(1, n):
if a[i] > a[i - 1]:
right[i] = right[i - 1] + 1
for i in range(n - 2, -1, -1):
if a[i] < a[i + 1]:
left[i] = left[i + 1] + 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUM... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
a = [0] + list(map(int, input().split()))
start = [0] * (n + 1)
end = [0] * (n + 1)
s, e = 1, 1
for i in range(2, n + 1):
e += 1
if a[i] <= a[i - 1]:
start[s:e] = [s] * (e - s)
end[s:e] = [e - 1] * (e - s)
s = e
start[s:] = [s] * (n - s + 1)
end[s:] = [n] * (n - s + 1)
b... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR V... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | def ii():
return int(input())
def si():
return input()
def mi():
return map(int, input().split())
def msi():
return map(str, input().split())
def li():
return list(mi())
n = ii()
a = li()
pre, suf = [1] * n, [1] * n
for i in range(1, n):
if a[i] > a[i - 1]:
pre[i] += pre[i - 1]... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN 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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP LIST NUMBER VA... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
s = list(map(int, input().split()))
B = [1]
E = [1]
ans = 0
if n < 3:
print(n)
else:
for i in range(1, n):
if s[i] > s[i - 1]:
B.append(B[-1] + 1)
else:
B.append(1)
for i in range(n - 1, 0, -1):
if s[i] > s[i - 1]:
E.append(E[-1] +... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER EXP... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
s = input()
s1 = s.split()
l = [int(i) for i in s1]
dp1 = [(1) for i in range(len(l))]
for i in range(1, len(l)):
if l[i] > l[i - 1]:
dp1[i] = dp1[i - 1] + 1
dp2 = [(1) for i in range(len(l))]
for i in range(len(l) - 2, -1, -1):
if l[i] < l[i + 1]:
dp2[i] = dp2[i + 1] + 1
maxlen... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VA... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | arg = int(input())
list1 = list(map(int, input().strip().split()))
origarr = [a for a in list1]
res = 1
if arg == 1:
print(1)
else:
global_maximum = 0
if list1[1] <= list1[0]:
orig_i = 0
orig = list1[0]
list1[0] = list1[1] - 1
counter = 1
maximum = 2
current =... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER NUMB... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
l = [*map(int, input().split())]
res = [[0, 0]]
for i in range(1, n):
if l[i] <= l[res[-1][-1]]:
res.append([i, i])
else:
res[-1][-1] = i
f = lambda p: p[-1] - p[0] + 1
ans = f(res[0])
for i, p in enumerate(res):
if i < len(res) - 1:
v = f(p)
if f(res[i + 1])... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR NUMBER NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER ASSIGN ... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | length = int(input())
nums = [int(num) for num in input().split()] + [float("inf"), float("-inf")]
ans = 0
small = 0
big = 0
for i in range(length):
if nums[i] > nums[i - 1]:
small += 1
big += 1
else:
ans = max(ans, small + 1, big)
big = (
small + 1
if num... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR LIST FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | import sys
def answer(n, a):
if n == 1:
return 1
if n == 2:
return 2
lord = [(0) for _ in range(n)]
lord[0] = 1
for i in range(1, n):
if a[i] > a[i - 1]:
lord[i] = lord[i - 1] + 1
else:
lord[i] = 1
rord = [(0) for _ in range(n)]
rord[... | IMPORT FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSI... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
a = list(map(int, input().strip().split()))
inc = [(0) for i in range(n)]
inc[0] = 1
for i in range(1, n):
if a[i] > a[i - 1]:
inc[i] = inc[i - 1] + 1
else:
inc[i] = inc[0]
dec = [(0) for i in range(n)]
dec[-1] = 1
for i in range(n - 2, -1, -1):
if a[i] < a[i + 1]:
d... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR NUM... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | N = int(input())
if N > 1:
a = list(map(int, input().split()))
b = a[::-1]
a.append(10**20)
b.append(0)
r = 0
dp = [(0) for i in range(N)]
for l in range(N):
while r < N and a[r] < a[r + 1]:
r += 1
if l == r:
dp[l] = 1
r += 1
elif l... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR WHILE VAR VAR VAR VAR VAR BI... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
a = [0] + list(map(int, input().split())) + [0]
l = []
st = 1
for i in range(2, n + 2):
if a[i] <= a[i - 1]:
l.append([st, i - 1])
st = i
if len(l) == 1:
print(n)
exit()
mx = 0
for i in range(1, len(l)):
lf = l[i - 1][1]
rt = l[i][0]
ln1 = l[i][1] - l[i][0] + 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR LIST NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR LIST VAR BIN_OP VAR NUMBER ASSIGN VAR VAR I... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
l = list(map(int, input().split())) + [-(99**9)]
t = 1
p = []
for i in range(1, n + 1):
if l[i] > l[i - 1]:
t += 1
else:
p.append((t, i - 1))
t = 1
best = p[0][0]
for i in range(len(p) - 1):
uz = p[i][0]
end = p[i][1]
uz2 = p[i + 1][0]
end2 = p[i + 1][1]
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR LIST BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMB... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
if n == 1:
print(1)
else:
a = [int(i) for i in input().split()]
good = [[(0) for j in range(2)] for i in range(n)]
good[0][1] = 1
for i in range(n):
if a[i] > a[i - 1]:
good[i][1] = good[i - 1][1] + 1
else:
good[i][1] = 1
good[n - 1][0] = ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER BIN_OP... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | N = eval(input())
Data = [10**9 + 5] + list(map(int, input().split())) + [0]
l, r, ans = [0] + [1] * N + [0], [0] + [1] * N + [0], 1
for i in range(1, N + 2):
if Data[i - 1] < Data[i]:
l[i] += l[i - 1]
for i in range(N, 0, -1):
if Data[i] < Data[i + 1]:
r[i] += r[i + 1]
for i in range(1, N + 1):... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP LIST BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR LIST NUMBER ASSIGN VAR VAR VAR BIN_OP BIN_OP LIST NUMBER BIN_OP LIST NUMBER VAR LIST NUMBER BIN_OP BIN_OP LIST NUMBER BIN_OP LIST NUMBER VAR LIST NUMBER NUMBER ... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | import sys
sequenceLength = int(sys.stdin.readline())
sequence = list(map(int, sys.stdin.readline().split()))
ans = 0
leftList = [1] * sequenceLength
rightlist = [1] * sequenceLength
for i in range(1, sequenceLength):
if sequence[i - 1] < sequence[i]:
leftList[i] += leftList[i - 1]
ans = max(ans, leftL... | IMPORT 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 BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR ... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
t = list(map(int, input().split()))
t.append(0)
p = [0] * (n + 1)
for i in range(n - 1):
p[i + 1] = p[i] + 1 if t[i + 1] > t[i] else 0
s = max(p) + 2
if s >= n:
print(n)
else:
i = 1
if p[i] == 0:
if t[i + 1] > t[i - 1] + 1:
d = p[i - 1] - 1
i += 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR B... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | num_nums = int(input())
nums = list(map(int, input().split(" ")))
increasing_subseqs = []
current_l = []
current_n = None
for i in range(len(nums)):
if len(current_l) == 0:
current_l.append(nums[i])
current_n = nums[i]
elif nums[i] > current_n:
current_l.append(nums[i])
current_n... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NONE FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASS... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n, b, i, ma = int(input()), [], 0, 0
a = list(map(int, input().split()))
while i < n:
j = i
while j < n - 1 and a[j] < a[j + 1]:
j += 1
b.append([i, j])
ma, i = max(j - i + 1 + (i != 0 or j != n - 1), ma), j + 1
for i in range(len(b) - 1):
if b[i + 1][0] - b[i][1] == 2 and a[b[i + 1][0]] > a... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR WHILE VAR VAR ASSIGN VAR VAR WHILE VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
arr = [int(i) for i in input().split(" ")]
a = []
last = 0
running_length = 0
for i in arr:
if i > last:
running_length += 1
else:
a.append(running_length)
running_length = 1
last = i
if running_length > 0:
a.append(running_length)
def canjoin(en, begin):
i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR FUNC_DEF IF VAR BIN_OP FUNC_CALL VAR V... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | from sys import stdin
n = int(input())
s = list(map(int, stdin.readline().strip().split()))
dp = [(1) for i in range(n)]
x = 1
for i in range(n - 2, -1, -1):
if s[i] < s[i + 1]:
x += 1
else:
x = 1
dp[i] = x
ans = 1
for i in range(n):
ans = max(ans, min(n, dp[i] + 1))
aux = i + dp[i]... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR ... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
vec = list(map(int, input().split()))
al = []
otrez = []
for x in vec:
if len(al) == 0:
al.append(x)
elif x <= al[-1]:
otrez.append(al)
al = [x]
else:
al.append(x)
otrez.append(al)
maxx = 0
if len(otrez) != 1:
for i in range(0, len(otrez) - 1):
if... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR N... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
if n <= 2:
print(n)
else:
al = list(map(int, input().split()))
sta = 0
nextsta = sta + 1
l = 0
while sta < n:
count = 0
last = al[sta]
nextsta = sta + 1
for end in range(nextsta, n):
if al[end] > last:
last = al[end]
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR IF... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
A = [int(ele) for ele in input().split(" ")]
if n <= 2:
print(n)
else:
LISend = [1] * n
LISbegin = [1] * n
for i in range(1, n):
if A[i] > A[i - 1]:
LISend[i] = LISend[i - 1] + 1
for i in range(n - 2, -1, -1):
if A[i] < A[i + 1]:
LISbegin[i] =... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NU... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
arr = list(map(int, input().split()))
left, right = [1] * n, [1] * n
left[0] = 0
for i in range(2, n):
if arr[i - 1] > arr[i - 2]:
left[i] += left[i - 1]
right[-1] = 0
for i in range(n - 3, -1, -1):
if arr[i + 1] < arr[i + 2]:
right[i] += right[i + 1]
ans = 1
for i in range(n):
... | 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 BIN_OP LIST NUMBER VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
sequence = [float("-inf")] + [int(i) for i in input().split()] + [float("inf")]
f1 = [0] * n
f2 = [0] * n
f3 = [
(True if sequence[i + 1] - sequence[i - 1] > 1 else False)
for i in range(1, len(sequence) - 1)
]
len_1 = 0
len_2 = 0
l = len(sequence) - 1
for i in range(1, len(sequence) - 1):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP LIST FUNC_CALL VAR STRING FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR LIST FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER NUMBER NUMBER VAR FUN... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
a = list(map(int, input().split()))
pre = [(1) for i in range(n)]
suf = [(1) for i in range(n)]
for i in range(1, n):
if a[i] > a[i - 1]:
pre[i] = pre[i - 1] + 1
for i in range(n - 2, -1, -1):
if a[i] < a[i + 1]:
suf[i] = suf[i + 1] + 1
ans = 0
for i in range(n):
if i == 0:
... | 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 VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
a = [int(x) for x in input().split()]
l, r = 0, 0
c = None
mx = 1
while r < n - 1:
r += 1
if a[r] <= (a[r - 1] if r - 1 != c else a[r - 2] + 1):
if c is not None and r - 1 == c and a[r - 1] < a[r]:
if a[c] < a[c + 1]:
l = c = c - 1
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NONE ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER NUMBER IF VAR NONE BIN_OP VAR NUMBER V... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
a = list(map(int, input().split()))
dp = [1] * n
for i in range(1, n):
if a[i] > a[i - 1]:
dp[i] = dp[i - 1] + 1
ans = 1
l = dp[-1]
for j in range(n - 1, 0, -1):
ans = max(ans, dp[j])
if dp[j - 1] >= dp[j]:
if j + 1 < n:
if (
a[j + 1] - a[j - 1] >... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR B... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | R = lambda: map(int, input().split())
n = int(input())
a = list(R())
dp = [1] * n
res = min(2, n)
for i in range(n - 2, -1, -1):
dp[i] = dp[i + 1] + 1 if a[i] < a[i + 1] else 1
cnt = 0
for i in range(n):
if 0 < i < n - 1 and a[i + 1] > a[i - 1] + 1:
res = max(res, cnt + dp[i + 1] + 1)
else:
... | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VA... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | def find_longest_streak(n, nums):
if n < 2:
return n
rights = [0] * n
lefts = [0] * n
rights[0] = 1
lefts[n - 1] = 1
for i in range(1, n):
if nums[i] > nums[i - 1]:
rights[i] = rights[i - 1] + 1
else:
rights[i] = 1
for i in range(n - 2, -1, -1)... | FUNC_DEF IF VAR NUMBER RETURN VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL ... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | N = int(input())
A = list(map(int, input().split()))
subseg = []
start = 0
for i in range(N - 1):
if A[i] >= A[i + 1]:
subseg.append((A[start], A[i], i - start, start, i))
start = i + 1
else:
if N - 1 == 0:
subseg.append((A[start], A[start], N - start - 1, start, start))
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | n = int(input())
arr = [int(x) for x in input().split(" ")]
af = [0] * n
ab = [0] * n
for i in range(n):
if i == 0 or arr[i] <= arr[i - 1]:
af[i] = 1
else:
af[i] = af[i - 1] + 1
for i in range(n - 1, -1, -1):
if i == n - 1 or arr[i] >= arr[i + 1]:
ab[i] = 1
else:
ab[i] = ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER FOR VA... |
DZY has a sequence a, consisting of n integers.
We'll call a sequence a_{i}, a_{i} + 1, ..., a_{j} (1 ≤ i ≤ j ≤ n) a subsegment of the sequence a. The value (j - i + 1) denotes the length of the subsegment.
Your task is to find the longest subsegment of a, such that it is possible to change at most one number (change... | def main():
n = int(input())
a = list(map(int, input().split()))
if n <= 2:
print(n)
return
left = [(0) for _ in range(n)]
right = [(0) for _ in range(n)]
left[0] = 1
right[-1] = 1
ans = 0
for i in range(1, n):
if a[i] > a[i - 1]:
left[i] = left[i ... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_... |
You are given two bracket sequences (not necessarily regular) s and t consisting only of characters '(' and ')'. You want to construct the shortest regular bracket sequence that contains both given bracket sequences as subsequences (not necessarily contiguous).
Recall what is the regular bracket sequence:
* () is t... | S, T = input(), input()
s1 = [(1 if c == "(" else -1) for c in S]
s2 = [(1 if c == "(" else -1) for c in T]
len1, len2 = len(s1), len(s2)
inf = 10**9
dp = [[([inf] * (len1 + len2 + 1)) for _ in range(len2 + 1)] for _ in range(len1 + 1)]
dp[0][0][0] = 0
for i in range(len1 + 1):
for j in range(len2 + 1):
for... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR STRING NUMBER NUMBER VAR VAR ASSIGN VAR VAR STRING NUMBER NUMBER VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP LIST VAR BIN_OP BIN_OP VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL ... |
You are given two bracket sequences (not necessarily regular) s and t consisting only of characters '(' and ')'. You want to construct the shortest regular bracket sequence that contains both given bracket sequences as subsequences (not necessarily contiguous).
Recall what is the regular bracket sequence:
* () is t... | def limitbal(a, b):
min_level = 0
level = 0
for aa in a:
if aa == "(":
level += 1
else:
level -= 1
if level < min_level:
min_level = level
for aa in b:
if aa == "(":
level += 1
else:
level -= 1
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR VAR FOR VAR VAR IF VAR STRING VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR VAR RETURN BIN_OP BIN_OP BIN_OP VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR... |
You are given two bracket sequences (not necessarily regular) s and t consisting only of characters '(' and ')'. You want to construct the shortest regular bracket sequence that contains both given bracket sequences as subsequences (not necessarily contiguous).
Recall what is the regular bracket sequence:
* () is t... | def scs(str1, str2):
INF = 10**9
dp = [[([INF] * 210) for _ in range(210)] for _ in range(210)]
dp[0][0][0] = 0
prv = [[([None] * 210) for _ in range(210)] for _ in range(210)]
len_str1 = len(str1)
len_str2 = len(str2)
str1 += "#"
str2 += "#"
for i in range(len_str1 + 1):
for... | FUNC_DEF ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP LIST VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NONE NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR STRING VA... |
You are given two bracket sequences (not necessarily regular) s and t consisting only of characters '(' and ')'. You want to construct the shortest regular bracket sequence that contains both given bracket sequences as subsequences (not necessarily contiguous).
Recall what is the regular bracket sequence:
* () is t... | import sys
import time
def play(s1, s2):
n = len(s1)
m = len(s2)
maxBalance = 200
dp = []
p = []
for i in range(0, n + 1):
dp.append([])
p.append([])
for j in range(0, m + 1):
dp[i].append([])
p[i].append([])
for a in range(0, maxBala... | IMPORT IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR LIST EXPR FUNC_CALL VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR LIST EXPR FUNC_CALL VAR ... |
You are given two bracket sequences (not necessarily regular) s and t consisting only of characters '(' and ')'. You want to construct the shortest regular bracket sequence that contains both given bracket sequences as subsequences (not necessarily contiguous).
Recall what is the regular bracket sequence:
* () is t... | s1 = input()
s2 = input()
inf = 10**8
n = len(s1)
m = len(s2)
d = [[[inf for x in range(n + m + 10)] for y in range(m + 10)] for z in range(n + 10)]
tata = [
[[(0) for x in range(n + m + 10)] for y in range(m + 10)] for z in range(n + 10)
]
d[0][0][0] = 0
for i in range(n + 1):
for j in range(m + 1):
i1... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP BIN... |
Monocarp is playing a game "Assimilation IV". In this game he manages a great empire: builds cities and conquers new lands.
Monocarp's empire has $n$ cities. In order to conquer new lands he plans to build one Monument in each city. The game is turn-based and, since Monocarp is still amateur, he builds exactly one Mon... | import sys
from sys import stdin
ans = 0
n, m = map(int, stdin.readline().split())
mod = 998244353
a = [list(map(int, stdin.readline().split())) for i in range(n)]
fac = 1
for i in range(1, n + 1):
fac *= i
inv = pow(fac, mod - 2, mod)
for j in range(m):
na = [a[i][j] for i in range(n)]
na.sort()
now =... | IMPORT ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR FOR VAR... |
Monocarp is playing a game "Assimilation IV". In this game he manages a great empire: builds cities and conquers new lands.
Monocarp's empire has $n$ cities. In order to conquer new lands he plans to build one Monument in each city. The game is turn-based and, since Monocarp is still amateur, he builds exactly one Mon... | import sys
input = sys.stdin.readline
fact, inv_fact = [0] * 21, [0] * 21
fact[0] = 1
mod = 998244353
def make_nCr_mod(max_n=20, mod=998244353):
global fact
global inv_fact
for i in range(max_n):
fact[i + 1] = fact[i] * (i + 1) % mod
inv_fact[-1] = pow(fact[-1], mod - 2, mod)
for i in rev... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR BIN_OP LIST NUMBER NUMBER BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER FUNC_DEF NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER VAR F... |
Monocarp is playing a game "Assimilation IV". In this game he manages a great empire: builds cities and conquers new lands.
Monocarp's empire has $n$ cities. In order to conquer new lands he plans to build one Monument in each city. The game is turn-based and, since Monocarp is still amateur, he builds exactly one Mon... | import sys
input = sys.stdin.buffer.readline
mod = 998244353
ans = 0
n, m = map(int, input().split())
fact = 1
for i in range(2, n + 1):
fact = fact * i % mod
inv_fact = pow(fact, mod - 2, mod)
dist = [list(map(int, input().split())) for i in range(n)]
for point in range(m):
time = [(n + 1 - dist[city][point] ... | IMPORT ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL... |
Monocarp is playing a game "Assimilation IV". In this game he manages a great empire: builds cities and conquers new lands.
Monocarp's empire has $n$ cities. In order to conquer new lands he plans to build one Monument in each city. The game is turn-based and, since Monocarp is still amateur, he builds exactly one Mon... | def get_one(ns, m):
n = len(ns)
ans = 1
for i in range(n):
t = ns[i] - i
if t <= 0:
return 0
ans = ans * t % m
return ans
def get_one_pre(ns: list):
ans = [0] * len(ns)
ns.sort()
l = 0
for i in range(len(ns)):
for j in range(l, len(ns)):
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR RETURN VAR FUNC_DEF VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VA... |
Monocarp is playing a game "Assimilation IV". In this game he manages a great empire: builds cities and conquers new lands.
Monocarp's empire has $n$ cities. In order to conquer new lands he plans to build one Monument in each city. The game is turn-based and, since Monocarp is still amateur, he builds exactly one Mon... | import sys
input = sys.stdin.readline
MOD = 998244353
def main():
n, m = map(int, input().split())
dlst = [list(map(int, input().split())) for _ in range(n)]
ans = 0
fact = 1
for i in range(2, n + 1):
fact *= i
fact %= MOD
for i in range(m):
lst = [dlst[j][i] for j in ... | IMPORT ASSIGN VAR VAR ASSIGN VAR NUMBER 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 VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR ... |
Monocarp is playing a game "Assimilation IV". In this game he manages a great empire: builds cities and conquers new lands.
Monocarp's empire has $n$ cities. In order to conquer new lands he plans to build one Monument in each city. The game is turn-based and, since Monocarp is still amateur, he builds exactly one Mon... | mod = 998244353
def gcd(a, b):
if a == 0 or b == 0:
return 1
while b:
a, b = b, a % b
return a
def gcdExtended(a, b):
if a == 0:
return b, 0, 1
gcd, x1, y1 = gcdExtended(b % a, a)
x = y1 - b // a * x1
y = x1
return gcd, x, y
def simpl(a):
gecd = gcd(a[0]... | ASSIGN VAR NUMBER FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER WHILE VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR RETURN VAR FUNC_DEF IF VAR NUMBER RETURN VAR NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR VAR RETURN VAR VAR VAR FUNC_DEF ASSIGN V... |
Monocarp is playing a game "Assimilation IV". In this game he manages a great empire: builds cities and conquers new lands.
Monocarp's empire has $n$ cities. In order to conquer new lands he plans to build one Monument in each city. The game is turn-based and, since Monocarp is still amateur, he builds exactly one Mon... | from sys import stdin
mod = 998244353
n, m = map(int, input().split())
arr = []
for i in range(m):
arr.append([])
for i in range(n):
temp = list(map(int, stdin.readline().split()))
for j in range(m):
arr[j].append(temp[j])
for i in range(m):
arr[i].sort()
ans = 1
for i in range(1, n + 1):
a... | ASSIGN VAR NUMBER 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 LIST 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 FOR VAR FUNC_CALL VAR VAR EXP... |
Monocarp is playing a game "Assimilation IV". In this game he manages a great empire: builds cities and conquers new lands.
Monocarp's empire has $n$ cities. In order to conquer new lands he plans to build one Monument in each city. The game is turn-based and, since Monocarp is still amateur, he builds exactly one Mon... | n, m = map(int, input().split())
mod = 998244353
dis = [([0] * (m + 1)) for i in range(n + 1)]
jc = 1
ans = 0
def ksm(a, b, p):
a = a % p
b = b % (p - 1)
cheng = a
ret = 1
while b > 0:
if b % 2:
ret = ret * cheng % p
cheng = cheng * cheng % p
b //= 2
return ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ... |
Monocarp is playing a game "Assimilation IV". In this game he manages a great empire: builds cities and conquers new lands.
Monocarp's empire has $n$ cities. In order to conquer new lands he plans to build one Monument in each city. The game is turn-based and, since Monocarp is still amateur, he builds exactly one Mon... | import sys
input = sys.stdin.readline
n, m = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(n)]
mod = 998244353
invF = 1
for i in range(1, n + 1):
invF = invF * i % mod
invF = pow(invF, mod - 2, mod)
ans = 0
for j in range(m):
cnt = [0] * (n + 1)
for i in range(n):
cn... | 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 VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN... |
Monocarp is playing a game "Assimilation IV". In this game he manages a great empire: builds cities and conquers new lands.
Monocarp's empire has $n$ cities. In order to conquer new lands he plans to build one Monument in each city. The game is turn-based and, since Monocarp is still amateur, he builds exactly one Mon... | import sys
input = sys.stdin.readline
get_int = lambda: int(input().rstrip())
get_arr = lambda: [int(w) for w in input().split()]
get_str = lambda: input().rstrip()
n, m = get_arr()
d = [get_arr() for _ in range(n)]
mod = 998244353
inv = 1
for t in range(1, n + 1):
inv *= pow(t, -1, mod)
inv %= mod
ans = 0
for... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBE... |
Monocarp is playing a game "Assimilation IV". In this game he manages a great empire: builds cities and conquers new lands.
Monocarp's empire has $n$ cities. In order to conquer new lands he plans to build one Monument in each city. The game is turn-based and, since Monocarp is still amateur, he builds exactly one Mon... | p = 998244353
def f(x, y):
r = 1
x = x % p
if x == 0:
return 0
while y > 0:
if y % 2 == 1:
r = r * x % p
y = y >> 1
x = x * x % p
return r
n, m = map(int, input().split())
l = []
for _ in range(n):
l.append(list(map(int, input().split())))
a = 1
fo... | ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER RETURN NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIG... |
Monocarp is playing a game "Assimilation IV". In this game he manages a great empire: builds cities and conquers new lands.
Monocarp's empire has $n$ cities. In order to conquer new lands he plans to build one Monument in each city. The game is turn-based and, since Monocarp is still amateur, he builds exactly one Mon... | def power(a, n, mod):
answer = 1
while n > 0:
if n % 2 == 0:
n //= 2
a = a * a % mod
else:
answer *= a
answer %= mod
n -= 1
return answer
def putin():
return map(int, input().split())
def main():
n, m = putin()
mod =... | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR NUMBER RETURN VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER B... |
Monocarp is playing a game "Assimilation IV". In this game he manages a great empire: builds cities and conquers new lands.
Monocarp's empire has $n$ cities. In order to conquer new lands he plans to build one Monument in each city. The game is turn-based and, since Monocarp is still amateur, he builds exactly one Mon... | MOD = 998244353
def inv_f(x):
return pow(x, MOD - 2, MOD)
inv = [0] * 50
for i in range(1, 50):
inv[i] = inv_f(i)
n, m = map(int, input().split())
board = []
for i in range(n):
board.append(list(map(int, input().split())))
out = 0
for j in range(m):
count = [0] * (n + 1)
for i in range(n):
... | ASSIGN VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR 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_CAL... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.