description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | from sys import stdin
inp = stdin.readline
n = int(inp())
arr = [int(x) for x in inp().split()]
count = 0
for i in range(0, n, 2):
start = arr[i]
rest = 0
for j in range(i + 1, n):
if j % 2:
if arr[j] < rest:
rest -= arr[j]
elif start + rest >= arr[j]:
... | ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP VAR NUMBER IF VAR VAR VAR VAR VAR VAR IF BIN_OP VAR VAR VAR ... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | import sys
input = sys.stdin.readline
def ri():
return [int(i) for i in input().split()]
def common(amin, amax, bmin, bmax):
if amax < bmin or bmax < amin:
return 0
return min(amax, bmax) - max(amin, bmin) + 1
def solve(Aseg, Bseg, fminopen, faddsopen):
if fminopen > Aseg:
return ... | IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR VAR VAR VAR RETURN NUMBER RETURN BIN_OP BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR VAR RETURN FUNC_CAL... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | from sys import stdin
def solve():
n = int(stdin.readline().strip())
seq = list(map(int, stdin.readline().split()))
ans = 0
for i in range(0, n, 2):
curr = seq[i]
inter_sum = 0
for j in range(i + 1, n):
if j % 2 == 0:
inter_sum += seq[j]
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP VAR NUMBER NUMBER VAR VAR VAR VAR VAR VAR IF V... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | import sys
input = sys.stdin.readline
n = int(input())
c = [0] + list(map(int, input().split()))
c1, c2 = [0], [0]
for i in range(1, n + 1):
ci = c[i]
if i % 2:
c1.append(ci + c1[-1])
c2.append(c2[-1])
else:
c2.append(ci + c2[-1])
c1.append(c1[-1])
dp = [([0] * (n + 1)) for ... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST NUMBER LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER EXPR F... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | from itertools import accumulate
n = int(input())
arr = [int(c) for c in input().split(" ")]
arr_par = [(arr[i] if not i % 2 else -arr[i]) for i in range(len(arr))]
acc = list(accumulate(arr_par))
ctr = 0
def d_inc(d, i):
if i in d:
d[i] += 1
else:
d[i] = 1
def summ(i):
return i * (i + ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FUNC_DEF IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER FUNC_DEF RETURN BI... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | n = int(input())
L = list(map(int, input().split()))
if len(L) % 2 != 0:
L.pop()
n = len(L)
ret = 0
for i in range(n // 2):
b = L[2 * i]
curr = 0
low = 1
for j in range(2 * i, n):
if j % 2 == 1:
if curr - (b - (low - 1)) < L[j]:
ret += min(L[j] - max(0, curr - (b ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMB... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | n = int(input())
arr = list(map(int, input().split()))
count = 0
ans = 0
for i in range(n):
count = 0
mini = 0
if i % 2 == 0:
for j in range(i + 1, n, 1):
if j % 2 == 0:
count += arr[j]
mini = min(mini, count)
else:
l_cont = arr... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR VAR V... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | import sys
from sys import stdin
n = int(stdin.readline())
c = list(map(int, stdin.readline().split()))
h = [0]
for i in range(n):
if i % 2 == 0:
h.append(h[-1] + c[i])
else:
h.append(h[-1] - c[i])
ans = 0
for l in range(0, n, 2):
if l == n - 1:
break
nmin = float("inf")
la ... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR ... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | N = int(input())
C = list(map(int, input().split()))
ans = 0
stack = [[0, 0]]
now = pre = mn = 0
for i, c in enumerate(C):
if i % 2 == 0:
pre = now
now += c
else:
pre = now
now -= c
ans += pre - max(now, mn)
is_mn = False
if mn > now:
mn = now
... | 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 LIST NUMBER NUMBER ASSIGN VAR VAR VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR BIN_OP VAR FUNC_CALL VAR VA... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | n = int(input())
a = list(map(int, input().split()))
s = []
answer = 0
for i in range(n):
if i % 2 == 0:
if len(s) == 0 or s[-1][0] != "(":
s.append(["(", a[i]])
else:
s[-1][1] += a[i]
else:
while len(s) > 0:
if len(s) > 0 and s[-1][0] == "(":
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER IF FUNC_CALL VAR VAR NUMBER VAR NUMBER NUMBER STRING EXPR FUNC_CALL VAR LIST STRING VAR VAR VAR NUMBER NUMBER VAR VAR WHILE FU... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | def doWork():
n = int(input())
a = map(int, input().split())
balance = 0
total = 0
stack = []
for i, x in enumerate(a):
if i % 2 == 0:
balance += x
continue
total += min(x, balance)
balance = balance - x
while stack and stack[-1][0] > balan... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR WHILE VAR VAR NUMBER NUMBER VAR ASSIGN VAR VAR NU... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | import sys
input = sys.stdin.readline
n = int(input())
C = list(map(int, input().split()))
S = [0]
for i in range(n):
c = C[i]
if i % 2 == 0:
S.append(S[-1] + c)
else:
S.append(S[-1] - c)
X = []
for s in S:
X.append(s - 1)
X.append(s)
X.append(s + 1)
X = sorted(set(X))
D = {X[i]... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR LIS... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | import sys
input = sys.stdin.readline
def main():
t = 1
for _ in range(t):
n = int(input())
ar = list(map(int, input().split()))
signs = [0]
for i, x in enumerate(ar):
if i % 2:
signs.append(signs[-1] - x)
else:
signs.app... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_O... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | n = int(input())
c = list(map(int, input().split()))
c.insert(0, 0)
ans = 0
for i in range(1, n + 1, 2):
bal, lo = 0, 1
for j in range(i + 1, n + 1):
if j % 2 == 0:
L = lo
R = max(1, bal + lo)
ans += max(0, min(c[i] - L + 1, c[j] - R + 1))
bal -= c[j]
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER N... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | debug = False
go_next = True
while go_next:
length = int(input())
values = list(map(int, input().split()))
if debug:
print(length, values)
result = 0
for s_ix in range(0, length, 2):
slackable = values[s_ix]
unclosed = 0
for i in range(s_ix, length):
if i ... | ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR IF BIN_OP... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | n = int(input())
arr = list(map(int, input().split()))
ans = 0
for i in range(0, n, 2):
st = [0, arr[i] - 1]
curr = 0
for j in range(i + 1, n, 2):
en = [curr + arr[j - 1] - arr[j], curr + arr[j - 1] - 1]
curr += arr[j - 1] - arr[j]
r1 = max(en[0], st[0])
r2 = min(en[1], st[1]... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR LIST NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR LIST BIN_OP BIN_OP VAR VAR BIN_... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | import sys
input = sys.stdin.readline
def inp():
return int(input())
def input_list():
return list(map(int, input().split()))
def input_string():
s = input()
return list(s[: len(s) - 1])
def input_int_gen():
return map(int, input().split())
tests = 1
for _ in range(tests):
n = inp()
... | IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR RETURN FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CA... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | n = int(input())
A = list(map(int, input().split()))
if n % 2 == 1:
A.pop()
Ans = 0
B = []
for i in range(1, n, 2):
x = A[i] - A[i - 1]
z = 0
Ans += min(A[i], A[i - 1])
if x >= 0:
for j in range(i - 2, -1, -2):
z += A[j]
w = A[j - 1]
W = min(z, w)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR V... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | n = int(input())
a = [int(i) for i in input().split()]
less = 0
zhan = [[0, 1]]
high = 0
ans = 0
flag = True
for i in a:
if flag:
high += i
else:
ans += min(high - less, i)
high -= i
less = min(high, less)
while len(zhan) != 0 and zhan[-1][0] > high:
ans += zh... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST LIST NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR WHILE FUNC_C... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | import sys
def main(N, A):
ans = 0
for i in range(0, N, 2):
op = 0, A[i]
bottom = A[i]
e = A[i]
for j in range(i + 1, N, 2):
cl = e - A[j], e
mx = min(op[1], cl[1], max(0, bottom))
mn = max(op[0], cl[0], -min(0, bottom))
now = mx ... | IMPORT FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR ... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | n = int(input())
c = list(map(int, input().split()))
n = len(c)
ans = 0
for i in range(0, n, 2):
diff = 0
a = 0
for j in range(i + 1, n):
if j % 2 == 0:
diff += c[j]
continue
ans += min(max(0, c[j] - diff), c[i])
if c[j] - diff >= 0:
ans += a
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP VAR NUMBER NUMBER VAR VAR VAR VAR FUN... |
William has a favorite bracket sequence. Since his favorite sequence is quite big he provided it to you as a sequence of positive integers $c_1, c_2, \dots, c_n$ where $c_i$ is the number of consecutive brackets "(" if $i$ is an odd number or the number of consecutive brackets ")" if $i$ is an even number.
For example... | def overlap(min1, max1, min2, max2):
if max1 < min2 or max2 < min1:
return 0
return max(0, min(max1, max2) - max(min1, min2)) + 1
n = int(input())
arr = list(map(int, input().split()))
ans = 0
li = []
for i in range(0, n, 2):
temp = 0
a = 0
b = arr[i] - 1
temp += arr[i]
flag = 0
... | FUNC_DEF IF VAR VAR VAR VAR RETURN NUMBER RETURN BIN_OP FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR 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 NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIG... |
In 2013, the writers of Berland State University should prepare problems for n Olympiads. We will assume that the Olympiads are numbered with consecutive integers from 1 to n. For each Olympiad we know how many members of the jury must be involved in its preparation, as well as the time required to prepare the problems... | fin = open("input.txt", "r")
fout = open("output.txt", "w")
mon = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
ans = [0] * 500
ba = []
for i in range(int(fin.readline())):
m, d, p, t = map(int, fin.readline().split())
ba.append([m, d, p, t])
for i in ba:
days = sum(mon[: i[0]]) + i[1] + 100
for j... | ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL... |
In 2013, the writers of Berland State University should prepare problems for n Olympiads. We will assume that the Olympiads are numbered with consecutive integers from 1 to n. For each Olympiad we know how many members of the jury must be involved in its preparation, as well as the time required to prepare the problems... | w, r = open("output.txt", "w"), open("input.txt", "r")
s, y = [0] * 466, [0, 100, 131, 159, 190, 220, 251, 281, 312, 343, 373, 404, 434]
for i in range(int(r.readline())):
m, d, p, t = map(int, r.readline().split())
x = y[m] + d
s[x] -= p
s[x - t] += p
for i in range(465):
s[i + 1] += s[i]
w.write(s... | ASSIGN VAR VAR FUNC_CALL VAR STRING STRING FUNC_CALL VAR STRING STRING ASSIGN VAR VAR BIN_OP LIST NUMBER NUMBER LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL V... |
In 2013, the writers of Berland State University should prepare problems for n Olympiads. We will assume that the Olympiads are numbered with consecutive integers from 1 to n. For each Olympiad we know how many members of the jury must be involved in its preparation, as well as the time required to prepare the problems... | def main():
days_in_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
month2day = {}
cnt = 0
for i in range(9, 12 + 1):
for j in range(1, days_in_month[i - 1] + 1):
month2day[i, j, 12] = cnt
cnt += 1
for i in range(1, 12 + 1):
for j in range(1, days_in_... | FUNC_DEF ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR NUMBER VAR VAR NUMBER FOR VAR FUNC_CALL VAR... |
In 2013, the writers of Berland State University should prepare problems for n Olympiads. We will assume that the Olympiads are numbered with consecutive integers from 1 to n. For each Olympiad we know how many members of the jury must be involved in its preparation, as well as the time required to prepare the problems... | import sys
def getMaxJuries(juries, m, d, t, months):
year = 1
res = 0
while t > 0:
if d < 0:
m -= 1
if m < 0:
m += 12
year = 0
d = months[m] - 1
res = max(res, juries[year][m][d])
d -= 1
t -= 1
return ... | IMPORT FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR NUMBER VAR NUMBER IF ... |
In 2013, the writers of Berland State University should prepare problems for n Olympiads. We will assume that the Olympiads are numbered with consecutive integers from 1 to n. For each Olympiad we know how many members of the jury must be involved in its preparation, as well as the time required to prepare the problems... | fin = open("input.txt", "r")
fout = open("output.txt", "w")
day = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
table = []
for i in range(int(fin.readline())):
table.append([int(i) for i in fin.readline().split()])
ans = [0] * 500
for it in table:
days = sum(day[0 : it[0]]) + it[1] + 100
for i in rang... | ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSI... |
In 2013, the writers of Berland State University should prepare problems for n Olympiads. We will assume that the Olympiads are numbered with consecutive integers from 1 to n. For each Olympiad we know how many members of the jury must be involved in its preparation, as well as the time required to prepare the problems... | from sys import stdin, stdout
def get_time(m, d, t):
month = ["dum", 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
day = 0
for i in range(1, m):
day += month[i]
day += d
end = day
start = end - t
return start, end
stdin = open("input.txt", "r")
stdout = open("output.txt", "w")
... | FUNC_DEF ASSIGN VAR LIST STRING NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR RETURN VAR VAR ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR STRING STRING... |
In 2013, the writers of Berland State University should prepare problems for n Olympiads. We will assume that the Olympiads are numbered with consecutive integers from 1 to n. For each Olympiad we know how many members of the jury must be involved in its preparation, as well as the time required to prepare the problems... | import sys
sys.stdin = open("input.txt", "r")
sys.stdout = open("output.txt", "w")
di = {}
k = 1
days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
for i in range(12):
for j in range(days[i]):
di[i + 1, j + 1] = k
k += 1
n = int(input())
a = [0] * 512
for _ in range(n):
m, d, p, t = map(in... | IMPORT ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR NU... |
In 2013, the writers of Berland State University should prepare problems for n Olympiads. We will assume that the Olympiads are numbered with consecutive integers from 1 to n. For each Olympiad we know how many members of the jury must be involved in its preparation, as well as the time required to prepare the problems... | w = open("output.txt", "w")
r = open("input.txt", "r")
arr = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
def get_date(m, d):
res = 0
for i in range(m - 1):
res += arr[i]
return res + d
n = int(r.readline())
used = [0] * 366
for i in range(n):
m, d, p, t = list(map(int, r.readline().spli... | ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR RETURN BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR AS... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | import sys
input = sys.stdin.readline
n, r = map(int, input().split())
xs = list(map(int, input().split()))
points = []
for x in xs:
y = r
for x0, y0 in points:
if abs(x - x0) <= 2 * r:
y = max(y, y0 + ((2 * r) ** 2 - (x - x0) ** 2) ** 0.5)
points.append((x, y))
print(" ".join("%.20f" %... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR VAR FOR VAR VAR VAR IF FUNC_CALL VAR BIN_OP VAR VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP BIN_OP BIN_OP BIN_... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | import sys
input = sys.stdin.readline
MOD = 1000000007
MOD2 = 998244353
ii = lambda: int(input().strip("\n"))
si = lambda: input().strip("\n")
dgl = lambda: list(map(int, input().strip("\n")))
f = lambda: map(int, input().strip("\n").split())
il = lambda: list(map(int, input().strip("\n").split()))
ls = lambda: list(i... | IMPORT ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN 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 VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | n, r = map(int, input().split())
a = list(map(int, input().split()))
st = []
for i in a:
left, right, cen = i - r, i + r, -1
for j in st:
if (
not (j[0] > right or j[1] < left)
and cen < ((2 * r) ** 2 - ((j[0] + j[1]) / 2 - i) ** 2) ** 0.5 + j[2]
):
cen = ((2 ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR VAR NUMBER VAR VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER BIN_OP BIN... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | ip = lambda: map(int, input().split())
ipl = lambda: list(map(int, input().split()))
n, r = ip()
a = ipl()
l = []
for i in range(n):
b = [r]
for j in range(i):
d = abs(a[i] - a[j])
if d <= 2 * r:
b.append((4 * r * r - d * d) ** 0.5 + l[j])
l.append(max(b))
print(max(b), end="... | 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 VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF VAR BIN... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | n, r = map(int, input().split())
l = list(map(int, input().split()))
ds = []
for i in range(len(l)):
ans = [l[i], r]
x = l[i]
for j in range(len(ds)):
if abs(x - ds[j][0]) <= 2 * r:
ans[1] = max(ans[1], ds[j][1] + (4 * r * r - (x - ds[j][0]) ** 2) ** 0.5)
ds.append(ans)
ls = []
for j... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER BIN_OP NUM... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | import sys
n, r = map(int, sys.stdin.readline().split())
x = list(map(int, sys.stdin.readline().split()))
y = [r]
for i in range(1, n):
m = r
for j in range(i):
temp = 4 * r * r - (x[i] - x[j]) ** 2
if temp >= 0:
m = max(m, temp**0.5 + y[j])
y.append(m)
for i in range(n):
pr... | IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR NUMBER IF VAR NUMB... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | num_disks, radius = list(map(int, input().strip().split()))
x_locs = list(map(int, input().strip().split()))
locs = []
for x_loc in x_locs:
max_y = radius
for x, y in locs:
base = (radius * 2) ** 2 - (x_loc - x) ** 2
if base < 0:
continue
new_y = base**0.5 + y
if new_... | ASSIGN VAR 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 LIST FOR VAR VAR ASSIGN VAR VAR FOR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | n, r = list(map(int, input().split()))
X = [int(x) for x in input().split()]
Y = []
for i in range(n):
forcedy = r
for j in range(len(Y)):
dist = abs(X[i] - X[j])
if dist <= 2 * r:
y = Y[j] + ((2 * r) ** 2 - dist**2) ** 0.5
forcedy = max(y, forcedy)
Y.append(forcedy)
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR ... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | n, r = map(int, input().split())
x_coord = list(map(int, input().split()))
d = {}
for i in x_coord:
final = r
for j in range(i - r, i + r + 1):
check = d.get(j, [-1, -1])
if check[0] > 0:
potential = check[1] + (4 * r * r - (i - check[0]) ** 2) ** 0.5
final = max(potentia... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR LIST NUMBER NUMBER IF VAR NUMBER NUMBER ASSIGN VAR BIN_OP ... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | def f(x1, x2, y2):
t = 4 * r * r - (x1 - x2) ** 2
if t >= 0:
return y2 + t**0.5
return r
n, r = map(int, input().split())
print(r)
(*a,) = map(int, input().split())
cor = [[a[i], r] for i in range(n)]
for i in range(1, n):
cor[i][1] = max(f(cor[i][0], cor[j][0], cor[j][1]) for j in range(i))
... | FUNC_DEF ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR NUMBER RETURN BIN_OP VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR VAR VAR VAR FUNC_CALL... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | n, r = list(map(int, input().split()))
p = 1
points = list(map(int, input().split()))
x, y = [(0) for i in range(n)], [(0) for i in range(n)]
for i in range(n):
x[i] = points[i]
y[i] = r
for j in range(i):
if abs(x[j] - x[i]) <= 2 * r:
ans = 4 * r**2
d = abs(x[j] - x[i])
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR V... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | n, r = map(int, input().split())
x = list(map(int, input().split()))
y = [r] * n
for i in range(n):
for j in range(i):
if not abs(x[i] - x[j]) > 2 * r:
y[i] = max(y[i], (4 * r**2 - (x[i] - x[j]) ** 2) ** 0.5 + y[j])
for i in y:
print(i, end=" ") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR BIN_OP VAR VAR VAR VAR BIN_OP NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP BIN_... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | read = lambda: map(int, input().split())
n, r = read()
x = list(read())
y = [0] * n
for i in range(n):
cur = r
for j in range(i):
if 2 * r >= abs(x[i] - x[j]):
cur = max(cur, y[j] + (4 * r * r - (x[i] - x[j]) ** 2) ** 0.5)
y[i] = cur
print(*y) | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP NUMBER VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR ... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | n, r = map(int, input().split())
x = list(map(int, input().split()))
y = []
for i in range(n):
s = []
for j in range(i):
if abs(x[i] - x[j]) < 2 * r + 1e-07:
s.append(j)
max = r
for j in s:
if (4 * r * r - (x[i] - x[j]) ** 2) ** 0.5 + y[j] > max:
max = (4 * r * r ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR BIN_OP VAR VAR VAR VAR BIN_OP BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR FO... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | n, r = map(int, input().split())
x = [int(i) for i in input().split()]
c = []
for i in range(n):
k = r
for x1, j in c:
d = abs(x[i] - x1)
if d <= 2 * r:
k = max(k, j + (4 * r**2 - d * d) ** 0.5)
c.append([x[i], k])
print(k) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FOR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR IF VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP BIN_OP BIN_OP NUM... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | import sys
input = sys.stdin.readline
def gcd(a, b):
if a == 0:
return b
return gcd(b % a, a)
def lcm(a, b):
return a * b / gcd(a, b)
def main():
n, r = map(int, input().split())
a = list(map(int, input().split()))
ans = []
ans.append(r)
for i in range(1, n):
ymax ... | IMPORT ASSIGN VAR VAR FUNC_DEF IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR BIN_OP VAR VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST EXPR FUNC_CALL ... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | n, r = map(int, input().split())
y = []
x = list(map(int, input().split()))
for xi in x:
yi = r
for tx, ty in zip(x, y):
if xi - 2 * r <= tx <= xi + 2 * r:
dy = (4.0 * r**2 - (tx - xi) ** 2) ** 0.5
yi = max(yi, ty + dy)
y.append(yi)
print(*y) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR ASSIGN VAR VAR FOR VAR VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR BIN_OP NUMBER VAR VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER BIN_OP VAR NUMB... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | l = list(map(int, input().rstrip().split()))
n = l[0]
r = l[1]
num = list(map(int, input().rstrip().split()))
final = []
mahalist = []
for i in range(len(num)):
mahalist = []
if i == 0:
final.append(r)
mahalist.append(r)
else:
for j in range(i):
if abs(num[i] - num[j]) <=... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR LIST IF VAR NUMBER EXPR FUNC_CALL VAR V... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | a = list(map(int, input().split(" ")))
y = list(map(int, input().split(" ")))
circ = []
for i in range(a[0]):
fy = a[1]
for j in circ:
delta = abs(y[i] - j[0])
if delta <= 2 * a[1]:
fy = max(fy, j[1] + ((2 * a[1]) ** 2 - delta**2) ** 0.5)
circ.append([y[i], fy])
for i in circ:
... | 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 ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER IF VAR BIN_OP NUMBER VAR NUMBER ASSIGN... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | n, r = list(map(int, input().split()))
disks = list(map(int, input().split()))
new_disks = []
for i in range(n):
y2 = r
x2 = disks[i]
for j in range(i):
x1, y1 = new_disks[j]
a = r * r * 4 - (x2 - x1) ** 2
if a < 0:
continue
else:
y2 = max(y2, a**0.5 +... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | n, r = list(map(int, input().split()))
x = list(map(int, input().split()))
r2r4 = 4 * r**2
y = []
for i in range(0, n):
max_y = r
for j in range(i):
if r2r4 >= (x[i] - x[j]) ** 2:
max_y = max(max_y, y[j] + (r2r4 - (x[i] - x[j]) ** 2) ** 0.5)
y.append(max_y)
print(*y) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP BIN_OP VAR VAR VAR VAR NUMBER ASSIG... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | import itertools
inf = float("inf")
read_ints = lambda: list(map(int, input().split()))
def intersects(x1, y1, x2, y2, r):
return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5 <= 2 * r
def get_intersection_y(x, xt, yt, r):
if abs(x - xt) > 2 * r:
return r
return yt + (4 * r**2 - (x - xt) ** 2) ** 0.... | IMPORT ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER NUMBER BIN_OP NUMBER VAR FUNC_DEF IF FUNC_CALL VAR BIN_OP VAR VAR BIN_OP NUMBER VAR RETURN VAR RETURN BIN_OP VAR BIN_OP BIN_OP... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | n, r = [int(i) for i in input().split(" ")]
x = [int(i) for i in input().split(" ")]
y = []
for i in range(n):
contact = -1
cury = r
for j in range(i):
if x[i] - r <= x[j] + r and x[i] + r >= x[j] - r:
if contact == -1:
contact = j
cury = y[j] + (4 * r**2 ... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR IF VAR N... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | n, r = map(int, input().split())
xs = list(map(float, input().split()))
ys = [0.0] * n
y = 0
for i in range(n):
maxy = r
for j in range(i):
if abs(xs[j] - xs[i]) <= 2.0 * r:
dx = xs[j] - xs[i]
newy = (4 * r * r - dx * dx) ** 0.5 + ys[j]
if maxy == -1 or maxy < newy:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR BIN_OP VAR VAR VAR VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP V... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | n, r = map(int, input().split())
a = [int(i) for i in input().split()]
s = []
arr = []
s.append(r)
arr.append(a[0])
for i in range(1, n):
an = r
f = False
temp = -1
for j in range(len(arr)):
if arr[j] <= a[i] + 2 * r and arr[j] >= a[i] - 2 * r:
an = max(an, s[j] + (pow(2 * r, 2) - po... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR V... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | n, r = map(int, input().split())
l = list(map(int, input().split()))
ans = [r] * n
for i in range(n):
for j in range(i):
if 4 * r**2 - (max(l[i], l[j]) - min(l[i], l[j])) ** 2 >= 0:
y = 4 * r**2 - (max(l[i], l[j]) - min(l[i], l[j])) ** 2
ans[i] = max(ans[i], ans[j] + y**0.5)
print(*a... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR V... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | R = lambda: map(int, input().split())
n, r = R()
xs = list(R())
ys = []
for i in range(n):
ys.append(
max(
[
(((2 * r) ** 2 - abs(xs[i] - xs[j]) ** 2) ** 0.5 + ys[j])
for j in range(i)
if abs(xs[i] - xs[j]) <= 2 * r
],
defau... | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER NUMBER VAR VAR VAR F... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | n, r = list(map(int, input().strip().split()))
x = list(map(int, input().strip().split()))
fallen = [[x[0], r]]
for i in range(1, len(x)):
k = len(fallen) - 1
maks = r
for k in range(len(fallen)):
xi, yi = fallen[k]
if abs(x[i] - xi) <= 2 * r + 10**-10:
y1 = ((2 * r) ** 2 - (xi -... | ASSIGN VAR 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 LIST LIST VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | n, r = map(int, input().split())
x = list(map(int, input().split()))
y = [0] * n
y[0] = r
for i in range(1, n):
temp = r
for j in range(i):
s = 4 * r * r - abs(x[j] - x[i]) * abs(x[j] - x[i])
if s >= 0:
temp = max(temp, s**0.5 + y[j])
y[i] = temp
for i in range(n):
y[i] = str... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER VAR VAR BIN_OP FUNC_CALL VA... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | n, r = map(int, input().split())
discs = {}
s = list(map(int, input().split()))
discs[s[0]] = r
print(r, end=" ")
b = lambda y: (4 * r**2 - y**2) ** 0.5
for i in range(1, n):
xi = s[i]
found = False
to_app = []
for x in discs:
res = b(x - xi)
if type(res) != complex:
to_app.a... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR EXPR FUNC_CALL VAR VAR STRING ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VA... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | n, r = map(int, input().split())
s = list(map(int, input().split()))
l = [r]
for i in range(1, len(s)):
b = r
for j in range(i - 1, -1, -1):
if abs(s[i] - s[j]) <= 2 * r:
b = max(b, l[j] + (4 * r * r - (s[i] - s[j]) ** 2) ** 0.5)
l.append(b)
print(*l) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF FUNC_CALL VAR BIN_OP VAR VAR VAR VAR BIN_OP NUMBER VAR AS... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | maxN = int(100000.0 + 3)
eps = 1e-10
x = [(0) for k in range(maxN)]
y = [(0) for k in range(maxN)]
n = 0
r = 0
d = 0
def read():
global x, n, r, d
n, r = (int(k) for k in input().split())
r = float(r)
d = 2 * r
x = [float(k) for k in input().split()]
def doit():
for i in range(n):
th... | ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBE... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | f = lambda: map(int, input().split())
n, r = f()
p, d = [], 2 * r
for x in f():
y = r
for a, b in p:
if abs(a - x) <= d:
y = max(y, b + (d * d - (a - x) ** 2) ** 0.5)
p.append((x, y))
for x, y in p:
print(y) | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR LIST BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR ASSIGN VAR VAR FOR VAR VAR VAR IF FUNC_CALL VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR F... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | n, r = map(int, input().split())
x = [int(i) for i in input().split()]
ans_y = [r]
for i in range(1, n):
curr_x = x[i]
stat = True
pos = []
index_of_check = 0
for j in range(0, i):
if x[j] - 2 * r <= curr_x <= x[j] + 2 * r:
pos.append(j)
stat = False
if stat:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR VAR BIN_OP NUMBER VAR VAR BIN_OP VA... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | n, r = map(int, input().split())
x, y = list(map(int, input().split())), [r] * n
def f(xi, xj, yj):
d = abs(xi - xj)
return r if d > 2 * r else yj + (4 * r**2 - d**2) ** 0.5
for i in range(1, n):
y[i] = max(f(x[i], x[j], y[j]) for j in range(i))
print(" ".join(map(str, y))) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR BIN_OP LIST VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR RETURN VAR BIN_OP NUMBER VAR VAR BIN_OP VAR BIN_OP BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER FOR VAR ... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | n, r = list(map(int, input().split()))
disks = list(map(int, input().split()))
atline = [[disks[0], r]]
for i in range(1, n):
sup = r
thisd = disks[i]
for disk in atline:
dx = disk[0] - thisd
if abs(dx) > 2 * r:
continue
y = disk[1] + (4 * r * r - dx * dx) ** 0.5
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST LIST VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR FOR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR IF FUNC_CALL VAR VAR BIN_OP NUMBER... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | import time
n, r = 0, 0
x = []
y = []
def calc_y(x, x1, y1):
dx = abs(x - x1)
if dx > 2 * r:
return r
dy = (4 * r**2 - dx**2) ** (1 / 2)
return y1 + dy
def let_fall_disk(i):
global n, r, x, y
return max([calc_y(x[i], x[j], y[j]) for j in range(i)] + [r])
def let_fall_disks():
... | IMPORT ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR IF VAR BIN_OP NUMBER VAR RETURN VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP NUMBER NUMBER RETURN BIN_OP VAR VAR FUNC_DEF RETURN FUNC_CALL VAR BIN_OP FUNC_CALL VA... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | n, r = map(int, input().split())
a = list(map(int, input().split()))
ans = [r]
for i in range(1, n):
maxx = -1
for j in range(i):
if abs(a[i] - a[j]) <= 2 * r:
c = ans[j] + (4 * r * r - (a[i] - a[j]) ** 2) ** 0.5
else:
c = r
maxx = max(maxx, c)
ans.append(maxx... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR BIN_OP VAR VAR VAR VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR VAR BIN_OP BIN_OP B... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | n, r = map(int, input().split())
A = list(map(int, input().split()))
B = []
B.append([r, A[0] - r, A[0] + r])
print(r, end=" ")
for i in range(1, n):
B = sorted(B, key=lambda l: l[0], reverse=True)
m = 0
k = 0
for j in B:
if j[1] - r <= A[i] <= j[2] + r:
k = j[0] + (4 * r * r - abs(A... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR LIST VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR STRING FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER NUMBE... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | I = lambda: input().split(" ")
a = I()
y = I()
c = []
for i in range(int(a[0])):
f = int(a[1])
g = 2 * f
h = int(y[i])
for j in c:
d = abs(h - j[0])
if d <= g:
f = max(f, j[1] + (g * g - d * d) ** 0.5)
c.append([h, f])
for i in c:
print(i[1]) | ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER IF VAR V... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | k, r = map(int, input().split())
S = list(map(int, input().split()))
Used = []
Answer = []
for i in S:
delta = r
for j in range(len(Used)):
if abs(i - Used[j]) <= 2 * r:
rass = abs(i - Used[j])
delta = max(delta, Answer[j] + ((2 * r) ** 2 - rass**2) ** 0.5)
Answer.append(delt... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR... |
Carol is currently curling.
She has n disks each with radius r on the 2D plane.
Initially she has all these disks above the line y = 10^100.
She then will slide the disks towards the line y = 0 one by one in order from 1 to n.
When she slides the i-th disk, she will place its center at the point (x_{i}, 10^100). ... | R = lambda: map(int, input().split())
R1 = lambda: map(float, input().split())
n, r = R()
a = list(R1())
pos = []
t = 4.0 * r * r
for i in range(n):
cons = [r]
for k in range(i):
t1 = t - (a[k] - a[i]) ** 2
if t1 >= 0:
t2 = t1 ** (1 / 2)
cons.append(pos[k] + t2)
pos.a... | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP ... |
Return all non-negative integers of length n such that the absolute difference between every two consecutive digits is k.
Note that every number in the answer must not have leading zeros except for the number 0 itself. For example, 01 has one leading zero and is invalid, but 0 is valid.
You may return the answer in any... | class Solution:
def numsSameConsecDiff(self, n: int, k: int) -> List[int]:
result = {1, 2, 3, 4, 5, 6, 7, 8, 9}
for i in range(1, n):
temp = list()
for r in result:
if k == 0:
temp.append(r * 10 + r % 10)
else:
... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR ... |
Return all non-negative integers of length n such that the absolute difference between every two consecutive digits is k.
Note that every number in the answer must not have leading zeros except for the number 0 itself. For example, 01 has one leading zero and is invalid, but 0 is valid.
You may return the answer in any... | class Solution:
def numsSameConsecDiff(self, N: int, K: int) -> List[int]:
def dfs(N, K, digit, rst):
if not N:
rst.append(int("".join(map(str, digit))))
return
if digit[-1] + K <= 9:
dfs(N - 1, K, digit + [digit[-1] + K], rst)
... | CLASS_DEF FUNC_DEF VAR VAR FUNC_DEF IF VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR RETURN IF BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_OP VAR LIST BIN_OP VAR NUMBER VAR VAR IF BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_OP VAR... |
Return all non-negative integers of length n such that the absolute difference between every two consecutive digits is k.
Note that every number in the answer must not have leading zeros except for the number 0 itself. For example, 01 has one leading zero and is invalid, but 0 is valid.
You may return the answer in any... | class Solution:
def numsSameConsecDiff(self, n, k):
res = []
for i in range(1, 10):
neighbors = self.helper(i, k)
for neighbor in neighbors:
res.append([i, neighbor])
if n > 2:
n -= 2
while n > 0:
temp = []
... | CLASS_DEF FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR IF VAR NUMBER VAR NUMBER WHILE VAR NUMBER ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR LIST VAR VAR NUMBER ... |
Return all non-negative integers of length n such that the absolute difference between every two consecutive digits is k.
Note that every number in the answer must not have leading zeros except for the number 0 itself. For example, 01 has one leading zero and is invalid, but 0 is valid.
You may return the answer in any... | class Solution:
def numsSameConsecDiff(self, n: int, k: int) -> List[int]:
if n == 1:
return list(range(10))
ans = []
for num in range(1, 10):
self.dfs(n - 1, num, ans, k)
return ans
def dfs(self, n, num, ans, k):
if n == 0:
return an... | CLASS_DEF FUNC_DEF VAR VAR IF VAR NUMBER RETURN FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR RETURN VAR VAR VAR FUNC_DEF IF VAR NUMBER RETURN FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR LIST BIN_OP VAR... |
Return all non-negative integers of length n such that the absolute difference between every two consecutive digits is k.
Note that every number in the answer must not have leading zeros except for the number 0 itself. For example, 01 has one leading zero and is invalid, but 0 is valid.
You may return the answer in any... | class Solution:
def numsSameConsecDiff(self, n: int, k: int) -> List[int]:
queue = []
ans = []
for i in range(1, 10):
queue.append(str(i))
while len(queue) > 0:
num = queue.pop(0)
if len(num) == n and num not in ans:
ans.append(num... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR WHILE FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF BIN_O... |
Return all non-negative integers of length n such that the absolute difference between every two consecutive digits is k.
Note that every number in the answer must not have leading zeros except for the number 0 itself. For example, 01 has one leading zero and is invalid, but 0 is valid.
You may return the answer in any... | import itertools
class Solution:
def step(self, n, k):
d = n % 10
b = n * 10
if k == 0:
yield b + d
if d < d + k < 10:
yield b + d + k
if 0 <= d - k < d:
yield b + d - k
def solve(self, nums, n, k):
if n == 1:
re... | IMPORT CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR BIN_OP VAR VAR IF VAR BIN_OP VAR VAR NUMBER EXPR BIN_OP BIN_OP VAR VAR VAR IF NUMBER BIN_OP VAR VAR VAR EXPR BIN_OP BIN_OP VAR VAR VAR FUNC_DEF IF VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR RETURN ... |
Return all non-negative integers of length n such that the absolute difference between every two consecutive digits is k.
Note that every number in the answer must not have leading zeros except for the number 0 itself. For example, 01 has one leading zero and is invalid, but 0 is valid.
You may return the answer in any... | class Solution:
def numsSameConsecDiff(self, n: int, k: int) -> List[int]:
def solve(x):
s = str(x)
if len(s) > 1 and abs(int(s[-1]) - int(s[-2])) != k:
return
if len(s) == n and abs(int(s[-1]) - int(s[-2])) == k:
result.append(x)
... | CLASS_DEF FUNC_DEF VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR RETURN IF FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR V... |
Return all non-negative integers of length n such that the absolute difference between every two consecutive digits is k.
Note that every number in the answer must not have leading zeros except for the number 0 itself. For example, 01 has one leading zero and is invalid, but 0 is valid.
You may return the answer in any... | class Solution:
def numsSameConsecDiff(self, N: int, K: int) -> List[int]:
dp = list(range(10))
for _ in range(N - 1):
_dp = set()
for x in dp:
for y in [x % 10 + K, x % 10 - K]:
if x and 0 <= y <= 9:
_dp.add(x * 10... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VAR FOR VAR LIST BIN_OP BIN_OP VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR VAR RETURN FUNC... |
Return all non-negative integers of length n such that the absolute difference between every two consecutive digits is k.
Note that every number in the answer must not have leading zeros except for the number 0 itself. For example, 01 has one leading zero and is invalid, but 0 is valid.
You may return the answer in any... | class Solution:
def numsSameConsecDiff(self, n: int, k: int) -> List[int]:
@functools.lru_cache(maxsize=128, typed=False)
def check(n, k, s):
rtv = []
if n == 0:
return []
rtv = []
for i in range(10):
if abs(i - s) == ... | CLASS_DEF FUNC_DEF VAR VAR FUNC_DEF ASSIGN VAR LIST IF VAR NUMBER RETURN LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR IF VAR FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP LIST VAR VAR EXPR FUNC_CALL VAR LIST VAR RETURN VAR FUNC_CALL VAR... |
Return all non-negative integers of length n such that the absolute difference between every two consecutive digits is k.
Note that every number in the answer must not have leading zeros except for the number 0 itself. For example, 01 has one leading zero and is invalid, but 0 is valid.
You may return the answer in any... | class Solution:
def numsSameConsecDiff(self, n: int, k: int) -> List[int]:
if n == 1:
return [i for i in range(10)]
queue = [digit for digit in range(1, 10)]
for level in range(n - 1):
next_queue = []
for num in queue:
tail_digit = num % 1... | CLASS_DEF FUNC_DEF VAR VAR IF VAR NUMBER RETURN VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR LIST BIN_OP VAR VAR BIN_OP VAR VAR FOR VAR VAR IF NUMBER VAR NUMBER ASSIGN... |
Return all non-negative integers of length n such that the absolute difference between every two consecutive digits is k.
Note that every number in the answer must not have leading zeros except for the number 0 itself. For example, 01 has one leading zero and is invalid, but 0 is valid.
You may return the answer in any... | class Solution:
def numsSameConsecDiff(self, N: int, K: int) -> List[int]:
ans = []
def DFS(N, num):
if N == 0:
return ans.append(num)
tail_digit = num % 10
next_digits = set([tail_digit + K, tail_digit - K])
for next_digit in next_di... | CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR LIST FUNC_DEF IF VAR NUMBER RETURN FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR LIST BIN_OP VAR VAR BIN_OP VAR VAR FOR VAR VAR IF NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMB... |
You have a simple undirected graph consisting of $n$ vertices and $m$ edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be disconnected.
Let's make a definition.
Let $v_1$ and $v_2$ be two some nonempty subsets of vertices that do not intersect. Let... | def type_(list_v, group):
cnt_0 = 0
cnt_1 = 0
for v in list_v:
if v in group:
cnt_1 += 1
else:
cnt_0 += 1
if cnt_1 == len(group):
return 1
if cnt_0 == len(list_v):
return 0
return 2
def is_all_type_1(ex_index, list_group, v):
for i, g... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER VAR NUMBER IF VAR FUNC_CALL VAR VAR RETURN NUMBER IF VAR FUNC_CALL VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR VAR IF FUNC_CALL VAR VAR VAR VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIG... |
You have a simple undirected graph consisting of $n$ vertices and $m$ edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be disconnected.
Let's make a definition.
Let $v_1$ and $v_2$ be two some nonempty subsets of vertices that do not intersect. Let... | def split_group(n):
for g in range(1, 4):
first_node = 1
while first_node <= n and group[first_node] != 0:
first_node = first_node + 1
if first_node > n:
return False
group[first_node] = g
group_cnt[g] = group_cnt[g] + 1
group_mem[g].append(fir... | FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR RETURN NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR NUMBER VAR VAR VAR ASSIGN VAR VAR... |
You have a simple undirected graph consisting of $n$ vertices and $m$ edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be disconnected.
Let's make a definition.
Let $v_1$ and $v_2$ be two some nonempty subsets of vertices that do not intersect. Let... | n, m = map(int, input().split())
EE = []
if m < 3:
print(-1)
else:
edge = [[] for i in range(n)]
a, b = map(int, input().split())
edge[a - 1].append(b - 1)
edge[b - 1].append(a - 1)
EE.append([a - 1, b - 1])
for i in range(m - 1):
x, y = map(int, input().split())
edge[x - 1].... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EX... |
You have a simple undirected graph consisting of $n$ vertices and $m$ edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be disconnected.
Let's make a definition.
Let $v_1$ and $v_2$ be two some nonempty subsets of vertices that do not intersect. Let... | import sys
n, m = [int(i) for i in sys.stdin.readline().split()]
group = [0] * n
data = [set() for i in range(n)]
gi = 0
for i in range(m):
a, b = [(int(j) - 1) for j in sys.stdin.readline().split()]
data[a].add(b)
data[b].add(a)
for i in range(n):
if group[i] == 0:
gi += 1
if gi == 4:
... | IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VA... |
You have a simple undirected graph consisting of $n$ vertices and $m$ edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be disconnected.
Let's make a definition.
Let $v_1$ and $v_2$ be two some nonempty subsets of vertices that do not intersect. Let... | import sys
input = sys.stdin.readline
def r1():
return int(input())
def r2():
return map(int, input().split())
n, m = r2()
d = {}
for i in range(1, n + 1):
d[i] = set()
for i in range(m):
x, y = r2()
d[x].add(y)
d[y].add(x)
first = set(range(1, n + 1)) - d[1]
if not d[1]:
print(-1)
el... | IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR V... |
You have a simple undirected graph consisting of $n$ vertices and $m$ edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be disconnected.
Let's make a definition.
Let $v_1$ and $v_2$ be two some nonempty subsets of vertices that do not intersect. Let... | n, m = map(int, input().split())
neigh = [set() for i in range(n + 1)]
total = set(range(1, n + 1))
for i in range(m):
a, b = map(int, input().split())
neigh[a].add(str(b))
neigh[b].add(str(a))
for i in range(len(neigh)):
neigh[i] = frozenset(neigh[i])
numbers = dict()
count = 0
r = []
for i in neigh[1:... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL... |
You have a simple undirected graph consisting of $n$ vertices and $m$ edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be disconnected.
Let's make a definition.
Let $v_1$ and $v_2$ be two some nonempty subsets of vertices that do not intersect. Let... | import sys
n, m = [int(x) for x in input().split()]
d = {i: [] for i in range(n)}
for _ in range(m):
ai, bi = [int(x) for x in input().split()]
d[ai - 1].append(bi - 1)
d[bi - 1].append(ai - 1)
which_set = [None for _ in range(n)]
SET_B_OR_C = 0
SET_A = 1
SET_B = 2
SET_C = 3
for x in d[0]:
which_set[x]... | IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NO... |
You have a simple undirected graph consisting of $n$ vertices and $m$ edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be disconnected.
Let's make a definition.
Let $v_1$ and $v_2$ be two some nonempty subsets of vertices that do not intersect. Let... | import sys
input = sys.stdin.readline
n, m = map(int, input().split())
E = [set() for i in range(n + 1)]
ECOUNT = [0] * (n + 1)
for i in range(m):
x, y = map(int, input().split())
E[x].add(y)
E[y].add(x)
ECOUNT[x] += 1
ECOUNT[y] += 1
Group = [i for i in range(n + 1)]
def find(x):
while Group[... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR... |
You have a simple undirected graph consisting of $n$ vertices and $m$ edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be disconnected.
Let's make a definition.
Let $v_1$ and $v_2$ be two some nonempty subsets of vertices that do not intersect. Let... | from sys import setcheckinterval, setrecursionlimit, stdin
setcheckinterval(1000)
setrecursionlimit(10**7)
def iin():
return int(stdin.readline())
def lin():
return list(map(int, stdin.readline().split()))
def BFS(s, adj):
parent = {s: None}
color = [-1] * len(adj)
color[s] += 1
u = [s]
... | EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR DICT VAR NONE ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR LIST VAR WHILE VAR ASSIGN VAR ... |
You have a simple undirected graph consisting of $n$ vertices and $m$ edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be disconnected.
Let's make a definition.
Let $v_1$ and $v_2$ be two some nonempty subsets of vertices that do not intersect. Let... | import sys
input = sys.stdin.readline
def r1():
return int(input())
def r2():
return map(int, input().split())
n, m = r2()
d = {}
for i in range(1, n + 1):
d[i] = set()
for i in range(m):
x, y = r2()
d[x].add(y)
d[y].add(x)
bc = d.get(1, [])
if len(bc) == 0:
print(-1)
exit()
ac = ... | IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR V... |
You have a simple undirected graph consisting of $n$ vertices and $m$ edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be disconnected.
Let's make a definition.
Let $v_1$ and $v_2$ be two some nonempty subsets of vertices that do not intersect. Let... | a = list(map(int, input().split()))
n = a[0]
e = a[1]
g = {}
for itr in range(1, n + 1):
g[itr] = []
for i in range(e):
a = list(map(int, input().split()))
g[a[0]].append(a[1])
g[a[1]].append(a[0])
for itr in range(1, n + 1):
g[itr] = frozenset(g[itr])
a = {}
k = 1
res = []
for i in range(1, n + 1):... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER VAR... |
You have a simple undirected graph consisting of $n$ vertices and $m$ edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be disconnected.
Let's make a definition.
Let $v_1$ and $v_2$ be two some nonempty subsets of vertices that do not intersect. Let... | import sys
input = lambda: sys.stdin.readline().rstrip()
N, M = list(map(int, input().split()))
E = [[] for _ in range(N)]
for _ in range(M):
a, b = list(map(int, input().split()))
E[a - 1].append(b - 1)
E[b - 1].append(a - 1)
inf = 1 << 20
A, B, C = [], [], []
X = [0] * N
for a in E[0]:
X[a] = 1
A = [... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VA... |
You have a simple undirected graph consisting of $n$ vertices and $m$ edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be disconnected.
Let's make a definition.
Let $v_1$ and $v_2$ be two some nonempty subsets of vertices that do not intersect. Let... | n, m = map(int, input().split())
d = {}
a = [["0"] for i in range(n + 1)]
for i in range(m):
u, v = map(int, input().split())
a[u].append(str(v) + "*")
a[v].append(str(u) + "*")
count = 1
for i in range(1, n + 1):
if len(a[i]) == 1:
print("-1")
return
a[i].sort()
for i in range(1, n ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR LIST STRING VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR ST... |
You have a simple undirected graph consisting of $n$ vertices and $m$ edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be disconnected.
Let's make a definition.
Let $v_1$ and $v_2$ be two some nonempty subsets of vertices that do not intersect. Let... | import sys
input = sys.stdin.readline
n, m = map(int, input().split())
g = [set() for i in range(n)]
cnt_e = [0] * n
for i in range(m):
u, v = map(int, input().split())
g[u - 1].add(v - 1)
g[v - 1].add(u - 1)
cnt_e[u - 1] += 1
cnt_e[v - 1] += 1
group = [i for i in range(n)]
def find(x):
while... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN... |
You have a simple undirected graph consisting of $n$ vertices and $m$ edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be disconnected.
Let's make a definition.
Let $v_1$ and $v_2$ be two some nonempty subsets of vertices that do not intersect. Let... | import sys
input = sys.stdin.readline
n, m = map(int, input().split())
tree = [set() for i in range(n)]
for i in range(m):
a, b = map(int, input().split())
tree[a - 1].add(b - 1)
tree[b - 1].add(a - 1)
check = [-1] * n
seen = [False] * n
now = 1
for i in range(n):
if not seen[i]:
for j in range... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER A... |
You have a simple undirected graph consisting of $n$ vertices and $m$ edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be disconnected.
Let's make a definition.
Let $v_1$ and $v_2$ be two some nonempty subsets of vertices that do not intersect. Let... | def exitprint():
print(-1)
exit(0)
n, m = list(map(int, input().split()))
al = [list() for _ in range(n)]
for _ in range(m):
u, v = list(map(int, input().split()))
al[u - 1].append(v - 1)
al[v - 1].append(u - 1)
for i in range(n):
al[i] = frozenset(al[i])
a = {}
k = 1
ans = []
for i in range(n... | FUNC_DEF EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP ... |
You have a simple undirected graph consisting of $n$ vertices and $m$ edges. The graph doesn't contain self-loops, there is at most one edge between a pair of vertices. The given graph can be disconnected.
Let's make a definition.
Let $v_1$ and $v_2$ be two some nonempty subsets of vertices that do not intersect. Let... | from sys import stdin
input = stdin.readline
v, e = map(int, input().split())
d = {}
for i in range(1, v + 1):
d[i] = []
for ed in range(e):
a, b = map(int, input().split())
d[a].append(b)
d[b].append(a)
for i in d:
d[i].sort()
sas = {}
for i in d:
sas[tuple(d[i])] = 0
if len(sas) != 3:
pri... | ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR FOR VAR VAR EXPR FUNC_CALL V... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.