description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Gaurang has grown up in a mystical universe. He is faced by $n$ consecutive 2D planes. He shoots a particle of decay age $k$ at the planes. A particle can pass through a plane directly, however, every plane produces an identical copy of the particle going in the opposite direction with a decay age $k-1$. If a particle...
for t in range(int(input())): n, k = map(int, input().split()) dp = [([0] * 1013) for i in range(1013)] ans = 1 for i in range(1, k + 1): for j in range(n + 1): dp[i][j] = ( 1 if j == 0 or i == 1 else (dp[i - 1][n - j] + dp[i][j - 1]) %...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER VAR NUMBER NUMBE...
Gaurang has grown up in a mystical universe. He is faced by $n$ consecutive 2D planes. He shoots a particle of decay age $k$ at the planes. A particle can pass through a plane directly, however, every plane produces an identical copy of the particle going in the opposite direction with a decay age $k-1$. If a particle...
from sys import stdin mod = pow(10, 9) + 7 t = int(stdin.readline().rstrip()) matrix_l = [([0] * 1001) for _ in range(1000)] matrix_r = [([0] * 1001) for _ in range(1000)] for _ in range(t): n, k = list(map(int, stdin.readline().rstrip().split())) for i in range(k): matrix_l[i][0] = 1 matrix_r[...
ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL F...
Gaurang has grown up in a mystical universe. He is faced by $n$ consecutive 2D planes. He shoots a particle of decay age $k$ at the planes. A particle can pass through a plane directly, however, every plane produces an identical copy of the particle going in the opposite direction with a decay age $k-1$. If a particle...
e = 1000000007 ma = {} def get(n, k, f): if ma[n][k][f] == -1: if k == 1: ma[n][k][f] = 1 elif k == 2: ma[n][k][f] = f + 1 elif f == 0: ma[n][k][f] = 1 else: res = get(n, k - 1, n - f) + get(n, k, f - 1) if res > e: ...
ASSIGN VAR NUMBER ASSIGN VAR DICT FUNC_DEF IF VAR VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER...
Gaurang has grown up in a mystical universe. He is faced by $n$ consecutive 2D planes. He shoots a particle of decay age $k$ at the planes. A particle can pass through a plane directly, however, every plane produces an identical copy of the particle going in the opposite direction with a decay age $k-1$. If a particle...
T = int(input()) while T: n, k = map(int, input().split()) ps = [([0] * 1007) for i in range(1007)] ans = 1 if k > 1: ans += n for i in range(1, n + 1): ps[k - 1][i] = 1 turn = 0 for i in range(k - 2, 0, -1): if not turn: for j in range(n - 1, 0, -...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR...
Gaurang has grown up in a mystical universe. He is faced by $n$ consecutive 2D planes. He shoots a particle of decay age $k$ at the planes. A particle can pass through a plane directly, however, every plane produces an identical copy of the particle going in the opposite direction with a decay age $k-1$. If a particle...
import sys input = sys.stdin.readline MOD = 1000000007 for _ in range(int(input())): n, k = map(int, input().split()) if k == 1: print(1) continue if n == 1: print(2) continue dp1 = [[(0) for i in range(n + 2)] for j in range(k + 1)] dp2 = [[(0) for i in range(n + 2)...
IMPORT ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASS...
Gaurang has grown up in a mystical universe. He is faced by $n$ consecutive 2D planes. He shoots a particle of decay age $k$ at the planes. A particle can pass through a plane directly, however, every plane produces an identical copy of the particle going in the opposite direction with a decay age $k-1$. If a particle...
import time from itertools import accumulate t = int(input()) for _ in range(t): n, k = list(map(int, input().split())) M = 10**9 + 7 if n == 1: print(1 + int(k > 1)) else: crossing = [[None for p in range(n)] for age in range(k + 1)] crossing[k] = [(1) for p in range(n)] ...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR NONE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN...
Gaurang has grown up in a mystical universe. He is faced by $n$ consecutive 2D planes. He shoots a particle of decay age $k$ at the planes. A particle can pass through a plane directly, however, every plane produces an identical copy of the particle going in the opposite direction with a decay age $k-1$. If a particle...
mod = 10**9 + 7 for t in range(int(input())): n, k = map(int, input().split()) n -= 1 state = [1] * n total = 1 if k == 1 else 2 nextState = [0] * n for _ in range(k - 1): temp = 0 for i in range(n): temp = (temp + state[i]) % mod nextState[n - i - 1] = te...
ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR N...
Gaurang has grown up in a mystical universe. He is faced by $n$ consecutive 2D planes. He shoots a particle of decay age $k$ at the planes. A particle can pass through a plane directly, however, every plane produces an identical copy of the particle going in the opposite direction with a decay age $k-1$. If a particle...
import sys def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int, sys.stdin.readline().rstrip().split()) def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) def LI2(): return list(map(int, sys.stdin.readline().rstrip())) def S(): return sys.stdin.re...
IMPORT FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL V...
Gaurang has grown up in a mystical universe. He is faced by $n$ consecutive 2D planes. He shoots a particle of decay age $k$ at the planes. A particle can pass through a plane directly, however, every plane produces an identical copy of the particle going in the opposite direction with a decay age $k-1$. If a particle...
import sys input = sys.stdin.readline mod = 10**9 + 7 for _ in range(int(input())): n, k = map(int, input().split()) dp = [([0] * (n + 1)) for _ in range(k + 1)] for i in range(1, k + 1): cur = 1 for j in range(n + 1): dp[i][j] = cur if j < n: cur = (...
IMPORT ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUM...
Gaurang has grown up in a mystical universe. He is faced by $n$ consecutive 2D planes. He shoots a particle of decay age $k$ at the planes. A particle can pass through a plane directly, however, every plane produces an identical copy of the particle going in the opposite direction with a decay age $k-1$. If a particle...
def helper(n, k): if k == 1: return 1 mod = 1000000007 res = n + 1 k -= 1 dp = [1] * n flag = -1 while k > 1: ndp = [0] * n if flag == -1: for i in range(n - 2, -1, -1): ndp[i] = (dp[i + 1] + ndp[i + 1]) % mod flag = 1 e...
FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR...
Gaurang has grown up in a mystical universe. He is faced by $n$ consecutive 2D planes. He shoots a particle of decay age $k$ at the planes. A particle can pass through a plane directly, however, every plane produces an identical copy of the particle going in the opposite direction with a decay age $k-1$. If a particle...
MOD = 1000000000.0 + 7 T = int(input()) coldp = [] def getsum(row1, row2, col): global coldp row1 -= 1 if row1 < 0: return coldp[row2][col] else: return coldp[row2][col] - coldp[row1][col] for t in range(T): n, k = [int(i) for i in input().split()] dp = [[(-1) for i in range(...
ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_DEF VAR NUMBER IF VAR NUMBER RETURN VAR VAR VAR RETURN BIN_OP VAR VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER V...
Gaurang has grown up in a mystical universe. He is faced by $n$ consecutive 2D planes. He shoots a particle of decay age $k$ at the planes. A particle can pass through a plane directly, however, every plane produces an identical copy of the particle going in the opposite direction with a decay age $k-1$. If a particle...
for i in range(int(input())): n, k = map(int, input().split()) dp = [([0] * n) for j in range(k - 1)] if k > 1: for j in range(n): dp[0][j] = 1 for j in range(1, k - 1): if j % 2 == 1: for l in range(1, n): dp[j][l] = (dp[j][l - 1] + dp[j - 1][l - ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER...
Gaurang has grown up in a mystical universe. He is faced by $n$ consecutive 2D planes. He shoots a particle of decay age $k$ at the planes. A particle can pass through a plane directly, however, every plane produces an identical copy of the particle going in the opposite direction with a decay age $k-1$. If a particle...
def sol(n, k): m = 1000000007 if k == 1: return 1 elif n == 1: return 2 arr = [[(0) for j in range(n)] for p in range(2)] sum = 0 if k < 3: return (sum + n + 1) % m for i in range(n): sum += i arr[(k - 2) % 2][n - i - 1] = i k = k - 2 buf_sum =...
FUNC_DEF ASSIGN VAR NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER RETURN BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP VA...
Gaurang has grown up in a mystical universe. He is faced by $n$ consecutive 2D planes. He shoots a particle of decay age $k$ at the planes. A particle can pass through a plane directly, however, every plane produces an identical copy of the particle going in the opposite direction with a decay age $k-1$. If a particle...
MODULE = 10**9 + 7 def r(n, k): a = [(1) for _ in range(n + 1)] new_a = [(0) for _ in range(n + 1)] cur_k = 1 while cur_k < k: new_a[0] = 1 for i in range(1, n + 1): new_a[i] = (new_a[i - 1] + a[n - i]) % MODULE cur_k += 1 a, new_a = new_a, a return a[-1...
ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VA...
Gaurang has grown up in a mystical universe. He is faced by $n$ consecutive 2D planes. He shoots a particle of decay age $k$ at the planes. A particle can pass through a plane directly, however, every plane produces an identical copy of the particle going in the opposite direction with a decay age $k-1$. If a particle...
mod = 10**9 + 7 cas = int(input()) while cas: cas -= 1 n, k = map(int, input().split()) dp = [(1) for i in range(n)] ans = 1 for i in range(k - 1): tmp = 0 for j in range(n): ans = (ans + dp[j]) % mod if i % 2 == 0: for j in range(n - 1, -1, -1): ...
ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR 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 ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_...
Gaurang has grown up in a mystical universe. He is faced by $n$ consecutive 2D planes. He shoots a particle of decay age $k$ at the planes. A particle can pass through a plane directly, however, every plane produces an identical copy of the particle going in the opposite direction with a decay age $k-1$. If a particle...
mod = int(1000000000.0 + 7) def iter_solver(N, K): dp = [[[(-1) for _ in range(2)] for __ in range(K + 1)] for ___ in range(N + 1)] for i in range(1, N + 1): dp[i][1][0] = dp[i][1][1] = 1 for k in range(2, K + 1): for n in range(N, 0, -1): ans = 2 if n < N: ...
ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER VAR VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBE...
Gaurang has grown up in a mystical universe. He is faced by $n$ consecutive 2D planes. He shoots a particle of decay age $k$ at the planes. A particle can pass through a plane directly, however, every plane produces an identical copy of the particle going in the opposite direction with a decay age $k-1$. If a particle...
mod = 10**9 + 7 def solve(n, k): left = [([0] * n) for _ in range(k + 1)] right = [([0] * n) for _ in range(k + 1)] res = 1 for i in range(n): right[k][i] = 1 for a in range(k - 1, 0, -1): for i in range(1, n): right[a][i] = left[a + 1][i - 1] + right[a][i - 1] ...
ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER F...
Gaurang has grown up in a mystical universe. He is faced by $n$ consecutive 2D planes. He shoots a particle of decay age $k$ at the planes. A particle can pass through a plane directly, however, every plane produces an identical copy of the particle going in the opposite direction with a decay age $k-1$. If a particle...
import sys from sys import stdin def solve(N, K): res_array = [0] * K if K == 1: return 1 if K == 2: return 1 + N res_array[0] = 1 res_array[1] = N old_array = [1] * (N - 1) for i in range(2, K): new_array = [0] * (N - 1) val = 0 for j in range(N - 1...
IMPORT FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN BIN_OP NUMBER VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR F...
Gaurang has grown up in a mystical universe. He is faced by $n$ consecutive 2D planes. He shoots a particle of decay age $k$ at the planes. A particle can pass through a plane directly, however, every plane produces an identical copy of the particle going in the opposite direction with a decay age $k-1$. If a particle...
t = int(input()) mod = 1000000007 for _ in range(t): n, k = list(map(int, input().split())) if k == 1: print(1) continue if n == 1: print(2) continue a = [1] * n total = 1 total += n k -= 1 r = True if k == 1: print(total) else: for...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR 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 NUMBER VAR VAR VAR NUMBER ASSIGN VAR NUMB...
Gaurang has grown up in a mystical universe. He is faced by $n$ consecutive 2D planes. He shoots a particle of decay age $k$ at the planes. A particle can pass through a plane directly, however, every plane produces an identical copy of the particle going in the opposite direction with a decay age $k-1$. If a particle...
from sys import gettrace, stdin if gettrace(): def inputi(): return input() else: def input(): return next(stdin)[:-1] def inputi(): return stdin.buffer.readline() MOD = 1000000007 def solve(): n, k = map(int, input().split()) if k == 1: print(1) retu...
IF FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR F...
Gaurang has grown up in a mystical universe. He is faced by $n$ consecutive 2D planes. He shoots a particle of decay age $k$ at the planes. A particle can pass through a plane directly, however, every plane produces an identical copy of the particle going in the opposite direction with a decay age $k-1$. If a particle...
import sys input = sys.stdin.readline def solve(): n, k = map(int, input().split()) m = 10**9 + 7 dp = [] for i in range(0, 1013): dp.append([0] * 1013) for i in range(1, k + 1): for j in range(0, n + 1): if j == 0 or i == 1: dp[i][j] = 1 el...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NU...
Gaurang has grown up in a mystical universe. He is faced by $n$ consecutive 2D planes. He shoots a particle of decay age $k$ at the planes. A particle can pass through a plane directly, however, every plane produces an identical copy of the particle going in the opposite direction with a decay age $k-1$. If a particle...
import sys get_string = lambda: sys.stdin.readline().strip() get_intmap = lambda: map(int, get_string().split()) for t in range(int(get_string())): n, k = get_intmap() m = int(1000000000.0 + 7) current_decay_age = k total_particles = 1 right = 1 start = 1 if current_decay_age > 1: l...
IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP...
Gaurang has grown up in a mystical universe. He is faced by $n$ consecutive 2D planes. He shoots a particle of decay age $k$ at the planes. A particle can pass through a plane directly, however, every plane produces an identical copy of the particle going in the opposite direction with a decay age $k-1$. If a particle...
t = int(input()) mod = 10**9 + 7 for _ in range(t): n, k = map(int, input().split()) ans = 2 if k == 1: ans = 1 elif n == 1: ans = 2 elif k > 1: count = 0 temp = [(1) for i in range(n - 1)] for i in range(k - 1, 0, -1): if count == 0: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BI...
a is an array of n positive integers, all of which are not greater than n. You have to process q queries to this array. Each query is represented by two numbers p and k. Several operations are performed in each query; each operation changes p to p + ap + k. There operations are applied until p becomes greater than n. ...
import sys n = int(sys.stdin.buffer.readline().decode("utf-8")) a = [0] + list(map(int, sys.stdin.buffer.readline().decode("utf-8").split())) q = int(sys.stdin.buffer.readline().decode("utf-8")) dp_size = 200 dp = [([1] * (n + 1)) for _ in range(dp_size + 1)] for k in range(1, dp_size + 1): for i in range(n, 0, -1...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUM...
This version of the problem differs from the next one only in the constraint on n. Note that the memory limit in this problem is lower than in others. You have a vertical strip with n cells, numbered consecutively from 1 to n from top to bottom. You also have a token that is initially placed in cell n. You will move...
primes = [] for p in range(2, 6000): is_prime = True for p2 in primes: if p2 * p2 > p: break if p % p2 == 0: is_prime = False break if is_prime: primes.append(p) def factor(n): d = {} for p in primes: if p * p > n: bre...
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR VAR VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR DICT FOR VAR VAR IF BIN_OP VAR VAR VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BI...
This version of the problem differs from the next one only in the constraint on n. Note that the memory limit in this problem is lower than in others. You have a vertical strip with n cells, numbered consecutively from 1 to n from top to bottom. You also have a token that is initially placed in cell n. You will move...
n, M = map(int, input().split()) if n == 1: print(1) exit(0) dp = [1] * (n + 1) accu = [0] * (n + 1) accu[1] = 1 accu[2] = 2 for j in range(4, n + 1, 2): dp[j] += dp[2] for i in range(3, n + 1): dp[i] += accu[i - 1] for j in range(2 * i, n + 1, i): dp[j] += dp[i] dp[j] = dp[j] % M ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR 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 FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMB...
This version of the problem differs from the next one only in the constraint on n. Note that the memory limit in this problem is lower than in others. You have a vertical strip with n cells, numbered consecutively from 1 to n from top to bottom. You also have a token that is initially placed in cell n. You will move...
class BIT: def __init__(self, n: int): q = 1 << (n - 1).bit_length() + 1 self.ceiling = q self.bittree = [0] * (q + 1) def updatebit(self, v: int, n: int): v = v * 2 - 1 self.bittree[v] = n while v < self.ceiling: s = int(v) count = 0 ...
CLASS_DEF FUNC_DEF VAR ASSIGN VAR BIN_OP NUMBER BIN_OP FUNC_CALL BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FUNC_DEF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER VAR...
This version of the problem differs from the next one only in the constraint on n. Note that the memory limit in this problem is lower than in others. You have a vertical strip with n cells, numbered consecutively from 1 to n from top to bottom. You also have a token that is initially placed in cell n. You will move...
n, m = map(int, input().split()) sumL = [0] * (n + 2) L = [0] * (n + 1) L[-1], sumL[-2] = 1, 1 for i in range(n - 1, 0, -1): L[i] = sumL[i + 1] j = 2 while i * j <= n: L[i] += sumL[i * j] - sumL[min(n, (i + 1) * j - 1) + 1] j += 1 L[i] = L[i] % m sumL[i] = (sumL[i + 1] + L[i]) % m pr...
ASSIGN VAR 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 NUMBER VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VA...
This version of the problem differs from the next one only in the constraint on n. Note that the memory limit in this problem is lower than in others. You have a vertical strip with n cells, numbered consecutively from 1 to n from top to bottom. You also have a token that is initially placed in cell n. You will move...
n, m = map(int, input().split()) dp = [0] * (n + 2) s = [0] * (n + 2) dp[n] = 1 s[n] = 1 for i in range(n - 1, 0, -1): dp[i] = s[i + 1] for j in range(2, n // i + 1): h = min(n + 1, (i + 1) * j) dp[i] = (dp[i] + s[i * j] - s[h]) % m s[i] = (s[i + 1] + dp[i]) % m print(dp[1])
ASSIGN VAR 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 ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN...
This version of the problem differs from the next one only in the constraint on n. Note that the memory limit in this problem is lower than in others. You have a vertical strip with n cells, numbered consecutively from 1 to n from top to bottom. You also have a token that is initially placed in cell n. You will move...
n, M = map(int, input().split()) fact = [{} for i in range(n + 1)] for i in range(1, n + 1): for j in range(i, n + 1, i): fact[j][i] = 1 dp = [0] * (n + 1) accu = [0] * (n + 1) dp[1] = 1 dp[2] = 2 extra = 0 for i in range(3, n + 1): dp[i] = 2 * dp[i - 1] % M for ele in fact[i]: if ele == i: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR N...
This version of the problem differs from the next one only in the constraint on n. Note that the memory limit in this problem is lower than in others. You have a vertical strip with n cells, numbered consecutively from 1 to n from top to bottom. You also have a token that is initially placed in cell n. You will move...
N, MOD = map(int, input().split()) DP = [0] * N DP[0] = 1 Cum = [0] * (N + 1) Cum[1] = 1 for i1 in range(1, N): i2 = N - i1 Value = Cum[i1] for j in range(2, N + 1): if i2 * j > N: break Value += Cum[N - i2 * j + 1] - Cum[max(0, N - i2 * j - j + 1)] Value %= MOD Cum[i...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN...
This version of the problem differs from the next one only in the constraint on n. Note that the memory limit in this problem is lower than in others. You have a vertical strip with n cells, numbered consecutively from 1 to n from top to bottom. You also have a token that is initially placed in cell n. You will move...
for u in range(1): n, m = map(int, input().split()) dp = [(0) for i in range(n + 1)] dp[1] = 1 p = [0] * (n + 1) cache = [[] for i in range(n + 1)] a = 0 b = 1 for i in range(2, n + 1): for j in cache[i]: a = (a - dp[p[j]] + m) % m p[j] += 1 a ...
FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL V...
This version of the problem differs from the next one only in the constraint on n. Note that the memory limit in this problem is lower than in others. You have a vertical strip with n cells, numbered consecutively from 1 to n from top to bottom. You also have a token that is initially placed in cell n. You will move...
def solve(n, mod): a = [0] * (n - 1) + [1] b = [0] * (n - 1) + [1] for i in range(n - 2, -1, -1): a[i], m = b[i + 1], 2 s = (i + 1) * m - 1 while s < n: e = min((i + 2) * m - 2, n - 1) a[i] = (a[i] + b[s] - b[e] + a[e]) % mod m += 1 s =...
FUNC_DEF ASSIGN VAR BIN_OP BIN_OP LIST NUMBER BIN_OP VAR NUMBER LIST NUMBER ASSIGN VAR BIN_OP BIN_OP LIST NUMBER BIN_OP VAR NUMBER LIST NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER WHILE VAR VAR ASSIGN ...
This version of the problem differs from the next one only in the constraint on n. Note that the memory limit in this problem is lower than in others. You have a vertical strip with n cells, numbered consecutively from 1 to n from top to bottom. You also have a token that is initially placed in cell n. You will move...
import sys input = sys.stdin.readline n, m = map(int, input().split()) mod = m dp = [0] * (n + 3) dp[n] = 1 sdp = [0] * (n + 3) sdp[n] = 1 for x in range(n - 1, 0, -1): dp[x] += sdp[x + 1] dp[x] %= mod z = 2 while x * z <= n: l = x * z r = (x + 1) * z - 1 if r > n: r...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER VAR VAR VAR BIN_OP VAR NUMBER VA...
This version of the problem differs from the next one only in the constraint on n. Note that the memory limit in this problem is lower than in others. You have a vertical strip with n cells, numbered consecutively from 1 to n from top to bottom. You also have a token that is initially placed in cell n. You will move...
from sys import stdin input = stdin.readline def add(x, y): return (x % mod + y % mod) % mod def sub(x, y): return (x - y + mod) % mod def answer(): dp = [0] * (n + 1) prefix = [0] * (n + 2) dp[n] = 1 for i in range(n, 0, -1): dp[i] = add(dp[i], prefix[i + 1]) j = 2 ...
ASSIGN VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_C...
This version of the problem differs from the next one only in the constraint on n. Note that the memory limit in this problem is lower than in others. You have a vertical strip with n cells, numbered consecutively from 1 to n from top to bottom. You also have a token that is initially placed in cell n. You will move...
import sys input = sys.stdin.readline def ri(): return [int(i) for i in input().split()] def rs(): return input().split()[0] def main(): t = 1 for _ in range(t): n, m = ri() ans = [0] * (n + 1) sum = [0] * (n + 2) ans[n] = 1 sum[n] = 1 for x in rang...
IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR 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 ...
This version of the problem differs from the next one only in the constraint on n. Note that the memory limit in this problem is lower than in others. You have a vertical strip with n cells, numbered consecutively from 1 to n from top to bottom. You also have a token that is initially placed in cell n. You will move...
n, M = map(int, input().split(" ")) D = [[] for _ in range(n + 1)] for d in range(2, n + 1): for dst in range(2 * d, n + 1, d): D[dst].append(d) F = [None] * (n + 1) F[1] = 1 F[2] = 2 for x in range(3, n + 1): F[x] = (2 * F[x - 1] + F[x // (x - 1)]) % M S = 0 for d in D[x]: if 2 <= d <= ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP LIST NONE BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMB...
This version of the problem differs from the next one only in the constraint on n. Note that the memory limit in this problem is lower than in others. You have a vertical strip with n cells, numbered consecutively from 1 to n from top to bottom. You also have a token that is initially placed in cell n. You will move...
import sys from sys import path_hooks, stdin, stdout def mapinput(): return map(int, stdin.readline().split()) n, m = mapinput() factors = [[] for i in range(n + 1)] for i in range(1, n + 1): for j in range(i + i, n + 1, i): factors[j].append(i) for test in range(1): def solve(): memo =...
IMPORT FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_DEF ASS...
This version of the problem differs from the next one only in the constraint on n. Note that the memory limit in this problem is lower than in others. You have a vertical strip with n cells, numbered consecutively from 1 to n from top to bottom. You also have a token that is initially placed in cell n. You will move...
from sys import gettrace, stdin if gettrace(): def inputi(): return input() else: def input(): return next(stdin)[:-1] def inputi(): return stdin.buffer.readline() def main(): n, m = map(int, input().split()) nways = [0, 1, 2] + [0] * (n - 1) divisors = [[] for _ i...
IF FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR...
This version of the problem differs from the next one only in the constraint on n. Note that the memory limit in this problem is lower than in others. You have a vertical strip with n cells, numbered consecutively from 1 to n from top to bottom. You also have a token that is initially placed in cell n. You will move...
n, mod = map(int, input().split()) if n == 1: print(1) exit() fact = [{} for i in range(n + 1)] for i in range(1, n + 1): for j in range(i, n + 1, i): fact[j][i] = 1 ans = [0] * n ans[0] = 1 ans[1] = 2 for i in range(2, n): ans[i] = 2 * ans[i - 1] % mod for j in fact[i + 1]: if j == ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR DICT VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER V...
This version of the problem differs from the next one only in the constraint on n. Note that the memory limit in this problem is lower than in others. You have a vertical strip with n cells, numbered consecutively from 1 to n from top to bottom. You also have a token that is initially placed in cell n. You will move...
n, m = map(int, input().split()) dp = [(0) for i in range(n + 3)] dp2 = [(0) for i in range(n + 3)] dp[n] = 1 dp2[n] = 1 for i in range(n - 1, 0, -1): dp[i] = dp2[i + 1] % m mul = 2 while i * mul <= n: dp[i] = (dp[i] % m + dp2[i * mul] % m - dp2[min((i + 1) * mul, n + 1)] % m) % m mul += 1 ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR ASSIGN VA...
This version of the problem differs from the next one only in the constraint on n. Note that the memory limit in this problem is lower than in others. You have a vertical strip with n cells, numbered consecutively from 1 to n from top to bottom. You also have a token that is initially placed in cell n. You will move...
n, m = map(int, input().split()) dp = [(0) for i in range(n + 1)] dp[1] = 1 dp[2] = 2 for i in range(2, n + 1): if i > 2: dp[i] = (dp[i] + dp[i - 1] + dp[i - 1] + 1) % m for j in range(i + i, n + 1, i): dp[j] = (dp[j] + dp[i] - dp[i - 1]) % m print((dp[n] + m) % m)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER NUM...
This version of the problem differs from the next one only in the constraint on n. Note that the memory limit in this problem is lower than in others. You have a vertical strip with n cells, numbered consecutively from 1 to n from top to bottom. You also have a token that is initially placed in cell n. You will move...
n, m = map(int, input().split()) c = [0] * n + [1] + [0] * n for i in range(n - 1, 0, -1): c[i] = 2 * c[i + 1] % m for j in range(2, n // i + 1): c[i] = (c[i] + c[i * j] - c[(i + 1) * j]) % m print((c[1] - c[2]) % m)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP LIST NUMBER VAR LIST NUMBER BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR BIN_OP BIN_OP NUMBER VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN...
This version of the problem differs from the next one only in the constraint on n. Note that the memory limit in this problem is lower than in others. You have a vertical strip with n cells, numbered consecutively from 1 to n from top to bottom. You also have a token that is initially placed in cell n. You will move...
import sys input = sys.stdin.readline n, m = map(int, input().split()) dp = [0] * (n + 2) dp[n] = 1 for i in range(n - 1, 0, -1): dpi = dp[i + 1] j = 2 while i * j < n + 2: dpi += dp[i * j] - dp[min(n + 1, (i + 1) * j)] dpi %= m j += 1 dp[i] = dpi + dp[i + 1] dp[i] %= m ans ...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR BIN_OP VAR V...
This version of the problem differs from the next one only in the constraint on n. Note that the memory limit in this problem is lower than in others. You have a vertical strip with n cells, numbered consecutively from 1 to n from top to bottom. You also have a token that is initially placed in cell n. You will move...
n, M = map(int, input().split()) dp = [0] * (n + 1) accu = [0] * (n + 1) dp[1] = 1 dp[2] = 1 accu[1] = 1 accu[2] = 2 extra = 0 for i in range(3, n + 1): dp[i] = accu[i - 1] for j in range(1, int(i**0.5) + 1): if i % j == 0: dp[i] += dp[j] dp[i] = dp[i] % M if j > 1 an...
ASSIGN VAR 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 NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER AS...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) ar = list(map(int, input().split())) su = r * ar[-1] suf = [0] * n for i in range(n - 1, -1, -1): su = suf[i] = max(r * ar[i], su) pr = p * ar[0] ans = -1111111111111111111111111111 for i in range(n): pr = max(pr, p * ar[i]) ans = max(ans, pr + q * ar[i] + suf[i]) prin...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR ...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = input().split() x = [] x = list(map(int, input().split())) p = int(p) q = int(q) r = int(r) for i in range(int(n)): t = int(x[i]) if i == 0: a = t * p b = a + t * q c = b + t * r else: if a < t * p: a = t * p if b < a + t * q: b = ...
ASSIGN VAR VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER ASSIGN VAR BIN_O...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) z = list(map(int, input().split())) pmini = [z[0]] pmaxa = [z[0]] xa = [z[0]] for i in range(1, len(z)): pmini.append(min(pmini[-1], z[i])) pmaxa.append(max(pmaxa[-1], z[i])) rmini = [(0) for i in range(len(z))] rmaxa = [(0) for i in range(len(z))] rmini[-1] = z[-1] rmaxa[...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER ASSIGN VAR LIST VAR NUMBER ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR VAR EXPR FUN...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
import sys input = sys.stdin.readline n, p, q, r = map(int, input().split()) l = list(map(int, input().split())) dpleft = [float("-inf") for _ in range(n)] dpright = [(0) for _ in range(n)] leftmax = float("-inf") for i in range(n): leftmax = max(leftmax, p * l[i]) dpleft[i] = leftmax rightmax = float("-inf") ...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUN...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
import sys input = sys.stdin.readline n, p, q, r = map(int, input().split()) a = list(map(int, input().split())) s1 = [(a[i] * p) for i in range(n)] s2 = [] m = s1[0] for i in range(n): m = max(m, s1[i]) s2.append(m + a[i] * q) s3 = [] m = s2[0] for i in range(n): m = max(m, s2[i]) s3.append(m + a[i] *...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CAL...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) a = list(map(int, input().split())) dpp = [(0) for i in range(n)] dpq = [(0) for i in range(n)] dpr = [(0) for i in range(n)] dpp[0] = a[0] * p dpq[0] = a[0] * q + dpp[0] dpr[0] = a[0] * r + dpq[0] for i in range(1, n): dpp[i] = max(dpp[i - 1], a[i] * p) dpq[i] = max(dpq[i...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER BIN_OP BIN...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = list(map(int, input().split())) arr = list(map(int, input().split())) premax = [] suffmax = [] for i in arr: premax.append(i * p) suffmax.append(i * r) for i in range(1, n): premax[i] = max(premax[i], premax[i - 1]) for i in range(2, n + 1): suffmax[-i] = max(suffmax[-i], suffmax[-i + 1]) m...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR ...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, x, y, z = map(int, input().split()) l = [int(x) for x in input().split()] a = -1e21 b = -1e21 c = -1e21 for i in range(n): temp = l[i] a = max(a, x * temp) b = max(b, a + y * temp) c = max(c, b + z * temp) print(c)
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP VAR VAR ...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
from sys import stdin, stdout nmbr = lambda: int(stdin.readline()) lst = lambda: list(map(int, stdin.readline().split())) for _ in range(1): n, p, q, r = lst() a = lst() NI = float("-inf") dp1 = [NI] * n dp2 = [NI] * n dp3 = [NI] * n for i in range(n): if i == 0: dp1[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 VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST VAR VAR ASSIGN VAR BIN_OP LIST VAR VAR ASSIGN VAR BIN_OP LIST VAR VA...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) arr = list(map(int, input().split())) dp = [] for i in range(n): dp.append([0, 0, 0]) dp[0][0] = p * arr[0] dp[0][1] = (p + q) * arr[0] dp[0][2] = (p + q + r) * arr[0] for i in range(1, n): dp[i][0] = max(p * arr[i], dp[i - 1][0]) dp[i][1] = max(dp[i][0] + q * arr[i], ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER NUMBER BIN_OP BIN_OP VAR VAR VAR NUM...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
s = input() c = s.split(" ") for i in range(4): c[i] = int(c[i]) s = input() a = s.split(" ") for i in range(c[0]): a[i] = int(a[i]) a[i] = [c[1] * a[i], c[2] * a[i], c[3] * a[i]] dp = [[0, 0, 0] for i in range(c[0])] m1 = -1000000000000000001 m2 = -2000000000000000001 m3 = -3000000000000000001 for i in ran...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR LIST BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR VA...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = [int(x) for x in input().split()] a = list(map(int, input().split())) ap = [a[0] * p] * n for i in range(1, n): ap[i] = max(ap[i - 1], a[i] * p) aq = [a[0] * q + ap[0]] * n for i in range(1, n): aq[i] = max(aq[i - 1], a[i] * q + ap[i]) ar = [a[0] * r + aq[0]] * n for i in range(1, n): ar[i] = m...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST BIN_OP VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP LIST BIN_OP BI...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) a = list(map(int, input().split())) ans = p * a[0] + q * a[0] + r * a[0] b = [0] * n c = [0] * n d = [0] * n e = [0] * n b[0] = a[0] c[0] = a[0] for i in range(1, n): b[i] = max(b[i - 1], a[i]) c[i] = min(c[i - 1], a[i]) d[n - 1] = a[n - 1] e[n - 1] = a[n - 1] for i in ran...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
def main(): n, p, q, r = [int(i) for i in input().split()] L = [int(i) for i in input().split()] LR_big = [L[0]] LR_small = [L[0]] for i in range(1, len(L)): LR_big.append(max(L[i], LR_big[-1])) LR_small.append(min(L[i], LR_small[-1])) RL_big = [L[-1]] RL_small = [L[-1]] ...
FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = input().split() n = int(n) p = int(p) q = int(q) r = int(r) arr = [int(i) for i in input().split()] def ring(arr, p, q, r): max_ = p * arr[0] + q * arr[0] + r * arr[0] maxr = [r * arr[-1]] maxl = [p * arr[0]] for i in range(1, len(arr)): maxl.append(max(p * arr[i], maxl[i - 1])) ...
ASSIGN VAR VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER ...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
P_I = 0 Q_I = 1 R_I = 2 def solve(n, pqr, a): max_p = [(0) for _ in range(n)] max_r = [(0) for _ in range(n)] max_p[0] = pqr[P_I] * a[0] max_r[n - 1] = pqr[R_I] * a[n - 1] for i in range(1, n): max_p[i] = max(max_p[i - 1], pqr[P_I] * a[i]) for k in range(n - 2, -1, -1): max_r[k...
ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER BIN_OP VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR B...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) a = list(map(int, input().split())) max_pa_i = [0] * n max_pa_i[0] = a[0] * p for i in range(1, n): max_pa_i[i] = max(a[i] * p, max_pa_i[i - 1]) max_ra_k = [0] * n max_ra_k[-1] = a[-1] * r for i in range(n - 2, -1, -1): max_ra_k[i] = max(a[i] * r, max_ra_k[i + 1]) x = -(10...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR ...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
def sign(n): return n // abs(n) n, p, q, r = map(int, input().split()) A = list(map(int, input().split())) Q = q P = p R = r if p <= 0 and q <= 0 and r <= 0: print((p + q + r) * min(A)) elif p >= 0 and q >= 0 and r >= 0: print((p + q + r) * max(A)) elif p * r >= 0 and p < 0: b = [] max1 = -9999999...
FUNC_DEF RETURN BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR FUNC_CALL ...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, q, s, r = list(map(int, input().split())) a = list(map(int, input().split())) pmax_f = [a[0]] pmin_f = [a[0]] for i in range(n): pmax_f += [max(pmax_f[-1], a[i])] pmin_f += [min(pmin_f[-1], a[i])] pmax_e = [a[-1]] pmin_e = [a[-1]] for i in range(n): i = n - i - 1 pmax_e += [max(pmax_e[-1], a[i])] ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR LIST FUNC_CALL VAR VAR NUMBER VAR VAR VAR LIST FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = [int(x) for x in input().split()] arr = [int(x) for x in input().split()] maxP = [] maxim = float("-inf") for i in range(n): maxP.append(arr[i] * p) maxim = max(maxim, arr[i] * p) maxP[i] = maxim maxim = float("-inf") maxR = [float("-inf") for x in range(n)] for i in range(n - 1, -1, -1): m...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
max1 = [] max2 = [] max3 = [] N, A, B, C = map(int, input().split()) p = list(map(int, input().split())) max1.append(-100000000000000000000) max2.append(-100000000000000000000) max3.append(-100000000000000000000) for x in range(1, N + 1): max1.append(max(max1[x - 1], A * p[x - 1])) for x in range(1, N + 1): max...
ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL ...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
def fun(n, p, q, r, li): sfmax = [(0) for i in range(n)] sfmax[n - 1] = r * li[n - 1] for j in range(n - 2, -1, -1): sfmax[j] = max(sfmax[j + 1], r * li[j]) ans = -float("inf") pmax = [] pmax.append(p * li[0]) for i in range(1, n): pmax.append(max(pmax[j - 1], p * li[i])) ...
FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR LIST EXPR FUNC_CALL VAR BIN_OP VAR VAR NUM...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) x = [int(i) for i in input().split()] x1 = [0] * n x2 = [0] * n x3 = [0] * n x1[0] = p * x[0] x2[0] = x1[0] + q * x[0] x3[0] = x2[0] + r * x[0] for i in range(1, len(x)): x1[i] = max(x1[i - 1], p * x[i]) x2[i] = max(x2[i - 1], q * x[i] + x1[i]) x3[i] = max(x3[i - 1], r...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBE...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
def binarySearch(arr, x): l = 0 r = len(arr) - 1 while l <= r: mid = (l + r) // 2 if arr[mid] == x: return mid elif arr[mid] < x: l = mid + 1 else: r = mid - 1 return -1 n, p, q, r = map(int, input().split()) ar = list(map(int, input(...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR RETURN VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CA...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
a = list(map(int, input().split())) arr = list(map(int, input().split())) n = a[0] dp = [[(0) for i in range(4)] for j in range(n + 1)] for i in range(4): dp[0][i] = (-10) ** 27 for i in range(1, n + 1): for j in range(1, 4): x = arr[i - 1] * a[j] + dp[i][j - 1] y = dp[i - 1][j] dp[i][j]...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
_, x, y, z = map(int, input().split()) a = list(map(int, input().split())) def ans(x, y, z, a): dummy_x, dummy_x_y, dummy_x_y_z = [-1 * float("inf")] * 3 for e in a: dummy_x = max(dummy_x, e * x) dummy_x_y = max(dummy_x_y, dummy_x + e * y) dummy_x_y_z = max(dummy_x_y_z, dummy_x_y + e *...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR VAR BIN_OP LIST BIN_OP NUMBER FUNC_CALL VAR STRING NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP VAR...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
Arr = list(map(int, input().split())) p = Arr[1] q = Arr[2] r = Arr[3] org_arr = list(map(int, input().split())) precal_premax = [-1] * len(org_arr) precal_suffmax = [-1] * len(org_arr) max_ele = p * org_arr[0] for i in range(len(org_arr)): if max_ele < p * org_arr[i]: max_ele = org_arr[i] * p precal_pr...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VA...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) nums = list(map(int, input().split())) dp0 = [(0) for i in range(100000)] dp1 = [(0) for i in range(100000)] dp2 = [(0) for i in range(100000)] dp0[0] = nums[0] * p for i in range(1, n): dp0[i] = max(dp0[i - 1], nums[i] * p) dp1[0] = dp0[0] + nums[0] * q for i in range(1, n): ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL V...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
x = list(map(int, input().split())) n = x[0] x[0] = 0 data = list(map(int, input().split())) ans = [-(10**19)] * 4 ans[0] = 0 for i in data: for j in range(1, 4): ans[j] = max(ans[j], ans[j - 1] + x[j] * i) print(ans[3])
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR ...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) v = list(map(int, input().split())) d = [0] * n for i in range(n - 1, -1, -1): if i == n - 1: d[i] = r * v[i] elif d[i + 1] > r * v[i]: d[i] = d[i + 1] else: d[i] = r * v[i] now, ans = 0, -3 * 10**18 for i in range(n): if i == 0: now...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR 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 BIN_OP VAR VAR VAR IF VAR BIN_OP VAR NUMBER BIN_OP VAR VAR V...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
a = [int(i) for i in input().split()] arr = [int(i) for i in input().split()] p, q, r = a[1], a[2], a[3] suff = [(0) for i in range(a[0])] suff[len(suff) - 1] = arr[len(arr) - 1] * r for i in range(len(arr) - 2, -1, -1): suff[i] = max(suff[i + 1], arr[i] * r) pre = arr[0] * p pre = max(pre, arr[0] * p) c = pre + ar...
ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER BIN_OP VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FOR VAR FUNC_CALL...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = list(map(int, input().split())) a = list(map(int, input().split())) dp1 = [0] * n for i in range(n): if i == 0: dp1[i] = p * a[i] else: dp1[i] = max(dp1[i - 1], p * a[i]) dp2 = [0] * n for i in range(n): if i == 0: dp2[i] = p * a[i] + q * a[i] else: dp2[i] = ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR ...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) arr = list(map(int, input().split())) n = len(arr) if n == 1: print(arr[0] * (p + q + r)) else: pref = [arr[0]] if p > 0: for i in range(1, n): pref.append(max(pref[-1], arr[i])) else: for i in range(1, n): pref.append(min(pr...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR LIST VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUN...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = input().split() n = int(n) p = int(p) q = int(q) r = int(r) ls = list(map(int, input().split())) ans = -9223372036854775807 ls1 = [None] * n ls2 = [None] * n ls3 = [None] * n ls5 = [None] * n ls4 = [([None] * n) for i in range(3)] for i in range(0, n): ls1[i] = p * ls[i] ls2[i] = r * ls[i] ls5[...
ASSIGN VAR VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR 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 LIST NONE VAR ASSIGN VAR BIN_OP LIST NONE VAR ASSIGN V...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
inf = int(1e-12) m = inf n, p, q, r = map(int, input().split(" ")) arr = list(map(int, input().split(" "))) dp = [[inf, inf, inf] for i in range(n + 1)] dp[1][0] = arr[0] * p dp[1][1] = arr[0] * q + dp[1][0] dp[1][2] = arr[0] * r + dp[1][1] for i in range(2, n + 1): dp[i][0] = max(arr[i - 1] * p, dp[i - 1][0]) ...
ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBE...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) l = list(map(int, input().split())) dp = [[(0) for i in range(n)] for j in range(3)] for i in range(3): for j in range(n): if i == 0: if j == 0: dp[i][j] = l[j] * p else: dp[i][j] = max(dp[i][j - 1], l[j] * p) ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR VAR VAR AS...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
vals = list(map(int, input().strip().split())) arr = list(map(int, input().strip().split())) dp = [[(0) for i in range(vals[0])] for i in range(3)] n = vals[0] ind = 0 for i in vals[1:]: dp[ind][n - 1] = i * arr[-1] for j in range(n - 2, -1, -1): dp[ind][j] = max(dp[ind][j + 1], i * arr[j]) ind += 1...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER BI...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) lst = [] for x in input().split(): lst.append(int(x)) a = -(10**20) b = -(10**20) c = -(10**20) for x in lst: a = max(a, x * p) b = max(b, a + x * q) c = max(c, b + x * r) print(c)
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CA...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
import sys length, p, q, r = [int(x) for x in sys.stdin.readline().strip().split(" ")] inp = [int(x) for x in sys.stdin.readline().strip().split(" ")] my_dict = dict() my_dict["p"] = -1 * float("inf") my_dict["q"] = -1 * float("inf") my_dict["r"] = -1 * float("inf") for x in inp: my_dict["p"] = max(my_dict["p"], p...
IMPORT ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING BIN_OP NUMBER FUNC_CALL VAR STRING ASSIGN VAR STRING BIN_OP NUMBER FUNC_CALL VAR STRING ASSIGN VAR STRING BIN_...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
def main(): n, p, q, r = list(map(int, input().split())) a = list(map(int, input().split())) dp = [float("-inf") for _ in range(n)] dp[-1] = r * a[-1] for i in range(n - 2, -1, -1): dp[i] = max(r * a[i], dp[i + 1]) dp2 = [float("-inf") for _ in range(n)] dp2[-1] = (q + r) * a[-1] ...
FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR FU...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = [int(i) for i in input().split()] aa = [int(i) for i in input().split()] max_from_p = [] m = None for i in range(n): if i == 0: m = aa[i] * p elif aa[i] * p > m: m = aa[i] * p max_from_p.append(m) max_from_pq = [] m = None for i in range(n): if i == 0: m = aa[i] * q ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NONE FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR IF BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LI...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) x = list(map(int, input().split())) p_max = [] q_max = [] r_max = [] p_max.append(p * x[0]) for i in range(1, n): p_max.append(max(p_max[i - 1], p * x[i])) q_max.append(x[0] * q + p_max[0]) for i in range(1, n): q_max.append(max(q_max[i - 1], p_max[i] + x[i] * q)) ans = -(...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR ...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
import sys def getX(ai, aj, ak): return ai * p + aj * q + ak * r inpt = input().split() n = int(inpt[0]) p = int(inpt[1]) q = int(inpt[2]) r = int(inpt[3]) arr = list(map(int, input().split())) minLeft = [] maxLeft = [] minRight = [] maxRight = [] for i in range(n): if i == 0: minLeft.append(arr[i])...
IMPORT FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_C...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
import sys n, p, q, r = map(int, input().split()) lis = [int(temp) for temp in input().split()] a = lis[0] * p b = a + lis[0] * q c = b + lis[0] * r for x in lis: a = max(a, x * p) b = max(b, a + x * q) c = max(c, b + x * r) print(c)
IMPORT ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUN...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
[n, p, q, r] = list(map(int, input().split())) a = list(map(int, input().split())) Inf = int(1000000000.0 + 7) pref_min = [Inf for i in range(n)] pref_max = [(-Inf) for i in range(n)] suf_min = [Inf for i in range(n)] suf_max = [(-Inf) for i in range(n)] pref_min[0] = a[0] pref_max[0] = a[0] for i in range(1, n): p...
ASSIGN LIST VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR V...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
import sys n, p, q, r = map(int, input().split()) a = list(map(int, input().split())) prefixmax = [(0) for i in range(0, n)] suffixmax = [(0) for i in range(0, n)] suffixmax[n - 1] = r * a[n - 1] prefixmax[0] = p * a[0] for i in range(1, n): prefixmax[i] = max(prefixmax[i - 1], p * a[i]) for i in range(n - 2, -1, ...
IMPORT ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER BIN_OP ...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
vals = list(map(int, input().strip().split())) arr = list(map(int, input().strip().split())) dp = [[(0) for i in range(vals[0])] for i in range(3)] n = vals[0] dp[-1][-1] = vals[3] * arr[-1] for i in range(n - 2, -1, -1): dp[-1][i] = max(dp[-1][i + 1], arr[i] * vals[3]) for i in range(1, -1, -1): dp[i][-1] = ar...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER NUMBER BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL ...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = list(map(int, input().split())) a = list(map(int, input().split())) z = -(100000000000000000000000000000**1000) if q >= 0 and p >= 0 and r >= 0: c = -100000000000 for i in range(len(a)): if a[i] > c: c = a[i] print(c * (q + p + r)) elif q <= 0 and p <= 0 and r <= 0: c = ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR EXPR FUNC_CALL...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = [int(i) for i in input().split(" ")] a = input() b = a.split() for i in range(n): b[i] = int(b[i]) dp = [p * b[0]] for i in range(1, n): dp.append(max(dp[i - 1], p * b[i])) dq = [dp[0] + q * b[0]] for i in range(1, n): dq.append(max(dq[i - 1], dp[i] + q * b[i])) dr = [dq[0] + r * b[0]] for i in...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_O...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = map(int, input().split()) arr = [int(i) for i in input().split()] siz = len(arr) pre_max = [0] * siz suf_max = [0] * siz pre_max[0] = p * arr[0] suf_max[n - 1] = r * arr[n - 1] for i in range(1, len(arr)): pre_max[i] = max(pre_max[i - 1], p * arr[i]) for i in range(len(arr) - 2, -1, -1): suf_max[i]...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR VAR BIN_OP VAR NUMBER...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = list(map(int, input().split())) a = list(map(int, input().split()))[::-1] INF = -(10**30) answer = INF dp = [INF, INF, INF] for i in range(n): dp[0] = max(dp[0], r * a[i]) dp[1] = max(dp[1], q * a[i] + dp[0]) dp[2] = max(dp[2], p * a[i] + dp[1]) answer = max(answer, dp[2]) print(answer)
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR LIST VAR VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER BIN_OP VAR VAR VAR ASSI...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
t, p, q, r = map(int, input().split()) l = [int(i) for i in input().split()] prex = [(0) for i in range(len(l))] suff = [(0) for i in range(len(l))] prex[0] = l[0] * p n = len(l) for i in range(1, n): prex[i] = max(l[i] * p, prex[i - 1]) suff[n - 1] = l[n - 1] * r for i in range(n - 2, -1, -1): suff[i] = max(l[...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = [int(x) for x in input().split()] a = [int(x) for x in input().split()] if len(a) == 0: print(0) pmax = [] pmax.append(p * a[0]) for i in range(1, n): pmax.append(max(pmax[i - 1], a[i] * p)) smax = a[n - 1] * r res = pmax[n - 1] + a[n - 1] * q + smax for i in range(n - 2, -1, -1): smax = max(sm...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NU...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
n, p, q, r = list(map(int, input().split())) a = list(map(int, input().split())) prefix = [None for _ in range(n)] suffix = [None for _ in range(n)] p_compare = max if p > 0 else min r_compare = max if r > 0 else min for i in range(n): if i == 0: prefix[i] = a[i] else: prefix[i] = p_compare(a[i]...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NONE VAR FUNC_CALL VAR VAR ASSIGN VAR NONE VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER VAR VAR ASSIGN VAR VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMBE...
Professor Dumbledore is helping Harry destroy the Horcruxes. He went to Gaunt Shack as he suspected a Horcrux to be present there. He saw Marvolo Gaunt's Ring and identified it as a Horcrux. Although he destroyed it, he is still affected by its curse. Professor Snape is helping Dumbledore remove the curse. For this, he...
R = lambda: map(int, input().split()) n, p, q, r = R() arr = list(R()) lmi, lmx, rmi, rmx = arr[:], arr[:], arr[:], arr[:] for i in range(1, n): lmi[i] = min(lmi[i], lmi[i - 1]) lmx[i] = max(lmx[i], lmx[i - 1]) for i in range(n - 2, -1, -1): rmi[i] = min(rmi[i], rmi[i + 1]) rmx[i] = max(rmx[i], rmx[i + ...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER F...