description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
You are playing a computer game, where you lead a party of $m$ soldiers. Each soldier is characterised by his agility $a_i$.
The level you are trying to get through can be represented as a straight line segment from point $0$ (where you and your squad is initially located) to point $n + 1$ (where the boss is located).... | import sys
zz = 1
sys.setrecursionlimit(10**5)
if zz:
input = sys.stdin.readline
else:
sys.stdin = open("input.txt", "r")
sys.stdout = open("all.txt", "w")
di = [[-1, 0], [1, 0], [0, 1], [0, -1]]
def fori(n):
return [fi() for i in range(n)]
def inc(d, c, x=1):
d[c] = d[c] + x if c in d else x
... | IMPORT ASSIGN VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER IF VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR LIST LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF NU... |
You are playing a computer game, where you lead a party of $m$ soldiers. Each soldier is characterised by his agility $a_i$.
The level you are trying to get through can be represented as a straight line segment from point $0$ (where you and your squad is initially located) to point $n + 1$ (where the boss is located).... | m, n, k, t = list(map(int, input().split()))
a = [0] + sorted(list(map(int, input().split()))) + [3 * 10**5]
data = sorted([list(map(int, input().split())) for _ in range(k)])
ok = m + 1
ng = 0
while ok - ng > 1:
mid = (ok + ng) // 2
A = a[mid]
interval_set = []
for i in range(k):
if data[i][2] ... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR LIST BIN_OP NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL... |
You are playing a computer game, where you lead a party of $m$ soldiers. Each soldier is characterised by his agility $a_i$.
The level you are trying to get through can be represented as a straight line segment from point $0$ (where you and your squad is initially located) to point $n + 1$ (where the boss is located).... | from sys import stdin
input = stdin.readline
def works(mid):
ag = A[-mid]
MAX = 0
cur = 0
out = N + 1
for l, r, d in traps:
if d <= ag:
continue
if l > MAX:
out += (MAX - cur) * 2
MAX, cur = r, l - 1
else:
MAX = max(MAX, r)
... | ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR VAR VAR VAR IF VAR VAR IF VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL F... |
You are playing a computer game, where you lead a party of $m$ soldiers. Each soldier is characterised by his agility $a_i$.
The level you are trying to get through can be represented as a straight line segment from point $0$ (where you and your squad is initially located) to point $n + 1$ (where the boss is located).... | import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep="\n")
def gcd(u, v):
while v:
u, v = v, u... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR STRING FUNC_DEF WHILE VAR ASSIGN VAR VAR VAR BIN_O... |
You are playing a computer game, where you lead a party of $m$ soldiers. Each soldier is characterised by his agility $a_i$.
The level you are trying to get through can be represented as a straight line segment from point $0$ (where you and your squad is initially located) to point $n + 1$ (where the boss is located).... | import sys
input = lambda: sys.stdin.readline().rstrip()
def chk(a):
Y = [0] * (N + 10)
for l, r, d in X:
if d <= a:
continue
Y[l - 1] += 1
Y[r] -= 1
for i in range(1, N + 10):
Y[i] += Y[i - 1]
return 1 if sum([min(Y[i], 1) for i in range(N + 5)]) * 2 + N +... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR VAR VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBE... |
You are playing a computer game, where you lead a party of $m$ soldiers. Each soldier is characterised by his agility $a_i$.
The level you are trying to get through can be represented as a straight line segment from point $0$ (where you and your squad is initially located) to point $n + 1$ (where the boss is located).... | import sys
input = sys.stdin.readline
def inter(a, b):
if b[0] <= a[1]:
return 1
return 0
def check(le):
if le == 0:
return 1
mi = it[le - 1]
tr = [i[:2] for i in aaa if i[2] > mi]
if tr == []:
return 1
aa = [tr[0][:]]
for i in range(1, len(tr)):
if i... | IMPORT ASSIGN VAR VAR FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER VAR VAR VAR NUMBER VAR IF VAR LIST RETURN NUMBER ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR ... |
You are playing a computer game, where you lead a party of $m$ soldiers. Each soldier is characterised by his agility $a_i$.
The level you are trying to get through can be represented as a straight line segment from point $0$ (where you and your squad is initially located) to point $n + 1$ (where the boss is located).... | import sys
input = sys.stdin.readline
m, n, k, t = list(map(int, input().split()))
A = list(map(int, input().split()))
T = [tuple(map(int, input().split())) for i in range(k)]
NG = 0
OK = 2 * 10**5 + 1
while OK - NG > 1:
mid = (OK + NG) // 2
USE = [0] * (2 * 10**5 + 3)
for l, r, d in T:
if d >= mid... | IMPORT ASSIGN VAR VAR 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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP NUMBER... |
You are playing a computer game, where you lead a party of $m$ soldiers. Each soldier is characterised by his agility $a_i$.
The level you are trying to get through can be represented as a straight line segment from point $0$ (where you and your squad is initially located) to point $n + 1$ (where the boss is located).... | m, n, k, t = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
traps = [tuple(map(int, input().split())) for _ in range(k)]
def calc(ans):
mina = a[ans - 1]
tc = [0] * (n + 2)
for l, r, d in traps:
if mina < d:
tc[l - 1] += 1
tc[r] -= 1
... | 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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER B... |
You are playing a computer game, where you lead a party of $m$ soldiers. Each soldier is characterised by his agility $a_i$.
The level you are trying to get through can be represented as a straight line segment from point $0$ (where you and your squad is initially located) to point $n + 1$ (where the boss is located).... | import sys
input = sys.stdin.readline
def check(num):
count = 0
prev = 0
for i in trap:
if i[2] > num:
if i[0] <= prev:
count += max(0, i[1] - prev)
prev = max(prev, i[1])
else:
count += i[1] - i[0] + 1
prev =... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR IF VAR NUMBER VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NU... |
You are playing a computer game, where you lead a party of $m$ soldiers. Each soldier is characterised by his agility $a_i$.
The level you are trying to get through can be represented as a straight line segment from point $0$ (where you and your squad is initially located) to point $n + 1$ (where the boss is located).... | import sys
def army(weak, traps, t_max, n):
t = n + 1
alone = [0] * (n + 1)
for l, r, d in traps:
if d <= weak:
break
alone[l - 1] += 1
alone[r] -= 1
interval = 0
for loc in range(n + 1):
interval += alone[loc]
if interval:
t += 2
... | IMPORT FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR VAR VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR IF VAR VAR NUMBER RETURN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_C... |
You are playing a computer game, where you lead a party of $m$ soldiers. Each soldier is characterised by his agility $a_i$.
The level you are trying to get through can be represented as a straight line segment from point $0$ (where you and your squad is initially located) to point $n + 1$ (where the boss is located).... | from sys import stdin
m, n, k, t = [int(x) for x in stdin.readline().split()]
a = sorted([int(x) for x in stdin.readline().split()], reverse=True)
traps = []
for x in range(k):
l, r, d = [int(x) for x in stdin.readline().split()]
traps.append((d, l - 1, r))
traps.sort()
low = 0
high = m - 1
valid = -1
while lo... | ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR AS... |
You are playing a computer game, where you lead a party of $m$ soldiers. Each soldier is characterised by his agility $a_i$.
The level you are trying to get through can be represented as a straight line segment from point $0$ (where you and your squad is initially located) to point $n + 1$ (where the boss is located).... | m, n, k, t = list(map(int, input().split()))
soldiers = list(map(int, input().split()))
traps = []
for _ in range(k):
l, r, d = list(map(int, input().split()))
traps.append((l, r, d))
soldiers.sort(reverse=True)
traps.sort()
def cost(count):
agil = soldiers[count - 1] if count > 0 else 10**6
current_b... | 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 FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ... |
You are playing a computer game, where you lead a party of $m$ soldiers. Each soldier is characterised by his agility $a_i$.
The level you are trying to get through can be represented as a straight line segment from point $0$ (where you and your squad is initially located) to point $n + 1$ (where the boss is located).... | import sys
input = sys.stdin.readline
sol_n, n, trap_n, t = [int(item) for item in input().split()]
sold = [int(item) for item in input().split()]
sold.sort(reverse=True)
trap = []
for i in range(trap_n):
l, r, d = [int(item) for item in input().split()]
trap.append((d, l, r))
trap.sort()
ll = 0
rr = sol_n + 1... | IMPORT ASSIGN VAR VAR 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 EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUN... |
You are playing a computer game, where you lead a party of $m$ soldiers. Each soldier is characterised by his agility $a_i$.
The level you are trying to get through can be represented as a straight line segment from point $0$ (where you and your squad is initially located) to point $n + 1$ (where the boss is located).... | import sys
input = sys.stdin.readline
m, n, k, t = map(int, input().split())
A = list(map(int, input().split()))
T = [tuple(map(int, input().split())) for i in range(k)]
seg_el = 1 << (n + 2).bit_length()
seg_height = 1 + (n + 2).bit_length()
SEG = [0] * (2 * seg_el)
LAZY = [0] * (2 * seg_el)
def indexes(L, R):
... | 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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER FUNC_CALL BIN_OP VAR NUMBER ASSIGN VAR BIN_OP NUMBER... |
You are playing a computer game, where you lead a party of $m$ soldiers. Each soldier is characterised by his agility $a_i$.
The level you are trying to get through can be represented as a straight line segment from point $0$ (where you and your squad is initially located) to point $n + 1$ (where the boss is located).... | import sys
input = sys.stdin.readline
def judge(x):
cnt = [0] * (n + 2)
for l, r, d in lrd:
if x < d:
cnt[l] += 1
cnt[r + 1] -= 1
for i in range(1, n + 2):
cnt[i] += cnt[i - 1]
sec = 0
for i in range(1, n + 2):
if cnt[i] == 0:
sec += 1
... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR VAR VAR VAR IF VAR VAR VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR NUMBER VAR NU... |
You are playing a computer game, where you lead a party of $m$ soldiers. Each soldier is characterised by his agility $a_i$.
The level you are trying to get through can be represented as a straight line segment from point $0$ (where you and your squad is initially located) to point $n + 1$ (where the boss is located).... | import sys
input = sys.stdin.buffer.readline
def movesRequired(agility):
nMoves = n + 1
repeatedIntervals = []
for l, r, d in traps:
if d > agility:
if repeatedIntervals and repeatedIntervals[-1][1] >= l:
repeatedIntervals[-1][1] = max(repeatedIntervals[-1][1], r)
... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR VAR VAR VAR IF VAR VAR IF VAR VAR NUMBER NUMBER VAR ASSIGN VAR NUMBER NUMBER FUNC_CALL VAR VAR NUMBER NUMBER VAR EXPR FUNC_CALL VAR LIST VAR VAR FOR VAR VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER RETURN VAR ASSIGN VAR VAR VA... |
You are playing a computer game, where you lead a party of $m$ soldiers. Each soldier is characterised by his agility $a_i$.
The level you are trying to get through can be represented as a straight line segment from point $0$ (where you and your squad is initially located) to point $n + 1$ (where the boss is located).... | m, n, k, t = [int(s) for s in input().split()]
A = [int(s) for s in input().split()]
A.sort()
traps = []
for i in range(k):
l, r, d = [int(s) for s in input().split()]
traps.append((l, r, d))
traps.sort()
def canTake(agi):
farest = 0
trapIndex = 0
wasteTime = 0
while trapIndex < len(traps):
... | 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 EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_DEF ASSIGN VA... |
You are playing a computer game, where you lead a party of $m$ soldiers. Each soldier is characterised by his agility $a_i$.
The level you are trying to get through can be represented as a straight line segment from point $0$ (where you and your squad is initially located) to point $n + 1$ (where the boss is located).... | m, n, k, t = list(map(int, input().split()))
a = list(map(int, input().split()))
trap = list()
for i in range(k):
x1, x2, x3 = list(map(int, input().split()))
trap.append([x1, x2, x3])
trap.sort()
a.sort()
x = -1
l = 0
r = len(a) - 1
s = 0
while r - l >= 0:
x = (l + r) // 2
weig = a[x]
ltrap = 0
... | 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 FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST VAR VAR VAR EXPR FUNC_CA... |
Limak is a little polar bear. He plays by building towers from blocks. Every block is a cube with positive integer length of side. Limak has infinitely many blocks of each side length.
A block with side a has volume a^3. A tower consisting of blocks with sides a_1, a_2, ..., a_{k} has the total volume a_1^3 + a_2^3 + ... | def rec(m):
if m <= 0:
return m, 0
a = int((m + 1e-09) ** (1 / 3))
x, y = rec(m - a**3)
q, w = rec(a**3 - (a - 1) ** 3 - 1)
return max((x + 1, a**3 + y), (q + 1, (a - 1) ** 3 + w))
print(*rec(int(input()))) | FUNC_DEF IF VAR NUMBER RETURN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER RETURN FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_... |
Limak is a little polar bear. He plays by building towers from blocks. Every block is a cube with positive integer length of side. Limak has infinitely many blocks of each side length.
A block with side a has volume a^3. A tower consisting of blocks with sides a_1, a_2, ..., a_{k} has the total volume a_1^3 + a_2^3 + ... | def c(n):
if n < 8:
return n, n
t1 = int(n ** (1 / 3) + 1e-11)
t2 = t1 - 1
v1 = c(n - t1 * t1 * t1)
v1 = v1[0] + 1, v1[1] + t1 * t1 * t1
v2 = c(t1 * t1 * t1 - 1 - t2 * t2 * t2)
v2 = v2[0] + 1, v2[1] + t2 * t2 * t2
if v2 > v1:
v1 = v2
return v1
print(" ".join(map(str... | FUNC_DEF IF VAR NUMBER RETURN VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP B... |
Limak is a little polar bear. He plays by building towers from blocks. Every block is a cube with positive integer length of side. Limak has infinitely many blocks of each side length.
A block with side a has volume a^3. A tower consisting of blocks with sides a_1, a_2, ..., a_{k} has the total volume a_1^3 + a_2^3 + ... | MAX = 100005
def big_pow3(n):
l = 0
p = MAX
while p - l != 1:
mid = (p + l + 1) // 2
if mid * mid * mid <= n:
l = mid
else:
p = mid
return l
def f(n):
if n < 8:
return [n, n]
a = int((n + 0.5) ** 0.3333333333333333)
r1 = f(n - a**3)... | ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER IF BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR RETURN VAR FUNC_DEF IF VAR NUMBER RETURN LIST VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSI... |
Limak is a little polar bear. He plays by building towers from blocks. Every block is a cube with positive integer length of side. Limak has infinitely many blocks of each side length.
A block with side a has volume a^3. A tower consisting of blocks with sides a_1, a_2, ..., a_{k} has the total volume a_1^3 + a_2^3 + ... | def cube(a):
return a**3
def steps(m):
if m <= 7:
return m
x = 1
while cube(x + 1) <= m:
x += 1
return 1 + steps(max(m - cube(x), cube(x) - 1 - cube(x - 1)))
class CodeforcesTask679BSolution:
def __init__(self):
self.result = ""
self.m = 0
def read_input... | FUNC_DEF RETURN BIN_OP VAR NUMBER FUNC_DEF IF VAR NUMBER RETURN VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR NUMBER RETURN BIN_OP NUMBER FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER CLASS_DEF FUNC_DEF ASSIGN VAR ST... |
Limak is a little polar bear. He plays by building towers from blocks. Every block is a cube with positive integer length of side. Limak has infinitely many blocks of each side length.
A block with side a has volume a^3. A tower consisting of blocks with sides a_1, a_2, ..., a_{k} has the total volume a_1^3 + a_2^3 + ... | def func(n):
if n < 8:
return n, n
max_a = int(n ** (1 / 3))
if (max_a + 1) ** 3 <= n:
max_a += 1
v1 = func(n - max_a**3)
v1 = v1[0] + 1, v1[1] + max_a**3
v2 = func(max_a**3 - 1 - (max_a - 1) ** 3)
v2 = v2[0] + 1, v2[1] + (max_a - 1) ** 3
if v2 > v1:
return v2
... | FUNC_DEF IF VAR NUMBER RETURN VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER NUMBER IF BIN_OP BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR... |
Limak is a little polar bear. He plays by building towers from blocks. Every block is a cube with positive integer length of side. Limak has infinitely many blocks of each side length.
A block with side a has volume a^3. A tower consisting of blocks with sides a_1, a_2, ..., a_{k} has the total volume a_1^3 + a_2^3 + ... | import sys
def cube_root(x):
v = max(int(x ** (1.0 / 3.0)) - 1, 0)
while (v + 1) ** 3 <= x:
v += 1
return v
def solution(x):
if x <= 7:
return x, x
next_smaller = cube_root(x) ** 3
candidate = solution(x - next_smaller)
candidate = candidate[0] + 1, candidate[1] + next_sm... | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER NUMBER NUMBER NUMBER WHILE BIN_OP BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER RETURN VAR FUNC_DEF IF VAR NUMBER RETURN VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBE... |
Limak is a little polar bear. He plays by building towers from blocks. Every block is a cube with positive integer length of side. Limak has infinitely many blocks of each side length.
A block with side a has volume a^3. A tower consisting of blocks with sides a_1, a_2, ..., a_{k} has the total volume a_1^3 + a_2^3 + ... | n, c = 0, 0
def dfs(now, m, t):
global n, c
if now == 0:
if m > n:
n, c = m, t
return
i = 1
while i**3 <= now:
i += 1
i -= 1
dfs(now - i**3, m + 1, t + i**3)
dfs(i**3 - 1 - (i - 1) ** 3, m + 1, t + (i - 1) ** 3)
m = int(input())
dfs(m, 0, 0)
print(n, c... | ASSIGN VAR VAR NUMBER NUMBER FUNC_DEF IF VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR VAR RETURN ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP... |
Limak is a little polar bear. He plays by building towers from blocks. Every block is a cube with positive integer length of side. Limak has infinitely many blocks of each side length.
A block with side a has volume a^3. A tower consisting of blocks with sides a_1, a_2, ..., a_{k} has the total volume a_1^3 + a_2^3 + ... | def g(m, s, n):
k = int(m ** (1 / 3))
if m == 0 or k == 1:
return s + m, n + m
x, y = k**3, (k - 1) ** 3
a = g(m - x, s + x, n + 1)
b = g(x - y - 1, s + y, n + 1)
return b if a[1] < b[1] else a
s, n = g(int(input()), 0, 0)
print(n, s) | FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER NUMBER IF VAR NUMBER VAR NUMBER RETURN BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ... |
Limak is a little polar bear. He plays by building towers from blocks. Every block is a cube with positive integer length of side. Limak has infinitely many blocks of each side length.
A block with side a has volume a^3. A tower consisting of blocks with sides a_1, a_2, ..., a_{k} has the total volume a_1^3 + a_2^3 + ... | im = int(input())
best_steps = 0
best_length = 0
def rec(m, steps, substracted):
global best_steps, best_length
if m == 0:
if steps > best_steps:
best_steps = steps
best_length = substracted
elif steps == best_steps:
best_length = max(best_length, substracte... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF IF VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN ASSIGN VAR NUMBER WHILE BIN_OP BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR ... |
Limak is a little polar bear. He plays by building towers from blocks. Every block is a cube with positive integer length of side. Limak has infinitely many blocks of each side length.
A block with side a has volume a^3. A tower consisting of blocks with sides a_1, a_2, ..., a_{k} has the total volume a_1^3 + a_2^3 + ... | def f(m, cnt, y):
global ans, x
if m == 0:
ans, x = max((ans, x), (cnt, y))
return
a = int(m ** (1 / 3))
k1, k2 = a**3, (a - 1) ** 3
f(m - k1, cnt + 1, y + k1)
f(k1 - k2 - 1, cnt + 1, y + k2)
m = int(input())
ans, x = 0, m
f(m, 0, 0)
print(ans, x) | FUNC_DEF IF VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR VAR RETURN ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP V... |
Limak is a little polar bear. He plays by building towers from blocks. Every block is a cube with positive integer length of side. Limak has infinitely many blocks of each side length.
A block with side a has volume a^3. A tower consisting of blocks with sides a_1, a_2, ..., a_{k} has the total volume a_1^3 + a_2^3 + ... | def g(m, n, s):
if not m:
return n, s
k = int(m ** (1 / 3))
x, y = k**3, (k - 1) ** 3
return max(g(m - x, n + 1, s + x), g(x - y - 1, n + 1, s + y))
print(*g(int(input()), 0, 0)) | FUNC_DEF IF VAR RETURN VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER RETURN FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR VAR EXPR FUN... |
Limak is a little polar bear. He plays by building towers from blocks. Every block is a cube with positive integer length of side. Limak has infinitely many blocks of each side length.
A block with side a has volume a^3. A tower consisting of blocks with sides a_1, a_2, ..., a_{k} has the total volume a_1^3 + a_2^3 + ... | def kil(n):
if n < 8:
return n, n
m = 2
while m * m * m <= n:
m += 1
m -= 1
k1, v1 = kil(n - m * m * m)
k2, v2 = kil(m * m * m - 1 - (m - 1) * (m - 1) * (m - 1))
return (
(k1 + 1, v1 + m * m * m)
if (k1, v1 + m * m * m) > (k2, v2 + (m - 1) * (m - 1) * (m - 1))... | FUNC_DEF IF VAR NUMBER RETURN VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP BIN_OP VAR VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUM... |
Limak is a little polar bear. He plays by building towers from blocks. Every block is a cube with positive integer length of side. Limak has infinitely many blocks of each side length.
A block with side a has volume a^3. A tower consisting of blocks with sides a_1, a_2, ..., a_{k} has the total volume a_1^3 + a_2^3 + ... | def main():
def f(n):
if n < 8:
return [n, n]
a = int((n + 0.5) ** 0.3333333333333333)
r1 = f(n - a * a * a)
r1[1] += a * a * a
a -= 1
r2 = f(3 * a * (a + 1))
r2[1] += a * a * a
if r1 < r2:
r1 = r2
r1[0] += 1
re... | FUNC_DEF FUNC_DEF IF VAR NUMBER RETURN LIST VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR VAR VAR NUMBER BIN_OP BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER BIN_OP BIN_OP VAR VAR ... |
Recently in Divanovo, a huge river locks system was built. There are now $n$ locks, the $i$-th of them has the volume of $v_i$ liters, so that it can contain any amount of water between $0$ and $v_i$ liters. Each lock has a pipe attached to it. When the pipe is open, $1$ liter of water enters the lock every second.
Th... | def ceil_div(a, b):
return (a - 1) // b + 1
n = int(input())
v = list(map(int, input().split()))
p_v = [0]
for v_i in v:
p_v.append(p_v[-1] + v_i)
m = max(ceil_div(p_v[i], i) for i in range(1, n + 1))
q = int(input())
for _ in range(q):
t_j = int(input())
if t_j < m:
print(-1)
else:
... | FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR NUMBER BIN... |
Recently in Divanovo, a huge river locks system was built. There are now $n$ locks, the $i$-th of them has the volume of $v_i$ liters, so that it can contain any amount of water between $0$ and $v_i$ liters. Each lock has a pipe attached to it. When the pipe is open, $1$ liter of water enters the lock every second.
Th... | num_locks = int(input())
volumn = list(map(int, input().split()))
sum_cur = 0
min_t = []
max_min_t = []
for i in range(len(volumn)):
sum_cur += volumn[i]
t_i = sum_cur // (i + 1) + (sum_cur % (i + 1) > 0) * 1
min_t.append(t_i)
if i == 0:
max_min_t.append(t_i)
else:
max_min_t.append(m... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL ... |
Recently in Divanovo, a huge river locks system was built. There are now $n$ locks, the $i$-th of them has the volume of $v_i$ liters, so that it can contain any amount of water between $0$ and $v_i$ liters. Each lock has a pipe attached to it. When the pipe is open, $1$ liter of water enters the lock every second.
Th... | import sys
n = int(input())
V = [int(i) for i in input().split()]
time, total = 0, 0
for i in range(n):
total += V[i]
time = max(time, (total + i) // (i + 1))
pass
for q in range(int(input())):
t = int(input())
if t < time:
res = -1
else:
res = (total + t - 1) // t
sys.stdou... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_C... |
Recently in Divanovo, a huge river locks system was built. There are now $n$ locks, the $i$-th of them has the volume of $v_i$ liters, so that it can contain any amount of water between $0$ and $v_i$ liters. Each lock has a pipe attached to it. When the pipe is open, $1$ liter of water enters the lock every second.
Th... | import sys
input = sys.stdin.readline
def solve():
n = int(input())
V = list(map(int, input().split()))
arr = []
curr = 0
val = -float("inf")
for i in range(n):
curr += V[i]
val = max(val, curr // (i + 1) + (curr % (i + 1) > 0) * 1)
arr.append(val)
S = sum(V)
q... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP BIN_OP ... |
Recently in Divanovo, a huge river locks system was built. There are now $n$ locks, the $i$-th of them has the volume of $v_i$ liters, so that it can contain any amount of water between $0$ and $v_i$ liters. Each lock has a pipe attached to it. When the pipe is open, $1$ liter of water enters the lock every second.
Th... | import itertools
n = int(input())
v = list(itertools.accumulate(map(int, input().split())))
m = max((v[i] - 1) // (i + 1) + 1 for i in range(n))
for _ in range(int(input())):
t = int(input())
print((v[-1] - 1) // t + 1 if t >= m else -1) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL ... |
Recently in Divanovo, a huge river locks system was built. There are now $n$ locks, the $i$-th of them has the volume of $v_i$ liters, so that it can contain any amount of water between $0$ and $v_i$ liters. Each lock has a pipe attached to it. When the pipe is open, $1$ liter of water enters the lock every second.
Th... | n = int(input())
V = [int(i) for i in input().split()]
time, total = 0, 0
for i in range(n):
total += V[i]
time = max(time, (total + i) // (i + 1))
pass
for q in range(int(input())):
t = int(input())
if t < time:
print(-1)
else:
print((total + t - 1) // t)
pass | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR... |
Recently in Divanovo, a huge river locks system was built. There are now $n$ locks, the $i$-th of them has the volume of $v_i$ liters, so that it can contain any amount of water between $0$ and $v_i$ liters. Each lock has a pipe attached to it. When the pipe is open, $1$ liter of water enters the lock every second.
Th... | n = int(input())
v = list(map(int, input().split()))
assert n == len(v)
vs = v[0]
ts = [0] * n
ts[0] = v[0]
for i in range(1, n):
vs += v[i]
ts[i] = max(ts[i - 1], (vs + i + 1 - 1) // (i + 1))
q = int(input())
for i in range(q):
t = int(input())
if t < ts[-1]:
print(-1)
else:
print((... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP BIN_... |
Recently in Divanovo, a huge river locks system was built. There are now $n$ locks, the $i$-th of them has the volume of $v_i$ liters, so that it can contain any amount of water between $0$ and $v_i$ liters. Each lock has a pipe attached to it. When the pipe is open, $1$ liter of water enters the lock every second.
Th... | n = int(input())
v = list(map(int, input().split()))
q = int(input())
sm = sum(v)
pr = v[0]
t = [sm]
smp = v[0]
for i in range(1, n):
smp += v[i]
pr = max(pr, pr + (smp - pr * (i + 1) + i) // (i + 1))
t += [max(pr, pr + (sm - (i + 1) * pr + i) // (i + 1))]
for _ in range(q):
ta = int(input())
if ta ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP V... |
Read problems statements in Mandarin Chinese , Russian and Vietnamese
Churu is taking the course called βIntroduction to Data Structuresβ. Yesterday, he learned how to use a stack to check is a given parentheses expression is balanced or not. He finds it intriguing, and more importantly, he was given an assignment. ... | __author__ = "Om Kumar Sahoo"
cas = int(input())
for i in range(cas):
a, b = [int(x) for x in input().split()]
arr = [0] * a
for j in range(b):
c, d = [int(x) for x in input().split()]
flag = 0
for k in range(c, d + 1):
if flag == 0:
arr[k] = "("
... | ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR ... |
Read problems statements in Mandarin Chinese , Russian and Vietnamese
Churu is taking the course called βIntroduction to Data Structuresβ. Yesterday, he learned how to use a stack to check is a given parentheses expression is balanced or not. He finds it intriguing, and more importantly, he was given an assignment. ... | a = int(input())
for _ in range(a):
aa = list(map(int, input().split()))
brr = []
for i in range(aa[1]):
cc = tuple(map(int, input().split()))
brr.append(cc)
brr = sorted(brr, key=lambda x: x[1] - x[0])
crr = [0] * aa[0]
for i in brr:
k = 0
j = i[0]
while ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VA... |
Read problems statements in Mandarin Chinese , Russian and Vietnamese
Churu is taking the course called βIntroduction to Data Structuresβ. Yesterday, he learned how to use a stack to check is a given parentheses expression is balanced or not. He finds it intriguing, and more importantly, he was given an assignment. ... | for _ in range(int(input())):
n, k = map(int, input().split())
ans = "00" * (n // 2) + "0" * (n % 2)
ans = list(ans)
qry = []
for i in range(k):
x, y = map(int, input().split())
qry.append([x, y])
qry.sort(key=lambda x: x[1] - x[0])
for i in range(k):
x = qry[i][0]
... | 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 BIN_OP STRING BIN_OP VAR NUMBER BIN_OP STRING BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXP... |
Read problems statements in Mandarin Chinese , Russian and Vietnamese
Churu is taking the course called βIntroduction to Data Structuresβ. Yesterday, he learned how to use a stack to check is a given parentheses expression is balanced or not. He finds it intriguing, and more importantly, he was given an assignment. ... | t = input()
for i in range(0, int(t)):
n, k = input().split(" ")
g = ""
h = ""
for p in range(0, int(n)):
g = g + "."
h = list(g)
for j in range(0, int(k)):
a, b = input().split(" ")
h[int(a)] = "("
h[int(b)] = ")"
fd = 1
for o in range(int(a) + 1,... | ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR... |
Read problems statements in Mandarin Chinese , Russian and Vietnamese
Churu is taking the course called βIntroduction to Data Structuresβ. Yesterday, he learned how to use a stack to check is a given parentheses expression is balanced or not. He finds it intriguing, and more importantly, he was given an assignment. ... | def brackets(N, intervals):
sequence = ["-" for _ in range(N)]
intervals.sort(key=lambda x: x[1])
b = ["(", ")"]
for interval in intervals:
l, r = interval
p = 0
for i in range(l, r + 1):
if sequence[i] == "-":
sequence[i] = b[p]
p = 1 ... | FUNC_DEF ASSIGN VAR STRING VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST STRING STRING FOR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR VAR STRING ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_OP NUMBER VAR RETURN FUNC_CALL STRING VAR STRING VAR STRING VA... |
Chef has a grid of size N \times M.
In one move, Chef can move from his current cell to an adjacent cell. If the Chef is currently at (i, j) then, in one move, Chef can move to (i + 1, j), (i - 1, j), (i, j + 1) or (i, j - 1).
There are also K *special* cells in the grid. These special cells support a corner move as... | def lis(nums, cmp=lambda x, y: x < y):
P = [0] * len(nums)
M = [0] * (len(nums) + 1)
L = 0
for i in range(len(nums)):
lo, hi = 1, L
while lo <= hi:
mid = (lo + hi) // 2
if cmp(nums[M[mid]], nums[i]):
lo = mid + 1
else:
h... | FUNC_DEF VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP ... |
Chef has a grid of size N \times M.
In one move, Chef can move from his current cell to an adjacent cell. If the Chef is currently at (i, j) then, in one move, Chef can move to (i + 1, j), (i - 1, j), (i, j + 1) or (i, j - 1).
There are also K *special* cells in the grid. These special cells support a corner move as... | from sys import stdin
input = stdin.readline
def lis(nums, cmp=lambda x, y: x < y):
P = [0] * len(nums)
M = [0] * (len(nums) + 1)
L = 0
for i in range(len(nums)):
lo, hi = 1, L
while lo <= hi:
mid = (lo + hi) // 2
if cmp(nums[M[mid]], nums[i]):
... | ASSIGN VAR VAR FUNC_DEF VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR VAR VAR ASS... |
Neil has a [perfect binary tree] with N nodes, and an integer M. He can assign values to nodes. He calls the tree good if the following conditions are met:
Nodes' values are positive integers no more than M.
Nodes at even levels have values strictly more than their parents' values.
Nodes at odd levels have values stric... | MOD = int(10**9) + 7
def solve(N, M):
height = 0
while N > 0:
height += 1
N = N // 2
dp = [[(0) for i in range(0, M + 1)] for j in range(0, height + 1)]
for j in range(1, M + 1):
dp[1][j] = 1
for i in range(2, height + 1):
if i & 1 == 0:
sum = 0
... | ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR NUM... |
Neil has a [perfect binary tree] with N nodes, and an integer M. He can assign values to nodes. He calls the tree good if the following conditions are met:
Nodes' values are positive integers no more than M.
Nodes at even levels have values strictly more than their parents' values.
Nodes at odd levels have values stric... | from sys import stdin
input = stdin.readline
mod = 10**9 + 7
def add(a, b):
return (a % mod + b % mod) % mod
def mul(a, b):
return a % mod * (b % mod) % mod
def sub(a, b):
return (a - b + mod) % mod
def answer():
for i in range(60):
if n >> i & 1:
x = i
dp = [(0) for j i... | ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER 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 BIN_OP VAR VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER ASSIGN V... |
It's late at night, and the college students are required to return to their college hostels from the hostel garden.
The hostel garden is a rectangular field of dimensions N \times M, with two hostels β one across the left edge and one across the top edge of the field.
Students are currently in the cells of the field... | t = int(input())
for _ in range(t):
n, m = list(map(int, input().split()))
A = [[(0) for i in range(m)] for j in range(n)]
B = [[(0) for i in range(m)] for j in range(n)]
for i in range(n):
A[i] = list(map(int, input().split()))
for i in range(n):
B[i] = list(map(int, input().split()... | 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 NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_... |
It's late at night, and the college students are required to return to their college hostels from the hostel garden.
The hostel garden is a rectangular field of dimensions N \times M, with two hostels β one across the left edge and one across the top edge of the field.
Students are currently in the cells of the field... | for _ in range(int(input())):
x, y = map(int, input().split())
a, b = [], []
for _ in range(x):
a.append(list(map(int, input().split())))
for _ in range(x):
b.append(list(map(int, input().split())))
for i in range(x):
temp1, temp2 = 0, 0
for j in range(y):
... | 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 VAR LIST LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL ... |
It's late at night, and the college students are required to return to their college hostels from the hostel garden.
The hostel garden is a rectangular field of dimensions N \times M, with two hostels β one across the left edge and one across the top edge of the field.
Students are currently in the cells of the field... | def integer_list():
return list(map(int, input().split()))
def string_list():
return list(map(str, input().split()))
def hetro_list():
return list(input().split())
def pprint(matrix):
for i in range(len(matrix)):
print(*matrix[i])
t = int(input())
for _ in range(t):
n, m = integer_li... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR... |
It's late at night, and the college students are required to return to their college hostels from the hostel garden.
The hostel garden is a rectangular field of dimensions N \times M, with two hostels β one across the left edge and one across the top edge of the field.
Students are currently in the cells of the field... | import sys
sys.setrecursionlimit(10**7)
def f(i, j):
if i >= n:
return 0
if j > m:
return 0
if dp[i][j] != -1:
return dp[i][j]
case1 = pref[i][j] + suff[i][j] + f(i + 1, j)
case2 = f(i, j + 1)
dp[i][j] = max(case1, case2)
return dp[i][j]
for _ in range(int(input(... | IMPORT EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR VAR RETURN NUMBER IF VAR VAR VAR NUMBER RETURN VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR ... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | t = int(input())
mod = 10**9 + 7
for _ in range(t):
sum = 0
p, q, r = map(int, input().split())
a = sorted(int(x) for x in input().split())
b = sorted(int(x) for x in input().split())
c = sorted(int(x) for x in input().split())
t1 = t2 = sum1 = sum2 = 0
for i in b:
while t1 < p and a... | 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 NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FU... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | def solve(p, q, r, a, b, c):
mod = 10**9 + 7
for i in range(len(b)):
a.sort()
b.sort()
c.sort()
m = 0
n = 0
sum1 = 0
sum2 = 0
count = 0
for i in b:
while m < p and a[m] <= i:
sum1 += a[m]
m += 1
... | FUNC_DEF ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR WHILE VAR VAR VAR VAR VAR VAR VAR VAR VAR NUMBER WHILE VAR VAR VAR... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | ls1 = []
ls2 = []
ls3 = []
for x in range(int(input())):
p, q, r = map(int, input().split())
ls1 = list(map(int, input().split()))
ls2 = list(map(int, input().split()))
ls3 = list(map(int, input().split()))
ls1.sort()
ls2.sort()
ls3.sort()
ans = 0
i = 0
j = 0
sum1 = 0
sum... | ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FU... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | for _ in range(int(input())):
p, q, r = map(int, input().split())
ar1 = sorted(list(map(int, input().split())))
ar2 = sorted(list(map(int, input().split())))
ar3 = sorted(list(map(int, input().split())))
a = b = c = d = 0
n = 0
mod = 10**9 + 7
for i in ar2:
while a < p and ar1[a]... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CAL... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | for _ in range(int(input())):
lx, ly, lz = [int(x) for x in input().split()]
x = sorted(int(x) for x in input().split())
y = sorted(int(x) for x in input().split())
z = sorted(int(x) for x in input().split())
nx = nz = sx = sz = r = 0
for yy in y:
while nx < lx and x[nx] <= yy:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_C... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | m = 1000000007
def tripet(l1, l2, l3, n1, n2, n3):
a = 0
b = 0
s = 0
r = 0
res = 0
for i in l2:
while a < n1 and l1[a] <= i:
s += l1[a]
a += 1
while b < n3 and l3[b] <= i:
r += l3[b]
b += 1
res += (i * a + s) * (i * b + r)... | ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR WHILE VAR VAR VAR VAR VAR VAR VAR VAR VAR NUMBER WHILE VAR VAR VAR VAR VAR VAR VAR VAR VAR NUMBER VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | t = int(input())
x = []
for i in range(t):
s1 = input().split()
p = int(s1[0])
q = int(s1[1])
r = int(s1[2])
suma = 0
sumc = 0
a = input().split()
for j in range(p):
a[j] = int(a[j])
suma += a[j]
b = input().split()
for j in range(q):
b[j] = int(b[j])
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL 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 NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | t = int(input())
for i in range(t):
p, q, r = list(map(int, input().split()))
a = list(sorted(list(map(int, input().split()))))
b = list(sorted(list(map(int, input().split()))))
c = list(sorted(list(map(int, input().split()))))
la = lc = 0
sa = sc = 0
s = 0
for y in b:
while la <... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | counter = int(input())
for mrinal in range(counter):
x_size, y_size, z_size = map(int, input().split())
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
z = [int(i) for i in input().split()]
x.sort()
y.sort()
z.sort()
x_sum = []
z_sum = []
if y[y_size -... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | z = 1000000007
for _ in range(int(input())):
p, q, r = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
sA = [0] * p
sB = [0] * q
sC = [0] * r
sA[0] = A[0]
sB[0... | ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR 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... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | mod = 1000000007
t = int(input())
for j in range(t):
p, q, r = input().split()
p = int(p)
q = int(q)
r = int(r)
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
res = 0
a.sort()
b.sort()
c.sort()
prev_suma =... | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CA... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | t = int(input())
modulo = 1000000007
for i in range(t):
lens = input()
lenlist = list(map(int, lens.split()))
a1 = input()
a = list(map(int, a1.split()))
b1 = input()
b = list(map(int, b1.split()))
c1 = input()
c = list(map(int, c1.split()))
maxy = min(c)
miny = min(a)
b = [x... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | T = int(input().strip())
for test in range(T):
mod = 1000000007
p, q, r = input().strip().split(" ")
p, q, r = int(p), int(q), int(r)
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
A.sort()
B.sort()
C.sort()
sumof... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | mdl = 1000000007
for _ in range(int(input())):
z = input().split()
p, q, r = map(int, z[:3])
z = input().split()
a = list(map(int, z[:p]))
z = input().split()
b = list(map(int, z[:q]))
z = input().split()
c = list(map(int, z[:r]))
a.sort()
b.sort()
c.sort()
cta = ctc = 0
... | ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR V... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | t = int(input())
for i in range(t):
x, y, z = map(int, input().split())
l = list(map(int, input().split()))
m = list(map(int, input().split()))
n = list(map(int, input().split()))
s = 0
for j in range(x):
for k in range(y):
for f in range(z):
if l[j] <= m[k] a... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR 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_CA... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | for v in range(int(input())):
p, q, r = input().split(" ")
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
d = [int(x) for x in input().split()]
a.sort()
b.sort()
d.sort()
s = 0
su = 0
c = 0
ss = 0
cc = 0
sum = 0
susu = 0
for w in r... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING 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 FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_C... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | def R():
return list(map(int, input().split()))
m = 1000000007
for i in range(int(input())):
a, b, c = R()
a1 = sorted(R())
b1 = sorted(R())
c1 = sorted(R())
ass = css = asum = csum = s = 0
for i in b1:
while ass < a and a1[ass] <= i:
asum += a1[ass]
ass += ... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR NUM... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | T = int(input())
for i in range(T):
n = list(map(int, input().split()))
a = n[0]
b = n[1]
c = n[2]
l = []
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
for i in range(b):
for j in range(a):
for k in ran... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | t = int(input())
while t:
p, q, r = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
a.append(1000000000000)
c.append(1000000000000)
a.sort()
b.sort()
c.sort()
sumx = [a[0]]
sumz = [c[0... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CAL... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | T = int(input())
for t in range(T):
inp = input().split()
P = int(inp[0])
Q = int(inp[1])
R = int(inp[2])
A = input().split()
A = list(map(int, A))
A.sort()
B = input().split()
B = list(map(int, B))
B.sort()
C = input().split()
C = list(map(int, C))
C.sort()
A_sum... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL 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 FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR ... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | import sys
t = int(input())
while t:
x, y, z = map(int, sys.stdin.readline().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
count = 0
a.sort()
b.sort()
c.sort()
i = 0
j = 0
asum = 0
csum = 0
... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER EXPR FUNC_CALL... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | def mod(n):
return n % 1000000007
for _ in range(int(input())):
p, q, r = map(int, input().split())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ans, i, l = 0, 0, 0
sa, sc = 0, 0
for b in B:
... | FUNC_DEF RETURN BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FU... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | M = 1000000007
def solve():
sum = 0
i, k = 0, 0
x_sum, z_sum = 0, 0
for b in B:
while i < p and A[i] <= b:
x_sum = (x_sum + A[i]) % M
i += 1
while k < r and C[k] <= b:
z_sum = (z_sum + C[k]) % M
k += 1
sum = (sum + (i * b % M + x_... | ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR WHILE VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR NUMBER WHILE VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP BIN_OP... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | t = int(input())
for k in range(t):
p, q, r = map(int, input().rstrip().split())
l1 = sorted(list(map(int, input().rstrip().split())))
l2 = sorted(list(map(int, input().rstrip().split())))
l3 = sorted(list(map(int, input().rstrip().split())))
i, j, k, s, sum = 0, 0, 0, 0, 0
for y in l2:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR AS... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | t = int(input())
for temp in range(0, t):
p, q, r = map(int, input().strip().split())
mod = 1000000007
res = 0
a = list(map(int, input().strip().split()))
b = list(map(int, input().strip().split()))
c = list(map(int, input().strip().split()))
a.sort()
b.sort(reverse=True)
c.sort()
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER 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 F... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | M = 1000000007
def func(y, xsum, zsum, vx, vz):
return (
y * ((xsum * vz % M + zsum * vx % M) % M) % M
+ vx * (vz * (y * y % M) % M) % M
+ xsum * zsum % M
)
t = int(input())
while t > 0:
p, q, r = input().split()
a = list(map(int, input().split()))
b = list(map(int, input... | ASSIGN VAR NUMBER FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | t = int(input())
for i in range(t):
[p, q, r] = [int(n) for n in input().split()]
A = [int(n) for n in input().split()]
B = [int(n) for n in input().split()]
C = [int(n) for n in input().split()]
A.sort()
B.sort()
C.sort()
sumA = p * [0]
sumB = q * [0]
sumC = r * [0]
sumA[0] ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN LIST 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 FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | T = int(input())
for _ in range(0, T):
x, y, z = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
Z = list(map(int, input().split()))
x = x + 1
z = z + 1
X.insert(0, 0)
Z.insert(0, 0)
X.sort()
Y.sort()
Z.sort()
sumx = list(... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR 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 ... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | t = int(input())
m = 1000000007
for i in range(t):
p, q, r = map(int, input().split())
pa = []
qa = []
ra = []
pa.extend(map(int, input().split()))
qa.extend(map(int, input().split()))
ra.extend(map(int, input().split()))
pa.sort(reverse=True)
qa.sort(reverse=True)
ra.sort(revers... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR F... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | t = int(input())
for i in range(t):
sum1 = 0
sum2 = 0
n = list(map(int, input().split()))
p = n[0]
q = n[1]
r = n[2]
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))
arr3 = list(map(int, input().split()))
sum1 = sum(arr1)
sum2 = sum(arr3)
arr1... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER 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 FUNC_CAL... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | def func(arr, key):
low = 0
high = len(arr)
mid = -1
flag = False
while low < high:
mid = (low + high) // 2
if arr[mid] == key:
flag = True
break
elif arr[mid] < key:
low = mid + 1
else:
high = mid
if flag:
w... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR IF VAR WHILE VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | def findind(sizea, mini, lista):
lo = 0
hi = sizea
mid = (lo + hi) // 2
while lo < hi:
mid = (lo + hi) // 2
if lista[mid] > mini:
hi = mid
else:
lo = mid + 1
return lo
def findind1(sizea, mini, lista):
lo = 0
hi = sizea
mid = (lo + hi) //... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP ... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | for ti in range(int(input())):
pn, qn, rn = list(map(int, input().split()))
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort()
q.sort()
r.sort()
x = y = z = 0
psum = rsum = 0
tsum = 0
for y in range(0, qn):
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN 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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CAL... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | from itertools import groupby
t = int(input())
for test in range(t):
p, q, r = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
tmpB = list(map(int, input().split()))
tmpB.sort()
C = list(map(int, input().split()))
C.sort()
B = []
freqB = []
for key, group ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL V... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | T = eval(input())
while T > 0:
inp = input()
a = inp.split()
Alen = eval(a[0])
Blen = eval(a[1])
Clen = eval(a[2])
A = list(map(int, input().split()))
A.sort()
B = list(map(int, input().split()))
B.sort()
C = list(map(int, input().split()))
C.sort()
y = 0
sumfinal = 0... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR 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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | t = int(input())
while t > 0:
p_a = []
q_a = []
r_a = []
p, q, r = input().split()
p, q, r = int(p), int(q), int(r)
p_a = list(map(int, input().split()))
q_a = list(map(int, input().split()))
r_a = list(map(int, input().split()))
p_a.sort()
q_a.sort()
r_a.sort()
tsum = 0
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CAL... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | MODVAL = 10**9 + 7
for t in range(int(input())):
p, q, r = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
ans = i = j = Xsum = Zsum = XZsum = 0
for Y in B:
while ... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | m = 1000000007
def value(a, b, c):
return (a + b) * (b + c) % m
t = int(input())
while t:
t -= 1
sum = 0
p, q, r = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
for i in b:
a1 = [j f... | ASSIGN VAR NUMBER FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | T = int(input())
while T > 0:
T -= 1
[p, q, r] = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
A_pos = 0
A_sum = 0
C_pos = 0
C_sum = 0
S = 0
for i in... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN LIST 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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL ... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | t = int(input())
for i in range(t):
sumf = 0
sumf1 = 0
p, q, r = map(int, input().split(" "))
a = list(map(int, input().split(" ")))
b = list(map(int, input().split(" ")))
c = list(map(int, input().split(" ")))
a.sort()
b.sort()
c.sort()
sum1 = 0
sum2 = 0
index1 = len(a) ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN 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 FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASS... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | import itertools
T = int(input())
for case in range(T):
p, q, r = map(int, input().split())
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))
zs = list(map(int, input().split()))
xs.sort(), ys.sort(), zs.sort()
sumx, sumz, ix, iz = 0, 0, 0, 0
ans = 0
for iy, y in... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR 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 ... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | mod = 1000000007
for i in range(int(input())):
p, q, r = map(int, input().split())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ans = 0
k = 0
l = 0
s1 = 0
c1 = 0
s2 = 0
c2 = 0
for j in ... | ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | T = int(input())
ans = []
mod = 10**9 + 7
for _ in range(T):
p, q, r = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
A.sort()
B.sort()
C.sort()
m = 0
n = 0
sum1 = 0
sum2 = 0
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN 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 FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUN... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | __author__ = ["vjn4006(Vaibhav Nagda)"]
def main():
t = int(input().strip())
for _ in range(t):
l, m, n = map(int, input().strip().split(" "))
a = sorted(list(map(int, input().strip().split(" "))))
b = sorted(list(map(int, input().strip().split(" "))))
c = sorted(list(map(int, ... | ASSIGN VAR LIST STRING FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VA... |
Given a triplet of integers (X , Y , Z), such that X β€ Y and Y β₯ Z, we define f(X , Y , Z) to be (X + Y) * (Y + Z). If either X > Y or Y < Z, or both, then f(X , Y , Z) is defined to be 0.
You are provided three arrays A , B and C of any length (their lengths may or may not be equal).
Your task is to find the sum ... | from sys import stdin, stdout
t = stdin.readline()
t = int(t)
M = 1000000007
for i in range(t):
length = [int(x) for x in stdin.readline().split()]
a = [int(x) for x in stdin.readline().split()]
b = [int(x) for x in stdin.readline().split()]
c = [int(x) for x in stdin.readline().split()]
a.sort()
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CAL... |
Given n, how many structurally unique BST's (binary search trees) that store values 1 ...Β n?
Example:
Input: 3
Output: 5
Explanation:
Given n = 3, there are a total of 5 unique BST's:
1 3 3 2 1
\ / / / \ \
3 2 1 1 3 2
/ / \ ... | class Solution:
def numTrees(self, n):
dp = [0] * (n + 1)
dp[0] = dp[1] = 1
for i in range(2, n + 1):
total = 0
for j in range(i):
total += dp[j] * dp[i - j - 1]
dp[i] = total
return dp[n] | CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR RETURN VAR VAR |
Given n, how many structurally unique BST's (binary search trees) that store values 1 ...Β n?
Example:
Input: 3
Output: 5
Explanation:
Given n = 3, there are a total of 5 unique BST's:
1 3 3 2 1
\ / / / \ \
3 2 1 1 3 2
/ / \ ... | class Solution:
def numTrees(self, n):
if n < 1:
return 1
tree_nums = [0] * (n + 1)
tree_nums[0] = 1
tree_nums[1] = 1
for t in range(2, n + 1):
for root in range(1, t + 1):
lt_num = root - 1
rt_num = t - root
... | CLASS_DEF FUNC_DEF IF VAR NUMBER RETURN 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 FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR VAR... |
Given n, how many structurally unique BST's (binary search trees) that store values 1 ...Β n?
Example:
Input: 3
Output: 5
Explanation:
Given n = 3, there are a total of 5 unique BST's:
1 3 3 2 1
\ / / / \ \
3 2 1 1 3 2
/ / \ ... | class Solution:
def numTrees(self, n):
dp = [1, 1, 2]
if n < 3:
return dp[n]
for i in range(3, n + 1):
dp.append(sum(dp[j - 1] * dp[i - j] for j in range(1, i + 1)))
return dp[n] | CLASS_DEF FUNC_DEF ASSIGN VAR LIST NUMBER NUMBER NUMBER IF VAR NUMBER RETURN VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER RETURN VAR VAR |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.