description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) v = list(map(int, input().split())) a = [0] * (n + 1) a[0] = 1 for i in range(1, n): if v[i] <= v[i - 1]: a[i] = 1 else: a[i] = a[i - 1] + 1 ans = [1] i = 1 while i < n - 1: if a[i] == 1: if v[i - 1] < v[i + 1]: j = a[i - 1] k = 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 BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER AS...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
def seq_len(arr, n): seqs = [] seq_b = 0 seq_e = 0 longest = -1 for i in range(0, n - 1): if arr[i + 1] > arr[i]: seq_e = i + 1 else: longest = max(longest, seq_e - seq_b + 1) seqs.append((seq_b, seq_e)) seq_b = i + 1 seq_e ...
FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP ...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) els = list(map(int, input().strip().split())) dp = [([0] * len(els)) for _ in range(2)] dp[0][0] = 1 dp[1][0] = 1 for i in range(1, len(els)): if els[i] > els[i - 1]: dp[0][i] = 1 + dp[0][i - 1] else: dp[0][i] = 1 for i in range(1, len(els)): if els[i] > els[i - 1]: ...
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 BIN_OP LIST NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR BIN_O...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) a = [int(i) for i in input().split()] d = [] actual = [a[0]] for i in range(1, n): if a[i] > a[i - 1]: actual.append(a[i]) else: d.append([len(actual), actual]) actual = [a[i]] d.append([len(actual), actual]) maxi = 0 if len(d) == 1: print(n) else: n = len(d) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR 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 LIST FUNC_CALL VAR VAR VAR ASSIGN VAR LIST VAR VAR EXPR FUNC_CALL VAR...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
N = int(input()) a = list(map(int, input().split())) dp = [([1] * 2) for i in range(N)] ans = 0 for i in range(N): if i == 0: continue else: if a[i - 1] < a[i]: dp[i][0] = max(dp[i][0], dp[i - 1][0] + 1) dp[i][1] = max(dp[i][1], dp[i - 1][1] + 1) if i > 1 and a[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 BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR VAR NUMBER FUNC_CALL VAR VAR VAR NUMBER BIN_OP VAR BI...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
import sys class Input: stdin_input = [] def get_next_token(self): if not self.stdin_input or len(self.stdin_input) == 0: self.stdin_input = sys.stdin.readline().split(" ") result = self.stdin_input[0] self.stdin_input = self.stdin_input[1:] return result def ...
IMPORT CLASS_DEF ASSIGN VAR LIST FUNC_DEF IF VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER RETURN VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) a = list(map(int, input().split())) dpright = [(1) for i in range(n)] for i in range(n - 2, -1, -1): if a[i] < a[i + 1]: dpright[i] = dpright[i + 1] + 1 dpleft = [(1) for i in range(n)] for i in range(1, n): if a[i] > a[i - 1]: dpleft[i] = dpleft[i - 1] + 1 m = max(dpright[0], d...
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 FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR ...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
from sys import stdin n = int(stdin.readline()) arr = [int(x) for x in stdin.readline().split()] flag = True for i in range(n - 1): if not arr[i] < arr[i + 1]: flag = False break if flag: print(n) quit() ans = 1 possible = [] prev, ptr = n - 1, n - 1 while ptr > 0: while ptr > 0 and arr...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR VAR BIN_OP VAR NUMBER...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) arr = list(map(int, input().split())) m = 1 l = 1 fw = [1] * n bw = [1] * n for i in range(1, n): if arr[i] > arr[i - 1]: l = l + 1 m = max(m, l) else: l = 1 fw[i] = l l = 1 for i in range(n - 2, -1, -1): if arr[i] < arr[i + 1]: l = l + 1 m = max(...
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 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 BIN_OP VAR NUMBER ASSIGN VAR FUNC...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) a = list(map(int, input().split())) + [0] max_len = 0 lr = [] cnt = left = right = 0 for i in range(n - 1): if a[i] < a[i + 1]: right += 1 else: lr.append([left, right]) left = right = i + 1 lr.append([left, right]) for i in range(len(lr) - 1): if lr[i][1] - lr[i][0]...
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 NUMBER ASSIGN VAR LIST ASSIGN VAR VAR VAR NUMBER 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 VAR BIN_...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
from sys import stdin n = int(stdin.readline().strip()) arr = list(map(int, stdin.readline().split())) dp1 = [0] * n for i in range(n - 1, -1, -1): if i == n - 1: dp1[i] = 1 continue if arr[i] < arr[i + 1]: dp1[i] = dp1[i + 1] + 1 else: dp1[i] = 1 dp2 = [0] * n for i in rang...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
def play(arr): n = len(arr) if n == 1: return 1 l = [0] * n r = [0] * n s = 0 for i in range(1, n): if arr[i] > arr[i - 1]: s += 1 l[i] = s else: s += 1 l[i] = s s = 0 s = 0 for i in range(n - 2, -1, -1):...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER RETURN NUMBER 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 VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VA...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) arr = [int(x) for x in input().split()] pre = [0] * n pos = [0] * n pre[0] = 1 pos[n - 1] = 1 for i in range(1, n): if arr[i] > arr[i - 1]: pre[i] = pre[i - 1] + 1 else: pre[i] = 1 for i in range(n - 2, -1, -1): if arr[i + 1] > arr[i]: pos[i] = pos[i + 1] + 1 els...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR 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 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...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
import sys n = int(sys.stdin.readline()) arr = list(map(int, sys.stdin.readline().split())) skip = [-1] * n noskip = [-1] * n noskip[0] = 1 prevskip = [-1] * n ans = 1 z = True for i in range(1, n): if arr[i] > arr[i - 1]: noskip[i] = noskip[i - 1] + 1 if z: skip[i] = skip[i - 1] + 1 ...
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 BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR ...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) b = [0] a = list(map(int, input().split())) a = b + a a1 = [0] * (n + 1) a2 = [0] * (n + 1) a1[1] = 1 for i in range(2, n + 1): if a[i] > a[i - 1]: a1[i] = a1[i - 1] + 1 a2[i] = a2[i - 1] + 1 else: a1[i] = 1 if a[i] > a[i - 2]: a2[i] = max(a2[i], a1[i - 2] + ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMB...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) l = [int(i) for i in input().split()] dp = [] for i in range(n): dp.insert(len(dp), 1) ma = 1 for i in range(1, n): if l[i] > l[i - 1]: dp[i] += dp[i - 1] ma = max(ma, dp[i]) else: j = i - 1 while j > 0 and l[j] > l[j - 1]: dp[j - 1] = dp[j] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) l = list(map(int, input().split())) res = [] temp = [l[0]] for j in range(1, n + 1): if j != n and l[j] > l[j - 1]: temp.append(l[j]) else: res.append(temp) temp = [l[j]] if j != n else 0 max_length = 0 for j in range(len(res)): max_length = max(max_length, len(res[j...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR LIST VAR VAR N...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) l = [int(x) for x in input().split()] l.append(0) l.insert(0, 987654321) m = [] idx = 0 max = 0 for x in range(1, n + 2): if l[x - 1] >= l[x]: m.append([idx, x - 1, x - 1 - idx + 1]) if x - 1 - idx + 1 > max: max = x - 1 - idx + 1 idx = x m.append([n + 1, n + 1, ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR LIST VAR BIN_O...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
N = int(input()) arr = list(map(int, input().split(" "))) counts = set() last = -1 for n in range(N): count = 1 delite = False delited = -1 i = n j = i + 1 if n < last: continue while True: if j < N: if arr[i] < arr[j]: count += 1 i...
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 FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR WHILE NUMBER IF VAR VAR IF VA...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
import sys fast_reader = sys.stdin.readline fast_writer = sys.stdout.write def input(): return fast_reader().strip() def print(*argv): fast_writer(" ".join(str(i) for i in argv)) fast_writer("\n") def list_input(): return list(map(int, input().split())) def sep_input(): return map(int, inpu...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) a = list(map(int, input().split())) d = [0] * n d[0] = 1 seg = [] for i in range(1, n): if a[i] > a[i - 1]: d[i] = d[i - 1] + 1 else: d[i] = 1 seg.append((d[i - 1], i - 1)) seg.append((d[n - 1], n - 1)) max_dist = seg[0][0] for i in range(1, len(seg)): dist_old, ind_...
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 NUMBER NUMBER ASSIGN VAR LIST 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 ...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
q = int(input()) a = list(map(int, input().split())) path = [1] start = [0] end = [0] max_len = [1] for i in range(1, len(a)): if a[i] > a[i - 1]: path.append(path[-1] + 1) max_len[-1] += 1 else: path.append(1) start.append(i) max_len.append(1) ans = max(max_len) for i in...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR LIST 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 NUMBER NUMBE...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) s = [int(x) for x in input().split()] ptr = 0 c = 1 L = [0] * len(s) L[0] = 1 P = [0] * len(s) for i in range(1, len(s)): if s[i] <= s[i - 1]: for j in range(ptr, i): P[j] = c c = 1 ptr = i else: c += 1 L[i] = c for j in range(ptr, len(s)): P[...
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 NUMBER ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER 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_O...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) a = [int(x) for x in input().split()] c, b, x, d = 1, 0, 0, 0 e, f, g, y = 0, 0, 0, 0 for i in range(1, n): if a[i - 1] < a[i]: c = c + 1 else: x = max(x, b + c - d) if a[i - 2] >= a[i]: b, d = 0, 0 else: d, b = 1, c c = 1 i = 0 x ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VA...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) l = list(map(int, input().split(" "))) lefts = [] leftsc = [] rights = [] rightsc = [] b = 0 for i in range(0, n - 1): if b == 0: if l[i] < l[i + 1]: b = 1 lefts.append(l[i]) leftsc.append(i) else: lefts.append(l[i]) leftsc...
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 LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CAL...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) a = list(map(int, input().split())) b = list(reversed(a)) dp = [1] * n dp1 = [1] * n for i in range(n - 1): dp[-i - 2] += dp[-i - 1] * int(b[i] > b[i + 1]) for i in range(n - 1): dp1[i + 1] += dp1[i] * int(a[i] < a[i + 1]) ans = max(dp1) for i in range(n - 2): ans = max(ans, (dp1[i] + dp[i ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER FUNC_CALL VA...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = input() s = input().split() s = [int(x) for x in s] maxis = [1] maxirs = [-1] maxit = 1 for i in range(1, len(s)): maxis.append(1) maxirs.append(-1) if s[i - 1] < s[i]: maxis[i] = maxis[i - 1] + 1 if maxirs[i - 1] != -1: maxirs[i] = maxirs[i - 1] + 1 if i > 1 and s[i - 2]...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR LIST NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR VAR BIN_OP VAR B...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) a = input().split() b = [] for i in a: b.append(int(i)) last = b[0] section = [b[0]] sections = [] for i in b[1:]: if i > last: section.append(i) else: sections.append(section) section = [i] last = i sections.append(section) ans = 0 for i in sections: ans = m...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST VAR NUMBER ASSIGN VAR LIST FOR VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR ASSIGN VAR VAR EXPR ...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
input() arr = list(map(int, input().split())) m_arr = [(1, 1), (2 if arr[-2] < arr[-1] else 1, 1)] for n in range(len(arr) - 3, -1, -1): t0 = m_arr[-1][0] + 1 if arr[n] < arr[n + 1] else 1 t1 = m_arr[-2][0] + 1 if arr[n] < arr[n + 2] else 1 m_arr.append((t0, t1)) idx = 0 while idx < len(m_arr): elem = m...
EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER VAR NUMBER VAR NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR VA...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) arr = list(map(int, input().strip().split())) maxi = 1 cont = 1 for i in range(n - 1): if arr[i] < arr[i + 1]: cont += 1 else: maxi = max(cont, maxi) cont = 1 maxi = max(cont, maxi) a_inc = [(1) for i in range(n)] a_dec = [(1) for i in range(n)] cont = 1 for i in range(1...
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 ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
def remove(n, a): i = 0 l = [] maxx = 0 while i < n: st = i end = i + 1 while end < n and a[end - 1] < a[end]: end += 1 l.append((st, end - 1)) diff = end - st if diff > maxx: maxx = diff i = end i = 1 while i < len(...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR FUNC_CALL ...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
from sys import stdin, stdout def INI(): return int(stdin.readline()) def INL(): return [int(_) for _ in stdin.readline().split()] def INS(): return stdin.readline() def MOD(): return pow(10, 9) + 7 def OPS(ans): stdout.write(str(ans) + "\n") def OPL(ans): [stdout.write(str(_) + " ")...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF RETURN BIN_OP FUNC_CALL VAR NUMBER NUMBER NUMBER FUNC_DEF EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR STRING FUNC_DEF EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR STRING VAR VA...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) l = list(map(int, input().split())) mass = [] p = [l[0]] le = [] for i in range(1, n): if l[i] > l[i - 1]: p += [l[i]] else: mass += [p] le += [len(p)] p = [l[i]] if len(p) > 0: le += [len(p)] mass += [p] res = max(le) for i2 in range(1, len(mass)): 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 LIST ASSIGN VAR LIST VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR LIST VAR VAR VAR LIST VAR VAR LIST FUNC_CALL VAR VAR ASSIGN VAR LIST VAR VAR IF FUNC_...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) arr = list(map(int, input().split())) index = -1 temp = 1 lis = [] ind = [] for i in range(n - 1): if arr[i + 1] > arr[i]: temp += 1 else: lis.append(temp) ind.append(i) temp = 1 index = i if index != n - 2: lis.append(temp) l = len(ind) p = len(lis) ...
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 ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBE...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
MOD = 1000000007 ii = lambda: int(input()) si = lambda: input() dgl = lambda: list(map(int, input())) f = lambda: map(int, input().split()) il = lambda: list(map(int, input().split())) ls = lambda: list(input()) n = ii() l = il() l1 = [1] * n l2 = [1] * n for i in range(1, n): if l[i - 1] < l[i]: l1[i] += l...
ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL V...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) a = list(map(int, input().split())) a.append end = [1] * n start = [1] * n tot = 0 for i in range(1, n): if a[i] > a[i - 1]: end[i] = end[i - 1] + 1 tot = max(tot, end[i]) else: end[i] = 1 i = n - 2 while i >= 0: if a[i] < a[i + 1]: start[i] = start[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 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 VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER AS...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) l = list(map(int, input().split())) ll = [] dum = [0, l[0]] i = 1 mxx = -1 while i < n: if l[i] > l[i - 1]: dum.append(l[i]) else: dum.append(i - 1) ll.append(dum) mxx = max(mxx, len(dum) - 2) dum = [i, l[i]] i += 1 if len(dum) >= 2: dum.append(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 LIST ASSIGN VAR LIST NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VA...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) arr = list(map(int, input().split())) start = 0 prev = arr[0] subarrays = [] for i, v in enumerate(arr): if i == 0: continue if v <= prev: if i - start > 1: subarrays.append((start, i - 1)) start = i prev = v i += 1 if i - start > 1: subarrays.append(...
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 VAR NUMBER ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR VAR NUM...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) l = list(map(int, input().split())) p = [0] * n z = [0] * n i = 0 d = 1 while i < len(l): cnt = 1 pi = i pj = i + 1 while pj < len(l): if l[pj] > l[pi]: cnt += 1 else: break pj += 1 pi += 1 j = i k1 = 1 k2 = cnt whi...
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 ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR FUNC_CALL ...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) a = list(map(int, input().split())) b = [1] * n tab = [] for i in range(n - 1): if a[i] < a[i + 1]: b[i + 1] = b[i] + 1 else: b[i + 1] = 1 tab.append((i - b[i] + 1, i, b[i])) tab.append((n - b[-1], n - 1, b[-1])) res = 0 for i in range(len(tab) - 1): res = max(res, t...
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 LIST FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER EXPR...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
import sys n = int(sys.stdin.readline().strip()) a = [int(i) for i in sys.stdin.readline().strip().split()] a.append(-2000000000.0) dp = [0] * (n + 1) dp[0] = 1 bg = 0 for i in range(1, n + 1): if a[i] > a[i - 1]: dp[i] = dp[i - 1] + 1 else: for j in range(bg, i): dp[j] = dp[i - 1] ...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) a = [int(i) for i in input().split()] l = [0] * n r = [0] * n l[0] = 1 for i in range(1, n): if a[i] > a[i - 1]: l[i] = l[i - 1] + 1 else: l[i] = 1 r[n - 1] = 1 for i in range(n - 2, -1, -1): if a[i] < a[i + 1]: r[i] = r[i + 1] + 1 else: r[i] = 1 final = ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR 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 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...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) a = list(map(int, input().split())) subarray = [] cur_length = 1 for i in range(n - 1): if a[i] < a[i + 1]: cur_length += 1 else: subarray.append(cur_length) cur_length = 1 subarray.append(cur_length) result = max(subarray) index_acc = 0 for i in range(len(subarray) - 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 ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASS...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) a = [int(x) for x in input().split()] a += [0] dp = [0] * (n + 5) i = n - 2 dp[n - 1] = 1 while i >= 0: if a[i] < a[i + 1]: dp[i] = dp[i + 1] + 1 else: dp[i] = 1 i -= 1 temp = 1 ans = 1 for i in range(1, n): if a[i + 1] > a[i - 1]: ans = max(ans, temp + dp[i + 1]...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR LIST NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER WHILE VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER N...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) L = list(map(int, input().split())) dp = [1] * n cnt = [1] * n dp[1], cnt[1] = (2, 2) if L[1] > L[0] else (1, 1) for idx in range(2, len(L)): cnt[idx] = cnt[idx - 1] + 1 if L[idx] > L[idx - 1] else 1 for idx in range(2, len(L)): dp[idx] = max( dp[idx - 1] + 1 if L[idx] > L[idx - 1] 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 BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR VAR V...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) nums = list(map(int, input().strip().split())) curUsed = [(0) for i in range(n)] curUnused = [(0) for i in range(n)] curUnused[0] = 1 ans = 1 for i in range(1, n): if nums[i] > nums[i - 1]: curUnused[i] = curUnused[i - 1] + 1 curUsed[i] = curUsed[i - 1] + 1 else: curUnus...
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 ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
def numbersListInput(): aux = list(map(int, input().strip().split())) return aux n = int(input()) a = numbersListInput() auxA = [1] * n auxB = [1] * n for i in range(1, n): if a[i] > a[i - 1]: auxA[i] = auxA[i - 1] + 1 for i in range(n - 2, -1, -1): if a[i] < a[i + 1]: auxB[i] = auxB[i...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
def main(): buf = input() n = int(buf) buf = input() buflist = buf.split() a = list(map(int, buflist)) sublen_inc = [] sublen_dec = [] for i in range(n): sublen_inc.append(None) sublen_dec.append(None) c = 1 sublen_inc[0] = c for i in range(1, n): if a...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NONE EXPR FUNC_CALL VAR NONE ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FOR VAR FUNC_C...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) line = input().split(" ") A = [] for e in line: A.append(int(e)) ans = 1 left = [1] * n right = [1] * n for i in range(1, n): if A[i] > A[i - 1]: left[i] = 1 + left[i - 1] if A[n - 1 - i] < A[n - i]: right[n - 1 - i] = 1 + right[n - i] ans = 1 for i in range(n): ans = ma...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR 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 VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP ...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
import sys input = sys.stdin.readline n = int(input()) A = list(map(int, input().split())) ANS = [0] * n count = 1 ANS[0] = 1 ANS2 = [0] * n ucount = 0 for i in range(1, n): if A[i] > A[i - 1]: count += 1 ANS[i] = count if ucount > 0: ucount += 1 ANS2[i] = ucount ...
IMPORT ASSIGN 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 BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMB...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) l = list(map(int, input().split())) ans = 1 count = 1 t = 1 ind = -1 for i in range(n - 1): if l[i] < l[i + 1]: count += 1 else: if ind == -1: ans = max(ans, count) elif l[ind - 1] < l[ind + 1] or l[ind] < l[ind + 2]: ans = max(ans, t + count - 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR BIN_...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
R = lambda: map(int, input().split()) n = int(input()) arr = list(R()) + [0] left, right = [0] * (n + 1), [0] * (n + 1) for i in range(n): left[i] = left[i - 1] + 1 if arr[i] > arr[i - 1] else 1 for i in range(n - 1, -1, -1): right[i] = right[i + 1] + 1 if arr[i] < arr[i + 1] else 1 res = max(left + right) for ...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR LIST NUMBER ASSIGN VAR VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) arr = list(map(int, input().split())) a = [] temp = [arr[0]] for i in range(1, n): if arr[i] > arr[i - 1]: temp.append(arr[i]) else: a.append(temp) temp = [arr[i]] a.append(temp) c = 0 ans = [] for i in range(len(a) - 1): x = a[i] y = a[i + 1] m = 0 n = 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 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 EXPR FUNC_CALL VAR VAR ASSIGN V...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) l = list(map(int, input().split())) end = [1] for i in range(1, n): if l[i] > l[i - 1]: end.append(end[-1] + 1) else: end.append(1) strt = [1] * n for i in range(n - 2, -1, -1): if l[i] < l[i + 1]: strt[i] = strt[i + 1] + 1 else: strt[i] = 1 ans = max(max...
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 BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) seq = list(map(int, input().split())) best = [None] * n best[0] = 1, 0 for i in range(1, n): if seq[i] > seq[i - 1]: a, b = best[i - 1][0] + 1, best[i - 1][1] + 1 if i >= 2 and seq[i] > seq[i - 2]: b = max(b, best[i - 2][0] + 1) best[i] = a, b else: a...
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 NONE VAR ASSIGN VAR NUMBER 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 NUMBER BIN_OP VAR BIN_OP VAR NUMB...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) ar = list(map(int, input().split())) l = [1] * n r = [1] * n ans = 0 for i in range(n - 1): if ar[i] < ar[i + 1]: l[i + 1] = l[i] + 1 for j in range(n - 1, 0, -1): if ar[j] > ar[j - 1]: r[j - 1] = r[j] + 1 for k in range(n - 2): if ar[k] < ar[k + 2]: ans = max(ans, 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 BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER FOR ...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
import sys input = sys.stdin.readline N = int(input()) A = list(map(int, input().split())) pre = -1 P = [] tmp = 0 for i, a in enumerate(A): if a > pre: P.append(tmp) else: tmp = i P.append(i) pre = a Q = [-1] * N tmp = N - 1 pre = N - 1 for i in reversed(range(N)): a = A[i] ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP LIST ...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) lis = [-1] + list(map(int, input().split())) + [0] ans = [0] + [1] * n + [1] prev = 0 for i in range(1, n + 1): if lis[i - 1] < lis[i]: ans[i] += ans[i - 1] k = max(ans) prev = 0 d = 0 ind = 0 for i in range(1, n + 2): if ans[i] == 1: if lis[ind + 2] > lis[ind]: d = ...
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 BIN_OP BIN_OP LIST NUMBER BIN_OP LIST NUMBER VAR LIST NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR VAR VA...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) l = list(map(int, input().split())) ans = [] v = [] x = [] for t in range(len(l)): if len(v) == 0: v.append(l[t]) elif l[t] > l[t - 1]: v.append(l[t]) else: ans.append(v) v = [l[t]] if t == len(l) - 1: ans.append(v) x.append(len(ans[-1])) for i in...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_C...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) a = list(map(int, input().split())) dp = [[0, 0] for i in range(n + 1)] dp[1][0] = 1 dp[1][1] = 1 for i in range(2, n + 1): if a[i - 1] > a[i - 2]: dp[i][0] = dp[i - 1][0] + 1 dp[i][1] = dp[i - 1][1] + 1 else: dp[i][0] = 1 dp[i][1] = 1 if i - 3 >= 0 and a[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 LIST NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR BIN_OP V...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
def maxIncSubarr(a, n): pre = [0] * n pos = [0] * n pre[0] = 1 pos[n - 1] = 1 l = 0 for i in range(1, n): if a[i] > a[i - 1]: pre[i] = pre[i - 1] + 1 else: pre[i] = 1 l = 1 for i in range(n - 2, -1, -1): if a[i] < a[i + 1]: pos[...
FUNC_DEF 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 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 ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
import sys def solve(): n = int(sys.stdin.readline()) arr = list(map(int, sys.stdin.readline().split())) arr.append(0) subarr = list() sappend = subarr.append start = 0 prev = arr[start] index = 1 mx = 0 while index <= n: cur = arr[index] if cur <= prev: ...
IMPORT FUNC_DEF 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 FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR VAR IF VAR VAR EXPR FUNC_CALL ...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) a = list(map(int, input().split())) ls = [] i = 0 while i < len(a): b = [] b.append(a[i]) i += 1 while i < len(a): if b[-1] < a[i]: b.append(a[i]) else: break i += 1 ls.append(b) mx = len(ls[0]) for i in range(len(ls) - 1): val = 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 ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR VAR VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) a = list(map(int, input().split())) sub = [1] for i in range(1, n): if a[i] > a[i - 1]: sub.append(sub[-1] + 1) else: sub.append(1) val = sub[n - 1] aa = [0] * n aa[n - 1] = 1 ans1 = max(sub) for i in range(n - 2, -1, -1): if sub[i] < sub[i + 1]: aa[i] = val - sub[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 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 VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST...
You are given an array $a$ consisting of $n$ integers. You can remove at most one element from this array. Thus, the final length of the array is $n-1$ or $n$. Your task is to calculate the maximum possible length of the strictly increasing contiguous subarray of the remaining array. Recall that the contiguous subar...
n = int(input()) a = [1e20] + list(map(int, input().split())) + [0] b = [0] * (n + 2) x = 0 for i in range(1, n + 1): if a[i] > a[i - 1]: x += 1 else: x = 1 b[i] = x x = 0 c = max(b) for i in range(n, 0, -1): if a[i - 1] < a[i + 1]: c = max(c, b[i - 1] + x) if a[i] < a[i + 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 BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER A...
Panda is fond of numbers. Given a number, he subtracts it with squares of any one particular digit of that number to get new numbers. This operation can be applied any number of times (possibly zero) till he obtains a pandatic number. If he is able to reach to a pandatic number then he wins. A pandatic number is a numb...
rr = raw_input panda = set([(k**k) for k in range(1, 8)]) dp = {} for i in range(10**6 + 1): dp[i] = None for i in panda: dp[i] = True def dpp(x): if dp[x] is not None: return dp[x] for d in str(x): cand = x - int(d) ** 2 if cand > 0 and dp[cand]: return True re...
ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR VAR NONE FOR VAR VAR ASSIGN VAR VAR NUMBER FUNC_DEF IF VAR VAR NONE RETURN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP FUNC_CALL V...
Panda is fond of numbers. Given a number, he subtracts it with squares of any one particular digit of that number to get new numbers. This operation can be applied any number of times (possibly zero) till he obtains a pandatic number. If he is able to reach to a pandatic number then he wins. A pandatic number is a numb...
""" pandatic_num = [] maxlimit = 10**6 + 1 for num in range(1, 10): numpow = num ** num if numpow <= maxlimit: val = 1 nextnum = (num + 1) ** (num + 1) pandatic_num.append(numpow) tempnum = numpow while tempnum <= (nextnum): tempnum = numpow + val**2 if str(val) in str(tempnum): pandatic_num.appen...
EXPR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING
Panda is fond of numbers. Given a number, he subtracts it with squares of any one particular digit of that number to get new numbers. This operation can be applied any number of times (possibly zero) till he obtains a pandatic number. If he is able to reach to a pandatic number then he wins. A pandatic number is a numb...
tc = int(input()) while tc: n = int(input()) if n == 90 or n == 91: print("No") elif n < 13: if n == 1 or n == 4: print("Yes") else: print("No") else: print("Yes") tc = tc - 1
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER
Panda is fond of numbers. Given a number, he subtracts it with squares of any one particular digit of that number to get new numbers. This operation can be applied any number of times (possibly zero) till he obtains a pandatic number. If he is able to reach to a pandatic number then he wins. A pandatic number is a numb...
t = int(eval(input())) for _ in range(t): n = int(eval(input())) if n == 90 or n == 91: print("No") elif n < 13: if n == 1 or n == 4: print("Yes") else: print("No") else: print("Yes")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING
It is the hard version of the problem. The difference is that in this version, there are nodes with already chosen colors. Theofanis is starving, and he wants to eat his favorite food, sheftalia. However, he should first finish his homework. Can you help him with this problem? You have a perfect binary tree of $2^k -...
MOD = 10**9 + 7 color = {"white": 0, "yellow": 5, "green": 2, "blue": 3, "red": 4, "orange": 1} special = {} marked = set() k = int(input()) n = int(input()) dp = {} def solve(i, j): if special.get(i, -1) != -1 and special[i] != j: return 0 if dp[i][j] != -1: return dp[i][j] nodel = 2 * i ...
ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR DICT STRING STRING STRING STRING STRING STRING NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT FUNC_DEF IF FUNC_CALL VAR VAR NUMBER NU...
It is the hard version of the problem. The difference is that in this version, there are nodes with already chosen colors. Theofanis is starving, and he wants to eat his favorite food, sheftalia. However, he should first finish his homework. Can you help him with this problem? You have a perfect binary tree of $2^k -...
k = int(input()) n = int(input()) l = [1] m = 10**9 + 7 for i in range(k - 1): l.append(16 * l[-1] ** 2 % m) counts = {} ind = {"white": 0, "green": 1, "red": 2, "yellow": 3, "blue": 4, "orange": 5} given = {} for i in range(n): v, c = input().split() v = int(v) c = ind[c] given[v] = c def count(k...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER VAR ASSIGN VAR DICT ASSIGN VAR DICT STRING STRING STRING STRING STRI...
It is the hard version of the problem. The difference is that in this version, there are nodes with already chosen colors. Theofanis is starving, and he wants to eat his favorite food, sheftalia. However, he should first finish his homework. Can you help him with this problem? You have a perfect binary tree of $2^k -...
import sys from sys import stdin cdic = {} cdic["white"] = 0 cdic["yellow"] = 0 cdic["green"] = 1 cdic["blue"] = 1 cdic["red"] = 2 cdic["orange"] = 2 mod = 10**9 + 7 k = int(stdin.readline()) n = int(stdin.readline()) dp = {} dplis = [] vtos = {} for i in range(n): v, s = stdin.readline()[:-1].split() v = int(...
IMPORT ASSIGN VAR DICT ASSIGN VAR STRING NUMBER ASSIGN VAR STRING NUMBER ASSIGN VAR STRING NUMBER ASSIGN VAR STRING NUMBER ASSIGN VAR STRING NUMBER ASSIGN VAR STRING NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN ...
It is the hard version of the problem. The difference is that in this version, there are nodes with already chosen colors. Theofanis is starving, and he wants to eat his favorite food, sheftalia. However, he should first finish his homework. Can you help him with this problem? You have a perfect binary tree of $2^k -...
import sys MOD = int(1000000000.0 + 7) colors_matrix = [ [2, 4, 3, 5], [2, 4, 3, 5], [0, 1, 4, 5], [0, 1, 4, 5], [0, 1, 2, 3], [0, 1, 2, 3], ] def rec(tree, vertex, level): global dp if vertex not in tree: return [dp[level]] * 6 vertex_color_restriction = tree[vertex] ...
IMPORT ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR LIST LIST NUMBER NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER NUMBER LIST NUMBER NUMBER NUMBER NUMBER FUNC_DEF IF VAR VAR RETURN BIN_OP LIST VAR VAR NUMBER...
Bessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However, Bessie is sure that there is a secret message hidden inside. The text is a string $s$ of lowercase Latin letters. She considers a string $t$ as hidden in string $s$ if $t$ exists as a subsequence of $s$ whose indices form an ari...
s = input() arr1 = [0] * 26 arr2 = [[(0) for k in range(26)] for i in range(26)] for i in s: c = ord(i) - ord("a") for j in range(26): arr2[j][c] += arr1[j] arr1[c] += 1 maxi = 0 for i in arr1: maxi = max(maxi, i) for i in arr2: maxi = max(maxi, max(i)) print(maxi)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VA...
Bessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However, Bessie is sure that there is a secret message hidden inside. The text is a string $s$ of lowercase Latin letters. She considers a string $t$ as hidden in string $s$ if $t$ exists as a subsequence of $s$ whose indices form an ari...
from sys import gettrace, stdin if not gettrace(): def input(): return next(stdin)[:-1] def main(): ss = [(ord(s) - ord("a")) for s in list(input())] lcount = [0] * 26 tlcount = [([0] * 26) for _ in range(26)] for s in ss: for i in range(26): tlcount[s][i] += lcount[i...
IF FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR NUMBER FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR VAR VAR ...
Bessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However, Bessie is sure that there is a secret message hidden inside. The text is a string $s$ of lowercase Latin letters. She considers a string $t$ as hidden in string $s$ if $t$ exists as a subsequence of $s$ whose indices form an ari...
import sys RI = lambda: [int(x) for x in sys.stdin.readline().split()] ri = lambda: sys.stdin.readline().strip() mod = 10**7 + 1 st = ri() cnt = [0] * 26 cnt2 = [[(0) for i in range(26)] for j in range(26)] ans = 0 for i in range(len(st)): c = ord(st[i]) - ord("a") for j in range(26): cnt2[j][c] += cnt...
IMPORT ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_...
Bessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However, Bessie is sure that there is a secret message hidden inside. The text is a string $s$ of lowercase Latin letters. She considers a string $t$ as hidden in string $s$ if $t$ exists as a subsequence of $s$ whose indices form an ari...
s = list(input()) list1 = [0] * 26 list2 = list() for i in range(26): p = [0] * 26 list2.append(p) for i in range(len(s)): t = ord(s[i]) - ord("a") for j in range(26): list2[j][t] += list1[j] list1[t] += 1 ans1 = 0 for i in range(26): ans1 = max(ans1, list1[i]) for i in range(26): fo...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER ...
Bessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However, Bessie is sure that there is a secret message hidden inside. The text is a string $s$ of lowercase Latin letters. She considers a string $t$ as hidden in string $s$ if $t$ exists as a subsequence of $s$ whose indices form an ari...
dp = [[(0) for i in range(26)] for j in range(26)] s = input() ans = [(0) for i in range(26)] ans[ord(s[0]) - ord("a")] = 1 for i in range(1, len(s)): for j in range(26): dp[j][ord(s[i]) - ord("a")] += ans[j] ans[ord(s[i]) - ord("a")] += 1 an = 0 for i in range(26): for j in range(26): an = ...
ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR STRING NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP FUNC_CALL VAR VAR VAR ...
Bessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However, Bessie is sure that there is a secret message hidden inside. The text is a string $s$ of lowercase Latin letters. She considers a string $t$ as hidden in string $s$ if $t$ exists as a subsequence of $s$ whose indices form an ari...
def solve(s, a, b): cnt = 0 res = 0 for ch in s: if ch == b: res += cnt if ch == a: cnt += 1 return res s = input() res = 0 for i in range(26): res = max(res, len([x for x in s if x == chr(i + 97)])) for j in range(26): res = max(res, solve(s, ch...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR VAR IF VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CAL...
Bessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However, Bessie is sure that there is a secret message hidden inside. The text is a string $s$ of lowercase Latin letters. She considers a string $t$ as hidden in string $s$ if $t$ exists as a subsequence of $s$ whose indices form an ari...
s = str(input()) num = [0] * 30 a = [[(0) for x in range(26)] for y in range(26)] res = 0 for i in range(0, len(s)): val = ord(s[i]) - ord("a") for j in range(26): a[j][val] += num[j] num[val] += 1 for i in range(26): for j in range(26): res = max(res, a[i][j]) res = max(res, max(num)) p...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR VAR V...
Bessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However, Bessie is sure that there is a secret message hidden inside. The text is a string $s$ of lowercase Latin letters. She considers a string $t$ as hidden in string $s$ if $t$ exists as a subsequence of $s$ whose indices form an ari...
s = input() n = len(s) arr = [(-1) for _ in range(n)] for i in range(n): arr[i] = ord(s[i]) - ord("a") ans = 0 cnt = [(0) for _ in range(26)] for i in range(n): cnt[arr[i]] += 1 ans = max(cnt) cntPrev = [(0) for _ in range(26)] cnt2 = [[(0) for _ in range(26)] for __ in range(26)] for i in range(n): for j i...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ...
Bessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However, Bessie is sure that there is a secret message hidden inside. The text is a string $s$ of lowercase Latin letters. She considers a string $t$ as hidden in string $s$ if $t$ exists as a subsequence of $s$ whose indices form an ari...
A = [(ord(a) - 97) for a in input()] N = len(A) X = [0] * 26 Y = [([0] * 26) for _ in range(26)] for a in A: for k in range(26): Y[k][a] += X[k] X[a] += 1 print(max([max(y) for y in Y] + X))
ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR V...
Bessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However, Bessie is sure that there is a secret message hidden inside. The text is a string $s$ of lowercase Latin letters. She considers a string $t$ as hidden in string $s$ if $t$ exists as a subsequence of $s$ whose indices form an ari...
a = input() s_map = {x: (0) for x in "abcdefghijklmnopqrstuvwxyz"} another_map = {} for i in range(0, len(a)): for x in s_map: if x + a[i] not in another_map: another_map[x + a[i]] = 0 another_map[x + a[i]] += s_map[x] s_map[a[i]] += 1 print(max(list(another_map.items()) + list(s_map...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR STRING ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR FOR VAR VAR IF BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR NUMBER VAR BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR FUNC_C...
Bessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However, Bessie is sure that there is a secret message hidden inside. The text is a string $s$ of lowercase Latin letters. She considers a string $t$ as hidden in string $s$ if $t$ exists as a subsequence of $s$ whose indices form an ari...
import sys message = sys.stdin.readline().strip() positions = {} for pos in range(len(message)): sym = message[pos] try: positions[sym].append(pos) except: positions[sym] = [pos] answer = 0 for sym in positions: answer = max(answer, len(positions[sym])) for sym1 in positions: for sy...
IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR LIST VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR FOR VAR VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUN...
Bessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However, Bessie is sure that there is a secret message hidden inside. The text is a string $s$ of lowercase Latin letters. She considers a string $t$ as hidden in string $s$ if $t$ exists as a subsequence of $s$ whose indices form an ari...
def solve(s): count = [0] * 26 count_pair = [([0] * 26) for _ in range(26)] res = -float("INF") for i in s: a = ord(i) - ord("a") for j in range(26): if count[j] == 0: continue count_pair[j][a] += count[j] res = max(count_pair[j][a], re...
FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING FOR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR...
Bessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However, Bessie is sure that there is a secret message hidden inside. The text is a string $s$ of lowercase Latin letters. She considers a string $t$ as hidden in string $s$ if $t$ exists as a subsequence of $s$ whose indices form an ari...
s = input() arr1 = [] arr2 = [] for i in range(26): lst = [] for j in range(26): lst.append(0) arr2.append(lst) arr1.append(0) for ch in s: ind = ord(ch) - ord("a") for j in range(26): arr2[j][ind] += arr1[j] arr1[ind] += 1 ans = 0 for i in range(26): ans = max(ans, arr1[...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR ...
Bessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However, Bessie is sure that there is a secret message hidden inside. The text is a string $s$ of lowercase Latin letters. She considers a string $t$ as hidden in string $s$ if $t$ exists as a subsequence of $s$ whose indices form an ari...
s = str(input()) cml = [[(0) for i in range(len(s) + 1)] for j in range(26)] c = 1 for i in s: k = ord(i) - ord("a") cml[k][c] = cml[k][c - 1] + 1 for j in range(26): if j != k: cml[j][c] = cml[j][c - 1] c += 1 ab = [[(0) for i in range(26)] for j in range(26)] c = 1 for k in s: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING ASSIGN VAR VAR VAR BIN_OP VAR VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR AS...
Bessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However, Bessie is sure that there is a secret message hidden inside. The text is a string $s$ of lowercase Latin letters. She considers a string $t$ as hidden in string $s$ if $t$ exists as a subsequence of $s$ whose indices form an ari...
s = input().strip() prev = [[(0) for i in range(len(s))] for i in range(26)] prev[ord(s[0]) - ord("a")][0] = 1 for index in range(1, len(s)): cmp = ord(s[index]) - ord("a") for letter in range(26): prev[letter][index] = prev[letter][index - 1] prev[cmp][index] = prev[cmp][index - 1] + 1 dp1 = [[(0) ...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR STRING NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VA...
Bessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However, Bessie is sure that there is a secret message hidden inside. The text is a string $s$ of lowercase Latin letters. She considers a string $t$ as hidden in string $s$ if $t$ exists as a subsequence of $s$ whose indices form an ari...
s = input() co = [0] * 26 co2 = [0] * (26 * 26) for a in s: a = ord(a) - ord("a") for b in range(26): r = a + 26 * b co2[r] += co[b] co[a] += 1 print(max(max(co), max(co2)))
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP NUMBER NUMBER FOR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR VAR VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_...
Bessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However, Bessie is sure that there is a secret message hidden inside. The text is a string $s$ of lowercase Latin letters. She considers a string $t$ as hidden in string $s$ if $t$ exists as a subsequence of $s$ whose indices form an ari...
s = list(input()) n = len(s) t = [[(0) for i in range(26)] for i in range(26)] o = [(0) for i in range(26)] ans = 0 for i in range(n): for j in range(26): t[j][ord(s[i]) - 97] += o[j] o[ord(s[i]) - 97] += 1 ans = max(ans, max(o)) for i in range(26): for j in range(26): ans = max(ans, t[i][j]...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR VAR VAR BIN_OP FUNC_...
Bessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However, Bessie is sure that there is a secret message hidden inside. The text is a string $s$ of lowercase Latin letters. She considers a string $t$ as hidden in string $s$ if $t$ exists as a subsequence of $s$ whose indices form an ari...
s = input() n = len(s) count1 = [(0) for _ in range(26)] count2 = [[(0) for _ in range(26)] for _ in range(26)] for i in range(n): curr = ord(s[i]) - 97 for j in range(26): count2[j][curr] += count1[j] count1[curr] += 1 ans = 0 for i in range(26): ans = max(ans, count1[i]) for j in range(26)...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ...
Bessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However, Bessie is sure that there is a secret message hidden inside. The text is a string $s$ of lowercase Latin letters. She considers a string $t$ as hidden in string $s$ if $t$ exists as a subsequence of $s$ whose indices form an ari...
s = input().strip() alph = "abcdefghijklmnopqrstuvwxyz" mx = max(s.count(i) for i in alph) for first in alph: for second in alph: count = 0 sc = s.count(second) for i in s: if i == second: sc -= 1 if i == first: count += sc mx =...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FOR VAR VAR FOR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR IF VAR VAR VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR
Bessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However, Bessie is sure that there is a secret message hidden inside. The text is a string $s$ of lowercase Latin letters. She considers a string $t$ as hidden in string $s$ if $t$ exists as a subsequence of $s$ whose indices form an ari...
q = 1 for i in range(q): s = list(input()) a = [0] * 26 arr = [([0] * 26) for i in range(26)] for i in range(len(s)): for j in range(26): arr[j][ord(s[i]) - 97] += a[j] a[ord(s[i]) - 97] += 1 ans = max(a) for i in range(26): for j in range(26): ans...
ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR VAR VAR BIN_OP FUNC_C...
Bessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However, Bessie is sure that there is a secret message hidden inside. The text is a string $s$ of lowercase Latin letters. She considers a string $t$ as hidden in string $s$ if $t$ exists as a subsequence of $s$ whose indices form an ari...
s = input() dp = [] n = len(s) dp1 = {} for _ in range(n): dp.append(list([0] * 26)) dp[0][ord(s[0]) - ord("a")] += 1 ans = 1 for i in range(1, len(s)): vl = ord(s[i]) - ord("a") for j in range(26): dp[i][j] = dp[i - 1][j] if dp[i - 1][j]: vl1 = chr(ord("a") + j) + s[i] ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP LIST NUMBER NUMBER VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR STRING NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BI...
Bessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However, Bessie is sure that there is a secret message hidden inside. The text is a string $s$ of lowercase Latin letters. She considers a string $t$ as hidden in string $s$ if $t$ exists as a subsequence of $s$ whose indices form an ari...
a, b = {}, {} for x in input(): for y in a: b[x, y] = b.get((x, y), 0) + a.get(y, 0) a[x] = a.get(x, 0) + 1 print(max(0, 0, *a.values(), *b.values()))
ASSIGN VAR VAR DICT DICT FOR VAR FUNC_CALL VAR FOR VAR VAR ASSIGN VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER NUMBER FUNC_CALL VAR FUNC_CALL VAR
Bessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However, Bessie is sure that there is a secret message hidden inside. The text is a string $s$ of lowercase Latin letters. She considers a string $t$ as hidden in string $s$ if $t$ exists as a subsequence of $s$ whose indices form an ari...
F = [[(0) for i in range(26)] for j in range(26)] t = [0] * 26 s = input() ans = 0 for k in s: number = ord(k) - 97 for m in range(26): F[number][m] += t[m] ans = max(ans, F[number][m]) t[number] += 1 ans = max(ans, t[number]) print(ans)
ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR F...
Bessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However, Bessie is sure that there is a secret message hidden inside. The text is a string $s$ of lowercase Latin letters. She considers a string $t$ as hidden in string $s$ if $t$ exists as a subsequence of $s$ whose indices form an ari...
s = list(input()) al = [] als = [] for i in s: if i in al: als[al.index(i)] += 1 else: al.append(i) als.append(1) ans1 = max(als) for i in al: for j in al: if i != j: f = 0 ans2 = 0 for k in range(len(s)): if s[k] == i: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF VAR VAR VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR FOR VAR VAR IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR V...
Bessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However, Bessie is sure that there is a secret message hidden inside. The text is a string $s$ of lowercase Latin letters. She considers a string $t$ as hidden in string $s$ if $t$ exists as a subsequence of $s$ whose indices form an ari...
s = input() instant_count = {} dict = {} a = set(s) a = "".join(a) for q in a: instant_count[q] = 0 for i in s: for j in a: x = j + i if x not in dict: dict[x] = instant_count[j] else: dict[x] += instant_count[j] instant_count[i] += 1 print(max(max(instant_cou...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL STRING VAR FOR VAR VAR ASSIGN VAR VAR NUMBER FOR VAR VAR FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_C...
Bessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However, Bessie is sure that there is a secret message hidden inside. The text is a string $s$ of lowercase Latin letters. She considers a string $t$ as hidden in string $s$ if $t$ exists as a subsequence of $s$ whose indices form an ari...
s = input() n = len(s) dp = [[(0) for i in range(26)] for j in range(n + 1)] for i in range(n): for j in range(26): if ord(s[i]) - ord("a") == j: dp[i + 1][j] = dp[i][j] + 1 else: dp[i + 1][j] = dp[i][j] m1 = 0 for i in range(26): p = dp[n][i] m1 = max(m1, p * (p - 1)...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING VAR ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR BIN_O...
Bessie the cow has just intercepted a text that Farmer John sent to Burger Queen! However, Bessie is sure that there is a secret message hidden inside. The text is a string $s$ of lowercase Latin letters. She considers a string $t$ as hidden in string $s$ if $t$ exists as a subsequence of $s$ whose indices form an ari...
s = input() ss = "a b c d e f g h i j k l m n o p q r s t u v w x y z".split() d1 = {} d2 = {} for ssi in ss: d1[ssi] = 0 for i in ss: for k in ss: d2[i + k] = 0 for si in s: for ki in d1.keys(): d2[ki + si] += d1[ki] d1[si] += 1 print(max(max(d1.values()), max(d2.values())))
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL STRING ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR VAR NUMBER FOR VAR VAR FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER FOR VAR VAR FOR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CA...