description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Chef has invited Alice for his birthday party. Now, Alice is thinking about what to give Chef as a present. She should obviously choose a sequence β what could possibly be a better birthday gift than a sequence!
After some thinking, Alice chose a sequence of integers $A_1, A_2, \ldots, A_N$. However, she does not want ... | m = 1000000007
for t in range(int(input())):
n = int(input())
B = list(map(int, input().split()))
if B != sorted(B):
print(0)
else:
freq = [(B[i] & B[i + 1]) for i in range(n - 1)]
p = 0
for b in freq:
b = bin(b)
p += b.count("1")
print(pow... | ASSIGN VAR NUMBER 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 IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR ... |
Chef has invited Alice for his birthday party. Now, Alice is thinking about what to give Chef as a present. She should obviously choose a sequence β what could possibly be a better birthday gift than a sequence!
After some thinking, Alice chose a sequence of integers $A_1, A_2, \ldots, A_N$. However, she does not want ... | for _ in range(int(input())):
n = int(input())
l = list(map(int, input().split()))
ans = 1
d = 0
for i in range(n - 1):
if l[i] & l[i + 1] != l[i]:
print(0)
d = 1
break
if d == 1:
continue
c = 0
for i in l:
c += bin(i)[2:].count... | 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 NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUM... |
Chef has invited Alice for his birthday party. Now, Alice is thinking about what to give Chef as a present. She should obviously choose a sequence β what could possibly be a better birthday gift than a sequence!
After some thinking, Alice chose a sequence of integers $A_1, A_2, \ldots, A_N$. However, she does not want ... | import sys
sys.setrecursionlimit(10**3)
def fast_expo(n):
mod = 10**9 + 7
if n == 1:
return 2
x = fast_expo(n // 2) % mod
if n % 2 == 0:
return x * x % (10**9 + 7)
else:
return x * x * 2 % (10**9 + 7)
for _ in range(int(input())):
n = int(input())
l = list(map(in... | IMPORT EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER FUNC_DEF ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER IF VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP VAR NUMBER NUMBER RETURN BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER RETURN BIN_OP BIN_OP BIN_OP VAR VAR NUMBER B... |
Chef has invited Alice for his birthday party. Now, Alice is thinking about what to give Chef as a present. She should obviously choose a sequence β what could possibly be a better birthday gift than a sequence!
After some thinking, Alice chose a sequence of integers $A_1, A_2, \ldots, A_N$. However, she does not want ... | t = int(input())
mod = pow(10, 9) + 7
while t > 0:
t -= 1
n = int(input())
b = [int(x) for x in input().split()]
bprev = b[0]
ans = 1
for i in range(1, n):
if bin(~b[i] & b[i - 1]).count("1"):
ans = 0
break
ans += bin(b[i] & b[i - 1]).count("1")
if ans... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER NUMBER NUMBER WHILE VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF FUNC_CALL FUNC_CALL VAR BIN_... |
Chef has invited Alice for his birthday party. Now, Alice is thinking about what to give Chef as a present. She should obviously choose a sequence β what could possibly be a better birthday gift than a sequence!
After some thinking, Alice chose a sequence of integers $A_1, A_2, \ldots, A_N$. However, she does not want ... | import sys
f = sys.stdin
readline = lambda: map(int, f.readline().rstrip().split(" "))
(T,) = readline()
for i in range(T):
(N,) = readline()
B = list(readline())
ans = 0
impossible = False
for i in range(len(B) - 1):
ans += bin(B[i] & B[i + 1]).count("1")
if bin(B[i] & ~B[i + 1]).c... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL FUNC_CALL... |
Chef has invited Alice for his birthday party. Now, Alice is thinking about what to give Chef as a present. She should obviously choose a sequence β what could possibly be a better birthday gift than a sequence!
After some thinking, Alice chose a sequence of integers $A_1, A_2, \ldots, A_N$. However, she does not want ... | T = int(input())
mod = 10**9 + 7
for z in range(T):
N = int(input())
arr = [int(x) for x in input().split()]
count = 1
flag = False
for i in range(1, N):
if arr[i] | arr[i - 1] > arr[i]:
flag = True
break
count_1 = bin(arr[i - 1]).count("1")
count = co... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR ... |
Chef has invited Alice for his birthday party. Now, Alice is thinking about what to give Chef as a present. She should obviously choose a sequence β what could possibly be a better birthday gift than a sequence!
After some thinking, Alice chose a sequence of integers $A_1, A_2, \ldots, A_N$. However, she does not want ... | m = pow(10, 9) + 7
for _ in range(int(input())):
n = int(input())
l = list(map(int, input().split()))
t = 1
for i in range(n - 1):
if l[i] <= l[i + 1] and l[i] & l[i + 1] == l[i]:
y = bin(l[i]).count("1")
t = t * pow(2, y, m) % m
else:
t = 0
... | ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER NUMBER NUMBER 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 NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR B... |
Chef has invited Alice for his birthday party. Now, Alice is thinking about what to give Chef as a present. She should obviously choose a sequence β what could possibly be a better birthday gift than a sequence!
After some thinking, Alice chose a sequence of integers $A_1, A_2, \ldots, A_N$. However, she does not want ... | def solve(n, b):
for i in range(n - 1):
if b[i] & b[i + 1] != b[i]:
print(0)
return
x = 0
for i in range(n - 1):
x += bin(b[i]).count("1")
print(pow(2, x, mod))
mod = 10**9 + 7
for _ in range(int(input())):
n = int(input())
b = list(map(int, input().spli... | FUNC_DEF FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NU... |
Chef has invited Alice for his birthday party. Now, Alice is thinking about what to give Chef as a present. She should obviously choose a sequence β what could possibly be a better birthday gift than a sequence!
After some thinking, Alice chose a sequence of integers $A_1, A_2, \ldots, A_N$. However, she does not want ... | const = 10**9 + 7
T = int(input())
for _ in range(T):
N = int(input())
ans = 1
Bi = list(map(int, input().split()))
for i in range(N - 1):
if str(bin(Bi[i])).count("1") - str(bin(Bi[i + 1])).count("1") > 0:
ans = 0
break
ans = ans % const * pow(2, str(bin(Bi[i])).... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP FUNC_CALL FUNC_CALL VAR FUNC_CALL V... |
Chef has invited Alice for his birthday party. Now, Alice is thinking about what to give Chef as a present. She should obviously choose a sequence β what could possibly be a better birthday gift than a sequence!
After some thinking, Alice chose a sequence of integers $A_1, A_2, \ldots, A_N$. However, she does not want ... | m = 10**9
m += 7
def calc(i):
a = 0
while i > 0:
q = i % 2
a += q
i = i // 2
return a
for tst in range(int(input())):
n = int(input())
a = [int(x) for x in input().split()]
ans = 1
for k in range(n - 1):
if a[k] & a[k + 1] == a[k]:
kk = calc(a[... | ASSIGN VAR BIN_OP NUMBER NUMBER VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN 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 VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR... |
Chef has invited Alice for his birthday party. Now, Alice is thinking about what to give Chef as a present. She should obviously choose a sequence β what could possibly be a better birthday gift than a sequence!
After some thinking, Alice chose a sequence of integers $A_1, A_2, \ldots, A_N$. However, she does not want ... | mod = 10**9 + 7
def pow2(x):
p, n = 1, 2
while x:
if x & 1:
p = p % mod * (n % mod) % mod
n = n % mod * (n % mod) % mod
x //= 2
return p
def count_bit(val):
bit = 0
for i in range(30):
if val >> i & 1:
bit += 1
return bit
def answer()... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER WHILE VAR IF BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP... |
Chef has invited Alice for his birthday party. Now, Alice is thinking about what to give Chef as a present. She should obviously choose a sequence β what could possibly be a better birthday gift than a sequence!
After some thinking, Alice chose a sequence of integers $A_1, A_2, \ldots, A_N$. However, she does not want ... | M = 1000000007
T = int(input())
for _ in range(T):
n = int(input())
l = [int(i) for i in input().split()]
count1 = 0
for i in range(1, n):
if l[i - 1] & l[i] != l[i - 1]:
count1 = 0
break
else:
count1 += bin(l[i - 1] & l[i]).count("1")
if count1 ==... | ASSIGN VAR NUMBER 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 NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_C... |
Chef has invited Alice for his birthday party. Now, Alice is thinking about what to give Chef as a present. She should obviously choose a sequence β what could possibly be a better birthday gift than a sequence!
After some thinking, Alice chose a sequence of integers $A_1, A_2, \ldots, A_N$. However, she does not want ... | def countSetBits(n):
total = 0
while n:
total += n & 1
n = n >> 1
return total
def totalWays(bArr, n):
valid = True
for i in range(1, len(bArr)):
if bArr[i] & bArr[i - 1] != bArr[i - 1]:
valid = False
if not valid:
return 0
mod = int(1000000000.0... | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ... |
Chef has invited Alice for his birthday party. Now, Alice is thinking about what to give Chef as a present. She should obviously choose a sequence β what could possibly be a better birthday gift than a sequence!
After some thinking, Alice chose a sequence of integers $A_1, A_2, \ldots, A_N$. However, she does not want ... | import sys
readline = lambda: map(int, sys.stdin.readline().split(" "))
(T,) = readline()
for _ in range(T):
(N,) = readline()
B = list(readline())
A0 = B[0]
B1 = None
setbits = 0
no = False
for j in range(1, N):
B1 = B[j]
if A0 & ~B1 > 0:
print(0)
no... | IMPORT ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NONE ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR IF BIN_OP VA... |
Chef has invited Alice for his birthday party. Now, Alice is thinking about what to give Chef as a present. She should obviously choose a sequence β what could possibly be a better birthday gift than a sequence!
After some thinking, Alice chose a sequence of integers $A_1, A_2, \ldots, A_N$. However, she does not want ... | def get_num_of_ones(x):
c = 0
while x:
x &= x - 1
c += 1
return c
mod = 10**9 + 7
twopow = {x: (pow(2, x) % mod) for x in range(35)}
for _ in range(int(input())):
n = int(input())
b = list(map(int, input().split()))
ones_in_prev = 0
ones_in_current = 0
ans = 1
flag ... | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR VAR BIN_OP FUNC_CALL VAR NUMBER VAR VAR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUN... |
Chef has invited Alice for his birthday party. Now, Alice is thinking about what to give Chef as a present. She should obviously choose a sequence β what could possibly be a better birthday gift than a sequence!
After some thinking, Alice chose a sequence of integers $A_1, A_2, \ldots, A_N$. However, she does not want ... | t = int(input())
for i in range(t):
n = int(input())
a = list([int(j) for j in input().split()])
count = 1
res = 1
if n > 1:
for j in range(n - 1):
if a[j + 1] | a[j] > a[j + 1]:
res = 0
break
x = str(bin(a[j + 1])[2:]).count("1")
... | 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 VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR BIN_OP VAR ... |
Chef has invited Alice for his birthday party. Now, Alice is thinking about what to give Chef as a present. She should obviously choose a sequence β what could possibly be a better birthday gift than a sequence!
After some thinking, Alice chose a sequence of integers $A_1, A_2, \ldots, A_N$. However, she does not want ... | def cb(n):
c = 0
while n:
if n & 1:
c += 1
n >>= 1
return c
for _ in range(int(input())):
n = int(input())
l = list(map(int, input().split()))
ans = 1
d = 0
for i in range(n - 1):
if l[i] & l[i + 1] != l[i]:
print(0)
d = 1
... | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR IF BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER RETURN 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 NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMB... |
Given two integers $n$ and $x$, construct an array that satisfies the following conditions: for any element $a_i$ in the array, $1 \le a_i<2^n$; there is no non-empty subsegment with bitwise XOR equal to $0$ or $x$, its length $l$ should be maximized.
A sequence $b$ is a subsegment of a sequence $a$ if $b$ can be... | def main():
N, X = map(int, input().split())
L = 2**N - 1
if X <= L:
P = [0]
checked = [False] * (L + 1)
checked[0] = True
for n in range(1, L + 1):
inv = n ^ X
if not checked[inv]:
P.append(n)
checked[n] = True
... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR LIST NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR EXPR FUNC_CALL VAR V... |
Given two integers $n$ and $x$, construct an array that satisfies the following conditions: for any element $a_i$ in the array, $1 \le a_i<2^n$; there is no non-empty subsegment with bitwise XOR equal to $0$ or $x$, its length $l$ should be maximized.
A sequence $b$ is a subsegment of a sequence $a$ if $b$ can be... | import sys
input = sys.stdin.readline
n, x = map(int, input().split())
b = [0]
for i in range(1, 2**n):
if i ^ x > i:
b.append(i)
a = [(b[i] ^ b[i - 1]) for i in range(1, len(b))]
print(len(a))
print(*a) | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VA... |
Given two integers $n$ and $x$, construct an array that satisfies the following conditions: for any element $a_i$ in the array, $1 \le a_i<2^n$; there is no non-empty subsegment with bitwise XOR equal to $0$ or $x$, its length $l$ should be maximized.
A sequence $b$ is a subsegment of a sequence $a$ if $b$ can be... | n, x = map(int, input().split())
if x >= 2**n:
print(2**n - 1)
print(*([1] + [(i ^ i + 1) for i in range(1, 2**n - 1)]))
else:
print(2 ** (n - 1) - 1)
if n == 1:
exit()
a = []
bad = [0] * 2**n
bad[0], bad[x] = 1, 1
for i in range(2**n):
if bad[i] == 0:
a.appen... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP LIST NUMBER BIN_OP VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBE... |
Given two integers $n$ and $x$, construct an array that satisfies the following conditions: for any element $a_i$ in the array, $1 \le a_i<2^n$; there is no non-empty subsegment with bitwise XOR equal to $0$ or $x$, its length $l$ should be maximized.
A sequence $b$ is a subsegment of a sequence $a$ if $b$ can be... | N, X = map(int, input().split())
ex = [False] * 2**18
ex[0] = True
ans = [0]
for i in range(1, 2**N):
if ex[i ^ X]:
continue
else:
ans.append(i)
ex[i] = True
print(len(ans) - 1)
for i in range(1, len(ans)):
print(ans[i] ^ ans[i - 1], end=" ") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR IF VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER... |
Given two integers $n$ and $x$, construct an array that satisfies the following conditions: for any element $a_i$ in the array, $1 \le a_i<2^n$; there is no non-empty subsegment with bitwise XOR equal to $0$ or $x$, its length $l$ should be maximized.
A sequence $b$ is a subsegment of a sequence $a$ if $b$ can be... | n, x = map(int, input().split())
if x >= 2**n:
prefix_array = []
for i in range(1, 2**n):
prefix_array.append(i)
else:
prefix_array = []
compl = {}
for i in range(1, 2**n):
if i == x:
continue
try:
if compl[i]:
pass
except:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR IF VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NU... |
Given two integers $n$ and $x$, construct an array that satisfies the following conditions: for any element $a_i$ in the array, $1 \le a_i<2^n$; there is no non-empty subsegment with bitwise XOR equal to $0$ or $x$, its length $l$ should be maximized.
A sequence $b$ is a subsegment of a sequence $a$ if $b$ can be... | def main():
buf = input()
buflist = buf.split()
n = int(buflist[0])
x = int(buflist[1])
npow2 = int(2**n)
if n == 1:
if x == 1:
print(0)
else:
print(1)
print(1)
return
mask = x
if x >= npow2:
mask = 0
available = set... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR VAR IF VAR VAR ASSIGN ... |
Given two integers $n$ and $x$, construct an array that satisfies the following conditions: for any element $a_i$ in the array, $1 \le a_i<2^n$; there is no non-empty subsegment with bitwise XOR equal to $0$ or $x$, its length $l$ should be maximized.
A sequence $b$ is a subsegment of a sequence $a$ if $b$ can be... | n, x = list(map(int, input().split()))
a = []
d = {(0): True}
d1 = [0]
if x < 1 << n:
for t in range(1, 1 << n):
if not d.get(t ^ x, False):
a.append(t ^ d1[-1])
d[t] = True
d1.append(t)
print(len(a))
print(" ".join(map(str, a)))
else:
for t in range(1, 1 << n... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR DICT NUMBER NUMBER ASSIGN VAR LIST NUMBER IF VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR VAR NUMBER EXPR F... |
Given two integers $n$ and $x$, construct an array that satisfies the following conditions: for any element $a_i$ in the array, $1 \le a_i<2^n$; there is no non-empty subsegment with bitwise XOR equal to $0$ or $x$, its length $l$ should be maximized.
A sequence $b$ is a subsegment of a sequence $a$ if $b$ can be... | n, x = [int(x) for x in input().split(" ")]
b = []
if x >= 2**n:
b = list(range(0, 2**n, 1))
else:
forb = {}
for i in range(2**n):
if i not in forb:
b.append(i)
forb[i ^ x] = 1
a = [(b[i] ^ b[i - 1]) for i in range(1, len(b))]
print(len(a))
print(" ".join([str(x) for x in a])... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST IF VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP... |
Given two integers $n$ and $x$, construct an array that satisfies the following conditions: for any element $a_i$ in the array, $1 \le a_i<2^n$; there is no non-empty subsegment with bitwise XOR equal to $0$ or $x$, its length $l$ should be maximized.
A sequence $b$ is a subsegment of a sequence $a$ if $b$ can be... | n, x = list(map(int, input().split()))
mark = [(0) for x in range(1 << 18 + 1)]
mark[x] = 1
cur = 0
MAXN = 1 << n
ans = []
for i in range(1, MAXN):
if i != x:
res = i ^ x
if mark[i] == 0:
ans.append(i ^ cur)
mark[res] = 1
mark[i] = 1
cur = i
print(len(... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR NUMBER EXPR ... |
Given two integers $n$ and $x$, construct an array that satisfies the following conditions: for any element $a_i$ in the array, $1 \le a_i<2^n$; there is no non-empty subsegment with bitwise XOR equal to $0$ or $x$, its length $l$ should be maximized.
A sequence $b$ is a subsegment of a sequence $a$ if $b$ can be... | n, x = list(map(int, input().split()))
n = 1 << n
ans = (n >> (x < n)) - 1
print(ans)
q, t = 0, 0
a = [0] * n
for i in range(1, n):
if i < i ^ x:
a[t] = i ^ q
q, t = i, t + 1
print(*a[:t]) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR BIN_OP VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR ASSIG... |
Given two integers $n$ and $x$, construct an array that satisfies the following conditions: for any element $a_i$ in the array, $1 \le a_i<2^n$; there is no non-empty subsegment with bitwise XOR equal to $0$ or $x$, its length $l$ should be maximized.
A sequence $b$ is a subsegment of a sequence $a$ if $b$ can be... | n, x = map(int, input().split())
flag = [True] * (1 << n)
flag[0] = False
if x <= (1 << n) - 1:
flag[x] = False
for S in range(1 << n):
if not flag[S]:
continue
flag[S ^ x] = False
xor = [0]
for S in range(1 << n):
if flag[S]:
xor.append(S)
ans = []
for i in range(len(xor... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP NUMBER VAR ASSIGN VAR NUMBER NUMBER IF VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR IF VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR ... |
Given two integers $n$ and $x$, construct an array that satisfies the following conditions: for any element $a_i$ in the array, $1 \le a_i<2^n$; there is no non-empty subsegment with bitwise XOR equal to $0$ or $x$, its length $l$ should be maximized.
A sequence $b$ is a subsegment of a sequence $a$ if $b$ can be... | n, x = map(int, input().split())
d = {}
for i in range(2**n):
if not d.get(i, False):
d[i ^ x] = 1
k = 0
print(len(d) - 1)
for i in range(1, 2**n):
if i not in d:
print(i ^ k, end=" ")
k = i | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR IF VAR VAR EXPR FUNC_CALL VAR ... |
Given two integers $n$ and $x$, construct an array that satisfies the following conditions: for any element $a_i$ in the array, $1 \le a_i<2^n$; there is no non-empty subsegment with bitwise XOR equal to $0$ or $x$, its length $l$ should be maximized.
A sequence $b$ is a subsegment of a sequence $a$ if $b$ can be... | v = [0]
n, x = map(int, input().split())
e = [0] * (1 << 18)
e[0] = 1
for i in range(1, 1 << n):
if e[x ^ i] == 1:
continue
e[i] = 1
v.append(i)
print(len(v) - 1)
print(*[(v[i] ^ v[i - 1]) for i in range(1, len(v))]) | ASSIGN VAR LIST NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR IF VAR BIN_OP VAR VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR... |
Given two integers $n$ and $x$, construct an array that satisfies the following conditions: for any element $a_i$ in the array, $1 \le a_i<2^n$; there is no non-empty subsegment with bitwise XOR equal to $0$ or $x$, its length $l$ should be maximized.
A sequence $b$ is a subsegment of a sequence $a$ if $b$ can be... | n, x = map(int, input().split())
if x >= 2**n:
print(2**n - 1)
print(*[(t ^ t + 1) for t in range(2**n - 1)])
else:
used = [False] * 2**n
r = [0]
used[0] = True
used[x] = True
for i in range(1, 2**n):
if not used[i]:
used[i] = used[i ^ x] = True
r.append(i)
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP NUMBER VAR ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER ... |
Given two integers $n$ and $x$, construct an array that satisfies the following conditions: for any element $a_i$ in the array, $1 \le a_i<2^n$; there is no non-empty subsegment with bitwise XOR equal to $0$ or $x$, its length $l$ should be maximized.
A sequence $b$ is a subsegment of a sequence $a$ if $b$ can be... | n, x = map(int, input().split())
ans = []
total = 1 << n
vis = [0] * (1 << 18)
for i in range(total):
if vis[i] == 0:
ans.append(i)
vis[i] = 1
vis[i ^ x] = 1
print(len(ans) - 1)
for i in range(1, len(ans)):
print(ans[i] ^ ans[i - 1], end=" ") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR N... |
Given two integers $n$ and $x$, construct an array that satisfies the following conditions: for any element $a_i$ in the array, $1 \le a_i<2^n$; there is no non-empty subsegment with bitwise XOR equal to $0$ or $x$, its length $l$ should be maximized.
A sequence $b$ is a subsegment of a sequence $a$ if $b$ can be... | import sys
input = sys.stdin.readline
n, x = list(map(int, input().split()))
if n == x == 1:
print(0)
return
ANS = []
for i in range(n):
if i + 1 == x.bit_length():
continue
ANS = ANS + [1 << i] + ANS
print(len(ANS))
print(*ANS) | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR LIST BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR F... |
Given two integers $n$ and $x$, construct an array that satisfies the following conditions: for any element $a_i$ in the array, $1 \le a_i<2^n$; there is no non-empty subsegment with bitwise XOR equal to $0$ or $x$, its length $l$ should be maximized.
A sequence $b$ is a subsegment of a sequence $a$ if $b$ can be... | n, x = map(int, input().split())
t = 2**n
ans = [0]
if x >= t:
ans = [*range(t)]
else:
c = set([0])
for i in range(1, t):
if i ^ x in c:
continue
ans.append(i)
c.add(i)
print(len(ans) - 1)
print(*[(ans[i] ^ ans[i - 1]) for i in range(1, len(ans))]) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR LIST NUMBER IF VAR VAR ASSIGN VAR LIST FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FU... |
Given two integers $n$ and $x$, construct an array that satisfies the following conditions: for any element $a_i$ in the array, $1 \le a_i<2^n$; there is no non-empty subsegment with bitwise XOR equal to $0$ or $x$, its length $l$ should be maximized.
A sequence $b$ is a subsegment of a sequence $a$ if $b$ can be... | from sys import stdin
input = stdin.readline
n, x = map(int, input().split())
x = 1 << len(bin(x)) - 3
a = [i for i in range(1, 1 << n) if i >> len(bin(x)) - 3 & 1 == 0] + [0]
b = [(a[i] ^ a[i - 1]) for i in range(len(a) - 1)]
print(len(b), *b) | ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR BIN_OP BIN_OP VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER NUMBER LIST NUMBER ASSIGN VAR BIN_OP VAR ... |
Given two integers $n$ and $x$, construct an array that satisfies the following conditions: for any element $a_i$ in the array, $1 \le a_i<2^n$; there is no non-empty subsegment with bitwise XOR equal to $0$ or $x$, its length $l$ should be maximized.
A sequence $b$ is a subsegment of a sequence $a$ if $b$ can be... | n, x = map(int, input().split())
def creat(n, x):
if x > 2**n:
arr = [i for i in range(1, 2**n)]
return arr
used = {i: (False) for i in range(1, 2**n)}
arr = []
for i in range(1, 2**n):
if i == x:
continue
if used[i] == True:
continue
use... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR BIN_OP NUMBER VAR ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR RETURN VAR ASSIGN VAR VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR IF VAR VAR IF VAR VAR NUMBER ASS... |
Given two integers $n$ and $x$, construct an array that satisfies the following conditions: for any element $a_i$ in the array, $1 \le a_i<2^n$; there is no non-empty subsegment with bitwise XOR equal to $0$ or $x$, its length $l$ should be maximized.
A sequence $b$ is a subsegment of a sequence $a$ if $b$ can be... | from sys import stdout
n, x = list(map(int, input().split()))
t = pow(2, n)
if x >= t:
print(t - 1)
for i in range(1, t):
stdout.write(str(i ^ i - 1) + " ")
exit(0)
ans = [0] * pow(2, n)
ans[x] = -1
for i in range(1, len(ans)):
if ans[i] != -1:
ans[x ^ i] = -1
last = 0
print(pow(2, n - ... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER ... |
Given two integers $n$ and $x$, construct an array that satisfies the following conditions: for any element $a_i$ in the array, $1 \le a_i<2^n$; there is no non-empty subsegment with bitwise XOR equal to $0$ or $x$, its length $l$ should be maximized.
A sequence $b$ is a subsegment of a sequence $a$ if $b$ can be... | n, x = list(map(int, input().split()))
a = []
lst = 0
for i in range(1, 1 << n):
if i ^ x > i:
a.append(i ^ lst)
lst = i
print(len(a))
print(" ".join(str(i) for i in a)) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VA... |
Given two integers $n$ and $x$, construct an array that satisfies the following conditions: for any element $a_i$ in the array, $1 \le a_i<2^n$; there is no non-empty subsegment with bitwise XOR equal to $0$ or $x$, its length $l$ should be maximized.
A sequence $b$ is a subsegment of a sequence $a$ if $b$ can be... | n, x = map(int, input().split())
mark = [(0) for x in range(1 << 18 + 1)]
mark[x] = 1
curent = 0
maxA = 1 << n
ans = []
for i in range(1, maxA):
if i != x:
result = i ^ x
if mark[i] == 0:
ans.append(i ^ curent)
mark[result] = 1
mark[i] = 1
curent = i
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR ... |
Given two integers $n$ and $x$, construct an array that satisfies the following conditions: for any element $a_i$ in the array, $1 \le a_i<2^n$; there is no non-empty subsegment with bitwise XOR equal to $0$ or $x$, its length $l$ should be maximized.
A sequence $b$ is a subsegment of a sequence $a$ if $b$ can be... | n, x = map(int, input().split())
d = {}
N = 2**n
d[0] = 1
b = [0]
for i in range(1, N):
if i ^ x in d:
continue
else:
d[i] = 1
b.append(i)
ans = []
for i in range(1, len(b)):
ans.append(b[i] ^ b[i - 1])
print(len(ans))
print(*ans) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR VAR VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR EXPR FU... |
Given two integers $n$ and $x$, construct an array that satisfies the following conditions: for any element $a_i$ in the array, $1 \le a_i<2^n$; there is no non-empty subsegment with bitwise XOR equal to $0$ or $x$, its length $l$ should be maximized.
A sequence $b$ is a subsegment of a sequence $a$ if $b$ can be... | n, x = map(int, input().split())
res = []
s = {x}
prev = 0
for i in range(1, 1 << n):
curr = prev ^ i
if curr in s:
continue
res.append(curr)
prev = i
s.add(x ^ i)
print(len(res))
print(*res) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VA... |
Given two integers $n$ and $x$, construct an array that satisfies the following conditions: for any element $a_i$ in the array, $1 \le a_i<2^n$; there is no non-empty subsegment with bitwise XOR equal to $0$ or $x$, its length $l$ should be maximized.
A sequence $b$ is a subsegment of a sequence $a$ if $b$ can be... | n, x = map(int, input().split())
d = []
for i in range(2**n):
if i < i ^ x:
d.append(i)
print(len(d) - 1)
for i in range(1, len(d)):
print(d[i] ^ d[i - 1], end=" ") | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR IF VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER STRING |
Given two integers $n$ and $x$, construct an array that satisfies the following conditions: for any element $a_i$ in the array, $1 \le a_i<2^n$; there is no non-empty subsegment with bitwise XOR equal to $0$ or $x$, its length $l$ should be maximized.
A sequence $b$ is a subsegment of a sequence $a$ if $b$ can be... | def main():
n, x = list(map(int, input().split()))
f = []
n = 1 << n
cx = [(0) for _ in range(n + 299)]
for i in range(n):
if Find_x(int(x ^ i), f) == False:
f.append(i)
print(len(f) - 1)
for i in range(len(f) - 1):
print(f[i] ^ f[i + 1], end=" ")
def Find_x(x, ... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL... |
Given two integers $n$ and $x$, construct an array that satisfies the following conditions: for any element $a_i$ in the array, $1 \le a_i<2^n$; there is no non-empty subsegment with bitwise XOR equal to $0$ or $x$, its length $l$ should be maximized.
A sequence $b$ is a subsegment of a sequence $a$ if $b$ can be... | n, x = map(int, input().split())
markings = [(0) for i in range(2**n - 1)]
for i in range(1, 2**n):
if markings[i - 1] == 0 and x ^ i < 2**n and i != x:
markings[(x ^ i) - 1] = 1
if x < 2**n:
markings[x - 1] = 1
arr = []
for i in range(2**n - 1):
if markings[i] == 0:
arr.append(i + 1)
print(... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR IF VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR VAR BIN_OP NUMBER VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER IF VAR BIN_OP NUMBER VAR ASS... |
Given two integers $n$ and $x$, construct an array that satisfies the following conditions: for any element $a_i$ in the array, $1 \le a_i<2^n$; there is no non-empty subsegment with bitwise XOR equal to $0$ or $x$, its length $l$ should be maximized.
A sequence $b$ is a subsegment of a sequence $a$ if $b$ can be... | N, X = map(int, input().split())
if X == 0 or X >= 2**N:
A = [a for a in range(N)]
else:
for i in range(N):
if 1 << i & X:
A = [a for a in range(N) if a != i]
break
def calc(B):
if B:
b = B[-1]
t = calc(B[:-1])
return t + [1 << b] + t
return []
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR BIN_OP NUMBER VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP NUMBER VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_DEF IF VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER RETURN BIN_OP... |
Given two integers $n$ and $x$, construct an array that satisfies the following conditions: for any element $a_i$ in the array, $1 \le a_i<2^n$; there is no non-empty subsegment with bitwise XOR equal to $0$ or $x$, its length $l$ should be maximized.
A sequence $b$ is a subsegment of a sequence $a$ if $b$ can be... | def gns():
return [int(x) for x in input().split()]
n, x = gns()
if n == 1:
if x == 1:
print(0)
quit()
print(1)
print(1)
quit()
b = len(bin(x)) - 2
if x != 1:
ans = [1]
else:
ans = [2]
cur = 1
for i in range(n - 2):
if cur == b - 1:
cur += 1
ans = ans + [1 <... | FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR LIS... |
Given two integers $n$ and $x$, construct an array that satisfies the following conditions: for any element $a_i$ in the array, $1 \le a_i<2^n$; there is no non-empty subsegment with bitwise XOR equal to $0$ or $x$, its length $l$ should be maximized.
A sequence $b$ is a subsegment of a sequence $a$ if $b$ can be... | n, x = map(int, input().split())
vis = set([0])
res = []
cur = 0
for c in range(1, 1 << n):
v = c ^ x
if c in vis or v in vis:
continue
vis.add(c)
res.append(c ^ cur)
cur = c
print(len(res))
if res:
print(" ".join(map(str, res))) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR LIST NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR FUNC_CALL... |
Given two integers $n$ and $x$, construct an array that satisfies the following conditions: for any element $a_i$ in the array, $1 \le a_i<2^n$; there is no non-empty subsegment with bitwise XOR equal to $0$ or $x$, its length $l$ should be maximized.
A sequence $b$ is a subsegment of a sequence $a$ if $b$ can be... | d = dict()
def solve(n):
if n == 0:
return []
if n == 1:
d[1] = [1]
return d[1]
if n in d:
return d[n]
else:
d[n] = solve(n - 1) + [2**n - 1] + solve(n - 1)
return d[n]
def solve2(n, x):
if 2 ** (n - 1) <= x:
return solve(n - 1)
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_DEF IF VAR NUMBER RETURN LIST IF VAR NUMBER ASSIGN VAR NUMBER LIST NUMBER RETURN VAR NUMBER IF VAR VAR RETURN VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER LIST BIN_OP BIN_OP NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER RETURN VAR VAR FUNC_DEF IF BIN_OP NUMBER B... |
Given two integers $n$ and $x$, construct an array that satisfies the following conditions: for any element $a_i$ in the array, $1 \le a_i<2^n$; there is no non-empty subsegment with bitwise XOR equal to $0$ or $x$, its length $l$ should be maximized.
A sequence $b$ is a subsegment of a sequence $a$ if $b$ can be... | n, x = list(map(int, input().split()))
k, b = 1 << n, []
if x >= k:
print(k - 1)
b = list(range(1, k))
else:
print(k - 2 >> 1)
_b, b = set(range(1, k)), set()
for bi in _b:
b.add(bi)
if x ^ bi in b:
b.remove(x ^ bi)
if x in b:
b.remove(x)
if b:
b = list(b)... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP NUMBER VAR LIST IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR FUNC_CAL... |
Given two integers $n$ and $x$, construct an array that satisfies the following conditions: for any element $a_i$ in the array, $1 \le a_i<2^n$; there is no non-empty subsegment with bitwise XOR equal to $0$ or $x$, its length $l$ should be maximized.
A sequence $b$ is a subsegment of a sequence $a$ if $b$ can be... | n, x = map(int, input().split())
nn = 2**n
if x >= nn:
x = 0
ans = []
for i in range(n):
oks = [True] * nn
oks[x] = False
cur = 0
for j in ans[::-1]:
cur ^= j
oks[cur] = False
oks[cur ^ x] = False
try:
a = next(j for j, ok in enumerate(oks[1:], 1) if ok)
excep... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR NUMBER VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER ASSIGN ... |
Given two integers $n$ and $x$, construct an array that satisfies the following conditions: for any element $a_i$ in the array, $1 \le a_i<2^n$; there is no non-empty subsegment with bitwise XOR equal to $0$ or $x$, its length $l$ should be maximized.
A sequence $b$ is a subsegment of a sequence $a$ if $b$ can be... | l = input().split()
n = int(l[0])
x = int(l[1])
hashi = dict()
for i in range(1, 2**n):
hashi[i] = 1
pref = [0]
for i in range(1, 2**n):
if i in hashi and i != x:
pref.append(i)
curr = x ^ i
if curr in hashi:
del hashi[curr]
if pref == [0]:
print(0)
else:
fina = []
... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN ... |
Given two integers $n$ and $x$, construct an array that satisfies the following conditions: for any element $a_i$ in the array, $1 \le a_i<2^n$; there is no non-empty subsegment with bitwise XOR equal to $0$ or $x$, its length $l$ should be maximized.
A sequence $b$ is a subsegment of a sequence $a$ if $b$ can be... | n, x = [int(x) for x in input().split()]
ans = []
vis = [0] * (2**18 + 1)
lmt = 2**n
xor = 0
vis[0], vis[x] = 1, 1
for i in range(1, lmt):
if vis[i]:
continue
ans.append(xor ^ i)
xor = i
vis[i] = 1
vis[i ^ x] = 1
print(len(ans))
print(*ans) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VA... |
Given two integers $n$ and $x$, construct an array that satisfies the following conditions: for any element $a_i$ in the array, $1 \le a_i<2^n$; there is no non-empty subsegment with bitwise XOR equal to $0$ or $x$, its length $l$ should be maximized.
A sequence $b$ is a subsegment of a sequence $a$ if $b$ can be... | n, x = map(int, input().split())
r = []
d = set()
for a in range(1, 2**n):
tmp = x ^ a
if tmp not in d and a not in d and a not in (0, x):
r.append(a)
d.add(a)
if not r:
print(0)
else:
res = [r[0]]
for i in range(1, len(r)):
res.append(r[i - 1] ^ r[i])
print(len(res))
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR VAR VAR VAR NUMBER VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST VAR NUMBER FOR VAR F... |
Given two integers $n$ and $x$, construct an array that satisfies the following conditions: for any element $a_i$ in the array, $1 \le a_i<2^n$; there is no non-empty subsegment with bitwise XOR equal to $0$ or $x$, its length $l$ should be maximized.
A sequence $b$ is a subsegment of a sequence $a$ if $b$ can be... | n, x = map(int, input().split())
a = [(True) for i in range(pow(2, n))]
check = []
if x < pow(2, n):
a[x] = False
for i in range(1, pow(2, n)):
if a[i] == True:
check.append(i)
if x ^ i < pow(2, n):
a[x ^ i] = False
print(len(check))
if len(check) == 1:
print(check[0])
elif len(c... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR LIST IF VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR IF BIN_OP VAR VAR FUNC_CALL VAR NUMBE... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | I = input
k, s, t = int(I()), I(), I()
answer = [""] * k
res = ord(s[-1]) + ord(t[-1]) - 194
for j in range(k - 2, -1, -1):
res += 26 * (ord(s[j]) + ord(t[j]) - 194)
answer[j + 1] = chr(res // 2 % 26 + 97)
res //= 26
answer[0] = chr(res // 2 % 26 + 97)
print("".join(answer)) | ASSIGN VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST STRING VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER VAR BIN_OP NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR VAR FUNC_C... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | n = int(input())
s = input()
t = input()
suma = [(ord(s[i]) + ord(t[i]) - 194) for i in range(n)]
for i in range(n - 1):
j = n - 1 - i
if suma[j] > 25:
suma[j] -= 26
suma[j - 1] += 1
chuj = 0
if suma[0] == 26:
chuj = 1
suma[0] = 0
print(chr(110), end="")
for i in range(chuj == 1, n):... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR IF VAR VAR NUMBER VAR VAR NUMBER VAR BIN_OP VAR NUMBE... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | def add(a, b):
c = []
z = 0
for i in range(k - 1, -1, -1):
x = ord(a[i]) - ord("a")
y = ord(b[i]) - ord("a")
if x + y + z >= 26:
c.append(x + y + z - 26)
z = 1
else:
c.append(x + y + z)
z = 0
if z:
c.append(z)
re... | FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING IF BIN_OP BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER ASSIGN... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | n = int(input())
s = input()
t = input()
dic = [
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z",
]
slis = []
tlis = []
for i in s:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING ASSIGN VAR LIST ASSIGN VAR LIST F... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | k = int(input())
ALPHABET = "abcdefghijklmnopqrstuvwxyz"
SIZE = len(ALPHABET)
ALPHABET_TO_NUMBER = dict(zip(ALPHABET, range(len(ALPHABET))))
big_sum = [
(ALPHABET_TO_NUMBER[l] + ALPHABET_TO_NUMBER[u]) for l, u in zip(input(), input())
]
additional = 0
for index in range(k - 1, 0, -1):
big_sum[index] += addition... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER VAR... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | import sys
class Main:
def __init__(self):
self.buff = None
self.index = 0
def next(self):
if self.buff is None or self.index == len(self.buff):
self.buff = sys.stdin.readline().split()
self.index = 0
val = self.buff[self.index]
self.index += 1... | IMPORT CLASS_DEF FUNC_DEF ASSIGN VAR NONE ASSIGN VAR NUMBER FUNC_DEF IF VAR NONE VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER RETURN VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | BASE = 26
def str2num(s):
return [(ord(x) - ord("a")) for x in reversed(s)]
def num2str(number):
return "".join(chr(x + ord("a")) for x in number)
def add(x, y):
k = len(x)
result = [0] * (k + 1)
memory = 0
for i in range(k):
memory, result[i] = divmod(x[i] + y[i] + memory, BASE)
... | ASSIGN VAR NUMBER FUNC_DEF RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING VAR FUNC_CALL VAR VAR FUNC_DEF RETURN FUNC_CALL STRING FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR STRING VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR A... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | n = int(input())
ss = input()
s = ss[::-1]
t = input()[::-1]
tt = [0] * n
for i in range(n):
c = ord(s[i]) - ord("a")
tt[i] = ord(t[i]) - ord("a")
tt[i] -= c
for i in range(n - 1):
if tt[i] < 0:
tt[i] += 26
tt[i + 1] -= 1
tt = tt[::-1]
rem = 0
for i in range(n):
rem = rem * 26 + tt[i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING VAR VAR VAR FOR ... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | f = lambda s: [(ord(c) - ord("a")) for c in s]
n = int(input())
a = f(input())
b = f(input())
c = [0]
for i in range(n - 1, -1, -1):
c[-1] += a[i] + b[i]
m = c[-1] // 26
c[-1] %= 26
c.append(m)
c.reverse()
for i in range(n + 1):
if c[i] & 1:
c[i + 1] += 26
c[i] >>= 1
print("".join(chr(or... | ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER VAR NUMBER BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBE... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | def plus(a, b):
c = ""
i = len(a) - 1
arg = 0
while i >= 0:
k = (arg + ord(a[i]) + ord(b[i])) % 26
if arg + ord(a[i]) + ord(b[i]) < 26:
arg = 0
else:
arg = 1
i -= 1
c = chr(k) + c
if arg:
c = chr(1) + c
return c
def minus(... | FUNC_DEF ASSIGN VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER IF BIN_OP BIN_OP VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER ASSIGN VA... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | BASE = 26
def convertToNum(s):
n = len(s)
ret = [-1] * n
for i in range(n - 1, -1, -1):
ret[i] = ord(s[i]) - ord("a")
return ret
def substract(a, b):
n = len(a)
ret = [-1] * n
for i in range(n - 1, -1, -1):
if b[i] > a[i]:
a[i] += BASE
a[i - 1] -= ... | ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | n = int(input())
a = list(input())
b = list(input())
num_a = [(ord(i) - 97) for i in a]
num_b = [(ord(i) - 97) for i in b]
num = [(0) for i in range(n)]
carry = 0
for i in range(n - 1, -1, -1):
if i == 0:
num[i] = num_a[i] + num_b[i] + carry
continue
add = num_a[i] + num_b[i] + carry
carry =... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUM... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | n = int(input())
s, t = input(), input()
a = [(ord(i) - ord("a")) for i in s]
b = [(ord(i) - ord("a")) for i in t]
a, b, c = a[::-1], b[::-1], [0] * (n + 1)
for i in range(n):
c[i] = c[i] + a[i] + b[i]
c[i + 1] = c[i] // 26
c[i] = c[i] % 26
c = c[::-1]
if c[0] == 0:
c = c[1:]
ans = []
ost = 0
for digit ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING VAR VAR ASSIGN VAR VAR VAR VAR NUMBER VAR NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSI... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | k = int(input())
s = input()
t = input()
num = [0] * k
num2 = [0] * k
alth = "abcdefghijklmnopqrstuvwxyz"
for i in range(k):
num[i] = alth.find(s[i])
num2[i] = alth.find(t[i])
num3 = [0] * k
rem = 0
for i in range(k - 1, -1, -1):
num3[i] = num2[i] - num[i] - rem
if num3[i] < 0:
num3[i] += 26
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR ... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | n = int(input())
a = [(ord(c) - 97) for c in input()]
b = [(ord(c) - 97) for c in input()]
ans = []
p = n - 1
bemp = b[p] + a[p]
while p > 0:
p -= 1
bemp += (b[p] + a[p]) * 26
ans.append(chr(int(bemp / 2) % 26 + 97))
bemp //= 26
ans.append(chr(int(bemp / 2) % 26 + 97))
p = n
while p:
p -= 1
prin... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR VAR WHILE VAR NUMBER VAR NUMBER VAR BIN_OP BIN_OP VAR VAR VAR VAR NUMBER EXPR FUNC_C... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | k = int(input())
A = list(input())[::-1]
B = list(input())[::-1]
C = []
pivot = (ord("z") - ord("a") + 1) // 2
for i in range(k):
a, b = ord(A[i]), ord(B[i])
if (b - a) % 2 == 0:
C += [chr((a + b) // 2)]
elif ord(C[-1]) - ord("a") >= pivot:
C[-1] = chr(ord(C[-1]) - pivot)
C += [chr((... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR BIN_OP BIN_OP BIN_OP FUNC_CALL VAR STRING FUNC_CALL VAR STRING NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | letters = [
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z",
]
k = int(input())
s = input()
t = input()
med = [(0) for i in range(k)]
f... | ASSIGN VAR LIST STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL V... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | k = int(input())
s = list(map(lambda x: ord(x) - ord("a"), input()))
t = list(map(lambda x: ord(x) - ord("a"), input()))
sum_ = []
old = 0
for i in reversed(range(k)):
s_ = s[i] + t[i] + old
new = s_ % 26
sum_.append(new)
old = s_ // 26
sum_.append(old)
sum_ = list(reversed(sum_))
for i in range(k + 1):... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VA... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | n = int(input())
a = [(ord(c) - 97) for c in input()]
b = [(ord(c) - 97) for c in input()]
ans = []
for i in range(n):
sum = a[i] + b[i]
if i + 1 < n:
a[i + 1] += sum % 2 * 26
sum //= 2
ans.append(sum)
for i in range(n - 1, -1, -1):
if i - 1 > -1:
ans[i - 1] += ans[i] // 26
ans[i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR IF BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER VAR ... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | n = int(input())
a = list(input())
b = list(input())
dic = {}
dic2 = {}
ans = [(0) for _ in range(n)]
for i in range(26):
text = chr(97 + i)
dic[text] = i
dic2[str(i)] = text
for i in range(n - 1, -1, -1):
down = dic[a[i]]
if ord(b[i]) < 97:
up = 25
b[i - 1] = chr(ord(b[i - 1]) - 1)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | dic = {}
dic2 = {}
for i in range(97, 123):
dic[chr(i)] = i
dic2[i] = chr(i)
k = int(input())
word1 = input()
word2 = input()
ords = []
carry = 0
for i in range(k):
c = dic[word1[i]] + dic[word2[i]] + carry
carry = 0
if c % 2 == 1:
carry = 26
ords.append(c // 2)
for i in range(k - 1, -1,... | ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | k = int(input())
def f(s):
r = [0] * k
for i, c in enumerate(s):
r[i] = ord(c) - ord("a")
return r
s = input()
t = input()
sr = f(s)
st = f(t)
for i in range(k - 1, -1, -1):
sr[i] += st[i]
if i > 0:
sr[i - 1] += sr[i] // 26
sr[i] %= 26
for i in range(k):
r = sr[i] % 2... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING RETURN VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
N = int(input())
S = [(ord(c) - ord("a")) for c in input()[:-1]]
T = [(ord(c) - ord("a")) for c in input()[:-1]]
ans = []
p = N - 1
bemp = S[p] + T[p]
while p > 0:
p -= 1
bemp += (S[p] + T[p]) * 26
ans.append(chr(bemp // 2 % 26 + ord("a")))... | IMPORT EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | def main():
n = int(input())
s = input()
k = input()
arr = [0] + [(ord(s[i]) + ord(k[i]) - 2 * ord("a")) for i in range(n)]
for i in range(n, -1, -1):
if arr[i] >= 26:
arr[i] -= 26
arr[i - 1] += 1
for i in range(n, -1, -1):
if arr[i] % 2:
arr[i... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR BIN_OP NUMBER FUNC_CALL VAR STRING VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF VAR VAR NUMBER VAR VAR NUMBER VAR ... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | n = int(input())
s1 = input()
s2 = input()
m = ord("z") - ord("a") + 1
s1 = list(reversed(s1))
s2 = list(reversed(s2))
s3 = []
c = 0
for i in range(n):
t = ord(s1[i]) + ord(s2[i]) - 2 * ord("a") + c
s3.append(chr(t % m + ord("a")))
c = t // m
if c != 0:
s3.append(chr(c + ord("a")))
s3 = list(reversed(s3... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR STRING FUNC_CALL VAR STRING NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR ... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | from sys import stdin
def ip():
return [int(i) for i in stdin.readline().split()]
def sp():
return [str(i) for i in stdin.readline().split()]
def pp(A):
for i in A:
print(i)
def solve():
n = int(input())
s = [0] + list(str(input()))
t = [0] + list(str(input()))
for i in range... | FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF FOR VAR VAR EXPR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FU... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | import sys
input = sys.stdin.readline
k = int(input())
s = input().rstrip()
t = input().rstrip()
ss = [(ord(s[i]) - ord("a")) for i in range(k)]
tt = [(ord(t[i]) - ord("a")) for i in range(k)]
z = [(ss[i] + tt[i]) for i in range(k)]
for i in range(1, k)[::-1]:
if z[i] // 26:
z[i] %= 26
z[i - 1] += ... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR V... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | n = int(input())
s = input()
t = input()
c = ord("a")
l = [(0) for i in range(n)]
for i in range(n):
l[-1 - i] += ord(s[i]) - c + 1
l[-1 - i] += ord(t[i]) - c + 1
for i in range(n - 1, -1, -1):
if l[i] % 2 and i != 0:
l[i - 1] += 26
l[i] = l[i] // 2
for i in range(0, n):
if l[i] > 26:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR BIN_OP NUMBER VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR VAR NUMBER VAR BIN_OP NUMBER VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR VAR NU... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | def b26sub(a, b, n, c):
for i in range(n - 1, -1, -1):
if a[i] > b[i]:
b[i] += 26
b[i - 1] -= 1
c[i] = b[i] - a[i]
def b26add(a, b, n, c):
car = 0
for i in range(n - 1, -1, -1):
x = a[i] + b[i] + car
car = x // 26
c[i] = x % 26
def b26div2(... | FUNC_DEF FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR VAR VAR VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR VAR VAR VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER A... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | n = int(input(""))
a = input("")
b = input("")
c = [(0) for _ in range(n + 1)]
for i in range(n - 1, -1, -1):
aa = ord(a[i]) - ord("a")
bb = ord(b[i]) - ord("a")
c[i + 1] += aa + bb
if c[i + 1] >= 26:
c[i] += c[i + 1] // 26
c[i + 1] %= 26
def show_str(l):
out = ""
for item in l... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR F... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | k = int(input())
s = input()
t = input()
val = [(0) for i in range(0, k)]
nval = [(0) for i in range(0, k)]
for i in range(0, k):
val[i] = ord(s[i]) - ord("a") + ord(t[i]) - ord("a")
ans = ["a" for i in range(0, k)]
carry = 0
for i in range(0, k):
ncarry = 0
t = val[i] // 2 + carry
if val[i] % 2 == 1:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR VAR VAR FUN... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | def divide_2(a, m):
r = 0
q = []
for x in a:
cur = r * m + x
q.append(cur // 2)
r = cur % 2
return q
def add(s, t, m):
r = 0
a = []
for x, y in zip(s[::-1], t[::-1]):
cur = r + x + y
a.append(cur % m)
r = cur // m
if r != 0:
a.app... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR BIN_... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | from sys import stdin
class base:
def __init__(self, s, base):
self.num, self.base = [0] + s, base
def __add__(self, other):
out = base([0] * (max(len(other.num), len(self.num)) - 1), self.base)
carry = 0
for i in range(len(self.num) - 1, -1, -1):
su = self.num[i]... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR BIN_OP LIST NUMBER VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR IF VAR ... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | k = int(input())
a = reversed(input())
b = reversed(input())
aa = [0] * (k + 1)
bb = [0] * (k + 1)
for i, x in enumerate(a):
aa[i] = ord(x) - 97
for i, x in enumerate(b):
bb[i] = ord(x) - 97
carry = 0
cc = [0] * (k + 1)
for i in range(k + 1):
cc[i] = aa[i] + bb[i] + carry
if cc[i] >= 26:
carry =... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR ... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | dicti = {}
for i in range(26):
dicti[chr(97 + i)] = i + 1
k = int(input())
str1 = list(input())
str2 = list(input())
delta = []
for i in range(k):
str1[i] = dicti[str1[i]]
str2[i] = dicti[str2[i]]
delta.append(str2[i] - str1[i])
for i in range(k - 1, 0, -1):
if delta[i] < 0:
delta[i - 1] -= ... | ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR E... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | length = int(input())
start = input()
slist = [(ord(char) - 97) for char in start]
end = input()
elist = [(ord(char) - 97) for char in end]
result = []
weirdnumber = 0
for i in range(0, length, 1):
dif = (elist[i] + slist[i]) / 2 + weirdnumber
weirdnumber = 0
if int(dif) != dif:
result.append(int(di... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR NUMBER ... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | n = int(input())
s1 = [(ord(x) - 97) for x in input()]
s2 = [(ord(x) - 97) for x in input()]
s12s = s1[n - 1] + s2[n - 1]
res = []
ni = n - 1
while ni > 0:
ni -= 1
s12s += (s1[ni] + s2[ni]) * 26
res.append(chr(s12s // 2 % 26 + 97))
s12s = s12s // 26
res.append(chr(s12s // 2 % 26 + 97))
ni = n
while ni >... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR LIST ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR NUMBER VAR BIN_OP BIN_OP VAR VA... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | def to_cc26(s):
result = [(ord(v) - ord("a")) for v in s]
result.reverse()
return result
def to_number(a):
result = 0
mult = 1
for v in a:
result += v * mult
mult *= 26
return result
def minus(b, a):
index = 0
result = []
additional = 0
while index < len(b... | FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING VAR VAR EXPR FUNC_CALL VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR BIN_OP VAR VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR VAR VAR... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | def main():
k = int(input())
s = list(reversed(input()))
t = list(reversed(input()))
st = [0] * (k + 1)
carry = 0
for pos in range(0, k):
s_pos = ord(s[pos]) - ord("a")
t_pos = ord(t[pos]) - ord("a")
total = s_pos + t_pos + carry
carry = total // 26
total ... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING ASSIGN... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | N = int(input())
s = input()
t = input()
def stoi(s):
return ord(s) - 97
def itos(i):
return chr(97 + i)
def stoL(s):
L = []
for ss in s:
L.append(stoi(ss))
return L
A = stoL(s)
B = stoL(t)
C = [(A[i] + B[i]) for i in range(N)]
for i in range(1, N)[::-1]:
if C[i] >= 26:
C... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF RETURN BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR BIN_OP NUMBER VAR FUNC_DEF ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL ... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | from itertools import accumulate
n, s, t = int(input()), input(), input()
a = [0] + [(ord(s[i]) + ord(t[i]) - (ord("a") << 1)) for i in range(n)]
for i in range(n, -1, -1):
if a[i] >= 26:
a[i] -= 26
a[i - 1] += 1
for i in range(n, -1, -1):
if a[i] & 1:
a[i + 1] += 13
a[i] >>= 1
prin... | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR STRING NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF VAR VAR NUMBER VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBE... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | def array_of(f, *dim):
return [array_of(f, *dim[1:]) for _ in range(dim[0])] if dim else f()
def atoi(c):
return ord(c) - ord("a")
def itoa(i):
return chr(i + ord("a"))
n = int(input())
s, t = input(), input()
s = list(map(atoi, reversed(s)))
t = list(map(atoi, reversed(t)))
ss = array_of(int, n + 1)
... | FUNC_DEF RETURN VAR FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR FUNC_DEF RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING FUNC_DEF RETURN FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL V... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | n = int(input())
s = input()
t = input()
def f(x):
return ord(x) - ord("a")
def g(x):
return chr(x + ord("a"))
A = []
for i in range(n):
A.append(f(s[i]) + f(t[i]))
for i in range(n - 1, 0, -1):
if A[i] // 26:
A[i - 1] += 1
A[i] %= 26
for i in range(n):
if A[i] % 2:
A[i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING FUNC_DEF RETURN FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | input()
a = input()
b = input()
x = []
y = []
for c in a:
x.append(ord(c) - 97)
for c in b:
y.append(ord(c) - 97)
result = [(u + v) for u, v in zip(x, y)]
for i in range(len(result) - 1, 0, -1):
result[i - 1] += result[i] // 26
result[i] %= 26
for i, r in enumerate(result):
if r % 2 == 1:
re... | EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CAL... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | def decto26(n):
a = []
while n > 0:
a.insert(0, n % 26)
n //= 26
return a
def f26todec(a):
n = 0
l = len(a) - 1
for i in a:
n += i * 26**l
l -= 1
return n
def sum26(a, b, n):
q = 0
c = []
for i in range(n + 1):
c.append(0)
for i in ... | FUNC_DEF ASSIGN VAR LIST WHILE VAR NUMBER EXPR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR VAR VAR BIN_OP VAR BIN_OP NUMBER VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR... |
You are given two strings $s$ and $t$, both consisting of exactly $k$ lowercase Latin letters, $s$ is lexicographically less than $t$.
Let's consider list of all strings consisting of exactly $k$ lowercase Latin letters, lexicographically not less than $s$ and not greater than $t$ (including $s$ and $t$) in lexicograp... | orda = ord("a")
ord0 = ord("z") - orda + 1
n = int(input())
s = input()
t = input()
sv = [(ord(si) - orda) for si in s]
tv = [(ord(ti) - orda) for ti in t]
medv = [(ord(si) - orda) for si in s]
for i in range(n - 1, -1, -1):
medv[i] += tv[i]
if i > 0 and medv[i] >= ord0:
medv[i] -= ord0
medv[i -... | ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR VAR VA... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.