description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) arr = [int(i) for i in input().split()] ans = [i for i in arr] def fun(arr, n, ans): for i in range(31, -1, -1): f, v = 0, 0 for j in range(n): if arr[j] & 1 << i != 0: f += 1 v = j if f > 1: break if ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR BIN_OP NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER IF VAR NUMB...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) a = list(map(int, input().split())) ind = -1 for i in range(32, -1, -1): ct = 0 x = 1 << i for j in range(n): if a[j] & x == x: ct += 1 if ct == 1: ind = j if ct == 1: break else: ind = -1 if ind == -1: for i in a: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER ...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
input() a = input().split() print( a.pop( next( (x for x in zip(*(f"{int(x):30b}" for x in a)) if x.count("1") == 1), "1" ).index("1") ), *a, )
EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR STRING VAR VAR FUNC_CALL VAR STRING NUMBER STRING STRING VAR
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) a = [int(s) for s in input().split(" ")] bitmap = [[] for _ in range(33)] for i, b in enumerate(a): b_bin = bin(b)[2:] for j, b_str in enumerate(b_bin[::-1]): if b_str == "1": bitmap[j].append(i) index = -1 for i in range(32, -1, -1): if bitmap[i].__len__() == 1: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST VAR FUNC_CALL VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR NUMBER IF VAR STRING EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_C...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) a = list(map(int, input().split())) bits = {i: (0) for i in range(0, 32)} for x in a: b = bin(x)[2:] counter = 0 for i in range(len(b) - 1, -1, -1): bits[counter] += int(b[i]) counter += 1 bits = list(filter(lambda x: x[1] == 1, bits.items())) m = 0 n = -1 for i in a: b ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER VAR VAR FUNC_CALL VAR VAR ...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) a = list(map(int, input().split())) lis = [0] * 31 for i in a: for j in range(31): if i & 2**j > 0: lis[j] += 1 nmax = 0 maxind = 0 for ind, i in enumerate(a): for j in range(31): if lis[j] >= 2: i |= 2**j i -= 2**j if nmax < i: nm...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CAL...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) l = list(map(int, input().split())) a = [[] for i in range(32)] for i in range(n): num = l[i] j = 0 while num > 0: if num % 2 == 1: a[j].append(i) num = num // 2 j += 1 flag = 0 ind = 0 for i in range(31, -1, -1): if len(a[i]) == 1: ind = a[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 LIST VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBE...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) a = [int(i) for i in input().split()] ones = [set() for _ in range(34)] for idx, i in enumerate(a): for j in range(34): if i >> j & 1 == 1: ones[j].add(idx) maxi = 0 for j in range(33, -1, -1): if len(ones[j]) == 1: maxi = ones[j].pop() break a[maxi], a[0] = ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NU...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) l = list(map(int, input().split())) p = [0] * n temp = ~l[0] for i in range(1, n): p[i] = temp temp &= ~l[i] temp = ~l[-1] ans = [-1, -float("inf")] for i in range(n - 2, -1, -1): if i != 0: p[i] &= temp temp &= ~l[i] p[i] &= l[i] if ans[1] < p[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 BIN_OP LIST NUMBER VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST NUMBER FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR BIN_OP...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
import sys inp = sys.stdin.readline input = lambda: inp().strip() flush = sys.stdout.flush def iin(): return int(input()) def lin(): return list(map(int, input().split())) def main(): n = iin() a = lin() ch = [0] * 35 for i in a: ch1 = 0 x = i while x: ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR ASSIGN VAR NUMBER ASSIGN...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) l = [int(x) for x in input().split()] l.sort() l.reverse() ll = [] sol = [] leng = len(bin(l[0])[2:]) i = 0 for x in l: ll.append("0" * (leng - len(bin(x)[2:])) + bin(x)[2:]) idx = -1 while i < leng: idx = -1 for x in range(n): if ll[x][i] == "1": if idx == -1: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING BIN_OP VAR FUNC_CALL VAR FU...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) A = list(map(int, input().split())) B = [([0] * 33) for i in range(n)] C = [0] * 33 for i in range(n): t = A[i] j = 0 while t > 0: B[i][j] += t % 2 C[j] += B[i][j] t //= 2 j += 1 M2 = [1] for i in range(40): M2.append(M2[-1] * 2) S = [0] * n for i in rang...
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 VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR VAR ...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
import sys input = sys.stdin.readline n = int(input()) a = list(map(int, input().split())) ruiseki = [0] * (n + 1) ruiseki2 = [0] * (n + 1) for i in range(n): ruiseki[i + 1] = ruiseki[i] | a[i] for i in range(n): ruiseki2[i + 1] = ruiseki2[i] | a[n - (i + 1)] ans = 0 ind = 0 for i in range(n): tmp = ruisek...
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 BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR VAR FOR VAR FUNC_CALL ...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) A = [int(x) for x in input().split()] bit = 2**30 while bit: B = [] for i in range(n): if A[i] & bit: B.append(i) if len(B) == 1: print(" ".join(str(x) for x in [A[B[0]]] + A[: B[0]] + A[B[0] + 1 :])) exit() bit >>= 1 print(" ".join(str(x) for x in A)...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER WHILE VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR BIN_OP BI...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) arr = list(map(int, input().split())) bs = 0 for i in range(32, -1, -1): cnt = 0 for j, c in enumerate(arr): if c >> i & 1: cnt += 1 bs = j if cnt == 1: break print(arr[bs], end=" ") for j, c in enumerate(arr): if j != bs: print(c, end=" "...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR STRING...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) a = [int(i) for i in input().split()] ans = 0 for i in range(31, -1, -1): cnt = 0 cur = -1 for j in range(n): if a[j] >> i & 1 == 0: cnt += 1 else: cur = j if cnt == n - 1: ans = cur break print(a.pop(ans), *a)
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 NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR VAR IF VAR BIN_OP VAR NUMBER ASSIGN ...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) mx = 0 a = [0] * n k = 0 for i in input().split(): a[k] = int(i) mx = max(a[k], mx) k += 1 m = 0 while 2**m <= mx: m += 1 rz = 0 for i in range(m, -1, -1): if rz: break for j in range(n): if a[j] & 2**i: if rz: rz = 0 b...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP NUMBER VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR V...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) s = list(map(int, input().split())) for i in range(30, -1, -1): if sum(1 for x in s if x & 1 << i) == 1: s.sort(key=lambda x: -(x & 1 << i)) break print(*s)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF FUNC_CALL VAR NUMBER VAR VAR BIN_OP VAR BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) aa = [int(i) for i in input().split()] pre = [~aa[0]] suff = [~aa[-1]] for i in range(1, n): pre.append(pre[-1] & ~aa[i]) for i in range(n - 2, -1, -1): suff.append(suff[-1] & ~aa[i]) suff = suff[::-1] maxi, ind = -1, -1 for i in range(0, n): cur = aa[i] if i == 0: if n > 1: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER V...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
class SegTree: def __init__(self, arr): self.arr = arr self.tree = [None for _ in range(2 * len(arr) * 2)] self.build() def build(self, node=1, start=0, end=None): if end == None: end = len(self.arr) - 1 if start == end: self.tree[node] = self.ar...
CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NONE VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_DEF NUMBER NUMBER NONE IF VAR NONE ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR ...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
def f(x, y): return (x | y) - y n = int(input()) l = list(map(int, input().split())) mp = [(0) for _ in range(31)] for num in l: b = bin(num)[2:].zfill(31) for i in range(31): if b[i] == "1": mp[i] += 1 largest = 0 largestNum = l[0] for num in l: b = bin(num)[2:].zfill(31) tmp ...
FUNC_DEF RETURN BIN_OP BIN_OP VAR 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 VAR FUNC_CALL VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR STRING VAR VAR NUMBER AS...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) l = list(map(int, input().split())) try: ans = [] for i in range(31, -1, -1): c = 0 tem = -100 flag = 0 for j in l: if j >> i & 1: tem = j c += 1 if c == 1: ans.append(tem) flag = 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 LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VA...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
def f(x, y): return (x | y) - y n = int(input()) s = list(map(int, input().split())) l = [] for i in range(32): l.append([]) for i in range(n): x = s[i] count = 0 while x > 0: if x % 2 != 0: l[count].append(s[i]) x = x // 2 count += 1 flag = 0 first = 0 for i in...
FUNC_DEF RETURN BIN_OP BIN_OP VAR 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 EXPR FUNC_CALL VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NU...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
q = int(input()) numArray = [int(x) for x in input().split()] binaryArray = ["{:030b}".format(x) for x in numArray] max = 0 first = -1 for x in range(30): count = 0 for y in range(q): if int(binaryArray[y][x]) == 1: count += 1 if count == 1: for y in range(q): if int(...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL STRING VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR NUMBER FOR VAR FUNC_C...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) a = list(map(int, input().split())) suf = [0] * (n + 1) for q in range(n - 1, -1, -1): suf[q] = suf[q + 1] | a[q] naw, ans = 0, [-1, -1] for q in range(n): w = a[q] & ~(naw | suf[q + 1]) if w > ans[0]: ans = [w, q] naw |= a[q] print(a[ans[1]], *a[: ans[1]], *a[ans[1] + 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 BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR VAR NUMBER LIST NUMBER NUMBER FOR VAR FUNC_CALL V...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) a = list(map(int, input().split())) b = set(a) x = max(a) d = 0 c = 0 r = 0 while x: x >>= 1 d += 1 for i in range(d - 1, -1, -1): c = 0 for j in b: if j >> i & 1: c += 1 r = j if c == 1: break a.remove(r) print(r, " ".join(map(str, a)))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBE...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) (*arr,) = map(int, input().split()) def CountBits(n): n = (n & 6148914691236517205) + ((n & 12297829382473034410) >> 1) n = (n & 3689348814741910323) + ((n & 14757395258967641292) >> 2) n = (n & 1085102592571150095) + ((n & 17361641481138401520) >> 4) n = (n & 71777214294589695) + ((n...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) a = list(map(int, input().split())) a.sort(reverse=True) data = [] use = [(True) for _ in range(n)] for i in range(30, -1, -1): key = -1 for j, x in enumerate(a): if x >> i & 1 and key == -1: key = j elif x >> i & 1: key = -1 break if key ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBE...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
import sys read = lambda: list(map(int, sys.stdin.readline().strip().split())) n = int(input()) a = read() s = 30 nu = -1 while s >= 0: count = 0 for i in range(n): if a[i] & 1 << s: count += 1 if count == 1: for i in range(n): if a[i] & 1 << s: nu = ...
IMPORT 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR BIN_OP NUMBER VAR VAR NUMBER IF VAR NUMBER FOR VAR FUNC_C...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
from sys import stdin, stdout def main(): n = int(stdin.readline()) arr = list(map(int, stdin.readline().split())) pow2 = [0] * 32 max = 0 ans = [0] * 32 for j, i in enumerate(arr): x = int(i) z = 0 while x > 0: if (x - pow(2, z)) % pow(2, z + 1) == 0: ...
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 BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP BIN_OP VA...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) arr = [int(x) for x in input().split()] for i in range(30, -1, -1): dem = 0 for x in arr: if x & 1 << i: dem += 1 if dem == 1: cur = 0 for j in range(n): if arr[j] & 1 << i: cur = j print(arr[cur], end=" ") for ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR BIN_OP NUMBER VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR BIN_OP NUMBER VAR ASSIGN VAR VAR...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
import sys n = int(input()) lst = list(map(int, input().split())) pre = [(0) for i in range(n + 1)] suf = [(0) for i in range(n + 1)] pre[0] = sys.maxsize for i in range(n): pre[i + 1] = pre[i] & ~lst[i] suf[n] = sys.maxsize for i in range(n - 1, -1, -1): suf[i] = suf[i + 1] & ~lst[i] Max = -sys.maxsize Ans = ...
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 NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR VAR...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) al = list(map(int, input().split())) bits = [(0) for i in range(40)] for a in al: idx = 0 while a > 0: bits[idx] += a % 2 a //= 2 idx += 1 ans = 0 for idx, b in enumerate(bits): if b == 1: ans += 2**idx tmp = 0 ans2 = al[0] for a in al: k = ans & a if...
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 NUMBER FOR VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR BIN_OP NUM...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
def answer(n, A): if n == 1: return A pre = [0] * n pre[0] = ~A[0] for i in range(1, n): pre[i] = ~A[i] & pre[i - 1] suff = [0] * n suff[-1] = ~A[-1] for i in range(n - 2, -1, -1): suff[i] = ~A[i] & suff[i + 1] ele = A[0] maxi = A[0] & suff[1] ans = 0 ...
FUNC_DEF IF VAR NUMBER RETURN VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR BIN_OP...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) vals = list(map(int, input().split())) pref, suff = [0] * (n + 1), [0] * (n + 1) for i in range(n): pref[i + 1] = pref[i] | vals[i] suff[n - i - 1] = suff[n - i] | vals[n - i - 1] ret = -float("inf"), -float("inf") for i, a in enumerate(vals): b = pref[i] | suff[i + 1] ret = max(ret, ((...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP ...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
def main(): n = int(input()) a = [int(i) for i in input().split()] before = [0] * n after = [0] * n accleft = 0 for i in range(n): before[i] = accleft accleft |= a[i] accright = 0 i = n - 1 while i >= 0: after[i] = accright accright |= a[i] i -...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER ASSIGN V...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) a = list(map(int, input().split())) pre = [(0) for i in range(n + 1)] suf = [(0) for i in range(n + 1)] for i in range(n): if i == 0: pre[i] = a[i] else: pre[i] = pre[i - 1] | a[i] for i in range(n - 1, -1, -1): if i == n - 1: suf[i] = a[i] else: suf[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 NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) a = [int(x) for x in input().split()] l = sorted(a, reverse=True) x = l[0] bits = 0 while x > 0: x = x >> 1 bits += 1 num = 0 for i in range(bits): count = 0 ind = 0 z = 1 << bits - i - 1 for j in range(len(a)): if z & l[j] == z: count += 1 ind = ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR ...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
def Input(): tem = input().split() ans = [] for it in tem: ans.append(int(it)) return ans n = Input()[0] a = Input() l_or = [(0) for i in range(n)] tem = 0 for i in range(n): l_or[i] = tem | a[i] tem = l_or[i] inx = 0 MAX = 0 tem = 0 for i in range(n - 1, -1, -1): if i - 1 >= 0: ...
FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
def wrapper(func): def inner(): return next(func) return inner n = int(input()) a = list(map(int, input().strip().split())) INF = (1 << 60) - 1 pre = [0] * (n + 1) pre[n] = INF for i in range(n): if i == 0: pre[i] = ~a[i] else: pre[i] = pre[i - 1] & ~a[i] suf = [0] * (n + 1) ...
FUNC_DEF FUNC_DEF RETURN FUNC_CALL VAR VAR RETURN VAR 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 BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMB...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) a = [int(s) for s in input().split()] b = [(-1) for i in range(32)] for i in range(n): t = a[i] j = 0 while t > 0: if t % 2 == 1: if b[j] == -1: b[j] = i elif b[j] >= 0: b[j] = -2 j += 1 t //= 2 k = 0 for i in r...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR NUM...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
from sys import stdin input = stdin.readline n = int(input()) a = list(map(int, input().split())) mask = 2**30 while mask and len([ai for ai in a if ai & mask]) != 1: mask //= 2 if mask: i = next(i for i in range(n) if a[i] & mask) a[i], a[0] = a[0], a[i] print(*a)
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 BIN_OP NUMBER NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR NUMBER VAR NUMBER IF VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR VAR NU...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
N = int(input()) A = list(map(int, input().split())) ans = -1 for i in range(32, -1, -1): count = 0 ans = -1 for n in A: if 1 << i & n != 0: ans = n count += 1 if count == 1: break if ans != -1: print(ans, end=" ") for n in A: if n != ans: print(n,...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP BIN_OP NUMBER VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CA...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) l = list(map(int, input().split())) b = [0] * 32 for i in range(n): p = l[i] for j in range(32): b[j] += p % 2 p = p // 2 ai = 0 m = -1 for i in range(n): p = l[i] q = 0 for j in range(32): if p % 2 == 1 and b[j] == 1: q += 2**j p = p // 2...
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 ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) a = list(map(int, input().split())) l = [set() for i in range(50)] for i, x in enumerate(a): y = list(reversed(str(bin(x)))) for j, k in enumerate(y): if k == "1": l[j].add(i) ans = -1 for x in l: if len(x) == 1: ans = list(x)[0] if ans == -1: a.sort(reverse=...
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 FUNC_CALL VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING EXPR FUNC_CALL VAR ...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) a = list(map(int, input().split())) b = [-1] * 32 ans = -1 for it in range(n): i = a[it] bi = bin(i)[2:][-1::-1] for ii, j in enumerate(bi): if j == "1": if b[ii] == -1: b[ii] = it else: b[ii] = -2 for i in range(31, -1, -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 BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR STRING IF VAR VAR NUMBER AS...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
import sys input = sys.stdin.readline n = int(input()) arr = [int(k) for k in input().split()] num = 0 for i in range(30, -1, -1): count = 0 for j in range(n): if arr[j] >> i & 1: count += 1 num = arr[j] if count == 1: break arr.remove(num) print(num, " ".join(map(st...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VA...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) x = list(map(int, input().split())) bi, ans, skip = [[] for i in range(31)], [], [0] * 31 ma = 0 for i in range(n): b = str(bin(x[i])) for i2 in range(len(b) - 1, -1, -1): if b[i2] == "b": break if b[i2] == "1": bi[len(b) - i2 - 1].append(i) m...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR LIST VAR FUNC_CALL VAR NUMBER LIST BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR ...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) a = list(map(int, input().split())) b = [bin(ele)[2:] for ele in a] b = [("0" * (32 - len(ele)) + ele) for ele in b] found = -1 for i in range(32): ans = -1 count = 0 for idx, ele in enumerate(b): if ele[i] == "1": count += 1 ans = idx if count == 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 FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP NUMBER FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) x = list(map(int, input().split())) y = 0 for i in range(32, -1, -1): c = 0 temp = -1 for j in range(n): if x[j] >> i & 1 == 0: c = c + 1 else: temp = j if c == n - 1: y = temp break x[0], x[y] = x[y], x[0] print(*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 NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR IF V...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) a = [int(v) for v in input().split()] x = [[] for _ in range(64)] for i, v in enumerate(a): mask = 1 for k in range(64): if v & mask: x[k].append(i) mask <<= 1 z = 0 for k in range(63, -1, -1): if len(x[k]) == 1: z = x[k][0] break print(a[z], *(a[...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUM...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) a = list(map(int, input().split(" "))) if n == 1: print(a[0]) else: prefix = [0] * n suffix = [0] * n prefix[0] = ~a[0] suffix[n - 1] = ~a[n - 1] for i in range(1, n): prefix[i] = prefix[i - 1] & ~a[i] for i in range(2, n + 1): suffix[n - i] = suffix[n - i + ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER FOR VAR FUNC_CA...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
import sys n = int(sys.stdin.readline().rstrip()) num = list(map(int, sys.stdin.readline().rstrip().split())) max_len = 0 for i in num: bi = bin(i)[2:] if max_len < len(bi): max_len = len(bi) st = 0 max_len -= 1 while True: cnt = 0 for idx, i in enumerate(num): if 2**max_len & i > 0: ...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR NUMBER WHILE NUMBER ASSIGN VAR NUMBER FOR VAR...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
def main(): n = int(input().strip()) A = [int(s) for s in input().strip().split()] for i in range(31, -1, -1): if sum(a >> i & 1 for a in A) == 1: break for j, a in enumerate(A): if a >> i & 1: break result = [A[j]] + A[:j] + A[j + 1 :] print(" ".join(str(...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP LIST...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) a = list(map(int, input().split())) r = 0 for i in range(29, -1, -1): c = 0 for j in a: if j >> i & 1: c += 1 r = j if c == 1: break a.remove(r) print(r, " ".join(map(str, a))) num_inp = lambda: int(input()) arr_inp = lambda: list(map(int, input().spl...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FUNC_...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) arr = [[] for i in range(32)] l = input().split() li = [int(i) for i in l] for i in li: for j in range(32): if i & 1 << j: arr[j].append(i) maxa = -1 for i in range(31, -1, -1): if len(arr[i]) == 1: maxa = arr[i][0] break if maxa == -1: for i in li: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FOR VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF FUNC...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
N = int(input()) L = list(map(int, input().split())) R = [] for i in range(N): R.append([0] * 32) cnt = [0] * 32 for i in range(N): x = L[i] n = 0 while x: if x % 2 == 1: R[i][n] = 1 cnt[n] += 1 else: R[i][n] = 0 n += 1 x = x // 2 index...
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 VAR EXPR FUNC_CALL VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR IF BIN_OP VAR NUM...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
import sys input = sys.stdin.readline N = int(input()) A = list(map(int, input().split())) if N == 1: ans = A else: dp1 = [0] * N bit = 0 for i, a in enumerate(A): bit |= a dp1[i] = bit dp2 = [0] * N bit = 0 for i in reversed(range(N)): bit |= A[i] dp2[i] = b...
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 IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FO...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) v = list(map(int, input().split())) max = -1 maxi = 0 for i in range(n): x = v[i] for j in range(n): if j == i: continue if x == 0: break x = (x | v[j]) - v[j] if x > max: max = x maxi = i print(v[maxi], end=" ") for i in range...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR ...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) pw = [(2 ** (30 - i)) for i in range(31)] def kek(x): global pw ans = set() mind = 0 for i in range(31): pwi = pw[i] if pwi <= x: x -= pwi ans.add(pwi) return ans ra = list(map(int, input().split())) a = list(map(kek, ra)) t = dict([[pw[i]...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER BIN_OP NUMBER VAR VAR FUNC_CALL VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CA...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) a = list(map(int, input().split())) max_c = 0 index = 0 bits = [] for i in range(n): w = bin(a[i])[2:] bits.append(w) p = w.count("1") if p > max_c: max_c = p index = i yy = max(a) for i in range(len(bits)): bits[i] = "0" * (len(bin(yy)[2:]) - len(bits[i])) + bits[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 NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) ar = [int(x) for x in input().split()] ar = sorted(ar)[::-1] d = {k: (0) for k in range(32)} for x in ar: for j in range(32): if x ^ 1 << j == x - (1 << j): d[j] += 1 maxn = 0 maxi = 0 for i, e in enumerate(ar): tmp = e for j in range(32): if e ^ 1 << j == e - (1...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR BIN_OP VAR BIN_OP NUMBER VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
def solve(a_s): bits = 31 a_bits = [[(a >> bit & 1) for bit in range(bits - 1, -1, -1)] for a in a_s] ans_i = 0 for i in range(bits): lone_j = -1 for j, a_bit in enumerate(a_bits): if a_bit[i] == 1: if lone_j != -1: lone_j = -1 ...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER ASSIGN VAR VAR ASSIGN VA...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
from sys import stdin, stdout for _ in range(1): n = int(stdin.readline()) a = list(map(int, stdin.readline().split())) ans = [] bits = [[(0) for _ in range(32)] for _ in range(n)] for i in range(n): num = a[i] for j in range(32): bits[i][j] = num >> j & 1 for i in r...
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 ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR BIN_OP BIN_...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) lst = list(map(int, input().split())) positions = {} for num in lst: t = str(bin(num)) t = t[2:] t = t[::-1] for j in range(len(t)): if t[j] == "1": if j in positions: positions[j][1] += 1 else: positions[j] = [0, 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 DICT FOR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING IF VAR VAR VAR VAR NUMBER NUMBER ASSIGN V...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) a = list(map(int, input().split())) b = [] for i in range(n): b.append(str(int(bin(a[i]).replace("0b", "")) + 10**30)) flag, store = 0, 0 for i in range(1, 31): add = 0 for j in range(n): if b[j][i] == str(1): add += 1 store = j if add == 1: flag ...
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 VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR VAR VAR STRING STRING BIN_OP NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR ...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
def checker(n, lst): a, b = [0] * n, [0] * n for i in range(1, n): a[i] = a[i - 1] | lst[i - 1] b[n - i - 1] = b[len(lst) - i] | lst[n - i] elem, pos = -1, -1 for i in range(n): y = a[i] | b[i] cur = (lst[i] | y) - y if cur > elem: elem, pos = cur, i ...
FUNC_DEF ASSIGN VAR VAR BIN_OP LIST NUMBER VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR BIN_OP FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR V...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) a = list(map(int, input().split())) x = max(a).bit_length() b = [([0] * x) for i in range(n)] for i in range(n): p = a[i] for j in range(x - 1, -1, -1): b[i][j] = p % 2 p //= 2 cnt = [0] * x for i in range(x): for j in range(n): cnt[i] += b[j][i] if cnt.count(1) == 0...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR B...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) arr = list(map(int, input().split())) pref = [0] * n suf = [0] * n pref[0] = arr[0] for i in range(1, n): pref[i] = pref[i - 1] | arr[i] suf[-1] = arr[-1] for i in range(n - 2, -1, -1): suf[i] = suf[i + 1] | arr[i] maxind = -1 maxans = -1 for i in range(n): prefval = pref[i - 1] if i else 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 LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR NUMBER VAR NUMBER FOR...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) arr = [int(i) for i in input().split()] dic = [0] * 34 for i in arr: temp = i bit = 0 while temp: if temp & 1: dic[bit] += 1 temp = temp >> 1 bit += 1 ans = -1 first = 0 for i in range(len(arr)): tempdic = [0] * 34 temp = arr[i] bit = 0 ra...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR IF BIN_OP VAR NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VA...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) a = list(map(int, input().split())) if n == 1: print(a[0]) else: com_a = [(~i) for i in a] prefix = [0] * n postfix = [0] * n prefix[0] = com_a[0] postfix[-1] = com_a[-1] for i in range(1, n): prefix[i] = prefix[i - 1] & com_a[i] postfix[n - i - 1] = com_a[n ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) a = [int(c) for c in input().split()] only_1 = (1 << 40) - 1 left = [only_1] right = [only_1] L = only_1 for i in range(n - 1): L = L & ~a[i] left.append(L) R = only_1 for i in range(n - 1): R = R & ~a[n - 1 - i] right.append(R) res = 0 res_i = 0 for i in range(n): r = a[i] & left[i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR LIST VAR ASSIGN VAR LIST VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CA...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) l = [(int(el), "{:032b}".format(int(el))) for el in input().split(" ")] res = [] ind = -1 for pos in range(32): count = 0 for i in range(n): if l[i][1][pos] == "1": count += 1 ind = i if count == 1: res.append(l[ind][0]) break ind = -1 for...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR STRING VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER EXPR F...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) a = list(map(int, input().split())) fl = False maxqqq = 0 maxi = 0 for i in range(n): qqq = a[i] for j in range(n): if j != i: qqq = (qqq | a[j]) - a[j] if qqq <= maxqqq: break if qqq > maxqqq: maxqqq = qqq maxi = i fl ...
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 ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR IF VAR VAR IF VAR VAR ASSIGN VAR ...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) A = [int(i) for i in input().split()] A.sort(reverse=True) if n == 1: print(A[0]) else: x = A[0] steps = len(bin(x)) - 3 mask = x >> steps mask = mask << steps f1 = True f2 = True while f1: ind = 0 num = 0 while f2: x = A[ind] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIG...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) a = [int(x) for x in input().split()] bits = {i: [] for i in range(33)} for i in range(n): cnt = 0 x = a[i] while x: if x & 1: bits[cnt].append(i) x >>= 1 cnt += 1 find = False for i in range(32, -1, -1): if len(bits[i]) == 1: k = bits[i][0] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR WHILE VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL ...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) a = list(map(int, input().split())) for d in range(29, -1, -1): bit = 1 << d count, j = 0, 0 for i, x in enumerate(a): if bit & x: count += 1 if count == 2: break else: j = i if count == 1: print(a[j], *...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER EXPR FUNC_C...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) a = list(map(int, input().split())) a.sort() a = a[::-1] k = 0 m = 0 l1 = [0] * n l1[0] = a[0] l2 = [0] * n l2[n - 1] = a[n - 1] for i in range(1, n): l1[i] = l1[i - 1] | a[i] l2[n - 1 - i] = l2[n - i] | a[n - i - 1] for i in range(n): s = 0 if i > 0: s = s | l1[i - 1] if i ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP ...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
s = int(input()) arr = list(map(int, input().split())) zero_bits = dict() index_max = 0 for i in range(0, 32): zero_bits[i] = [] power_ = [(2**i) for i in range(0, 32)] _enumerate = enumerate _reversed = reversed for index, i in _enumerate(arr): temp = i for index_, j in _enumerate(_reversed(power_)): ...
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 ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR LIST ASSIGN VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR VAR FOR VAR VAR FUNC_CALL VA...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
def iinput(): return [int(x) for x in input().split()] def main(): n = int(input()) data = iinput() s = 0 data1 = [] for i in range(n): data1.append(s) s = s | data[i] data2 = [] w = 0 for i in range(n - 1, -1, -1): data2.append(w) w = w | data[i] ...
FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBE...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
input() a = input().split() for x in zip(*(f"{int(x):30b}" for x in a)): if x.count("1") == 1: i = x.index("1") a = [a.pop(i)] + a break print(*a)
EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR STRING VAR VAR IF FUNC_CALL VAR STRING NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
import sys from itertools import permutations input = sys.stdin.readline n = int(input()) a = [int(item) for item in input().split()] cnt = [0] * 32 for item in a: for i in range(32): if item & 1 << i: cnt[i] += 1 mask = 0 for i, item in enumerate(cnt): if item == 1: mask |= 1 << i ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR BIN_OP NUMB...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
def solve(a): count = [0] * 30 for e in a: for i in range(30): if e & 1 << i: count[i] += 1 i = 29 while i >= 0 and count[i] != 1: i -= 1 if i < 0: return a for j in range(len(a)): if a[j] & 1 << i: return [a[j]] + a[:j] + a...
FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR NUMBER VAR NUMBER IF VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR BIN_OP NUMBER VAR RETURN BIN_OP BIN_OP LIS...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) a = [int(x) for x in input().split()] val = [0] * n pos = [list() for i in range(31)] cnt = [0] * 31 ans = int(0) for i in range(n): for j in range(31): if a[i] >> j & 1: cnt[j] += 1 pos[j].append(i) for i in range(31): if cnt[i] != 1: continue for p ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = 0 a = [0] i = 0 j = 0 x = 0 b = [0] n = int(input()) b = list(map(int, input().split())) a = a + b cnt = [0] * 32 for i in range(1, n + 1): x = a[i] for j in range(0, 32): cnt[j] += x & 1 x >>= 1 high = 0 for high in range(31, -1, -1): if cnt[high] == 1: break if high == -1: ...
ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST 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 BIN_OP VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_...
Anu has created her own function $f$: $f(x, y) = (x | y) - y$ where $|$ denotes the bitwise OR operation . For example, $f(11, 6) = (11|6) - 6 = 15 - 6 = 9$. It can be proved that for any nonnegative numbers $x$ and $y$ value of $f(x, y)$ is also nonnegative. She would like to research more about this function and has...
n = int(input()) arr = [int(p) for p in input().split()] pre = [~arr[0]] suff = [~arr[-1]] for i in range(1, n): pre.append(pre[-1] & ~arr[i]) for i in range(n - 2, -1, -1): suff.append(suff[-1] & ~arr[i]) curr = 0 if n == 1: print(*arr) exit(0) suff = list(reversed(suff)) l = arr[0] & suff[1] r = arr[-...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER V...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
n = int(input()) cc = input() aa = input() na = 0 nb = 0 nc = 0 nd = 0 for i in range(len(aa)): if cc[i] == "0" and aa[i] == "0": na += 1 if cc[i] == "0" and aa[i] == "1": nb += 1 if cc[i] == "1" and aa[i] == "0": nc += 1 if cc[i] == "1" and aa[i] == "1": nd += 1 ans = []...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR VAR STRIN...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
def func(clown, acro, x): if clown[x] == "1": if acro[x] == "1": return 3 else: return 1 elif acro[x] == "1": return 2 else: return 0 def main(): length = int(input()) clown = input() acro = input() arr = [0, 0, 0, 0] for x in ran...
FUNC_DEF IF VAR VAR STRING IF VAR VAR STRING RETURN NUMBER RETURN NUMBER IF VAR VAR STRING RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR NUM...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
def find_sol1(result, num_dict): ans_list = [] for i in range(num_dict["a"] + 1): for j in range(num_dict["d"] + 1): if i - j == result: ans_list.append((i, j)) return ans_list def find_sol2(N, num_dict, ans_list): for a, d in ans_list: for i in range(num_di...
FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP VAR STRING NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR STRING NUMBER IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR RETURN VAR FUNC_DEF FOR VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR STRING NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR STRING NUMBER IF BIN_OP BIN_OP BIN_O...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
n = int(input()) c = list(map(int, input())) a = list(map(int, input())) b = [0, 0, 0, 0] for x, y in zip(c, a): if x ^ y: b[0] += x b[1] += y elif x: b[2] += 1 else: b[3] += 1 l = [0, 0, 0, 0] r = [0, 0, 0, 0] z = min(b[0], b[1]) l[0] += z r[1] += z b[0] -= z b[1] -= z if b[...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR VAR VAR NUMBER VAR VAR NUMBER VAR IF VAR VAR NUMBER NUMBER VAR NUMBER NUMBE...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
import sys def rint(): return map(int, sys.stdin.readline().split()) n = int(input()) c = input() a = input() v = [] for i in range(n): v.append(int(a[i]) + int(c[i]) * 2) cnt = [(0) for i in range(4)] c1 = [(0) for i in range(4)] for i in range(n): cnt[v[i]] += 1 t = cnt[1] + cnt[3] - n // 2 found = 0 ...
IMPORT FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMB...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
n = int(input()) c = input() a = input() a1 = 0 c1 = 0 ac = 0 ac0 = 0 lista = [] listc = [] listac = [] listac0 = [] output = [] p = n // 2 for i in range(0, n): if a[i] == "1" and c[i] == "0": a1 += 1 lista.append(i + 1) if c[i] == "1" and a[i] == "0": c1 += 1 listc.append(i + 1...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
import sys n = int(sys.stdin.readline().strip()) c = sys.stdin.readline().strip() a = sys.stdin.readline().strip() onlyc = 0 onlya = 0 both = 0 neither = 0 for i in range(0, n): if c[i] == "1": if a[i] == "1": both = both + 1 else: onlyc = onlyc + 1 elif a[i] == "1": ...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NU...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
from sys import stdin, stdout N = int(input()) clown = input() acro = input() clown = list(clown) acro = list(acro) k1 = 0 k2 = 0 k3 = 0 k4 = 0 for i in range(N): if clown[i] == "0" and acro[i] == "0": k1 += 1 if clown[i] == "0" and acro[i] == "1": k2 += 1 if clown[i] == "1" and acro[i] == ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR VAR STRIN...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
n = int(input()) aa = input() bb = input() s = [0] * n t = [0] * n ans = [0] * n for i in range(n): s[i] = aa[i] t[i] = bb[i] ans[i] = i + 1 k = n // 2 cs, at = 0, 0 for i in range(n // 2): if s[i] == "1": cs += 1 if t[k + i] == "1": at += 1 if cs == at: for i in range(n // 2): ...
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 BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NU...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
import sys N = int(input()) n = N // 2 A = input() B = input() C = [((a == "1") * 2 + (b == "1")) for a, b in zip(A, B)] w = C.count(0) x = C.count(1) y = C.count(2) z = N - w - x - y Ans = [] for i in range(x + 1): for j in range(y + 1): z1 = x + z - i - j if z1 % 2: continue z...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR STRING NUMBER VAR STRING VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
a, b, c, d = 0, 0, 0, 0 n, s, t = int(input()), input(), input() for i in range(n): if s[i] == "1" and t[i] == "1": d += 1 elif s[i] == t[i]: a += 1 elif s[i] == "1": c += 1 else: b += 1 if n % 2 == 1: print(-1) exit(0) hi = n // 2 for x in range(a + 1): for m...
ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
n = int(input()) d = {v: [] for v in [(0, 0), (0, 1), (1, 0), (1, 1)]} for j, x, y in zip(range(n), map(int, input()), map(int, input())): d[x, y] += [j + 1] x = n // 2 y = len(d[0, 1]) + len(d[1, 1]) x += x - y c = min(x, y, len(d[0, 1]) + len(d[1, 0])) if c % 2 != y % 2: c -= 1 b = (y - c) // 2 a = (x - c) //...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR LIST VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER FOR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR LIST BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP FU...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
n = int(input()) n2 = n // 2 c = input() a = input() cl = [] ac = [] uni = [] par = [] res = [] for i in range(0, n): if c[i] == "1": if a[i] == "0": cl.append(i + 1) else: uni.append(i + 1) elif a[i] == "0": par.append(i + 1) else: ac.append(i + 1) lc...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR STRING IF VAR VAR STRING EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL V...
Polycarp is a head of a circus troupe. There are n — an even number — artists in the troupe. It is known whether the i-th artist can perform as a clown (if yes, then c_i = 1, otherwise c_i = 0), and whether they can perform as an acrobat (if yes, then a_i = 1, otherwise a_i = 0). Split the artists into two performance...
def half(a): sa = sum(a) sb = sa // 2 a13 = a[1] + a[3] for b1 in range(a[1] + 1): for b3 in range(a[3] + 1): b2 = a13 - b1 - 2 * b3 if not 0 <= b2 <= a[2]: continue b0 = sb - b1 - b2 - b3 if 0 <= b0 <= a[0]: return ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP NUMBER VAR IF NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR...