description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | def KMPSearch(pat, txt):
M = len(pat)
N = len(txt)
lps = [0] * M
j = 0
computeLPSArray(pat, M, lps)
i = 0
while i < N:
if pat[j] == txt[i]:
i += 1
j += 1
if j == M:
print("Found pattern at index " + str(i - j))
j = lps[j - 1]
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR BIN_OP VA... |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | s = input()
n = len(s)
p = [-1] * n
mark = [False] * n
q = -1
for i in range(1, n):
while q >= 0 and s[i] != s[q + 1]:
q = p[q]
if s[i] == s[q + 1]:
q += 1
p[i] = q
if q >= 0 and i < n - 1:
mark[q] = True
q = p[n - 1]
while q >= 0:
if s[0 : q + 1] == s[n - q - 1 :] and ma... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR WHILE VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR IF VAR NUMBER VAR ... |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | def z_func(s):
n = len(s)
z = [0] * n
l, r = 0, 0
for i in range(1, n):
if i <= r:
z[i] = min(r - i + 1, z[i - l])
while i + z[i] < n and s[z[i]] == s[i + z[i]]:
z[i] += 1
if i + z[i] - 1 > r:
l = i
r = i + z[i] - 1
return z
d... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR ASSIGN VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR WHILE BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR NUMBER IF BIN_OP BIN_OP VA... |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | a = input()
n = len(a)
z = [0] * n
l = 0
r = 0
for i in range(1, n):
if i <= r:
z[i] = min(r - i, z[i - l])
while i + z[i] < n and a[z[i]] == a[i + z[i]]:
z[i] += 1
if i + z[i] - 1 >= r:
r = i + z[i] - 1
l = i
mx = 0
ans = 0
for i in range(n):
if z[i] == n - i and mx >= z... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR WHILE BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR NUMBER IF BIN_OP ... |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | s = input()
n = len(s)
p = [0] * (n + 1)
i = 0
j = 1
while j < n:
if s[j] == s[i]:
j += 1
i += 1
p[j] = i
elif i:
i = p[i]
else:
j += 1
a = p.pop()
b = p[a]
if a and a in p:
print(s[:a])
elif b:
print(s[:b])
else:
print("Just a legend") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR IF VAR ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR IF VAR VAR VAR EXPR FUNC_CA... |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | from sys import stdin
def Zarr(pat, text):
s = pat + "/" + text
z = [(0) for i in range(len(s))]
L = 0
R = 0
n = len(s)
for i in range(1, len(s)):
if i > R:
L = R = i
while R < n and s[R - L] == s[R]:
R += 1
z[i] = R - L
R... | FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR STRING VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR VAR WHILE VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR BIN_OP V... |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | s = input()
i, n = 0, len(s)
p = [-1] + [0] * n
for j in range(1, n):
while i + 1 and s[i] != s[j]:
i = p[i]
i += 1
p[j + 1] = i
k = p.pop()
print(s[:k] if k and k in p else s[: p[k]] if p[k] > 0 else "Just a legend") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR WHILE BIN_OP VAR NUMBER VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR VAR VA... |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | def KMP(st):
i = 0
j = 1
arr = [(0) for i in range(len(st))]
while j < len(st):
if s[j] == s[i]:
arr[j] = i + 1
i += 1
else:
while i > 0:
i = arr[i - 1]
if s[i] == s[j]:
arr[j] = i + 1
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR WHILE VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER VAR NUMBER WHILE VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER RETURN... |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | P = input()
m = len(P)
f = [0] * m
j = 1
k = 0
while j < m:
if P[j] == P[k]:
f[j] = k + 1
j += 1
k += 1
elif k > 0:
k = f[k - 1]
else:
j += 1
l = f.pop()
if l:
if l in f:
print(P[:l])
elif f[l - 1]:
print(P[: f[l - 1]])
else:
print(... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR IF VAR IF VAR VAR EXPR FU... |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | def kmp_preprocess(s, kmp):
kmp[0] = 0
i = 1
j = 0
while i < len(s):
if s[i] == s[j]:
j += 1
kmp[i] = j
i += 1
elif j != 0:
j = kmp[j - 1]
else:
kmp[i] = 0
i += 1
s = input()
kmp = [None] * len(s)
kmp_prepr... | FUNC_DEF ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NONE FUNC_CALL VAR VAR EXPR FUNC_C... |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | import sys
I = lambda: int(input())
readline = lambda: sys.stdin.readline().strip()
RM = readlist = lambda x=int: map(x, readline().split())
def prefix_function(s):
n = len(s)
pi = [0] * n
for i in range(1, n):
j = pi[i - 1]
while j > 0 and s[i] != s[j]:
j = pi[j - 1]
... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR VAR VAR VAR ASSIGN ... |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | import sys
Ri = lambda: [int(x) for x in sys.stdin.readline().split()]
ri = lambda: sys.stdin.readline().strip()
def input():
return sys.stdin.readline().strip()
def list2d(a, b, c):
return [([c] * b) for i in range(a)]
def list3d(a, b, c, d):
return [[([d] * c) for j in range(b)] for i in range(a)]
... | IMPORT ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUN... |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | from sys import stdin
def prefix_calculator(string):
p = [0] * len(string)
j = 0
for i in range(1, len(string)):
while j > 0 and string[i] != string[j]:
j = p[j - 1]
if string[i] == string[j]:
j += 1
p[i] = j
return p
string = stdin.readline().strip()
... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR WHILE VAR NUMBER VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC... |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | def prefix(lsa, n):
index = 0
i = 1
while i < n:
if s[i] == s[index]:
lsa[i] = index + 1
i += 1
index += 1
elif index == 0:
lsa[i] = 0
i += 1
else:
index = lsa[index - 1]
s = input()
n = len(s)
lsa = [0] * n
pr... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR EXPR FUNC_CALL VAR ... |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | def kmpTable(s, n):
res = [0] * n
check_idx = 0
for i in range(1, n):
while check_idx > 0 and s[check_idx] != s[i]:
check_idx = res[check_idx - 1]
if s[check_idx] == s[i]:
check_idx += 1
res[i] = check_idx
return res
s = input()
n = len(s)
kmp_table = km... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR WHILE VAR NUMBER VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VA... |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | def password(str):
lst = [0] * len(str)
n = 0
for i in range(1, len(str)):
while n > 0 and str[n] != str[i]:
n = lst[n - 1]
if str[n] == str[i]:
n += 1
lst[i] = n
else:
lst[i] = n
return lst
x = None
in_c = input()
lst = password(... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR WHILE VAR NUMBER VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR RETURN VAR ASSIGN VAR NONE ASSIGN VAR FUNC_CALL VAR ASSIGN VAR F... |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | s = input()
count = -1
arr = [-1]
for x in s:
while count != -1 and s[count] != x:
count = arr[count]
count = count + 1
arr.append(count)
le = arr[-1]
if arr.count(le) < 2:
le = arr[le]
if le > 0:
print(s[:le])
else:
print("Just a legend") | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER FOR VAR VAR WHILE VAR NUMBER VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | s = input()
n = len(s)
lps = [0] * n
i = 1
length = 0
while i < n:
if s[i] == s[length]:
length += 1
lps[i] = length
i += 1
elif length == 0:
i += 1
else:
length = lps[length - 1]
x = lps[-1]
flag = 1
while x:
for i in range(1, n - 1):
if lps[i] == x:
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FOR VAR FUNC_C... |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | from sys import stderr, stdin, stdout
def lcp(string):
l = len(string)
lis = [0] * l
j = 1
k = 0
while j < l:
if string[j] == string[k]:
lis[j] = k + 1
j += 1
k += 1
elif k > 0:
k = lis[k - 1]
else:
j += 1
retu... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR I... |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | from sys import stdin, stdout
s = stdin.readline().rstrip()
n = len(s)
def compute_lps(s):
lps = [(0) for i in range(n)]
Len = 0
lps[0] = 0
i = 1
while i < n:
if s[i] == s[Len]:
Len += 1
lps[i] = Len
i += 1
elif Len != 0:
Len = lps[L... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER VAR... |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | def lcp(text):
length = len(text)
lis = [0] * length
j = 1
k = 0
while j < length:
if text[j] == text[k]:
lis[j] = k + 1
j += 1
k += 1
elif k > 0:
k = lis[k - 1]
else:
j += 1
return lis
text = input()
length = ... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR A... |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | from sys import stdin, stdout
def z_function(s):
z = [0] * len(s)
l, r = 0, 0
for i in range(1, len(s)):
z[i] = max(0, min(z[i - l], r - i))
while z[i] + i < len(s) and s[z[i]] == s[z[i] + i]:
z[i] += 1
if i + z[i] - 1 > r:
l, r = i, i + z[i]
return z
... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR WHILE BIN_OP VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR NUMBER IF BIN_OP ... |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | import sys
input = sys.stdin.readline
def swaparr(arr, a, b):
temp = arr[a]
arr[a] = arr[b]
arr[b] = temp
def gcd(a, b):
if a == 0:
return b
return gcd(b % a, a)
def nCr(n, k):
if k > n - k:
k = n - k
res = 1
for i in range(k):
res = res * (n - i)
r... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR FUNC_DEF IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR BIN_OP VAR VAR VAR FUNC_DEF IF VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR BIN_O... |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | s = input()
longest_matching = [-1]
for c in s[1:]:
last_matching = longest_matching[-1]
no_match = False
while s[last_matching + 1] != c:
if last_matching != -1:
last_matching = longest_matching[last_matching]
else:
last_matching = last_matching - 1
break... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER VAR IF VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN ... |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | def prefix_function(s):
pi = [0] * len(s)
for i in range(1, len(s)):
j = pi[i - 1]
while j > 0 and s[i] != s[j]:
j = pi[j - 1]
if s[i] == s[j]:
j += 1
pi[i] = j
return pi
s = input()
pi = prefix_function(s)
n = len(s)
ok = True
if pi[n - 1] != 0 and ... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASS... |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | def z_func(s):
l = 0
r = 0
n = len(s)
z = [0] * n
z[0] = n
for i in range(1, n):
if i <= r:
z[i] = min(r - i + 1, z[i - l])
while i + z[i] < n and s[z[i]] == s[i + z[i]]:
z[i] += 1
if i + z[i] - 1 > r:
l = i
r = i + z[i] - 1... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR ASSIGN VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR WHILE BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR V... |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | s = input()
def count_unique_substring(s):
n = len(s)
p = 31
m = 10**9 + 9
p_pow = [1]
for i in range(1, n):
p_pow.append(p_pow[i - 1] * p % m)
hash = [0]
count = 0
flag = 0
for i in range(n):
hash.append((hash[i] + (ord(s[i]) - ord("a") + 1) * p_pow[i]) % m)
fo... | ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CA... |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | def main():
t = 1
for z in range(t):
s = input()
s = s
n = len(s)
z = [0] * n
l = 0
r = 0
for i in range(1, n):
if r >= i:
z[i] = min(z[i - l], r - i + 1)
while z[i] + i < n and s[z[i]] == s[z[i] + i]:
... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER WHILE B... |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | def buildZ(S):
L, R = 0, 0
n = len(S)
Z = [0] * n
for i in range(1, n):
if i > R:
L = R = i
while R < n and S[R - L] == S[R]:
R += 1
Z[i] = R - L
R -= 1
else:
k = i - L
if Z[k] < R - i + 1:
... | FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR ASSIGN VAR VAR VAR WHILE VAR VAR VAR BIN_OP VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR BIN_OP BIN_OP VAR VAR NUMB... |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | n = input()
hm = [0] * (len(n) + 1)
p = 31
m = len(n)
mod = 10**9 + 9
pow = [0] * (m + 1)
pow[0] = 1
for i in range(1, m):
pow[i] = pow[i - 1] * p % mod
hm[0] = 1 * (ord(n[0]) - ord("a") + 1)
m = len(n)
s = 0
e = 0
ans = []
a = 0
for i in range(1, m):
x = ord(n[i]) - ord("a") + 1
hm[i] = (hm[i - 1] % mod + ... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR B... |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | def KMPS(pat, txt, lps):
M = len(pat)
N = len(txt)
j = 0
i = 0
while i < N:
if pat[j] == txt[i]:
i += 1
j += 1
if j == M:
return 1
j = lps[j - 1]
elif i < N and pat[j] != txt[i]:
if j != 0:
j = lps[j ... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR RETURN NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR VAR VAR IF VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER VAR NUMBER RETURN NUMBER ASSIG... |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | from sys import stdin
def findpass(s):
arr = suff_array(s)
n = len(s)
maxidx = arr[n - 1]
valid = False
for i in range(n - 1):
if arr[i] == maxidx:
valid = True
break
if not valid:
maxidx = arr[maxidx - 1]
if maxidx == 0:
return "Just a legen... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR ASSIGN VAR NUMBER IF VAR ASSIGN VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER RETURN STRING RETURN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN V... |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | def longestPrefixSuffix(s):
global d
n = len(s)
lps = [0] * n
l = 0
m = 0
i = 1
while i < n:
if s[i] == s[l]:
l = l + 1
lps[i] = l
i = i + 1
elif l != 0:
l = lps[l - 1]
else:
lps[i] = 0
i = i + 1
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_... |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | s = input()
n = len(s)
p = [0] * n
for i in range(1, n):
cur = p[i - 1]
while s[i] != s[cur] and cur > 0:
cur = p[cur - 1]
if s[i] == s[cur]:
p[i] = cur + 1
if p[-1] == 0:
print("Just a legend")
else:
sa = p[:-1]
if p[-1] not in sa:
if p[p[-1] - 1] == 0:
print... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR NUMBER WHILE VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING A... |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | pat = input()
m = len(pat)
lps = [(0) for i in range(m)]
j, i = 0, 1
while i < m:
if pat[i] == pat[j]:
j += 1
lps[i] = j
i += 1
elif j == 0:
lps[i] = 0
i += 1
else:
j = lps[j - 1]
req = lps[-1]
if lps[-1] != 0 and lps.count(req) > 1:
print(pat[:req])
elif ... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER WHILE VAR VAR IF VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR NUMBER NUMBER ... |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | def knuthMorrisonPreprocess(pattern, m):
fail = [0] * m
i = 0
j = 1
fail[0] = 0
while j < m:
if pattern[i] == pattern[j]:
fail[j] = i + 1
i += 1
j += 1
elif i > 0:
i = fail[i - 1]
else:
j += 1
return fail
strin... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER NUMBER WHILE VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIG... |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | s, k, l = input(), -1, [-1]
for c in s:
while k != -1 and s[k] != c:
k = l[k]
k += 1
l += [k]
q = l[-1]
if l.count(q) < 2:
q = l[q]
if q > 0:
print(s[:q])
else:
print("Just a legend") | ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER LIST NUMBER FOR VAR VAR WHILE VAR NUMBER VAR VAR VAR ASSIGN VAR VAR VAR VAR NUMBER VAR LIST VAR ASSIGN VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | def prefix(s):
p = [0]
for i in s[1:]:
j = p[-1]
while j > 0 and s[j] != i:
j = p[j - 1]
p.append(j + (s[j] == i))
return p
def kmp(s, p):
s = p + "$" + s
pre = prefix(s)
o = []
for i in range(len(p), len(pre)):
if pre[i] == len(p):
o... | FUNC_DEF ASSIGN VAR LIST NUMBER FOR VAR VAR NUMBER ASSIGN VAR VAR NUMBER WHILE VAR NUMBER VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR STRING VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VA... |
Asterix, Obelix and their temporary buddies Suffix and Prefix has finally found the Harmony temple. However, its doors were firmly locked and even Obelix had no luck opening them.
A little later they found a string s, carved on a rock below the temple's gates. Asterix supposed that that's the password that opens the t... | s = input()
t = [0]
i, length = 1, 0
while i < len(s):
if s[i] == s[length]:
length += 1
t.append(length)
i += 1
elif length == 0:
t.append(length)
i += 1
else:
length = t[length - 1]
if t[-1] != 0:
if len([a for a in t if a == t[-1]]) >= 2:
print(... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR VAR NUMBER NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER NUMBER IF FUNC_CALL VAR VAR VAR VAR VAR VAR NUMBER NUMBE... |
You are given a rooted tree of $2^n - 1$ vertices. Every vertex of this tree has either $0$ children, or $2$ children. All leaves of this tree have the same distance from the root, and for every non-leaf vertex, one of its children is the left one, and the other child is the right one. Formally, you are given a perfect... | import sys
N = int(sys.stdin.readline().strip())
s = sys.stdin.readline().strip()
m = 1 << N
mod = 998244353
def dfs(i):
if i >= m:
return 1, ""
ln, ls = dfs(i * 2)
rn, rs = dfs(i * 2 + 1)
if ls < rs:
return ln * rn * 2 % mod, ls + s[i - 1] + rs
elif ls > rs:
return ln * r... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER FUNC_DEF IF VAR VAR RETURN NUMBER STRING ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR VAR RETURN BIN_OP BIN_OP B... |
You are given a rooted tree of $2^n - 1$ vertices. Every vertex of this tree has either $0$ children, or $2$ children. All leaves of this tree have the same distance from the root, and for every non-leaf vertex, one of its children is the left one, and the other child is the right one. Formally, you are given a perfect... | N = int(input())
N = 2**N
S = input()
U = [0] * N
cnt = 0
for i in range(N - 2, -1, -1):
a = 2 * i + 1
b = 2 * i + 2
if b >= N:
U[i] = ord(S[i])
continue
if U[a] != U[b]:
cnt += 1
U[i] = (
ord(S[i])
+ 331 * min(U[a], U[b])
+ 3331 * max(U[a], U[b])
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR VAR FUNC_CALL... |
You are given a rooted tree of $2^n - 1$ vertices. Every vertex of this tree has either $0$ children, or $2$ children. All leaves of this tree have the same distance from the root, and for every non-leaf vertex, one of its children is the left one, and the other child is the right one. Formally, you are given a perfect... | from sys import setrecursionlimit, stdin
input = stdin.readline
setrecursionlimit(10**6)
inp = lambda: list(map(int, input().split()))
mod = 998244353
def add(a, b):
return (a % mod + b % mod) % mod
def mul(a, b):
return a % mod * (b % mod) % mod
def solve(i):
if i >= (1 << n) - 1:
return [""... | ASSIGN VAR VAR EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR 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 IF VAR BIN_OP BIN_OP NUMBER VAR NUMBER RETU... |
You are given a rooted tree of $2^n - 1$ vertices. Every vertex of this tree has either $0$ children, or $2$ children. All leaves of this tree have the same distance from the root, and for every non-leaf vertex, one of its children is the left one, and the other child is the right one. Formally, you are given a perfect... | MOD = 998244353
n, s = int(input()), input()
def calc(u: int) -> tuple:
if u >= 1 << n:
return 0, 0
t1, t2 = calc(u * 2), calc(u * 2 + 1)
return t1[0] + t2[0] + (t1[1] != t2[1]), hash(
(min(t1[1], t2[1]), max(t1[1], t2[1]), s[u - 1])
)
print(pow(2, calc(1)[0], MOD)) | ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF VAR IF VAR BIN_OP NUMBER VAR RETURN NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER RETURN BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR ... |
You are given a rooted tree of $2^n - 1$ vertices. Every vertex of this tree has either $0$ children, or $2$ children. All leaves of this tree have the same distance from the root, and for every non-leaf vertex, one of its children is the left one, and the other child is the right one. Formally, you are given a perfect... | class Node:
def __init__(self, v, left, right):
self.v = v
self.left = left
self.right = right
def f(self):
if self.left is None:
return 1, self.v
lc, lp = self.left.f()
rc, rp = self.right.f()
return (1 + int(lp != rp)) * lc * rc % 998244353... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF IF VAR NONE RETURN NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR RETURN BIN_OP BIN_OP BIN_OP BIN_OP NUMBER FUNC_CALL VAR VAR VAR VAR VAR NUMBER BIN_OP VAR FUNC_CALL STRING FUNC_CALL VAR LIST VAR VAR FUNC_DEF IF VAR FUNC_CALL... |
You are given a rooted tree of $2^n - 1$ vertices. Every vertex of this tree has either $0$ children, or $2$ children. All leaves of this tree have the same distance from the root, and for every non-leaf vertex, one of its children is the left one, and the other child is the right one. Formally, you are given a perfect... | import sys
MOD = 998244353
n = int(next(sys.stdin))
s = next(sys.stdin)
m = len(s) - 1
h = [(0) for i in range(m)]
f = [[0, 0] for i in range(m)]
for i in range(m - 1, -1, -1):
l = (i + 1) * 2 - 1
r = (i + 1) * 2
c = int(s[i] == "B")
if l < m:
h[i] = h[l] * 2 + 1
p1 = min(f[l][0], f[r][... | IMPORT ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VA... |
You are given a rooted tree of $2^n - 1$ vertices. Every vertex of this tree has either $0$ children, or $2$ children. All leaves of this tree have the same distance from the root, and for every non-leaf vertex, one of its children is the left one, and the other child is the right one. Formally, you are given a perfect... | if True:
def compute_hashes(v):
if v < nodes_count:
l, r = sorted([compute_hashes(2 * v), compute_hashes(2 * v + 1)])
b[v] = l + b[v] + r
return b[v]
return b[v]
n = int(input())
nodes_count = 2 ** (n - 1)
s = input()
b = ["dum"]
for c in s:
... | IF NUMBER FUNC_DEF IF VAR VAR ASSIGN VAR VAR FUNC_CALL VAR LIST FUNC_CALL VAR BIN_OP NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR RETURN VAR VAR RETURN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL ... |
You are given a rooted tree of $2^n - 1$ vertices. Every vertex of this tree has either $0$ children, or $2$ children. All leaves of this tree have the same distance from the root, and for every non-leaf vertex, one of its children is the left one, and the other child is the right one. Formally, you are given a perfect... | n = int(input())
s = input()
a = [-1]
for i in range(0, 2**n - 1):
if s[i] == "A":
a.append("A")
else:
a.append("B")
res = 1
for i in range(2 ** (n - 1) - 1, 0, -1):
if a[2 * i] == a[2 * i + 1]:
a[i] = a[i] + a[2 * i] + a[2 * i + 1]
elif a[2 * i] < a[2 * i + 1]:
res = res... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER IF VAR VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER NUMBER NUMBER IF... |
Polycarp found on the street an array $a$ of $n$ elements.
Polycarp invented his criterion for the beauty of an array. He calls an array $a$ beautiful if at least one of the following conditions must be met for each different pair of indices $i \ne j$:
$a_i$ is divisible by $a_j$;
or $a_j$ is divisible by $a_i$.
Fo... | for _ in range(int(input())):
length = int(input())
array = list(map(int, input().split()))
array.sort()
cnt = [0] * (max(array) + 1)
dp = [0] * (max(array) + 1)
for x in array:
cnt[x] += 1
for i in range(1, len(dp)):
dp[i] += cnt[i]
for j in range(i, len(dp), i):
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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 ASSIGN VAR BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR VAR VAR VAR N... |
Polycarp found on the street an array $a$ of $n$ elements.
Polycarp invented his criterion for the beauty of an array. He calls an array $a$ beautiful if at least one of the following conditions must be met for each different pair of indices $i \ne j$:
$a_i$ is divisible by $a_j$;
or $a_j$ is divisible by $a_i$.
Fo... | from sys import stdin
input = stdin.buffer.readline
t = int(input())
for i in range(t):
n = int(input())
arr = [int(x) for x in input().split()]
d = {}
for i in arr:
if i in d:
d[i] = d[i] + 1
else:
d[i] = 1
l = list(d.keys())
l.sort()
m = max(l)
... | ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR IF VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FU... |
Polycarp found on the street an array $a$ of $n$ elements.
Polycarp invented his criterion for the beauty of an array. He calls an array $a$ beautiful if at least one of the following conditions must be met for each different pair of indices $i \ne j$:
$a_i$ is divisible by $a_j$;
or $a_j$ is divisible by $a_i$.
Fo... | import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")
inp = lambda: list(map(int, sys.stdin.readline().rstrip("\r\n").split()))
mod = 10**9 + 7
Mod = 998244353
INF = float("inf")
tc = 1
M = 2 * 10**5 + 1
cnt = [0] * (M + 1)
dp = [0] * (M + 1)
(tc,) = inp()
for _ in range(tc):
(n,) = inp()
a = sorted(i... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BI... |
Polycarp found on the street an array $a$ of $n$ elements.
Polycarp invented his criterion for the beauty of an array. He calls an array $a$ beautiful if at least one of the following conditions must be met for each different pair of indices $i \ne j$:
$a_i$ is divisible by $a_j$;
or $a_j$ is divisible by $a_i$.
Fo... | for _ in range(int(input())):
n = int(input())
arr = list(map(int, input().split()))
count = [0] * 200001
for v in arr:
count[v] += 1
dp = [0] * 200001
for i in range(1, 200001):
if count[i]:
dp[i] += count[i]
for j in range(2 * i, 200001, i):
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR VAR VAR VAR VAR ... |
Polycarp found on the street an array $a$ of $n$ elements.
Polycarp invented his criterion for the beauty of an array. He calls an array $a$ beautiful if at least one of the following conditions must be met for each different pair of indices $i \ne j$:
$a_i$ is divisible by $a_j$;
or $a_j$ is divisible by $a_i$.
Fo... | def solve():
for _ in range(int(input())):
n = int(input())
cnt = [0] * 200001
dp = [0] * 200001
best = 0
for a in map(int, input().split()):
cnt[a] += 1
for a, c in enumerate(cnt):
if c:
c += dp[a]
if best < c:
... | FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR IF VAR VAR ASSIG... |
Polycarp found on the street an array $a$ of $n$ elements.
Polycarp invented his criterion for the beauty of an array. He calls an array $a$ beautiful if at least one of the following conditions must be met for each different pair of indices $i \ne j$:
$a_i$ is divisible by $a_j$;
or $a_j$ is divisible by $a_i$.
Fo... | import sys
def solve():
input = sys.stdin.readline
MAXN = int(200000.0) + 1
for t in range(int(input())):
dp = [0] * MAXN
n = int(input())
a = list(map(int, input().split()))
a.sort()
ans = 0
i = 0
while i < n:
v = a[i]
ii = i... | IMPORT FUNC_DEF ASSIGN VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBE... |
Polycarp found on the street an array $a$ of $n$ elements.
Polycarp invented his criterion for the beauty of an array. He calls an array $a$ beautiful if at least one of the following conditions must be met for each different pair of indices $i \ne j$:
$a_i$ is divisible by $a_j$;
or $a_j$ is divisible by $a_i$.
Fo... | import sys
t = int(input())
for i in range(t):
n = int(input())
arr = list(map(int, input().split()))
m = max(arr) + 1
dp = [0] * m
cnt = [0] * m
for i in range(len(arr)):
cnt[arr[i]] += 1
for i in range(1, m):
dp[i] += cnt[i]
for j in range(2 * i, m, i):
... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR 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 BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR FUNC_CALL... |
Polycarp found on the street an array $a$ of $n$ elements.
Polycarp invented his criterion for the beauty of an array. He calls an array $a$ beautiful if at least one of the following conditions must be met for each different pair of indices $i \ne j$:
$a_i$ is divisible by $a_j$;
or $a_j$ is divisible by $a_i$.
Fo... | import sys
factorsMemo = [(-1) for _ in range(200001)]
def getAllFactors(x):
if factorsMemo[x] == -1:
factors = []
for i in range(1, int(x**0.5) + 1):
if x % i == 0:
factors.append(i)
if x // i != i:
factors.append(x // i)
fa... | IMPORT ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FUNC_DEF IF VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR RETURN VAR VAR FUNC_DEF ASSIG... |
Polycarp found on the street an array $a$ of $n$ elements.
Polycarp invented his criterion for the beauty of an array. He calls an array $a$ beautiful if at least one of the following conditions must be met for each different pair of indices $i \ne j$:
$a_i$ is divisible by $a_j$;
or $a_j$ is divisible by $a_i$.
Fo... | import sys
input = sys.stdin.readline
for _ in range(int(input())):
N = int(input())
a = list(map(int, input().split()))
mx = max(a)
table = [0] * (mx + 1)
for x in a:
table[x] += 1
dp = [0] * (mx + 1)
for x in range(mx, 0, -1):
if table[x] == 0:
continue
... | IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL 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 FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP V... |
Polycarp found on the street an array $a$ of $n$ elements.
Polycarp invented his criterion for the beauty of an array. He calls an array $a$ beautiful if at least one of the following conditions must be met for each different pair of indices $i \ne j$:
$a_i$ is divisible by $a_j$;
or $a_j$ is divisible by $a_i$.
Fo... | for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
mx = max(a)
b, c = [0] * (mx + 1), [0] * (mx + 1)
for i in a:
b[i] += 1
for k in range(1, mx + 1):
c[k] += b[k]
for j in range(2 * k, mx + 1, k):
c[j] = max(c[j], c[k])
prin... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL 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 FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL V... |
Polycarp found on the street an array $a$ of $n$ elements.
Polycarp invented his criterion for the beauty of an array. He calls an array $a$ beautiful if at least one of the following conditions must be met for each different pair of indices $i \ne j$:
$a_i$ is divisible by $a_j$;
or $a_j$ is divisible by $a_i$.
Fo... | from sys import stdin, stdout
def strange_beauty(n, a_a):
mx = max(a_a)
dp = [0] * (mx + 1)
cnt = [0] * (mx + 1)
r = 0
for a in a_a:
cnt[a] += 1
for i in range(1, mx + 1):
if cnt[i] == 0:
continue
dp[i] += cnt[i]
j = i * 2
while j <= mx:
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR NUMBER VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR FU... |
Polycarp found on the street an array $a$ of $n$ elements.
Polycarp invented his criterion for the beauty of an array. He calls an array $a$ beautiful if at least one of the following conditions must be met for each different pair of indices $i \ne j$:
$a_i$ is divisible by $a_j$;
or $a_j$ is divisible by $a_i$.
Fo... | T = int(input())
for _ in range(T):
n = int(input())
A = list(map(int, input().split()))
mv = max(A)
DP = [(0) for i in range(mv + 1)]
G = {}
for i in A:
try:
G[i] = G[i] + 1
except:
G[i] = 1
for i in range(mv, 0, -1):
if i in G:
j ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR 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 FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR NUMBER A... |
This is the hard version of the problem. The difference between versions is the constraints on $n$ and $a_i$. You can make hacks only if all versions of the problem are solved.
First, Aoi came up with the following idea for the competitive programming problem:
Yuzu is a girl who collecting candies. Originally, she ha... | import sys
input = sys.stdin.readline
n, p = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
mn = 0
mx = 2000000000000000
for i in range(n):
d = a[i] - i
mn = max(d, mn)
if i >= p - 1:
d2 = a[i] - i + p - 1
mx = min(mx, d2)
print(max(mx - mn, 0))
for i in range(mn, mx... | 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 EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR BIN_OP VAR NUMBER ASSIG... |
This is the hard version of the problem. The difference between versions is the constraints on $n$ and $a_i$. You can make hacks only if all versions of the problem are solved.
First, Aoi came up with the following idea for the competitive programming problem:
Yuzu is a girl who collecting candies. Originally, she ha... | n, p = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
m = max(a[i] - i for i in range(n))
M = a[p - 1] - 1
ban = [(0) for i in range(p)]
ans = []
query = [(a[i] - 1 - i, 1, -100) for i in range(n)]
for x in range(m, M + 1):
query.append((x, 0, -100))
for i in range(n):
query.append... | 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 EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR... |
This is the hard version of the problem. The difference between versions is the constraints on $n$ and $a_i$. You can make hacks only if all versions of the problem are solved.
First, Aoi came up with the following idea for the competitive programming problem:
Yuzu is a girl who collecting candies. Originally, she ha... | n, p = map(int, input().split())
arr = list(map(int, input().split()))
l, r = 0, float("inf")
arr.sort()
for i in range(len(arr)):
l = max(l, arr[i] - i)
if i + 1 >= p:
r = min(r, arr[i] - i + p - 1)
print(max(0, r - l))
res = []
for i in range(l, r):
res.append(i)
print(*res) | 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 VAR NUMBER FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR IF BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL ... |
While Farmer John rebuilds his farm in an unfamiliar portion of Bovinia, Bessie is out trying some alternative jobs. In her new gig as a reporter, Bessie needs to know about programming competition results as quickly as possible. When she covers the 2016 Robot Rap Battle Tournament, she notices that all of the robots o... | n, m = [int(i) for i in input().split()]
n += 1
A = [[int(i) for i in input().split()] for j in range(m)]
m += 1
def check(upper):
p = [[] for i in range(n)]
d = [0] * n
for u, v in A[:upper]:
p[u].append(v)
d[v] += 1
if d.count(0) > 2:
return False
x = d.index(0, 1)
wh... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR NUMBER FUNC_DEF ASSIGN VAR LIST VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR NUMBER IF FUNC_CALL VA... |
While Farmer John rebuilds his farm in an unfamiliar portion of Bovinia, Bessie is out trying some alternative jobs. In her new gig as a reporter, Bessie needs to know about programming competition results as quickly as possible. When she covers the 2016 Robot Rap Battle Tournament, she notices that all of the robots o... | from sys import stdin
def main():
def f(k):
g, cnt = [[] for _ in range(n)], [0] * n
for u, v in data[:k]:
g[u].append(v)
cnt[v] += 1
if cnt.count(0) > 1:
return False
w, u = cnt.index(0), -1
while u != w:
u = w
f... | FUNC_DEF FUNC_DEF ASSIGN VAR VAR LIST VAR FUNC_CALL VAR VAR BIN_OP LIST NUMBER VAR FOR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR NUMBER IF FUNC_CALL VAR NUMBER NUMBER RETURN NUMBER ASSIGN VAR VAR FUNC_CALL VAR NUMBER NUMBER WHILE VAR VAR ASSIGN VAR VAR FOR VAR VAR VAR VAR VAR NUMBER IF VAR VAR IF VAR VAR RETUR... |
At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$
We can see that if we choose some value $v$ and will apply function $f$ to it, then apply $f$ to $f(v)$, an... | def ans(m, n):
q1, q2, k = m, 2, 0
while q1 <= n:
q1 *= 2
k += q2
q2 *= 2
q2 //= 2
q1 //= 2
if n - q1 < q2:
return k + n - q1 - q2 + 1
return k
n, k = list(map(int, input().split()))
if k == n:
print(1)
elif k == 1:
print(n)
else:
l, r = 1, n // 2 + ... | FUNC_DEF ASSIGN VAR VAR VAR VAR NUMBER NUMBER WHILE VAR VAR VAR NUMBER VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR VAR RETURN BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR NU... |
At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$
We can see that if we choose some value $v$ and will apply function $f$ to it, then apply $f$ to $f(v)$, an... | import sys
def minp():
return sys.stdin.readline().strip()
def mint():
return int(minp())
def mints():
return list(map(int, minp().split()))
def full(x, n):
if n + 1 & n != 0:
raise Exception("qwe")
r = 1
while True:
if r >= x:
return n
if n == 1:
... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL 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 IF BIN_OP BIN_OP VAR NUMBER VAR NUMBER FUNC_CALL VAR STRING ASSIGN VAR NUMBER WHILE NUMBER IF VAR VAR RETURN VAR IF VAR NUMBER RETURN NONE VAR NUMBE... |
At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$
We can see that if we choose some value $v$ and will apply function $f$ to it, then apply $f$ to $f(v)$, an... | N, K = [int(x) for x in input().split(" ")]
def f(x):
ret, i = 0, 0
while x << i <= N:
ret += min(N, (x << i) + (1 << i) - 1) - (x << i) + 1
i += 1
return ret
lo, hi = 1, N // 2
while lo < hi:
mi = (lo + hi + 1) // 2
if f(2 * mi) + f(2 * mi + 1) >= K:
lo = mi
else:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER WHILE BIN_OP VAR VAR VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP NUMBER VAR NUMBER BIN_OP VAR VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER WHILE VAR VAR A... |
At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$
We can see that if we choose some value $v$ and will apply function $f$ to it, then apply $f$ to $f(v)$, an... | def paths(x):
c = 1 if x % 2 else 2
a = 0
m = 1
while m * x + c * m - 1 <= n:
a += c * m
m *= 2
a += max(-1, n - m * x) + 1
return a
def search_odd(k, i, j):
if i == j:
return 2 * i + 1
if i + 1 == j:
return 2 * j + 1 if paths(2 * j + 1) >= k else 2 * i ... | FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR NUMBER VAR VAR BIN_OP VAR VAR VAR NUMBER VAR BIN_OP FUNC_CALL VAR NUMBER BIN_OP VAR BIN_OP VAR VAR NUMBER RETURN VAR FUNC_DEF IF VAR VAR RETURN BIN_OP BIN_OP NUMBER VAR NUMBER IF BIN... |
At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$
We can see that if we choose some value $v$ and will apply function $f$ to it, then apply $f$ to $f(v)$, an... | n, k = [int(x) for x in input().split()]
def chg(n):
lis = []
for i in range(100):
if 2**i > n:
break
lis.append((n & 2**i) >> i)
return lis
def calc(x):
cnt = 0
k = 1
if x % 2 == 0:
x = x // 2
cnt = -1
while k * x <= n:
cnt += min(k * ... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN V... |
At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$
We can see that if we choose some value $v$ and will apply function $f$ to it, then apply $f$ to $f(v)$, an... | def gg(n, lol):
ans = 0
cur = 1
lol2 = lol
while 2 * lol + 1 <= n:
cur *= 2
ans += cur
lol = 2 * lol + 1
lol2 *= 2
if lol2 * 2 <= n:
ans += n - lol2 * 2 + 1
return ans
n, k = map(int, input().split())
low = 1
high = n // 2
res = 1
while low <= high:
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE BIN_OP BIN_OP NUMBER VAR NUMBER VAR VAR NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIG... |
At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$
We can see that if we choose some value $v$ and will apply function $f$ to it, then apply $f$ to $f(v)$, an... | import sys
input = sys.stdin.readline
n, k = [int(item) for item in input().split()]
possible = set()
t = n
while t > 1:
possible.add(t)
possible.add(t - 1)
possible.add(t - 2)
possible.add(t - 3)
t //= 2
if 0 in possible:
possible.remove(0)
possible.add(1)
possible = sorted(list(possible), rev... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR WHILE VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF NUMBER VAR EXPR FUNC_CALL VAR NU... |
At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$
We can see that if we choose some value $v$ and will apply function $f$ to it, then apply $f$ to $f(v)$, an... | n, k = map(int, input().split())
left = 0
right = 10**18 + 2
p = [(2**i) for i in range(61)]
while right - left > 2:
mid = (right + left) // 2
mid -= mid % 2
l = 0
r = 60
if mid > n:
right = mid
continue
while r - l > 1:
m = (r + l) // 2
if mid * p[m] <= n:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR ASSIGN V... |
At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$
We can see that if we choose some value $v$ and will apply function $f$ to it, then apply $f$ to $f(v)$, an... | import sys
def cnt(x):
c = 0
for i in range(65):
if int(x) << i > n:
break
if x & 1:
c += min(int(1) << i, n - (x << i) + 1)
else:
c += min(int(1) << i + 1, n - (x << i) + 1)
return c
n, k = [int(x) for x in input().split()]
if k == 1:
prin... | IMPORT FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR VAR VAR IF BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR NUMBER VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER BIN_OP BIN_OP VAR BIN_OP VAR VAR NUMBER RETURN... |
At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$
We can see that if we choose some value $v$ and will apply function $f$ to it, then apply $f$ to $f(v)$, an... | n, k = map(int, input().split())
def c(m):
a = b = m
ans = 0
if m % 2 == 0:
b += 1
while b <= n:
ans += b - a + 1
a *= 2
b *= 2
b += 1
return ans + max(0, n - a + 1)
if n < 100:
ans = 1
for i in range(1, n + 1):
if c(i) >= k:
an... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR VAR ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER WHILE VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER RETURN BIN_OP VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBE... |
At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$
We can see that if we choose some value $v$ and will apply function $f$ to it, then apply $f$ to $f(v)$, an... | import sys
def cnt(y, n):
if y <= 1:
return n
if y > n:
return 0
if y % 2 == 1:
return 1 + cnt(2 * y, n)
c = 0
p = 1
while p * y <= n:
mx = min(n, p * y + 2 * p - 1)
c += mx - p * y + 1
p *= 2
return c
n, k = input().split()
n, k = int(n), ... | IMPORT FUNC_DEF IF VAR NUMBER RETURN VAR IF VAR VAR RETURN NUMBER IF BIN_OP VAR NUMBER NUMBER RETURN BIN_OP NUMBER FUNC_CALL VAR BIN_OP NUMBER VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP NUMBER VAR NUMBER VAR BIN_OP BIN_OP VAR BIN... |
At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$
We can see that if we choose some value $v$ and will apply function $f$ to it, then apply $f$ to $f(v)$, an... | import sys
input = sys.stdin.readline
N, K = map(int, input().split())
def search(odd_num):
c = 0
upper = odd_num
down = odd_num
while upper <= N:
c += upper - down + 1
upper = 2 * upper + 1
down = 2 * down
if down <= N:
c += N - down + 1
return c
def binary_... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR WHILE VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR IF VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER RETURN VAR FUNC_DEF A... |
At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$
We can see that if we choose some value $v$ and will apply function $f$ to it, then apply $f$ to $f(v)$, an... | n, k = list(map(int, input().split()))
s = bin(n)[2:]
ans = 1
if k == 1:
ans = n
else:
f = len(s)
for d in range(1, f):
rgt = int(s[-d:], 2)
lft = int(s[:-d], 2)
c = 2**d
if rgt + c >= k:
if rgt + c > k:
ans = max(lft * 2, ans)
else:
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER... |
At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$
We can see that if we choose some value $v$ and will apply function $f$ to it, then apply $f$ to $f(v)$, an... | n, k = [int(x) for x in input().split()]
def DTB(num, x):
if num > 1:
DTB(num // 2, x)
x.append(num % 2)
nn = []
kk = []
DTB(n, nn)
DTB(k, kk)
if k == 1:
print(n)
elif k == 2:
if n == 2:
print(1)
elif n % 2 == 0:
print(n - 2)
else:
print(n - 1)
elif k == 3:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR NUMBER EXPR FU... |
At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$
We can see that if we choose some value $v$ and will apply function $f$ to it, then apply $f$ to $f(v)$, an... | n, k = map(int, input().split())
def check(m):
if m % 2 == 0:
ret = check(m + 1)
else:
ret = 0
i = 0
while True:
if (m + 1 << i) - 1 <= n:
ret += 1 << i
elif m << i > n:
break
else:
ret += n - (m << i) + 1
break
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR VAR BIN_OP NUMBER VAR IF BIN_OP VAR VAR VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR NUM... |
At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$
We can see that if we choose some value $v$ and will apply function $f$ to it, then apply $f$ to $f(v)$, an... | n, k = map(int, input().split())
ans = 0
if n == k:
ans = 1
elif k == 1:
ans = n
else:
p = 2
s = 2
while s < k:
p *= 2
s += p
n1 = n
n -= k
ans = (n + p - 1) // p
ans *= 2
flag = False
for i in range(1, 64):
if 2**i - 1 == k:
flag = True
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CA... |
At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$
We can see that if we choose some value $v$ and will apply function $f$ to it, then apply $f$ to $f(v)$, an... | a, b = input().split()
a = int(a)
b = int(b)
if b == 1:
print(a)
elif b == 2:
if a % 2 == 0:
print(a // 2)
else:
print(a - 1)
else:
chopped_even = bin(b + 1)[3:]
len_even = len(chopped_even)
best_even = (a - int(chopped_even, 2)) // 2**len_even * 2
chopped_odd = bin(b)[2:]
... | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL... |
At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$
We can see that if we choose some value $v$ and will apply function $f$ to it, then apply $f$ to $f(v)$, an... | count = 0
def f(t, n):
count = 0
if t % 2 == 1:
while t <= n:
t *= 2
count += 1
if n - t // 2 + 1 >= pow(2, count - 1):
return pow(2, count - 1) - 1 + pow(2, count - 1)
else:
return pow(2, count - 1) - 1 + (n - t // 2 + 1)
else:
... | ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER WHILE VAR VAR VAR NUMBER VAR NUMBER IF BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP... |
At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$
We can see that if we choose some value $v$ and will apply function $f$ to it, then apply $f$ to $f(v)$, an... | def c(x):
global n
a = b = x
if x % 2 == 0:
b += 1
res = b - a + 1
while 2 * b < n:
a = 2 * a
b = 2 * b + 1
res += b - a + 1
if 2 * a <= n:
res += n - 2 * a + 1
return res
n, k = map(int, input().split())
cnt = 0
l = 0
r = n // 2 + 1
while r - l > 1:... | FUNC_DEF ASSIGN VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER WHILE BIN_OP NUMBER VAR VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP NUMBER VAR VAR VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR NUMBER RETURN V... |
At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$
We can see that if we choose some value $v$ and will apply function $f$ to it, then apply $f$ to $f(v)$, an... | def _calc(prefix, n):
if prefix > n:
return 0
prefix = bin(prefix)[2:]
n = bin(n)[2:]
plen = len(prefix)
nlen = len(n)
res = (1 << nlen - plen) - 1
nprefix = n[:plen]
if nprefix == prefix:
for i in range(plen, nlen):
if n[i] == "1":
res += 1 <<... | FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR IF VAR VAR FOR VAR FUNC_CALL VAR VAR VAR IF VAR VAR STRING VAR BIN_OP NUMBER BIN_OP... |
At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$
We can see that if we choose some value $v$ and will apply function $f$ to it, then apply $f$ to $f(v)$, an... | n, k = map(int, input().split())
def calc(z):
global n
if z > n:
return False
if z == 0:
return True
if z % 2 == 1:
ans = 1
now = 2 * z
co = 1
if k == 1:
return True
elif now > n:
return False
else:
ans = 0
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER IF VAR NUMBER RETURN NUMBER IF VAR VAR RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHIL... |
At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$
We can see that if we choose some value $v$ and will apply function $f$ to it, then apply $f$ to $f(v)$, an... | n, k = map(int, input().split())
p = 1
w = 0
while p * 2 <= k:
p *= 2
w += 1
kk = k - p
odd = (n - kk) // 2**w
if odd % 2 == 0:
odd -= 1
p = 1
w = 0
while 2 * (2 * p - 1) < k:
p *= 2
w += 1
poz = k - 2 * (p - 1)
if poz == 0:
even = (n - (2**w - 1)) // 2 ** (w - 1)
if even % 2 == 1:
e... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP NUMBER VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP NUMBER BIN_O... |
At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$
We can see that if we choose some value $v$ and will apply function $f$ to it, then apply $f$ to $f(v)$, an... | def check(md, n, k):
s = 0
temp, i = md, 1
while temp <= n:
s += min(n - temp + 1, i)
temp *= 2
i *= 2
if md % 2 == 0:
temp, i = md + 1, 1
while temp <= n:
s += min(n - temp + 1, i)
temp *= 2
i *= 2
if s >= k:
return... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR VAR NUMBER WHILE VAR VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER NUMBER WHILE VAR VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR NUMBER VAR NUMBER IF VAR VAR RETURN NUMBER ... |
At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$
We can see that if we choose some value $v$ and will apply function $f$ to it, then apply $f$ to $f(v)$, an... | n, k = map(int, input().split())
if n == k:
print(1)
exit(0)
def calc(x):
ans = 1
if x % 2 == 1:
t = x
while True:
x *= 2
t = 2 * t + 1
if x > n:
break
ans += min(t, n) - x + 1
elif x + 1 <= n:
t = x + 1
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR WHILE NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF VAR VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR VAR NUMBER I... |
At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$
We can see that if we choose some value $v$ and will apply function $f$ to it, then apply $f$ to $f(v)$, an... | a, N, K = [0] + [int(i) for i in input().split()]
d = lambda n: sum([min(N - (n << e) + 1, 1 << e) for e in range(99) if n << e <= N])
c = lambda n: d(n) + (d(n + 1), 0)[n & 1]
for b in range(59, -1, -1):
a += (0, 1 << b)[c(a + 2**b) >= K]
print(a) | ASSIGN VAR VAR VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR NUMBER BIN_OP NUMBER VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER FO... |
At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$
We can see that if we choose some value $v$ and will apply function $f$ to it, then apply $f$ to $f(v)$, an... | import sys
reader = (map(int, line.split()) for line in sys.stdin)
def count(num):
ans = 0
if num % 2:
add = 1
else:
add = 2
while num + add - 1 <= n:
ans += add
add *= 2
num *= 2
if num <= n:
ans += n - num + 1
return ans
def func(n, k):
... | IMPORT ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP BIN_OP VAR VAR NUMBER VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER RETURN VAR FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR NUMBER AS... |
At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$
We can see that if we choose some value $v$ and will apply function $f$ to it, then apply $f$ to $f(v)$, an... | n, k = map(int, input().split())
j = n
odd = 3
even = 6
if j % 2 == 0:
n1 = 1
n2 = 1
elif j % 2 != 0:
n1 = 1
n2 = 2
preodd = 1
preeven = 2
if k == n:
print(1)
elif k == 1:
print(j)
elif k == 2:
if j % 2 == 0:
print(j - 2)
else:
print(j - 1)
else:
pre = n
j = n // ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR NUMB... |
At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$
We can see that if we choose some value $v$ and will apply function $f$ to it, then apply $f$ to $f(v)$, an... | def binary_search(lb, ub, criterion):
ok = lb
ng = ub
while ng - ok > 1:
mid = (ng + ok) // 2
if criterion(mid):
ok = mid
else:
ng = mid
return ok
n, k = list(map(int, input().split()))
odd_acc_count = 0
odd_count = 1
depth = 0
while odd_acc_count < k:
... | FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR VAR ... |
At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$
We can see that if we choose some value $v$ and will apply function $f$ to it, then apply $f$ to $f(v)$, an... | N, K = map(int, input().split())
def even(a):
if a == 0:
return True
n = 2 * a
res = 0
m = n.bit_length()
M = N.bit_length()
for i in range(60):
if i + m < M:
res += 2 ** (i + 1)
elif i + m == M:
if N >> i > n:
res += 2**i
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR VAR VAR VAR BIN_OP NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR IF BIN_OP VAR VAR VA... |
At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$
We can see that if we choose some value $v$ and will apply function $f$ to it, then apply $f$ to $f(v)$, an... | import sys
def f(n, mid):
a, b, ans = 1, mid, 0
while 2 * mid + 1 <= n:
a *= 2
ans += a
mid = 2 * mid + 1
b *= 2
if 2 * b <= n:
ans += n - 2 * b + 1
return ans
n, k = map(int, input().split())
if n == k:
print(1)
sys.exit()
low, high, m = 0, n // 2, 1
... | IMPORT FUNC_DEF ASSIGN VAR VAR VAR NUMBER VAR NUMBER WHILE BIN_OP BIN_OP NUMBER VAR NUMBER VAR VAR NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR NUMBER IF BIN_OP NUMBER VAR VAR VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR E... |
At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$
We can see that if we choose some value $v$ and will apply function $f$ to it, then apply $f$ to $f(v)$, an... | import sys
input = sys.stdin.readline
n, k = map(int, input().split())
l = 0
r = n
while r - l > 1:
mid = (l + r) // 2
x = mid * 2
cnt = 0
if x <= n:
cnt += 1
if x + 1 <= n:
cnt += 1
v = 2
while v * x <= n:
if v * x + 2 * v - 1 <= n:
cnt += 2 * v
... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR ... |
At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$
We can see that if we choose some value $v$ and will apply function $f$ to it, then apply $f$ to $f(v)$, an... | n, k = map(int, input().split())
def solve(n, num):
ans = 0
keta_num = num.bit_length()
keta_n = n.bit_length()
keta_diff = keta_n - keta_num
if keta_diff < 0:
return ans
ans += (1 << keta_diff) - 1
if n >> keta_diff > num:
ans += 1 << keta_diff
elif n >> keta_diff == n... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER RETURN VAR VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF BIN_OP VAR VAR VAR VAR BIN_OP NUMBER VAR IF BIN_OP VAR VAR VAR VAR BIN_OP VAR BIN_OP BIN_OP NUMB... |
At first, let's define function $f(x)$ as follows: $$ \begin{matrix} f(x) & = & \left\{ \begin{matrix} \frac{x}{2} & \mbox{if } x \text{ is even} \\ x - 1 & \mbox{otherwise } \end{matrix} \right. \end{matrix} $$
We can see that if we choose some value $v$ and will apply function $f$ to it, then apply $f$ to $f(v)$, an... | from sys import stdin, stdout
def getmaxval(n, k):
if n == k:
return 1
ol = 1
oh = n // 2
while ol < oh:
om = (ol + oh + 1) // 2
cnt = counteven(om * 2, n)
if cnt >= k:
ol = om
else:
oh = om - 1
r1 = ol * 2
if r1 < n:
cnt2... | FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_... |
A new innovative ticketing systems for public transport is introduced in Bytesburg. Now there is a single travel card for all transport. To make a trip a passenger scan his card and then he is charged according to the fare.
The fare is constructed in the following manner. There are three types of tickets: a ticket f... | n = int(input())
t = [int(input()) for _ in range(n)]
INF = 10**12
ll = [1, 90, 1440]
pp = [20, 50, 120]
lowest_price = [0] * n
p = pp[0]
lowest_price[0] = p
for i in range(1, n):
u = lowest_price[i - 1] + pp[0]
for j in range(1, 3):
l = ll[j]
p = pp[j]
start = t[i] - l + 1
prev ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASS... |
A new innovative ticketing systems for public transport is introduced in Bytesburg. Now there is a single travel card for all transport. To make a trip a passenger scan his card and then he is charged according to the fare.
The fare is constructed in the following manner. There are three types of tickets: a ticket f... | n = int(input())
time = []
for i in range(n):
time.append(int(input()))
ptr90 = 0
ptrs = 0
dp = [0] * n
dp[0] = 20
print(20)
for i in range(1, n):
s1 = dp[i - 1] + 20
if time[i] <= 89 + time[ptr90]:
if ptr90 == 0:
s2 = 50
else:
s2 = dp[ptr90 - 1] + 50
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBE... |
A new innovative ticketing systems for public transport is introduced in Bytesburg. Now there is a single travel card for all transport. To make a trip a passenger scan his card and then he is charged according to the fare.
The fare is constructed in the following manner. There are three types of tickets: a ticket f... | n = int(input())
travel_times = list()
travel_pay = list()
pay_ticket1 = 0
time_ticket1 = 0
pay_ticket2 = 0
time_ticket2 = 0
for travel_id in range(n):
t = int(input())
travel_times.append(t)
pay2 = 20
sum_time1 = t - travel_times[time_ticket1]
sum_time2 = t - travel_times[time_ticket2]
if sum_t... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR V... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.