description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | ans = []
for _ in range(int(input())):
n, k = map(int, input().split())
otv = []
if k != n - 1:
otv.append([k, n - 1])
if k != 0:
otv.append([n - k - 1, 0])
i = 1
while i < n - i - 1:
if i != k and i != n - k - 1 and n - i - 1 != k and n - i - 1 != n -... | ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR LIST VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR LIST BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP B... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | def func():
n, k = map(int, input().split())
a = [(0) for i in range(n // 2)]
b = [(0) for i in range(n // 2)]
if k == 0:
for i in range(n // 2):
a[i], b[i] = i, i ^ n - 1
elif k > 0 and k < n - 1:
itr = min(k, k ^ n - 1)
for i in range(n // 2):
if i !... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR VAR BIN_OP VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR BIN_OP VAR NUMBER ... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | for t in range(int(input())):
n, k = map(int, input().split())
if k == n - 1 and n == 4:
print(-1)
continue
used = set()
if k == n - 1:
for i in range(n - 1):
if i in used:
continue
if i == 0:
print(i, n - 1 - 3)
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP BIN_OP... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | import sys
input = sys.stdin.readline
t = int(input().strip())
def comp(x, n):
return n - 1 ^ x
for _ in range(t):
n, k = map(int, input().split())
if k == 0:
for i in range(n // 2):
print(i, comp(i, n))
elif k < n - 1:
print(k, n - 1)
print(0, comp(k, n))
... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR IF VAR BIN_OP VAR NUMB... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | def c(n, i):
return n - i - 1
def solve(n, k):
if k == 0:
for i in range(n // 2):
print(i, c(n, i))
elif k < n - 1:
ignore = [0, k, c(n, k), n - 1]
print(0, c(n, k))
print(k, n - 1)
for i in range(n // 2):
if i in ignore:
cont... | FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR NUMBER FUNC_DEF IF VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR LIST NUMBER VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR BIN_... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | tc = int(input())
for t in range(tc):
n, k = map(int, input().split())
if n == 4 and k == 3:
print(-1)
elif n == 2:
if k == 0:
print("0 1")
else:
print(-1)
else:
nums = list()
for i in range(n // 2):
nums.append([0, 0])
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EX... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | import sys
for _ in range(int(sys.stdin.readline())):
n, k = map(int, sys.stdin.readline().split())
if k > n * (n - 2) / 4:
print(-1)
else:
if k != 0 and k != n - 1:
print(k, n - 1)
print(0, k ^ n - 1)
elif k == 0:
print(0, n - 1)
else:
... | IMPORT FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBE... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | for _ in range(int(input())):
n, m = map(int, input().split())
arr = [i for i in range(n)]
if n == 4 and m == 3:
print(-1)
continue
if n == m + 1:
arr[0], arr[m - 1] = arr[m - 1], arr[0]
arr[1], arr[n - 4] = arr[n - 4], arr[1]
else:
arr[0], arr[m] = arr[m], ar... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR BIN_O... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | cases = int(input())
for _ in range(cases):
n, k = map(int, input().split())
if k == 0:
for i in range(n // 2):
print("%d %d" % (i, n - 1 ^ i))
elif k == n - 1:
if n == 4:
print("-1")
else:
print("%d %d" % (n - 1, n - 2))
print("1 %d" %... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP STRING VAR BIN_OP BIN_OP VAR NUMBER VAR IF VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CAL... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | test_cases = int(input())
for _ in range(test_cases):
a = list(map(int, input().split()))
n = a[0]
k = a[1]
if n == 4 and k == 3:
print(-1)
elif k == 0:
for i in range(0, n // 2):
print(f"{i} {n - i - 1}")
elif k < n - 1:
print(f"{n - 1} {k}")
print(f"... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR STRING BI... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | T = int(input())
for t in range(T):
n, k = list(map(int, input().split()))
if k == n - 1:
if n == 4:
print(-1)
else:
print(n - 2, n - 1)
print(1, 3)
print(0, n - 4)
a, b = 2, n - 3
for i in range(n // 2 - 2):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER BIN_O... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | def swap_partners(a, b, l):
a_index = -1
b_index = -1
for i, pair in enumerate(l):
if a in pair:
a_index = i
if b in pair:
b_index = i
if l[a_index][0] != a:
l[a_index] = l[a_index][::-1]
if l[b_index][0] != b:
l[b_index] = l[b_index][::-1]
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR IF VAR VAR ASSIGN VAR VAR IF VAR VAR NUMBER VAR ASSIGN VAR VAR VAR VAR NUMBER IF VAR VAR NUMBER VAR ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR FOR VAR FUNC_CALL VAR FUNC... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | import sys
ip = sys.stdin.readline
for _ in range(int(ip())):
n, k = map(int, ip().split())
vis = [(False) for _ in range(n)]
ans = []
if n - 1 == k:
if n - 1 == 3:
print(-1)
else:
vis[n - 2] = vis[n - 1] = True
ans.append((n - 2, n - 1))
... | IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR LIST IF BIN_OP VAR NUMBER VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER NUMBE... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | def solve():
n, k = map(int, input().split())
res = 0
if n == 4 and k == 3:
print(-1)
return
pool = set([i for i in range(n)])
pairs = []
if k < n - 1:
pairs.append((k, n - 1))
print(k, n - 1)
res += k & n - 1
pool.remove(k)
pool.remove(n -... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR ... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | def find_pairs(n, k):
if n == 2:
if k == 1:
print(0, 1)
else:
print(-1)
elif k == 0:
for i in range(n // 2):
print(i, n - i - 1)
elif n == 4 and k == 3:
print(-1)
elif k != n - 1:
print(k, n - 1)
print(0, n - k - 1)
... | FUNC_DEF IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER E... |
You are given a set of $n$ ($n$ is always a power of $2$) elements containing all integers $0, 1, 2, \ldots, n-1$ exactly once.
Find $\frac{n}{2}$ pairs of elements such that:
Each element in the set is in exactly one pair.
The sum over all pairs of the bitwise AND of its elements must be exactly equal to $k$. Forma... | t = int(input())
while t != 0:
n, summ = [int(x) for x in input().split()]
if summ == n - 1:
if summ == 3:
print(-1)
else:
print(n - 2, n - 1)
print(1, n - 3)
print(0, 2)
l = 3
while l < n // 2:
if l != summ ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | import sys
def length(n):
i = 0
while n >= pow(2, i):
i += 1
return i
def minmax(a):
c = []
for i in range(len(a)):
if not i:
c.append([a[i]])
elif length(a[i]) == length(a[i - 1]):
c[-1].append(a[i])
else:
c.append([a[i]])
... | IMPORT FUNC_DEF ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR NUMBER VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR EXPR FUNC_CALL VAR LIST VAR VAR IF FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR VAR EXPR FUNC_CALL VAR LIST VAR VA... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | from itertools import *
int(input())
a = sorted(list(map(int, input().split())))
if a[0] == a[-1]:
print(0)
else:
k = 30
while not (a[0] ^ a[-1]) >> k & 1:
k -= 1
print(
min(
i ^ j
for i, j in product(
[i for i in a if i >> k & 1], [i for i in a if not i >> k & 1]
... | EXPR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR FUNC_CALL ... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | input()
numlist = [int(num) for num in input().split()]
big, small = numlist[0], numlist[0]
for num in numlist:
big = max(num, big)
small = min(num, small)
dist = big ^ small
k = len("{0:b}".format(dist))
split = big >> k - 1 << k - 1
bignums = []
smallnums = []
for num in numlist:
if num >= split:
... | EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | def bitize(n, bits=32):
max_bit = -1
L = [(0) for i in range(0, bits)]
if n == 0:
return [L, -1]
for i in range(0, bits):
if n == 0 and max_bit == -1:
max_bit = i - 1
L[i] = n % 2
n //= 2
return [L, max_bit]
def find_min_max(A):
BA = [bitize(a) for a... | FUNC_DEF NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR IF VAR NUMBER RETURN LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER VAR NUMBER RETURN LIST VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIG... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | import sys
def find_answer(bin_l):
while True:
len_set = set(map(lambda x: len(x), bin_l))
if len(len_set) > 1:
break
if 0 in len_set or bin_l[0][0] == "0":
return 0
bin_l = list(map(lambda x: bin(int(x[1:], 2)), bin_l))
max_len = max(map(lambda x: len(x... | IMPORT FUNC_DEF WHILE NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER IF NUMBER VAR VAR NUMBER NUMBER STRING RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | def solve(As):
a = max(As)
b = -1
while a > 0:
a >>= 1
b += 1
if b < 0:
return 0
l = 1 << b
while all(a & l for a in As):
l >>= 1
if l == 0:
return 0
Al = [a for a in As if not a & l]
Au = [a for a in As if a & l]
best = l << 1
for al i... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP NUMBER VAR WHILE FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR NUMBER IF VAR NUMBER RETURN NUMBER ASSIGN VAR VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | n = int(input())
a = list(map(int, input().split()[:n]))
a.sort(reverse=True)
lens = []
for i in range(n):
lens.append(len(bin(a[i])[2:]))
mmlen = lens[0]
xor = 10**9
start = n
for i in range(len(a)):
if mmlen != lens[i]:
start = i
break
while start == n:
if mmlen == 1:
xor = 0
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR FOR VAR FUN... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | import itertools as it
l = int(input())
arr = [int(num) for num in input().split(" ")]
arr = list(set(arr))
arr_tup = [(num, len(bin(num))) for num in arr]
max_bin = max(arr_tup, key=lambda x: x[1])[1]
set_big = {num[0] for num in arr_tup if num[1] == max_bin}
set_small = set(arr) - set_big
general_min = float("Inf")
... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER VAR VAR VAR NUMBER VAR ASSIGN VAR BIN_OP FU... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | n = int(input())
a = list(map(int, input().rstrip().split()))
if len(set(a)) == 1 and list(set(a))[0] == 0:
print(0)
else:
bitor = bitnot = 0
for number in a:
bitor |= number
bitnot |= ~number
i = bitor & bitnot
while i & i - 1:
i &= i - 1
xs = [number for number in a if ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR WHILE BIN_OP V... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | N = int(input())
v = list(map(int, input().split(" ")))
def findLeftOne(n):
h1 = 0
while n >> h1:
h1 += 1
return h1 - 1
biggest = []
shift = 0
eh = 0
while True:
for n in v:
if n & eh:
print(n)
n -= eh
shifted = n >> shift
if shifted:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR NUMBER RETURN BIN_OP VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER FOR VAR VAR IF BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR VAR V... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | def binary(a):
x = ""
while a > 0:
x = str(a % 2) + x
a //= 2
return x
def update(x):
x = x[1:]
i = 0
while i < len(x) and x[i] != "1":
i += 1
x = x[i:]
return x
n = int(input())
a = list(map(int, input().split()))
lengths = []
binary_a = {}
for i in range(len... | FUNC_DEF ASSIGN VAR STRING WHILE VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR STRING VAR NUMBER ASSIGN VAR VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUN... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | import sys
from itertools import groupby, product
input()
alist = sorted(int(c) for c in input().strip().split(" "))
while True:
blens = set(a.bit_length() for a in alist)
if len(blens) > 1:
break
blen = blens.pop()
if blen > 1:
alist = [(a ^ 1 << blen - 1) for a in alist]
else:
... | IMPORT EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING WHILE NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VA... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | def find_interesting_power_of_2(a):
biggest = max(a)
res = 1
bits = 1
while res < biggest:
res = res * 2
bits += 1
counters = [0] * bits
for ai in a:
for p in range(bits):
if ai & 1 << p != 0:
counters[p] += 1
for p in reversed(range(bits))... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR BIN_OP NUMBER VAR NUMBER VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR ... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | n = int(input().strip())
arr = map(int, input().strip().split(" "))
smax = set(arr)
other = set()
while True:
it = smax.copy()
smax.clear()
blmax = -1
for a in it:
bl = a.bit_length()
if bl > blmax:
other |= smax
smax.clear()
smax.add(a)
bl... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR WHILE NUMBER ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR IF VAR VAR VAR VAR EXPR FUNC_CALL V... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | n = int(input())
ns = [int(x) for x in input().split()]
res = 0
for x in ns:
for y in ns:
res = max(res, x ^ y)
bit = 1 << len(bin(res)[3:])
A = [x for x in ns if x & bit]
B = [x for x in ns if x & bit == 0]
for x in A:
for y in B:
res = min(res, x ^ y)
print(res) | 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 VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR VAR BIN_OP VAR VA... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | import sys
def anotherMinimaxProblem(a):
msb1 = []
msb0 = []
shifter = 32
allinone = 1
while allinone and shifter > 1:
shifter -= 1
msb1 = []
msb0 = []
for i in range(len(a)):
sh = a[i] >> shifter
if sh & 1 == 1:
msb1.append(a... | IMPORT FUNC_DEF ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR NUMBER VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | import sys
def anotherMinimaxProblem(a):
a_min = min(a)
a_max = max(a)
if a_min == a_max:
return 0
a_min_bin = bin(a_min)
a_max_bin = bin(a_max)
if len(a_min_bin) < len(a_max_bin):
barrier = 2 ** (len(a_max_bin) - 3)
else:
for i in range(2, len(a_min_bin)):
... | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR VAR A... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | def trim(a):
to_trim = max_length
for number in a:
for i in range(max_length):
if number[i] == "0":
to_trim = min(to_trim, i)
break
a = list(map(lambda x: x[to_trim:], a))
return a
def enrich():
for i in range(len(a)):
a[i] = "0" * (max_l... | FUNC_DEF ASSIGN VAR VAR FOR VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR RETURN VAR FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP BIN_OP STRING BIN_OP VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CAL... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | n, data, r = int(input()), [int(x) for x in input().split(" ")], 0
def cal1(hbuf, lbuf):
if len(hbuf) == 1 and len(lbuf) == 1:
return list(hbuf)[0] ^ list(lbuf)[0]
mm, ms = max(max(hbuf), max(lbuf)), 1
while ms <= mm:
ms += ms
mh = ms >> 1
lz1 = set([(y - mh) for y in filter(lambda... | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING NUMBER FUNC_DEF IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER RETURN BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER WHILE VAR VAR V... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | class Node:
def __init__(self, bit: int):
if bit != 0 and bit != 1:
raise ValueError(
"An argument called bit... maybe you should give it a value of either 0 or 1!"
)
self.bit = bit
self.children = [None, None]
def addNumber(root: Node, v: int):
... | CLASS_DEF FUNC_DEF VAR IF VAR NUMBER VAR NUMBER FUNC_CALL VAR STRING ASSIGN VAR VAR ASSIGN VAR LIST NONE NONE FUNC_DEF VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR IF VAR VAR NONE ASSIGN VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR NUMBER FUNC_DEF VAR WHILE FUNC_C... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | import sys
def permutation_gen(aa):
stack = [([], aa)]
while stack:
p, rest = stack.pop()
if not rest:
yield p
else:
for i, r in enumerate(rest):
stack.append((p + [r], rest[:i] + rest[i + 1 :]))
def score(aa):
rval = None
for a, b in z... | IMPORT FUNC_DEF ASSIGN VAR LIST LIST VAR WHILE VAR ASSIGN VAR VAR FUNC_CALL VAR IF VAR EXPR VAR FOR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR LIST VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR NONE FOR VAR VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR VAR ASSIGN VAR ... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | n = int(input())
a = list(map(int, input().split()))
try:
c = 1 << max(a).bit_length() - 1
while min(a) >= c:
a = [(i - c) for i in a]
c = 1 << max(a).bit_length() - 1
print(min(i ^ j for i in a for j in a if i < c and j >= c))
except:
print(0) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER BIN_OP FUNC_CALL FUNC_CALL VAR VAR NUMBER WHILE FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP NUMBER BIN_OP FUNC_CALL FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | n = int(input())
a = sorted([int(x) for x in input().split()])
idx = 0
while idx == 0 and a[-1] > 0:
max_bit = a[-1].bit_length()
while idx < n and a[idx].bit_length() < max_bit:
idx += 1
if idx == 0:
for i in range(n):
a[i] -= 1 << max_bit - 1
res = 0
if a[-1] > 0:
res = 1 <... | 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 WHILE VAR NUMBER VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER WHILE VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP NUMBER BIN_OP VAR NUMBE... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | import sys
def anotherMinimaxProblem(a, n):
if all(e == 0 for e in a):
return 0
digit_keys = {}
for elem in a:
count = 0
while elem > 0:
one = elem % 2
if one == 1:
digit_keys[count] = digit_keys.get(count, 0) + 1
elem //= 2
... | IMPORT FUNC_DEF IF FUNC_CALL VAR VAR NUMBER VAR VAR RETURN NUMBER ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VA... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | n = int(input())
a = list(map(int, input().split()))
bitlen = max(x.bit_length() for x in a)
if bitlen == 0:
print(0)
else:
mask = 1 << bitlen - 1
while mask != 0:
msbzeroes = set()
msbones = set()
for x in a:
if x & mask == 0:
msbzeroes.add(x)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF BI... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | n = input()
arr = list(map(int, input().split()))
barr = ["{0:b}".format(i) for i in arr]
l = max([len(i) for i in barr])
barr = [("0" * (l - len(i)) + i) for i in barr]
while all([(i[0] == "1") for i in barr]):
barr = [i[1:] for i in barr]
barr = sorted(barr)
i = 0
while i < len(barr) and barr[i][0] == "0":
i ... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL STRING VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP VAR FUNC_CALL VAR VAR VAR VAR VAR WHILE FUNC_CALL VAR VAR NUMBER STRING VAR VAR ASSIGN VAR VAR NUM... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | import sys
def solve(ar):
answer = 0
byLen = [
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],... | IMPORT FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | def get_closest_power_2(x):
if x == 0:
return 0
v = 1
while v <= x:
v <<= 1
return v >> 1
def get_mask(x, y):
assert x >= y
if y == 0:
return 0
p_x = get_closest_power_2(x)
p_y = get_closest_power_2(y)
assert p_x > 0 and p_y > 0
if p_x != p_y:
re... | FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER RETURN BIN_OP VAR NUMBER FUNC_DEF VAR VAR IF VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE BIN_OP VAR VAR NUMBER VAR ... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | n = int(input())
a = list(map(int, input().split()))
ind = 0
x = max(a)
while x:
ind += 1
x >>= 1
d = {}
for i in range(ind + 1):
d[i] = []
for el in a:
if el & 1 << i:
d[i].append(el)
while ind >= 0 and len(d[ind]) == n or len(d[ind]) == 0:
ind -= 1
if ind < 0:
break... | 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 FUNC_CALL VAR VAR WHILE VAR VAR NUMBER VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR LIST FOR VAR VAR IF BIN_OP VAR BIN_OP NUMBER VAR EXPR FUNC_CALL ... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | _ = int(input())
lst = list(map(int, input().split()))
def find_left_most_1(n):
cnt = 0
while n > 1:
n = n >> 1
cnt += 1
return cnt
def solution(lst):
max_n = max(lst)
if max_n == 0:
return 0
max_left = find_left_most_1(max_n)
all_max = set()
for i in lst:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | n = int(input())
a = [int(x) for x in input().split()]
M, m = max(a), min(a)
maxbit = 2 ** (len(bin(M)) - 3)
while m >= maxbit:
a = [(x - maxbit) for x in a]
M, m = M - maxbit, m - maxbit
maxbit = 2 ** (len(bin(M)) - 3)
small, large = [], []
for x in a:
if x < maxbit:
small.append(x)
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VA... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | def bin_len(number):
return len(bin(number)) - 2
def trim(numbers):
numbers = sorted(numbers)
min_bits, max_bits = bin_len(numbers[0]), bin_len(numbers[-1])
while min_bits == max_bits and max_bits > 1:
mask = 2 ** (min_bits - 1) - 1
numbers = [(n & mask) for n in numbers]
min_b... | FUNC_DEF RETURN BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER WHILE VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | n = int(input())
a = [int(x) for x in input().split()]
bit = 1
for x in a:
while x > bit:
bit <<= 1
while bit:
a0 = []
a1 = []
for x in a:
if x & bit:
a1.append(x)
else:
a0.append(x)
if a0 and a1:
small = bit << 1
for x0 in a0:
... | 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 VAR WHILE VAR VAR VAR NUMBER WHILE VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR IF BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER FOR VAR VAR... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | n = input()
arr = list(set(list(map(int, input().split()))))
arr2 = sorted(arr)
maxv = arr2[len(arr) - 1]
count = 0
while maxv > 0:
count = count + 1
maxv = maxv >> 1
if count == 0:
print(0)
else:
mask = 1 << count - 1
filteredtops = [(i ^ mask) for i in arr2 if i & mask == mask]
filteredbottoms... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VA... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | N = int(input())
arr = list(map(int, input().split()))
arrSmaller = [(0) for i in range(N)]
arrLarger = [(0) for i in range(N)]
numbersReduced = False
while not numbersReduced:
maxv = max(arr)
hsb = 1
while maxv >= hsb:
hsb *= 2
hsb //= 2
indLarger = 0
indSmaller = 0
for val in arr:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIG... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | input()
A = [int(i) for i in input().strip().split()]
k = 1 << max(A).bit_length()
while True:
P, Q = [], []
k >>= 1
for a in A:
if a & k:
P.append(a)
else:
Q.append(a)
if P and Q or k <= 1:
break
if P and Q:
best = P[0] ^ Q[0]
for p in P:
... | EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER FUNC_CALL FUNC_CALL VAR VAR WHILE NUMBER ASSIGN VAR VAR LIST LIST VAR NUMBER FOR VAR VAR IF BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR N... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | def bit_set(x, b):
return x & 1 << b != 0
def get_bit_options(arr, b):
foundZeros = False
foundOnes = False
for a in arr:
if bit_set(a, b):
foundOnes = True
else:
foundZeros = True
if foundOnes and foundZeros:
break
return foundZeros, fou... | FUNC_DEF RETURN BIN_OP VAR BIN_OP NUMBER VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR RETURN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | class MinMaxXor:
def __init__(self, arr, n):
self.n = n
self.a = list(sorted(arr))
self.mbl = self.a[n - 1].bit_length()
self.max_xor_sum = (1 << self.a[n - 1].bit_length()) - 1
self.splind = n
self.xor_sum = 0
self.reducer()
print(self.xor_sum)
... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FUNC_DEF WHILE VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | n = int(input())
arr = list(map(int, input().strip().split()))
mx = -1
mxarr, mnarr = [], []
for x in arr:
l = x.bit_length() - 1
if l > mx:
mxarr = [x]
mx = l
elif l == mx:
mxarr.append(x)
fil = list(filter(lambda x: x not in mxarr, arr))
anarr = []
if len(fil) == 0:
print(mxarr... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR LIST LIST FOR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER IF VAR VAR ASSIGN VAR LIST VAR ASSIGN VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | n = int(input())
a = [int(x) for x in input().split(" ")]
more = True
while more:
if not (len(a) and a[0].bit_length() > 0):
break
bitMask = 1 << a[0].bit_length() - 1
for val in a:
if 0 == val & bitMask:
more = False
break
if more:
bitMask = ~bitMask
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER WHILE VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP FUNC_CALL VAR NUMBER NUMBER FOR VAR VAR IF NUMBER BIN_OP VAR VAR ASSIGN VAR NUMBER IF VAR ASSIGN VAR VAR FOR... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | n = int(input())
a = list(map(int, input().split()))
max_num = max(a)
digits = len(bin(int(max_num))[2:])
a = [("0" * (digits - len(bin(int(i))[2:])) + bin(int(i))[2:]) for i in a]
while True:
for i in range(len(a)):
if a[i][0] == "0":
break
else:
a = [i[1:] for i in a]
conti... | 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 FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR FUNC_CALL V... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | import sys
def anotherMinimaxProblem(a):
a.sort()
t = 0
while 2**t <= a[-1]:
t += 1
ander = ["1" for x in range(t)]
if ander == []:
return 0
ander = int("".join(ander), 2)
ander2 = ander
for i in a:
ander = ander & i
ander2 = ander2 ^ ander
tt = 0
wh... | IMPORT FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE BIN_OP NUMBER VAR VAR NUMBER VAR NUMBER ASSIGN VAR STRING VAR FUNC_CALL VAR VAR IF VAR LIST RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING VAR NUMBER ASSIGN VAR VAR FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | def bit_length(k):
return k.bit_length()
def occurence(arr):
s = 0
for i in range(len(arr)):
if arr[i] == arr[0]:
s += 1
return s
def transf(ar, occ):
if occ == len(ar) and ar[0].bit_length() > 1:
a = ar[0].bit_length() - 1
for i in range(occ):
ar[... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF IF VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP NUMBER V... |
You are given $n$ non-negative integers, $a_0,a_1,\ldots,a_{n-1}$. We define the score for some permutation ($\boldsymbol{p}$) of length $n$ to be the maximum of $a_{p_i}\oplus a_{p_{i+1}}$ for $0\leq i<n-1$.
Find the permutation with the minimum possible score and print its score.
Note: $\oplus$ is the exclusive-OR... | n, a = int(input()), list(map(int, input().split()))
up, down = [], []
while len(down) == 0:
maxBit = 1 << max([len(bin(i)) for i in a]) - 3
for i in a:
if i >= maxBit:
up.append(i)
else:
down.append(i)
if len(down) == 0:
for i in range(n):
a[i] ^=... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST LIST WHILE FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR NUMBER FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF ... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | n = int(input())
arr = [int(_) for _ in input("").split()]
p = n // 2
if n % 2 == 0:
p = (n - 1) // 2
xor = arr[0]
for i in range(1, n):
xor ^= arr[i]
if n % 2 != 0 or xor == 0 and n % 2 == 0:
print("YES")
print(2 * p - 1)
a = 1
for i in range(p):
print(a, a + 1, a + 2)
a += 2
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER BIN_OP VAR ... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | n = int(input())
a = list(map(int, input().split()))
if n % 2 == 1:
print("YES")
print(n - 1)
for i in range(n // 2):
print(2 * i + 1, 2 * i + 2, n)
for i in range(n // 2):
print(2 * i + 1, 2 * i + 2, n)
else:
ct = [0] * 31
for x in a:
for bit in range(31):
ct... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER ... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | from sys import stdin
input = stdin.readline
def solve():
n = int(input())
a = list(map(int, input().split()))
if n & 1 == 0:
s = 0
for i, v in enumerate(a):
s ^= v
if s != 0:
print("NO")
return
print("YES")
last = n if n & 1 == 1 else n... | ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER NUMB... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | c = 0
n = int(input())
ans = list(map(int, input().split()))
if n % 2 == 0:
xor = 0
for i in ans:
xor = xor ^ i
if xor != 0:
print("NO")
else:
print("YES")
n = n - 1
num = n // 2
print(num + num - 1)
oper = num + num - 1
i = 1
while... | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | t = 1
while t > 0:
t -= 1
n = int(input())
l = list(map(int, input().split()))
flag = 1
if n % 2 == 0:
total = 0
for i in range(n):
total ^= l[i]
if total != 0:
flag = 0
exit
n -= 1
if flag == 0:
print("NO")
else:
... | ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER EXPR VAR VAR NUMBER IF VAR NUMBER ... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | n = int(input())
s = input()
list1 = s.split()
t = 0
for i in range(n):
t = t ^ int(list1[i])
if n % 2 == 0 and t != 0:
print("NO")
elif n % 2 == 0:
print("YES")
n = n - 1
print(n - 2)
for i in range(1, n - 1, 2):
print(i, i + 1, i + 2)
i = n - 2
while i >= 3:
print(i - 2... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NU... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | n = int(input())
l = [int(x) for x in input().split()]
xx = 0
for i in l:
xx = xx ^ i
if n % 2 == 0 and xx != 0:
print("NO")
else:
print("YES")
ans = []
for i in range(3, n + 1, 2):
ans.append([i - 2, i - 1, i])
for i in range(2, n, 2):
ans.append([i - 1, i, n])
print(len(ans... | 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 VAR ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER EXPR FU... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | from sys import stdin
def c(i, j, k):
tmp = a[i] ^ a[j] ^ a[k]
a[i] = tmp
a[j] = tmp
a[k] = tmp
tt = 1
for loop in range(tt):
n = int(stdin.readline())
a = list(map(int, stdin.readline().split()))
if n % 2 == 1:
ans = []
for i in range(0, n - 2, 2):
ans.append... | FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUN... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | n = int(input())
a = list(map(int, input().split()))
res = "YES"
if n % 2 != 0:
res = "YES"
else:
xor = 0
n -= 1
for i in a:
xor ^= i
if xor == 0:
res = "YES"
else:
res = "NO"
if res == "YES":
print("YES")
print(n - 1)
i = 1
while i < n:
print(1, i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR STRING ASSIGN VAR NUMBER VAR NUMBER FOR VAR VAR VAR VAR IF VAR NUMBER ASSIGN VAR STRING ASSIGN VAR STRING IF VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_C... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | import sys
input = sys.stdin.readline
def main():
n = int(input())
alst = list(map(int, input().split()))
if n % 2 == 1:
print("YES")
ans = []
for i in range(3, n + 1, 2):
ans.append([i - 2, i - 1, i])
for i in range(3, n - 1, 2):
ans.append([i - 2,... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR LIST BIN_OP VAR NUMBER BIN_OP VAR NUMBER... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | n = int(input())
a = list(map(int, input().split()))
f = 0
even = False
if n % 2 == 0:
even = True
xor = a[0]
for i in a[1:]:
xor = xor ^ i
if xor != 0:
f = 1
if f == 1:
print("NO")
else:
print("YES")
if not even:
print(n // 2 + n // 2)
for i in range(0, n - 1... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR ... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | from sys import exit
n = int(input())
a = [int(i) for i in input().split()]
if n % 2 == 0:
kek = 0
for el in a:
kek ^= el
if kek != 0:
print("NO")
exit(0)
else:
n -= 1
print("YES")
print(n - 1)
for i in range((n - 1) // 2):
print(1, 2 * (i + 1), 2 * (i + 1) + 1)
for ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL ... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | n = int(input())
a = [int(x) for x in input().split()]
xor = 0
if len(a) % 2 == 0:
for i in a:
xor ^= i
if n % 2 == 0 and xor != 0:
print("NO")
else:
print("YES")
arr = [(i, i + 1, i + 2) for i in range(1, n - 1, 2)]
arr += arr[::-1][1:]
print(len(arr))
for i, j, k in arr:
pr... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VA... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | import sys
sys.setrecursionlimit(10**5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II():
return int(sys.stdin.buffer.readline())
def MI():
return map(int, sys.stdin.buffer.readline().split())
def LI():
return list(map(int, sys.stdin.buffer.readline().split()))
def LLI(rows_... | IMPORT EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | import sys
input = sys.stdin.readline
n = int(input())
arr = list(map(int, input().split()))
ans = []
for i in range(0, len(arr) - 2, 2):
arr[i] = arr[i + 1] = arr[i + 2] = arr[i] ^ arr[i + 1] ^ arr[i + 2]
ans.append((i, i + 1, i + 2))
for i in range(0, len(arr) - 2, 2):
arr[i] = arr[i + 1] = arr[i] ^ arr[... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR B... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | from sys import stdin, stdout
def powerful_ksenia(n, a_a):
xor = 0
for a in a_a:
xor ^= a
if n % 2 == 0 and xor != 0:
return ["NO"]
else:
r_a = ["YES", str((n - 1) // 2 * 2)]
for i in range((n - 1) // 2):
r_a.append(str(1) + " " + str(i * 2 + 2) + " " + str(... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER RETURN LIST STRING ASSIGN VAR LIST STRING FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP FUNC_CALL VAR NUMBER STRING FUN... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | def solve(n, arr):
xor_sum = arr[0]
for i in range(1, n):
xor_sum ^= arr[i]
if n % 2 == 0:
if xor_sum:
print("NO")
return
else:
n -= 1
if n == 3:
print(1)
print(1, 2, 3)
return
print("YES")
print(n - 2)
for i... | FUNC_DEF ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER IF VAR EXPR FUNC_CALL VAR STRING RETURN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER NUMBER RETURN EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CA... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | n = int(input())
a = list(map(int, input().split()))
def solveOdd(a, n):
a = [(a[i], i + 1) for i in range(n)]
a.sort(key=lambda x: x[0])
ans = []
for i in range(0, n - 2, 2):
ans.append((a[i][1], a[i + 1][1], a[i + 2][1]))
x = a[i][0] ^ a[i + 1][0] ^ a[i + 2][0]
a[i : i + 3] =... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER VAR BIN_OP V... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | for _ in range(1):
n = int(input())
arr = list(map(int, input().split()))
out = []
if n % 2:
i = 2
while i < n:
out.append([i - 1, i, i + 1])
k = arr[i - 2] ^ arr[i - 1] ^ arr[i]
arr[i - 2], arr[i - 1], arr[i] = k, k, k
i += 2
i = 1... | FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST IF BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR EXPR FUNC_CALL VAR LIST BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR B... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | import sys
input = sys.stdin.readline
def prog():
n = int(input())
a = list(map(int, input().split()))
if n % 2 == 0:
tot = 0
for i in a:
tot ^= i
if tot != 0:
print("NO")
return
print("YES")
print(n - 1 - (n % 2 == 0))
for j in rang... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER ... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | import sys
input = sys.stdin.readline
n = int(input())
A = list(map(int, input().split()))
XOR = 0
for a in A:
XOR ^= a
if n % 2 == 0 and XOR != 0:
print("NO")
sys.exit()
print("YES")
ANS = []
for i in range(2, n, 2):
ANS.append((1, i, i + 1))
for i in range(2, n, 2):
ANS.append((1, i, i + 1))
prin... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | def resu(n, L):
s = 0
if n == 3:
return [(1, 2, 3)]
for i in range(n):
x = L[i]
s = x ^ s
if n % 2 == 0 and s != 0:
return -1
if n % 2 == 1:
res = []
for _ in range(2):
for i in range((n - 1) // 2):
j = 2 * i + 1
... | FUNC_DEF ASSIGN VAR NUMBER IF VAR NUMBER RETURN LIST NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER RETURN NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NU... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | n = int(input())
a = list(map(int, input().split()))
if n % 2 != 0:
print("YES")
print(n - 2)
for i in range(n):
print(i * 2 + 1, i * 2 + 2, i * 2 + 3)
if i * 2 + 3 == n:
break
for i in range(2, n):
if n - i * 2 + 2 < 3:
break
print(n - i * 2, n - ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP ... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | from sys import *
input = stdin.readline
n = int(input())
a = list(map(int, input().split()))
def solve(a, n):
if n == 1:
return []
if n == 3:
return [[1, 2, 3]]
if n % 2 == 1:
ops = []
for i in range(0, n - 2, 2):
ops.append([i + 1, i + 2, i + 3])
for ... | ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR NUMBER RETURN LIST IF VAR NUMBER RETURN LIST LIST NUMBER NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | n = int(input())
a = list(map(int, input().split()))
if n & 1:
print("YES")
print(n - 1)
for i in range(1, n, 2):
print(i, i + 1, i + 2)
for i in range(1, n, 2):
print(i, i + 1, n)
else:
s = 0
for i in a:
s ^= i
if s > 0:
print("NO")
else:
print("Y... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VA... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | import sys
input = sys.stdin.readline
n = int(input())
l = input().split()
li = [int(i) for i in l]
xori = 0
for i in range(n):
xori ^= li[i]
if xori == 0 or n % 2:
print("YES")
ans = []
if n % 2 == 0:
n -= 1
for i in range(n // 2):
ans.append((2 * i + 1, 2 * i + 2, n))
for i in... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST IF BIN_OP VAR NUMBER NUMBER VAR NUMBER FOR VAR FUNC_CALL ... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | import sys
input = lambda: sys.stdin.readline().strip()
inp = lambda: list(map(int, sys.stdin.readline().strip().split()))
n = int(input())
a = list(map(int, input().split()))
def solve(a, n):
ans = []
i = 1
for j in range(n // 2):
ans.append([i, i + 1, i + 2])
i += 2
this = ans[-1][-... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL 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 FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CA... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | def solve():
n = int(input())
a = list(map(int, input().split()))
if n % 2 == 1:
number_of_operations, moves, _ = change_bits(a, n)
print_correct(moves, number_of_operations)
else:
number_of_operations, moves, a[:-1] = change_bits(a[:-1], n - 1)
if a[0] == a[-1]:
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL ... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | import sys
n = int(input())
a = list(map(int, input().split()))
count = [0] * 40
for i in range(n):
for j in range(40):
if a[i] & 1 << j:
count[j] = (count[j] + 1) % 2
if n % 2 == 0 and sum(count) != 0:
print("NO")
sys.exit()
print("YES")
ans = []
ans.append("1 2 3")
if n == 3:
prin... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR VAR BIN_OP NUMBER VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER ... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | n = int(input())
arr = list(map(int, input().split()))
if n % 2 == 1:
print("YES")
print(n - 2)
print(*[1, 2, 3])
for x in range(2, n - 2, 2):
print(*[x + 1, x + 2, x + 3])
for x in range(0, n - 3, 2):
print(*[x + 1, x + 2, n])
else:
xor = 0
for i in range(n):
xor = x... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR LIST NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR LIST ... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | n = int(input())
l = input().split()
li = [int(i) for i in l]
xori = 0
for i in range(n):
xori ^= li[i]
if n % 2 == 0 and xori:
print("NO")
quit()
if n % 2 == 0:
n = n - 1
print("YES")
l = []
for i in range((n - 1) // 2):
l.append((2 * i + 1, 2 * i + 2, 2 * i + 3))
for i in range((n - 3) // 2):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR ... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | n = int(input())
l = list(map(int, input().split()))
if len(set(l)) == 1:
print("YES")
print(0)
exit()
if n % 2 == 0:
ans = []
for i in range(1, n, 2):
if i + 1 < n and i + 2 < n:
ans.append([i + 1, i + 2, i + 3])
z = l[i] ^ l[i + 1] ^ l[i + 2]
l[i], l[i +... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER IF BIN_OP VAR NUM... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | n = int(input())
a = [int(x) for x in input().split()]
xor_sum = 0
for x in a:
xor_sum = xor_sum ^ x
if n % 2 == 0 and xor_sum != 0:
print("NO")
else:
print("YES")
l = [(x, x + 1, x + 2) for x in range(1, n - 1, 2)]
l += list(reversed(l))[1:]
print(len(l))
for x in l:
print(" ".join(... | 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 VAR ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER B... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | mod = 10**9 + 7
def solve():
n = int(input())
a = list(map(int, input().split()))
s = 0
for x in a:
s = s ^ x
if s != 0 and n % 2 == 0:
print("NO")
return
ans = []
for i in range(3, n + 1, 2):
ans.append([i - 2, i - 1, i])
for i in range(2, n, 2):
... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR LIST FOR VAR FUNC_CA... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | import sys
input = sys.stdin.readline
def solve(n):
print("YES")
ans = []
for i in range(0, n - 1, 2):
ans.append([i + 1, i + 2, i + 3])
for i in range(n - 2, -1, -2):
ans.append([n, i + 1, i])
print(len(ans))
for i in ans:
print(*i)
n = int(input())
a = list(map(int... | IMPORT ASSIGN VAR VAR FUNC_DEF EXPR FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR LIST BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR LIST VAR BIN_OP VAR NUMBER VAR EXPR FUNC_C... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | from sys import stdin, stdout
input = stdin.readline
t = 1
for _ in range(t):
n = int(input())
arr = [int(x) for x in input().split()]
if n % 2:
print("YES")
print(n - 1)
for i in range(0, n - 2, 2):
print(i + 1, i + 2, n)
for i in range(0, n - 2, 2):
... | ASSIGN VAR VAR ASSIGN VAR 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 IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP V... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | n = int(input())
arr = [int(x) for x in input().split()]
xor = 0
answer = []
for elem in arr:
xor ^= elem
if n % 2 or not xor:
for i in range(0, n - 1 >> 1):
x = 2 * i
y = arr[x] ^ arr[x + 1] ^ arr[x + 2]
arr[x] = y
arr[x + 1] = y
arr[x + 2] = y
answer.append((x +... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR VAR VAR IF BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | n = int(input())
arr = [int(i) for i in input().split()]
if n % 2 == 1:
print("YES")
print(n - 2)
for i in range(n // 2):
print(str(2 * i + 1), str(2 * i + 2), str(2 * i + 3))
for i in range(n // 2 - 1):
print(str(2 * i + 1), str(2 * i + 2), str(n - 1))
else:
xor = arr[0]
for i i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP BIN_OP ... |
Ksenia has an array $a$ consisting of $n$ positive integers $a_1, a_2, \ldots, a_n$.
In one operation she can do the following: choose three distinct indices $i$, $j$, $k$, and then change all of $a_i, a_j, a_k$ to $a_i \oplus a_j \oplus a_k$ simultaneously, where $\oplus$ denotes the bitwise XOR operation.
She ... | from sys import stdin, stdout
t = int(stdin.readline())
arr = list(map(int, stdin.readline().split()))
if t % 2 != 0:
print("YES")
print(t - 2)
for i in range(1, t - 1, 2):
print("{} {} {}".format(i, i + 1, i + 2))
for i in range(1, t - 3, 2):
print("{} {} {}".format(i, i + 1, t))
else:... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING VAR BIN_OP VAR NUMBER BIN_OP VAR ... |
Read problems statements in [Mandarin Chinese], [Russian], and [Bengali] as well.
Construct an array of length N containing only positive integers in the range [1, 1000] such that there doesnβt exist a subarray that has all elements occurring in even frequency and the maximum element in the array is minimized. In case... | for tc in range(int(input())):
n = int(input())
dp = [[1]]
st = 2
for x in range(2, n + 1):
if x % 2 == 0:
dp.append(dp[-1] + [st])
st += 1
else:
dp.append(dp[-1] + dp[-2])
if len(dp[-1]) >= n:
break
for x in dp[-1][0:n]:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST LIST NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER LIST VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF FU... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.