description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
There is a new attraction in Singapore Zoo: The Infinite Zoo. The Infinite Zoo can be represented by a graph with an infinite number of vertices labeled $1,2,3,\ldots$. There is a directed edge from vertex $u$ to vertex $u+v$ if and only if $u\&v=v$, where $\&$ denotes the bitwise AND operation . There are no other edges in the graph. Zookeeper has $q$ queries. In the $i$-th query she will ask you if she can travel from vertex $u_i$ to vertex $v_i$ by going through directed edges. -----Input----- The first line contains an integer $q$ ($1 \leq q \leq 10^5$) — the number of queries. The $i$-th of the next $q$ lines will contain two integers $u_i$, $v_i$ ($1 \leq u_i, v_i < 2^{30}$) — a query made by Zookeeper. -----Output----- For the $i$-th of the $q$ queries, output "YES" in a single line if Zookeeper can travel from vertex $u_i$ to vertex $v_i$. Otherwise, output "NO". You can print your answer in any case. For example, if the answer is "YES", then the output "Yes" or "yeS" will also be considered as correct answer. -----Examples----- Input 5 1 4 3 6 1 6 6 2 5 5 Output YES YES NO NO YES -----Note----- The subgraph on vertices $1,2,3,4,5,6$ is shown below.
for _ in range(int(input())): u, v = map(int, input().split()) fla = 1 if u > v: print("NO") continue num1 = 0 num2 = 0 for i in range(32): if u & 1 << i: num1 += 1 if v & 1 << i: num2 += 1 if num1 < num2: fla = 0 if fla: print("YES") else: print("NO")
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 IF VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING
There is a new attraction in Singapore Zoo: The Infinite Zoo. The Infinite Zoo can be represented by a graph with an infinite number of vertices labeled $1,2,3,\ldots$. There is a directed edge from vertex $u$ to vertex $u+v$ if and only if $u\&v=v$, where $\&$ denotes the bitwise AND operation . There are no other edges in the graph. Zookeeper has $q$ queries. In the $i$-th query she will ask you if she can travel from vertex $u_i$ to vertex $v_i$ by going through directed edges. -----Input----- The first line contains an integer $q$ ($1 \leq q \leq 10^5$) — the number of queries. The $i$-th of the next $q$ lines will contain two integers $u_i$, $v_i$ ($1 \leq u_i, v_i < 2^{30}$) — a query made by Zookeeper. -----Output----- For the $i$-th of the $q$ queries, output "YES" in a single line if Zookeeper can travel from vertex $u_i$ to vertex $v_i$. Otherwise, output "NO". You can print your answer in any case. For example, if the answer is "YES", then the output "Yes" or "yeS" will also be considered as correct answer. -----Examples----- Input 5 1 4 3 6 1 6 6 2 5 5 Output YES YES NO NO YES -----Note----- The subgraph on vertices $1,2,3,4,5,6$ is shown below.
t = int(input()) def lsb(a): return a & -a def solve(): a, b = map(int, input().split()) if a > b: return "NO" else: ispossible = True while b != 0: if lsb(a) > lsb(b) or a == 0: return "NO" else: a -= lsb(a) b -= lsb(b) return "YES" for qwerty in range(t): print(solve())
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN BIN_OP VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR RETURN STRING ASSIGN VAR NUMBER WHILE VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR NUMBER RETURN STRING VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR RETURN STRING FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR
There is a new attraction in Singapore Zoo: The Infinite Zoo. The Infinite Zoo can be represented by a graph with an infinite number of vertices labeled $1,2,3,\ldots$. There is a directed edge from vertex $u$ to vertex $u+v$ if and only if $u\&v=v$, where $\&$ denotes the bitwise AND operation . There are no other edges in the graph. Zookeeper has $q$ queries. In the $i$-th query she will ask you if she can travel from vertex $u_i$ to vertex $v_i$ by going through directed edges. -----Input----- The first line contains an integer $q$ ($1 \leq q \leq 10^5$) — the number of queries. The $i$-th of the next $q$ lines will contain two integers $u_i$, $v_i$ ($1 \leq u_i, v_i < 2^{30}$) — a query made by Zookeeper. -----Output----- For the $i$-th of the $q$ queries, output "YES" in a single line if Zookeeper can travel from vertex $u_i$ to vertex $v_i$. Otherwise, output "NO". You can print your answer in any case. For example, if the answer is "YES", then the output "Yes" or "yeS" will also be considered as correct answer. -----Examples----- Input 5 1 4 3 6 1 6 6 2 5 5 Output YES YES NO NO YES -----Note----- The subgraph on vertices $1,2,3,4,5,6$ is shown below.
t = int(input()) for _ in range(t): a, b = map(int, input().split()) if b == a: print("YES") continue if b < a: print("NO") continue works = True aCount = 0 bCount = 0 i = 0 c = 1 << i while c <= b: if b & c: bCount += 1 if a & c: aCount += 1 if bCount > aCount: works = False break i += 1 c = 1 << i if not works: print("NO") else: print("YES")
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 VAR EXPR FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR WHILE VAR VAR IF BIN_OP VAR VAR VAR NUMBER IF BIN_OP VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR IF VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING
There is a new attraction in Singapore Zoo: The Infinite Zoo. The Infinite Zoo can be represented by a graph with an infinite number of vertices labeled $1,2,3,\ldots$. There is a directed edge from vertex $u$ to vertex $u+v$ if and only if $u\&v=v$, where $\&$ denotes the bitwise AND operation . There are no other edges in the graph. Zookeeper has $q$ queries. In the $i$-th query she will ask you if she can travel from vertex $u_i$ to vertex $v_i$ by going through directed edges. -----Input----- The first line contains an integer $q$ ($1 \leq q \leq 10^5$) — the number of queries. The $i$-th of the next $q$ lines will contain two integers $u_i$, $v_i$ ($1 \leq u_i, v_i < 2^{30}$) — a query made by Zookeeper. -----Output----- For the $i$-th of the $q$ queries, output "YES" in a single line if Zookeeper can travel from vertex $u_i$ to vertex $v_i$. Otherwise, output "NO". You can print your answer in any case. For example, if the answer is "YES", then the output "Yes" or "yeS" will also be considered as correct answer. -----Examples----- Input 5 1 4 3 6 1 6 6 2 5 5 Output YES YES NO NO YES -----Note----- The subgraph on vertices $1,2,3,4,5,6$ is shown below.
for ct in range(int(input())): u, v = map(int, input().split()) if u > v: print("NO") else: total = 0 for i in range(30): if 1 << i & u: total += 1 if 1 << i & v: total -= 1 if total < 0: break print("YES") if total >= 0 else print("NO")
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 VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP NUMBER VAR VAR VAR NUMBER IF BIN_OP BIN_OP NUMBER VAR VAR VAR NUMBER IF VAR NUMBER EXPR VAR NUMBER FUNC_CALL VAR STRING FUNC_CALL VAR STRING
There is a new attraction in Singapore Zoo: The Infinite Zoo. The Infinite Zoo can be represented by a graph with an infinite number of vertices labeled $1,2,3,\ldots$. There is a directed edge from vertex $u$ to vertex $u+v$ if and only if $u\&v=v$, where $\&$ denotes the bitwise AND operation . There are no other edges in the graph. Zookeeper has $q$ queries. In the $i$-th query she will ask you if she can travel from vertex $u_i$ to vertex $v_i$ by going through directed edges. -----Input----- The first line contains an integer $q$ ($1 \leq q \leq 10^5$) — the number of queries. The $i$-th of the next $q$ lines will contain two integers $u_i$, $v_i$ ($1 \leq u_i, v_i < 2^{30}$) — a query made by Zookeeper. -----Output----- For the $i$-th of the $q$ queries, output "YES" in a single line if Zookeeper can travel from vertex $u_i$ to vertex $v_i$. Otherwise, output "NO". You can print your answer in any case. For example, if the answer is "YES", then the output "Yes" or "yeS" will also be considered as correct answer. -----Examples----- Input 5 1 4 3 6 1 6 6 2 5 5 Output YES YES NO NO YES -----Note----- The subgraph on vertices $1,2,3,4,5,6$ is shown below.
import sys zz = 1 sys.setrecursionlimit(10**5) if zz: input = sys.stdin.readline else: sys.stdin = open("input.txt", "r") sys.stdout = open("all.txt", "w") di = [[-1, 0], [1, 0], [0, 1], [0, -1]] def fori(n): return [fi() for i in range(n)] def inc(d, c, x=1): d[c] = d[c] + x if c in d else x def ii(): return input().rstrip() def li(): return [int(xx) for xx in input().split()] def fli(): return [float(x) for x in input().split()] def dadd(d, p, val): if p in d: d[p].append(val) else: d[p] = [val] def gi(): return [xx for xx in input().split()] def gtc(tc, ans): print("Case #" + str(tc) + ":", ans) def cil(n, m): return n // m + int(n % m > 0) def fi(): return int(input()) def pro(a): return reduce(lambda a, b: a * b, a) def swap(a, i, j): a[i], a[j] = a[j], a[i] def prec(a, pre): for i in a: pre.append(pre[-1] + i) pre.pop(0) def YN(flag): print("YES" if flag else "NO") def si(): return list(input().rstrip()) def mi(): return map(int, input().split()) def gh(): sys.stdout.flush() def isvalid(i, j, n, m): return 0 <= i < n and 0 <= j < m def bo(i): return ord(i) - ord("a") def graph(n, m): for i in range(m): x, y = mi() a[x].append(y) a[y].append(x) t = fi() INF = 10**18 uu = t def dfs(i): vis[i] = 1 if i > n: return for j in a[i]: if j not in vis: dfs(j) while t > 0: t -= 1 u, v = mi() if u > v: print("NO") else: flag = 0 p = bin(u)[2:] q = bin(v)[2:] p = (len(q) - len(p)) * "0" + p c = d = 0 for i in range(len(p) - 1, -1, -1): c += int(p[i]) d += int(q[i]) if d > c: flag = 1 break YN(flag ^ 1)
IMPORT ASSIGN VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER IF VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR LIST LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER LIST NUMBER NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF NUMBER ASSIGN VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR LIST VAR FUNC_DEF RETURN VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR BIN_OP BIN_OP STRING FUNC_CALL VAR VAR STRING VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR BIN_OP VAR VAR VAR FUNC_DEF ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR FUNC_DEF FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER FUNC_DEF EXPR FUNC_CALL VAR VAR STRING STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR FUNC_DEF RETURN NUMBER VAR VAR NUMBER VAR VAR FUNC_DEF RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING FUNC_DEF FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR NUMBER IF VAR VAR RETURN FOR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR STRING VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER
There is a new attraction in Singapore Zoo: The Infinite Zoo. The Infinite Zoo can be represented by a graph with an infinite number of vertices labeled $1,2,3,\ldots$. There is a directed edge from vertex $u$ to vertex $u+v$ if and only if $u\&v=v$, where $\&$ denotes the bitwise AND operation . There are no other edges in the graph. Zookeeper has $q$ queries. In the $i$-th query she will ask you if she can travel from vertex $u_i$ to vertex $v_i$ by going through directed edges. -----Input----- The first line contains an integer $q$ ($1 \leq q \leq 10^5$) — the number of queries. The $i$-th of the next $q$ lines will contain two integers $u_i$, $v_i$ ($1 \leq u_i, v_i < 2^{30}$) — a query made by Zookeeper. -----Output----- For the $i$-th of the $q$ queries, output "YES" in a single line if Zookeeper can travel from vertex $u_i$ to vertex $v_i$. Otherwise, output "NO". You can print your answer in any case. For example, if the answer is "YES", then the output "Yes" or "yeS" will also be considered as correct answer. -----Examples----- Input 5 1 4 3 6 1 6 6 2 5 5 Output YES YES NO NO YES -----Note----- The subgraph on vertices $1,2,3,4,5,6$ is shown below.
q = int(input().strip()) out = "" AAA = 2**30 for _ in range(q): u, v = map(int, input().strip().split()) if u > v: out += "NO\n" else: U, V = bin(u + AAA), bin(v + AAA) u_1, v_1 = 0, 0 for x in range(32, 2, -1): u_1 += U[x] == "1" v_1 += V[x] == "1" if u_1 < v_1: out += "NO\n" break else: out += "YES\n" print(out)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR IF VAR VAR VAR STRING ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER VAR VAR VAR STRING VAR VAR VAR STRING IF VAR VAR VAR STRING VAR STRING EXPR FUNC_CALL VAR VAR
There is a new attraction in Singapore Zoo: The Infinite Zoo. The Infinite Zoo can be represented by a graph with an infinite number of vertices labeled $1,2,3,\ldots$. There is a directed edge from vertex $u$ to vertex $u+v$ if and only if $u\&v=v$, where $\&$ denotes the bitwise AND operation . There are no other edges in the graph. Zookeeper has $q$ queries. In the $i$-th query she will ask you if she can travel from vertex $u_i$ to vertex $v_i$ by going through directed edges. -----Input----- The first line contains an integer $q$ ($1 \leq q \leq 10^5$) — the number of queries. The $i$-th of the next $q$ lines will contain two integers $u_i$, $v_i$ ($1 \leq u_i, v_i < 2^{30}$) — a query made by Zookeeper. -----Output----- For the $i$-th of the $q$ queries, output "YES" in a single line if Zookeeper can travel from vertex $u_i$ to vertex $v_i$. Otherwise, output "NO". You can print your answer in any case. For example, if the answer is "YES", then the output "Yes" or "yeS" will also be considered as correct answer. -----Examples----- Input 5 1 4 3 6 1 6 6 2 5 5 Output YES YES NO NO YES -----Note----- The subgraph on vertices $1,2,3,4,5,6$ is shown below.
from itertools import zip_longest Q = int(input()) queries = [tuple(map(int, input().split())) for _ in range(Q)] def popcnt(x): return bin(x).count("1") for u, v in queries: if u > v: print("NO") elif u == v: print("YES") else: u = bin(u)[::-1] v = bin(v)[::-1] battle = 0 for x, y in zip_longest(u, v[:-2]): battle += int(x == "1") - int(y == "1") if battle < 0: print("NO") break else: print("YES")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR VAR STRING FOR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR STRING FUNC_CALL VAR VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING
There is a new attraction in Singapore Zoo: The Infinite Zoo. The Infinite Zoo can be represented by a graph with an infinite number of vertices labeled $1,2,3,\ldots$. There is a directed edge from vertex $u$ to vertex $u+v$ if and only if $u\&v=v$, where $\&$ denotes the bitwise AND operation . There are no other edges in the graph. Zookeeper has $q$ queries. In the $i$-th query she will ask you if she can travel from vertex $u_i$ to vertex $v_i$ by going through directed edges. -----Input----- The first line contains an integer $q$ ($1 \leq q \leq 10^5$) — the number of queries. The $i$-th of the next $q$ lines will contain two integers $u_i$, $v_i$ ($1 \leq u_i, v_i < 2^{30}$) — a query made by Zookeeper. -----Output----- For the $i$-th of the $q$ queries, output "YES" in a single line if Zookeeper can travel from vertex $u_i$ to vertex $v_i$. Otherwise, output "NO". You can print your answer in any case. For example, if the answer is "YES", then the output "Yes" or "yeS" will also be considered as correct answer. -----Examples----- Input 5 1 4 3 6 1 6 6 2 5 5 Output YES YES NO NO YES -----Note----- The subgraph on vertices $1,2,3,4,5,6$ is shown below.
from itertools import zip_longest from sys import * input = stdin.readline for _ in range(int(input())): u, v = map(int, input().split()) bit_u, bit_v = bin(u)[2:][::-1], bin(v)[2:][::-1] cnt_u, cnt_v = 0, 0 ans = 0 for i, j in zip_longest(bit_u, bit_v, fillvalue="0"): if i == "1": cnt_u += 1 if j == "1": cnt_v += 1 if cnt_v > cnt_u: break if cnt_v > cnt_u or v < u: print("No") else: print("Yes")
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 VAR FUNC_CALL VAR VAR NUMBER NUMBER FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR STRING IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER IF VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING
There is a new attraction in Singapore Zoo: The Infinite Zoo. The Infinite Zoo can be represented by a graph with an infinite number of vertices labeled $1,2,3,\ldots$. There is a directed edge from vertex $u$ to vertex $u+v$ if and only if $u\&v=v$, where $\&$ denotes the bitwise AND operation . There are no other edges in the graph. Zookeeper has $q$ queries. In the $i$-th query she will ask you if she can travel from vertex $u_i$ to vertex $v_i$ by going through directed edges. -----Input----- The first line contains an integer $q$ ($1 \leq q \leq 10^5$) — the number of queries. The $i$-th of the next $q$ lines will contain two integers $u_i$, $v_i$ ($1 \leq u_i, v_i < 2^{30}$) — a query made by Zookeeper. -----Output----- For the $i$-th of the $q$ queries, output "YES" in a single line if Zookeeper can travel from vertex $u_i$ to vertex $v_i$. Otherwise, output "NO". You can print your answer in any case. For example, if the answer is "YES", then the output "Yes" or "yeS" will also be considered as correct answer. -----Examples----- Input 5 1 4 3 6 1 6 6 2 5 5 Output YES YES NO NO YES -----Note----- The subgraph on vertices $1,2,3,4,5,6$ is shown below.
import sys mod = 1000000007 eps = 10**-9 def main(): import sys input = sys.stdin.buffer.readline for _ in range(int(input())): u, v = map(int, input().split()) if u > v: print("NO") continue u_bin = bin(u)[2:] v_bin = bin(v)[2:] if u_bin.count("1") < v_bin.count("1"): print("NO") continue L = len(v_bin) u_bin = u_bin.zfill(L) ok = 1 cnt_01 = cnt_10 = 0 for i in range(L - 1, -1, -1): if u_bin[i] == "0" and v_bin[i] == "1": cnt_01 += 1 elif u_bin[i] == "1" and v_bin[i] == "0": cnt_10 += 1 if cnt_01 > cnt_10: ok = 0 break if ok: print("YES") else: print("NO") main()
IMPORT ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FUNC_DEF 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 IF VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR STRING FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR STRING VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR VAR STRING VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR
There is a new attraction in Singapore Zoo: The Infinite Zoo. The Infinite Zoo can be represented by a graph with an infinite number of vertices labeled $1,2,3,\ldots$. There is a directed edge from vertex $u$ to vertex $u+v$ if and only if $u\&v=v$, where $\&$ denotes the bitwise AND operation . There are no other edges in the graph. Zookeeper has $q$ queries. In the $i$-th query she will ask you if she can travel from vertex $u_i$ to vertex $v_i$ by going through directed edges. -----Input----- The first line contains an integer $q$ ($1 \leq q \leq 10^5$) — the number of queries. The $i$-th of the next $q$ lines will contain two integers $u_i$, $v_i$ ($1 \leq u_i, v_i < 2^{30}$) — a query made by Zookeeper. -----Output----- For the $i$-th of the $q$ queries, output "YES" in a single line if Zookeeper can travel from vertex $u_i$ to vertex $v_i$. Otherwise, output "NO". You can print your answer in any case. For example, if the answer is "YES", then the output "Yes" or "yeS" will also be considered as correct answer. -----Examples----- Input 5 1 4 3 6 1 6 6 2 5 5 Output YES YES NO NO YES -----Note----- The subgraph on vertices $1,2,3,4,5,6$ is shown below.
def main(u, v): if u > v: return False if u == v: return True if u & 1 == 0 and v & 1 == 1: return False if u & 1 == v & 1: return main(u >> 1, v >> 1) if u & 2 == 0: return main(u + 1, v) k = 1 while k & u == k: k <<= 1 k += 1 k >>= 1 if u + k >= v: return True return main(u + k, v) res = [] for _ in range(int(input())): u, v = map(int, input().split()) res.append("YES" if main(u, v) else "NO") print(*res, sep="\n")
FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR VAR RETURN NUMBER IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER RETURN NUMBER IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER RETURN FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER RETURN FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR VAR RETURN NUMBER RETURN FUNC_CALL VAR BIN_OP VAR VAR VAR 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 EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR STRING STRING EXPR FUNC_CALL VAR VAR STRING
There is a new attraction in Singapore Zoo: The Infinite Zoo. The Infinite Zoo can be represented by a graph with an infinite number of vertices labeled $1,2,3,\ldots$. There is a directed edge from vertex $u$ to vertex $u+v$ if and only if $u\&v=v$, where $\&$ denotes the bitwise AND operation . There are no other edges in the graph. Zookeeper has $q$ queries. In the $i$-th query she will ask you if she can travel from vertex $u_i$ to vertex $v_i$ by going through directed edges. -----Input----- The first line contains an integer $q$ ($1 \leq q \leq 10^5$) — the number of queries. The $i$-th of the next $q$ lines will contain two integers $u_i$, $v_i$ ($1 \leq u_i, v_i < 2^{30}$) — a query made by Zookeeper. -----Output----- For the $i$-th of the $q$ queries, output "YES" in a single line if Zookeeper can travel from vertex $u_i$ to vertex $v_i$. Otherwise, output "NO". You can print your answer in any case. For example, if the answer is "YES", then the output "Yes" or "yeS" will also be considered as correct answer. -----Examples----- Input 5 1 4 3 6 1 6 6 2 5 5 Output YES YES NO NO YES -----Note----- The subgraph on vertices $1,2,3,4,5,6$ is shown below.
def f(x): a = [] while x: a.append(x & 1) x //= 2 return a + [0] * (30 - len(a)) for _ in range(int(input())): u, v = map(int, input().split()) if u > v: print("NO") continue a, b = f(u), f(v) if a.count(1) < b.count(1): print("NO") continue flag = 0 ac = bc = 0 for i in range(30): bc += b[i] ac += a[i] if b[i] == 1 and a[i] == 0: if bc > ac: print("NO") flag = 1 break if flag == 0: print("YES")
FUNC_DEF ASSIGN VAR LIST WHILE VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER RETURN BIN_OP VAR BIN_OP LIST NUMBER BIN_OP NUMBER FUNC_CALL 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 IF VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR NUMBER FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR VAR VAR IF VAR VAR NUMBER VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING
There is a new attraction in Singapore Zoo: The Infinite Zoo. The Infinite Zoo can be represented by a graph with an infinite number of vertices labeled $1,2,3,\ldots$. There is a directed edge from vertex $u$ to vertex $u+v$ if and only if $u\&v=v$, where $\&$ denotes the bitwise AND operation . There are no other edges in the graph. Zookeeper has $q$ queries. In the $i$-th query she will ask you if she can travel from vertex $u_i$ to vertex $v_i$ by going through directed edges. -----Input----- The first line contains an integer $q$ ($1 \leq q \leq 10^5$) — the number of queries. The $i$-th of the next $q$ lines will contain two integers $u_i$, $v_i$ ($1 \leq u_i, v_i < 2^{30}$) — a query made by Zookeeper. -----Output----- For the $i$-th of the $q$ queries, output "YES" in a single line if Zookeeper can travel from vertex $u_i$ to vertex $v_i$. Otherwise, output "NO". You can print your answer in any case. For example, if the answer is "YES", then the output "Yes" or "yeS" will also be considered as correct answer. -----Examples----- Input 5 1 4 3 6 1 6 6 2 5 5 Output YES YES NO NO YES -----Note----- The subgraph on vertices $1,2,3,4,5,6$ is shown below.
import sys input = sys.stdin.buffer.readline for i in range(int(input())): u, v = map(int, input().split()) gu = [] gv = [] c = 0 k = 0 while u > 0 or v > 0: gu.append(u % 2) gv.append(v % 2) u = u // 2 v = v // 2 c = c + 1 for j in range(c - 1, -1, -1): if gu[j] == 1 and gv[j] == 0: k = k + 1 break elif gu[j] == 0 and gv[j] == 1: break sum1 = 0 sum2 = 0 for j in range(c): if gu[j] == 1: sum1 = sum1 + 1 if gv[j] == 1: sum2 = sum2 + 1 if sum1 < sum2: k = k + 1 break if k > 0: print("NO") else: print("YES")
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 LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING
There is a new attraction in Singapore Zoo: The Infinite Zoo. The Infinite Zoo can be represented by a graph with an infinite number of vertices labeled $1,2,3,\ldots$. There is a directed edge from vertex $u$ to vertex $u+v$ if and only if $u\&v=v$, where $\&$ denotes the bitwise AND operation . There are no other edges in the graph. Zookeeper has $q$ queries. In the $i$-th query she will ask you if she can travel from vertex $u_i$ to vertex $v_i$ by going through directed edges. -----Input----- The first line contains an integer $q$ ($1 \leq q \leq 10^5$) — the number of queries. The $i$-th of the next $q$ lines will contain two integers $u_i$, $v_i$ ($1 \leq u_i, v_i < 2^{30}$) — a query made by Zookeeper. -----Output----- For the $i$-th of the $q$ queries, output "YES" in a single line if Zookeeper can travel from vertex $u_i$ to vertex $v_i$. Otherwise, output "NO". You can print your answer in any case. For example, if the answer is "YES", then the output "Yes" or "yeS" will also be considered as correct answer. -----Examples----- Input 5 1 4 3 6 1 6 6 2 5 5 Output YES YES NO NO YES -----Note----- The subgraph on vertices $1,2,3,4,5,6$ is shown below.
def toBinArr(n, size=None): if size is None: arr = [] while n > 0: arr.append(n % 2) n //= 2 else: arr = [0] * size i = 0 while n > 0: arr[i] = n % 2 n //= 2 i += 1 return arr def solve(src, dst): if dst < src: return False dst = toBinArr(dst) src = toBinArr(src, len(dst) + 1) for i in range(len(dst)): if src[i] == dst[i]: continue elif dst[i] == 0: src[i] = 0 src[i + 1] += 1 elif dst[i] == 1: if src[i] == 0: return False elif src[i] == 2: src[i] = 1 src[i + 1] += 1 else: print("Fail") if src[-1] == 1: return False return True def solve2(src, dst): if dst < src: return False dst = toBinArr(dst) src = toBinArr(src, len(dst)) accSrc, accDst = 0, 0 for i in range(len(dst)): accSrc += src[i] accDst += dst[i] if accDst > accSrc: return False return True numCases = int(input()) for i in range(1, numCases + 1): src, dst = [int(s) for s in input().split(" ")] ans = solve2(src, dst) if ans == True: print("YES") else: print("NO")
FUNC_DEF NONE IF VAR NONE ASSIGN VAR LIST WHILE VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR NUMBER IF VAR VAR NUMBER RETURN NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR VAR IF VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING
There is a new attraction in Singapore Zoo: The Infinite Zoo. The Infinite Zoo can be represented by a graph with an infinite number of vertices labeled $1,2,3,\ldots$. There is a directed edge from vertex $u$ to vertex $u+v$ if and only if $u\&v=v$, where $\&$ denotes the bitwise AND operation . There are no other edges in the graph. Zookeeper has $q$ queries. In the $i$-th query she will ask you if she can travel from vertex $u_i$ to vertex $v_i$ by going through directed edges. -----Input----- The first line contains an integer $q$ ($1 \leq q \leq 10^5$) — the number of queries. The $i$-th of the next $q$ lines will contain two integers $u_i$, $v_i$ ($1 \leq u_i, v_i < 2^{30}$) — a query made by Zookeeper. -----Output----- For the $i$-th of the $q$ queries, output "YES" in a single line if Zookeeper can travel from vertex $u_i$ to vertex $v_i$. Otherwise, output "NO". You can print your answer in any case. For example, if the answer is "YES", then the output "Yes" or "yeS" will also be considered as correct answer. -----Examples----- Input 5 1 4 3 6 1 6 6 2 5 5 Output YES YES NO NO YES -----Note----- The subgraph on vertices $1,2,3,4,5,6$ is shown below.
def solve(u, v): if u == v: return True if v % u == 0 and v // u & v // u - 1 == 0: return True if u > v: return False if u % 2 == 0 and v % 2 == 1: return False binU = format(u, "b") binV = format(v, "b") binULength = len(binU) binVLength = len(binV) uOnesCount = 0 vOnesCount = 0 for i in range(1, binVLength + 1): if i <= binULength: if binU[binULength - i] == "1": uOnesCount += 1 if binV[binVLength - i] == "1": vOnesCount += 1 if uOnesCount < vOnesCount: return False return True q = int(input()) for i in range(q): u, v = map(int, input().split()) result = solve(u, v) print("YES" if result else "NO")
FUNC_DEF IF VAR VAR RETURN NUMBER IF BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER RETURN NUMBER IF VAR VAR RETURN NUMBER IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR IF VAR BIN_OP VAR VAR STRING VAR NUMBER IF VAR BIN_OP VAR VAR STRING VAR NUMBER IF VAR VAR RETURN NUMBER RETURN NUMBER 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 ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR STRING STRING
There is a new attraction in Singapore Zoo: The Infinite Zoo. The Infinite Zoo can be represented by a graph with an infinite number of vertices labeled $1,2,3,\ldots$. There is a directed edge from vertex $u$ to vertex $u+v$ if and only if $u\&v=v$, where $\&$ denotes the bitwise AND operation . There are no other edges in the graph. Zookeeper has $q$ queries. In the $i$-th query she will ask you if she can travel from vertex $u_i$ to vertex $v_i$ by going through directed edges. -----Input----- The first line contains an integer $q$ ($1 \leq q \leq 10^5$) — the number of queries. The $i$-th of the next $q$ lines will contain two integers $u_i$, $v_i$ ($1 \leq u_i, v_i < 2^{30}$) — a query made by Zookeeper. -----Output----- For the $i$-th of the $q$ queries, output "YES" in a single line if Zookeeper can travel from vertex $u_i$ to vertex $v_i$. Otherwise, output "NO". You can print your answer in any case. For example, if the answer is "YES", then the output "Yes" or "yeS" will also be considered as correct answer. -----Examples----- Input 5 1 4 3 6 1 6 6 2 5 5 Output YES YES NO NO YES -----Note----- The subgraph on vertices $1,2,3,4,5,6$ is shown below.
for _ in range(int(input())): ui, vi = map(int, input().split()) if ui <= vi: uib = str(bin(ui)[2:]).rjust(31, "0") vib = str(bin(vi)[2:]).rjust(31, "0") nosu = 0 nosv = 0 for i in range(30, -1, -1): if nosu < nosv: print("NO") break if uib[i] == "1": nosu += 1 if vib[i] == "1": nosv += 1 else: print("YES") else: print("NO")
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 VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING
There is a new attraction in Singapore Zoo: The Infinite Zoo. The Infinite Zoo can be represented by a graph with an infinite number of vertices labeled $1,2,3,\ldots$. There is a directed edge from vertex $u$ to vertex $u+v$ if and only if $u\&v=v$, where $\&$ denotes the bitwise AND operation . There are no other edges in the graph. Zookeeper has $q$ queries. In the $i$-th query she will ask you if she can travel from vertex $u_i$ to vertex $v_i$ by going through directed edges. -----Input----- The first line contains an integer $q$ ($1 \leq q \leq 10^5$) — the number of queries. The $i$-th of the next $q$ lines will contain two integers $u_i$, $v_i$ ($1 \leq u_i, v_i < 2^{30}$) — a query made by Zookeeper. -----Output----- For the $i$-th of the $q$ queries, output "YES" in a single line if Zookeeper can travel from vertex $u_i$ to vertex $v_i$. Otherwise, output "NO". You can print your answer in any case. For example, if the answer is "YES", then the output "Yes" or "yeS" will also be considered as correct answer. -----Examples----- Input 5 1 4 3 6 1 6 6 2 5 5 Output YES YES NO NO YES -----Note----- The subgraph on vertices $1,2,3,4,5,6$ is shown below.
def check(u, v): a = 0 b = 0 for i in range(31): if u >> i & 1: a += 1 if v >> i & 1: b += 1 if b > 0: if a <= 0: return 0 a -= 1 b -= 1 return 1 T = int(input()) while T > 0: T -= 1 u, v = map(int, input().split()) if u <= v and check(u, v) == 1: print("YES") else: print("NO")
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER IF VAR NUMBER IF VAR NUMBER RETURN NUMBER VAR NUMBER VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING
This is an easier version of the problem with smaller constraints. Korney Korneevich dag up an array $a$ of length $n$. Korney Korneevich has recently read about the operation bitwise XOR , so he wished to experiment with it. For this purpose, he decided to find all integers $x \ge 0$ such that there exists an increasing subsequence of the array $a$, in which the bitwise XOR of numbers is equal to $x$. It didn't take a long time for Korney Korneevich to find all such $x$, and he wants to check his result. That's why he asked you to solve this problem! A sequence $s$ is a subsequence of a sequence $b$ if $s$ can be obtained from $b$ by deletion of several (possibly, zero or all) elements. A sequence $s_1, s_2, \ldots , s_m$ is called increasing if $s_1 < s_2 < \ldots < s_m$. -----Input----- The first line contains a single integer $n$ ($1 \le n \le 10^5$). The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($0 \le a_i \le 500$) — the elements of the array $a$. -----Output----- In the first line print a single integer $k$ — the number of found $x$ values. In the second line print $k$ integers in increasing order $x_1, x_2, \ldots x_k$ ($0 \le x_1 < \ldots < x_k$) — found $x$ values. -----Examples----- Input 4 4 2 2 4 Output 4 0 2 4 6 Input 8 1 0 1 7 12 5 3 2 Output 12 0 1 2 3 4 5 6 7 10 11 12 13 -----Note----- In the first test case: To get value $x = 0$ it is possible to choose and empty subsequence To get value $x = 2$ it is possible to choose a subsequence $[2]$ To get value $x = 4$ it is possible to choose a subsequence $[4]$ To get value $x = 6$ it is possible to choose a subsequence $[2, 4]$
n = int(input()) a = list(map(int, input().split())) min_subsequence_end = [None] * 1024 min_subsequence_end[0] = 0 for a_i in a: for x, end in enumerate(min_subsequence_end): if end is not None and end < a_i: if ( min_subsequence_end[a_i ^ x] is None or min_subsequence_end[a_i ^ x] > a_i ): min_subsequence_end[a_i ^ x] = a_i x = [i for i, end in enumerate(min_subsequence_end) if end is not None] print(len(x)) 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 BIN_OP LIST NONE NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR VAR FOR VAR VAR FUNC_CALL VAR VAR IF VAR NONE VAR VAR IF VAR BIN_OP VAR VAR NONE VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR NONE EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR
This is an easier version of the problem with smaller constraints. Korney Korneevich dag up an array $a$ of length $n$. Korney Korneevich has recently read about the operation bitwise XOR , so he wished to experiment with it. For this purpose, he decided to find all integers $x \ge 0$ such that there exists an increasing subsequence of the array $a$, in which the bitwise XOR of numbers is equal to $x$. It didn't take a long time for Korney Korneevich to find all such $x$, and he wants to check his result. That's why he asked you to solve this problem! A sequence $s$ is a subsequence of a sequence $b$ if $s$ can be obtained from $b$ by deletion of several (possibly, zero or all) elements. A sequence $s_1, s_2, \ldots , s_m$ is called increasing if $s_1 < s_2 < \ldots < s_m$. -----Input----- The first line contains a single integer $n$ ($1 \le n \le 10^5$). The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($0 \le a_i \le 500$) — the elements of the array $a$. -----Output----- In the first line print a single integer $k$ — the number of found $x$ values. In the second line print $k$ integers in increasing order $x_1, x_2, \ldots x_k$ ($0 \le x_1 < \ldots < x_k$) — found $x$ values. -----Examples----- Input 4 4 2 2 4 Output 4 0 2 4 6 Input 8 1 0 1 7 12 5 3 2 Output 12 0 1 2 3 4 5 6 7 10 11 12 13 -----Note----- In the first test case: To get value $x = 0$ it is possible to choose and empty subsequence To get value $x = 2$ it is possible to choose a subsequence $[2]$ To get value $x = 4$ it is possible to choose a subsequence $[4]$ To get value $x = 6$ it is possible to choose a subsequence $[2, 4]$
def korney(a): inf = float("inf") xors_by_a = {(0): [0]} a_by_xor = {(0): 0} used_a = [0] recent = set() for ai in a: if len(a_by_xor.keys()) == 512: break if ai in recent: continue else: recent.add(ai) changed = False for aj in used_a: if aj >= ai: break for existing_xor in xors_by_a[aj]: new_xor = ai ^ existing_xor if a_by_xor.get(new_xor, inf) > ai: a_by_xor[new_xor] = ai changed = True if changed: xors_by_a = recreate_xors_by_a(a_by_xor) used_a = sorted(xors_by_a.keys()) recent = set() print(len(a_by_xor.keys())) print(" ".join(map(str, sorted(a_by_xor.keys())))) def recreate_xors_by_a(a_by_xor): xors_by_a = {} for xor_value, a in a_by_xor.items(): if a in xors_by_a: xors_by_a[a] += [xor_value] else: xors_by_a[a] = [xor_value] return xors_by_a n = int(input()) a = list(map(int, input().split(" "))) korney(a)
FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR DICT NUMBER LIST NUMBER ASSIGN VAR DICT NUMBER NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF FUNC_CALL VAR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR FOR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER IF VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR DICT FOR VAR VAR FUNC_CALL VAR IF VAR VAR VAR VAR LIST VAR ASSIGN VAR VAR LIST VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR
This is an easier version of the problem with smaller constraints. Korney Korneevich dag up an array $a$ of length $n$. Korney Korneevich has recently read about the operation bitwise XOR , so he wished to experiment with it. For this purpose, he decided to find all integers $x \ge 0$ such that there exists an increasing subsequence of the array $a$, in which the bitwise XOR of numbers is equal to $x$. It didn't take a long time for Korney Korneevich to find all such $x$, and he wants to check his result. That's why he asked you to solve this problem! A sequence $s$ is a subsequence of a sequence $b$ if $s$ can be obtained from $b$ by deletion of several (possibly, zero or all) elements. A sequence $s_1, s_2, \ldots , s_m$ is called increasing if $s_1 < s_2 < \ldots < s_m$. -----Input----- The first line contains a single integer $n$ ($1 \le n \le 10^5$). The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($0 \le a_i \le 500$) — the elements of the array $a$. -----Output----- In the first line print a single integer $k$ — the number of found $x$ values. In the second line print $k$ integers in increasing order $x_1, x_2, \ldots x_k$ ($0 \le x_1 < \ldots < x_k$) — found $x$ values. -----Examples----- Input 4 4 2 2 4 Output 4 0 2 4 6 Input 8 1 0 1 7 12 5 3 2 Output 12 0 1 2 3 4 5 6 7 10 11 12 13 -----Note----- In the first test case: To get value $x = 0$ it is possible to choose and empty subsequence To get value $x = 2$ it is possible to choose a subsequence $[2]$ To get value $x = 4$ it is possible to choose a subsequence $[4]$ To get value $x = 6$ it is possible to choose a subsequence $[2, 4]$
import sys input = sys.stdin.readline n = int(input()) a = list(map(int, input().split())) inf = float("inf") A = [inf] * 512 A[0] = 0 for x in a: B = A[:] for y in range(512): if A[y] < x: B[y ^ x] = min(B[y ^ x], A[y ^ x], x) A = B[:] ans = [] for y in range(512): if A[y] != inf: ans.append(y) print(len(ans)) print(*ans)
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 FUNC_CALL VAR STRING ASSIGN VAR BIN_OP LIST VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR
This is an easier version of the problem with smaller constraints. Korney Korneevich dag up an array $a$ of length $n$. Korney Korneevich has recently read about the operation bitwise XOR , so he wished to experiment with it. For this purpose, he decided to find all integers $x \ge 0$ such that there exists an increasing subsequence of the array $a$, in which the bitwise XOR of numbers is equal to $x$. It didn't take a long time for Korney Korneevich to find all such $x$, and he wants to check his result. That's why he asked you to solve this problem! A sequence $s$ is a subsequence of a sequence $b$ if $s$ can be obtained from $b$ by deletion of several (possibly, zero or all) elements. A sequence $s_1, s_2, \ldots , s_m$ is called increasing if $s_1 < s_2 < \ldots < s_m$. -----Input----- The first line contains a single integer $n$ ($1 \le n \le 10^5$). The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($0 \le a_i \le 500$) — the elements of the array $a$. -----Output----- In the first line print a single integer $k$ — the number of found $x$ values. In the second line print $k$ integers in increasing order $x_1, x_2, \ldots x_k$ ($0 \le x_1 < \ldots < x_k$) — found $x$ values. -----Examples----- Input 4 4 2 2 4 Output 4 0 2 4 6 Input 8 1 0 1 7 12 5 3 2 Output 12 0 1 2 3 4 5 6 7 10 11 12 13 -----Note----- In the first test case: To get value $x = 0$ it is possible to choose and empty subsequence To get value $x = 2$ it is possible to choose a subsequence $[2]$ To get value $x = 4$ it is possible to choose a subsequence $[4]$ To get value $x = 6$ it is possible to choose a subsequence $[2, 4]$
def process(A): answer = [float("inf") for i in range(512)] answer[0] = -1 my_count = 511 for x in A: for y in range(512): if answer[x ^ y] < x: my_count -= 1 answer[y] = min(answer[y], x) final_answer = [] for i in range(512): if answer[i] < float("inf"): final_answer.append(i) return final_answer n = int(input()) A = [int(x) for x in input().split()] answer = process(A) print(len(answer)) print(" ".join(map(str, answer)))
FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF VAR BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR RETURN VAR 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 EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR
This is an easier version of the problem with smaller constraints. Korney Korneevich dag up an array $a$ of length $n$. Korney Korneevich has recently read about the operation bitwise XOR , so he wished to experiment with it. For this purpose, he decided to find all integers $x \ge 0$ such that there exists an increasing subsequence of the array $a$, in which the bitwise XOR of numbers is equal to $x$. It didn't take a long time for Korney Korneevich to find all such $x$, and he wants to check his result. That's why he asked you to solve this problem! A sequence $s$ is a subsequence of a sequence $b$ if $s$ can be obtained from $b$ by deletion of several (possibly, zero or all) elements. A sequence $s_1, s_2, \ldots , s_m$ is called increasing if $s_1 < s_2 < \ldots < s_m$. -----Input----- The first line contains a single integer $n$ ($1 \le n \le 10^5$). The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($0 \le a_i \le 500$) — the elements of the array $a$. -----Output----- In the first line print a single integer $k$ — the number of found $x$ values. In the second line print $k$ integers in increasing order $x_1, x_2, \ldots x_k$ ($0 \le x_1 < \ldots < x_k$) — found $x$ values. -----Examples----- Input 4 4 2 2 4 Output 4 0 2 4 6 Input 8 1 0 1 7 12 5 3 2 Output 12 0 1 2 3 4 5 6 7 10 11 12 13 -----Note----- In the first test case: To get value $x = 0$ it is possible to choose and empty subsequence To get value $x = 2$ it is possible to choose a subsequence $[2]$ To get value $x = 4$ it is possible to choose a subsequence $[4]$ To get value $x = 6$ it is possible to choose a subsequence $[2, 4]$
n = int(input()) a = list(map(int, input().split())) pos = {(0): 0} to_skip = set() for ai in a: if ai in to_skip: continue changed = False for k, v in list(pos.items()): if v < ai: nou = k ^ ai if nou not in pos or ai < pos[nou]: pos[nou] = ai changed = True if not changed: to_skip.add(ai) else: to_skip = set() print(len(pos)) print(" ".join(str(v) for v in sorted(pos)))
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 NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR VAR ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR
This is an easier version of the problem with smaller constraints. Korney Korneevich dag up an array $a$ of length $n$. Korney Korneevich has recently read about the operation bitwise XOR , so he wished to experiment with it. For this purpose, he decided to find all integers $x \ge 0$ such that there exists an increasing subsequence of the array $a$, in which the bitwise XOR of numbers is equal to $x$. It didn't take a long time for Korney Korneevich to find all such $x$, and he wants to check his result. That's why he asked you to solve this problem! A sequence $s$ is a subsequence of a sequence $b$ if $s$ can be obtained from $b$ by deletion of several (possibly, zero or all) elements. A sequence $s_1, s_2, \ldots , s_m$ is called increasing if $s_1 < s_2 < \ldots < s_m$. -----Input----- The first line contains a single integer $n$ ($1 \le n \le 10^5$). The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($0 \le a_i \le 500$) — the elements of the array $a$. -----Output----- In the first line print a single integer $k$ — the number of found $x$ values. In the second line print $k$ integers in increasing order $x_1, x_2, \ldots x_k$ ($0 \le x_1 < \ldots < x_k$) — found $x$ values. -----Examples----- Input 4 4 2 2 4 Output 4 0 2 4 6 Input 8 1 0 1 7 12 5 3 2 Output 12 0 1 2 3 4 5 6 7 10 11 12 13 -----Note----- In the first test case: To get value $x = 0$ it is possible to choose and empty subsequence To get value $x = 2$ it is possible to choose a subsequence $[2]$ To get value $x = 4$ it is possible to choose a subsequence $[4]$ To get value $x = 6$ it is possible to choose a subsequence $[2, 4]$
import sys n = int(sys.stdin.readline().strip()) a = list(map(int, sys.stdin.readline().strip().split(" "))) dp = [10000] * n upd = [[0] for _ in range(8192)] dp = [8192] * 8192 dp[0] = 0 for i in range(n): for x in upd[a[i]]: z = x ^ a[i] p = dp[z] if p > a[i]: dp[z] = a[i] for j in range(a[i] + 1, p): upd[j].append(z) upd[a[i]] = [] res = [] for i in range(8192): if dp[i] != 8192: res.append(i) print(len(res)) print(" ".join(map(str, res)))
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 STRING ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR VAR IF VAR VAR VAR ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l, r = map(int, input().split()) z = l ^ r c = 0 if z == 0: print(0) exit() while z: c += 1 z >>= 1 x = "1" * c print(int(x, 2))
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR WHILE VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
def solve(): l, r = map(int, input().split()) ans = l ^ r j = 0 while 1 << j <= ans: ans |= 1 << j j += 1 print(ans) solve()
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP NUMBER VAR VAR VAR BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l, r = map(int, input().split()) if l == r: print(0) elif r & r - 1 == 0: print(r ^ r - 1) else: x = l ^ r p1 = 1 while p1 <= x: p1 *= 2 print(p1 - 1)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l, r = map(int, input().split(" ")) n1 = bin(l)[2:] n2 = bin(r)[2:] if l == r: print(0) elif len(n1) < len(n2): print(int(len(n2) * "1", 2)) else: index = 0 for i in range(len(n1)): if n1[i] != n2[i]: index = i break print(int((len(n1) - index) * "1", 2))
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR STRING NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR STRING NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
left, right = [int(x) for x in input().split(" ")] if left == right: print(0) else: x = 1 while x <= right: x *= 2 x //= 2 y = x while y > 0 and x <= left or x > right: if x <= left: x += y else: x -= y y //= 2 print(x ^ x - 1)
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER VAR VAR VAR VAR IF VAR VAR VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
import sys l, r = map(int, sys.stdin.readline().split()) i = 64 while i >= 0: if 1 << i & l != 0 and 1 << i & r != 0 or 1 << i & l == 0 and 1 << i & r == 0: i -= 1 else: break print((1 << i + 1) - 1)
IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP BIN_OP NUMBER VAR VAR NUMBER BIN_OP BIN_OP NUMBER VAR VAR NUMBER BIN_OP BIN_OP NUMBER VAR VAR NUMBER BIN_OP BIN_OP NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
a, b = [int(x) for x in input().split(" ")] idx = 0 if a == b: print(0) else: for i in range(63, -1, -1): set1 = a >> i & 1 set2 = b >> i & 1 if set1 != set2: idx = i break print((1 << idx + 1) - 1)
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l, r = [int(i) for i in input().split()] bitafter = -1 for i in range(60, -1, -1): if l & 1 << i != r & 1 << i: bitafter = i break res = 0 while bitafter >= 0: res += 1 << bitafter bitafter -= 1 print(res)
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
a = [int(x) for x in input().split()] n = a[0] ^ a[1] x = bin(n)[2:] f = 0 for i in range(len(x)): if x[i] == "1": f = 1 break l = len(x) - i sum = 0 for i in range(l): sum += 2**i if f == 0: sum = 0 print(sum)
ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP NUMBER VAR IF VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l, r = map(int, input().split()) if l == r: print(0) exit() binr, binl = bin(r)[2:], bin(l)[2:] binl = "0" * (len(binr) - len(binl)) + binl for i in range(len(binl)): if binl[i] != binr[i]: binl = "1" * len(binl[i:]) break print(int(binl, 2))
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR BIN_OP STRING FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
import sys l, r = map(int, sys.stdin.readline().split()) binr = list(str(bin(r)))[2:] binl = list(str(bin(l)))[2:] lenr = len(binr) lenl = len(binl) for i in range(lenr - lenl): binl.insert(0, 0) ans = ["1"] length = lenr status = 0 for i in range(0, length): if status == 1: ans.append("1") if binr[i] != binl[i]: status = 1 if status == 0: print(0) else: strans = "".join(ans) print(int(strans, 2))
IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR LIST STRING ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL STRING VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
numeros = [int(i) for i in input().split(" ")] l = bin(numeros[0]) r = bin(numeros[1]) p = -1 if len(r) == len(l): for i in range(len(l)): if l[i] != r[i]: p = i break if numeros[0] != numeros[1]: saida = 2 ** (len(r) - p) - 1 print(saida) else: print(0) elif numeros[0] != numeros[1]: saida = 2 ** (len(r) - 2) - 1 print(saida) else: print(0)
ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
import sys l, r = tuple(int(x) for x in sys.stdin.readline().split()) l = bin(l) r = bin(r) l = l[2:] r = r[2:] l = l.zfill(len(r)) i = 0 while l[i] == r[i]: if i == len(l) - 1: print(0) return i += 1 i = len(l) - i print(2**i - 1)
IMPORT ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
def bina(bi): binary1 = bi decimal, i, n = 0, 0, 0 while bi != 0: dec = bi % 10 decimal = decimal + dec * pow(2, i) bi = bi // 10 i += 1 return decimal def con(n): return bin(n).replace("0b", "") l, r = map(int, input().split()) k = con(l) m = con(r) k = list(str(k)) m = list(str(m)) j = len(m) - len(k) k = ["0"] * j + k c = 0 for i in range(len(m)): if k[i] != m[i]: c = 1 if k[i] == m[i] and k[i] == "1" and c == 1: k[i] = "0" elif k[i] == m[i] and k[i] == "0" and c == 1: k[i] = "1" k = int("".join(k)) m = int("".join(m)) print(bina(k) ^ bina(m))
FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR VAR STRING STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP LIST STRING VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR VAR VAR VAR VAR VAR STRING VAR NUMBER ASSIGN VAR VAR STRING IF VAR VAR VAR VAR VAR VAR STRING VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l, r = map(int, input().split()) lx = l rx = r l1 = list(bin(l))[2:] r1 = list(bin(r))[2:] l1 = ["0"] * (len(r1) - len(l1)) + l1 n = len(r1) ans = ["0"] * n d = [0] * n f = 0 for i in range(n): if l1[i] != r1[i]: f = 1 d[i] = f for i in range(n): if d[i] == 0: ans[i] = "0" elif l1[i] == "0" and r1[i] == "0": if lx + 2 ** (n - i - 1) < rx: lx += 2 ** (n - i - 1) ans[i] = "1" l1[i] = "1" elif l1[i] == "1" and r1[i] == "1": if rx - 2 ** (n - i - 1) > lx: rx -= 2 ** (n - i - 1) ans[i] = "1" r1[i] = "0" else: ans[i] = "1" k = "".join(ans) print(int(k, 2))
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP LIST STRING BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST STRING VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR STRING IF VAR VAR STRING VAR VAR STRING IF BIN_OP VAR BIN_OP NUMBER BIN_OP BIN_OP VAR VAR NUMBER VAR VAR BIN_OP NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING IF VAR VAR STRING VAR VAR STRING IF BIN_OP VAR BIN_OP NUMBER BIN_OP BIN_OP VAR VAR NUMBER VAR VAR BIN_OP NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING ASSIGN VAR FUNC_CALL STRING VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
def main(): l, r = map(int, input().split()) if l == r: print(0) else: rs = "" while r: rs += "1" if r % 2 else "0" r //= 2 for i in range(len(rs), 65): rs += "0" ls = "" while l: ls += "1" if l % 2 else "0" l //= 2 for i in range(len(ls), 65): ls += "0" pos = -1 for i in range(64, -1, -1): if rs[i] == "1" and ls[i] == "0": pos = i break ans = 2 ** (pos + 1) - 1 print(ans) main()
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR STRING WHILE VAR VAR BIN_OP VAR NUMBER STRING STRING VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR STRING ASSIGN VAR STRING WHILE VAR VAR BIN_OP VAR NUMBER STRING STRING VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF VAR VAR STRING VAR VAR STRING ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
start, end = input().split() start = int(start) end = int(end) maximum = 0 save = end count = 0 if end ^ start == 0: print(0) else: while end ^ start > 0: end = end >> 1 start = start >> 1 count += 1 print(2**count - 1)
ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l, r = map(int, input().split()) z = str(bin(l ^ r))[2:] if int(z) == 0: print(0) else: print(2 ** (len(z) - z.index("1")) - 1)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
a, b = map(int, input().split()) b1 = bin(b)[2:] a1 = bin(a)[2:] if len(a1) == len(b1): d = b ^ a v = d.bit_length() print(int("0" + "1" * v, 2)) else: print(int("1" * len(b1), 2))
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP STRING BIN_OP STRING VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
import sys Ri = lambda: [int(x) for x in sys.stdin.readline().split()] ri = lambda: sys.stdin.readline().strip() def input(): return sys.stdin.readline().strip() def list2d(a, b, c): return [([c] * b) for i in range(a)] def list3d(a, b, c, d): return [[([d] * c) for j in range(b)] for i in range(a)] def list4d(a, b, c, d, e): return [[[([e] * d) for j in range(c)] for j in range(b)] for i in range(a)] def ceil(x, y=1): return int(-(-x // y)) def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)] def Yes(): print("Yes") def No(): print("No") def YES(): print("YES") def NO(): print("NO") INF = 10**18 MOD = 10**8 N = 5 * 10**6 def solve(n): arr = [] while n > 0: arr.append(n % 2) n = n // 2 return arr l, r = Ri() arrl = solve(l) arrr = solve(r) if len(arrr) > len(arrl): ans = (1 << len(arrr)) - 1 print(ans) else: ind = -1 for i in range(len(arrr) - 1, -1, -1): if arrr[i] != arrl[i]: ind = i break if ind == -1: print(0) else: ans = (1 << ind + 1) - 1 print(ans)
IMPORT ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF NUMBER RETURN FUNC_CALL VAR BIN_OP VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF NONE RETURN VAR NONE FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF EXPR FUNC_CALL VAR STRING FUNC_DEF EXPR FUNC_CALL VAR STRING FUNC_DEF EXPR FUNC_CALL VAR STRING FUNC_DEF EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP NUMBER NUMBER FUNC_DEF ASSIGN VAR LIST WHILE VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR 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 BIN_OP NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR VAR VAR VAR ASSIGN VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
a, b = map(int, input().split()) bina = bin(a)[2:] binb = bin(b)[2:] length = len(binb) length2 = len(bina) bina = "0" * (length - length2) + bina for i in range(length): if bina[i] == binb[i] and bina[i] == "1": z = bina[:i] + "0" + bina[i + 1 :] z1 = int(z, 2) if z1 <= b and z1 >= a: bina = z continue z = binb[:i] + "0" + binb[i + 1 :] z1 = int(z, 2) if z1 <= b and z1 >= a: binb = z continue if bina[i] == binb[i] and bina[i] == "0": z = binb[:i] + "1" + binb[i + 1 :] z1 = int(z, 2) if z1 <= b and z1 >= a: binb = z continue z = bina[:i] + "1" + bina[i + 1 :] z1 = int(z, 2) if z1 <= b and z1 >= a: bina = z continue n1 = int(bina, 2) n2 = int(binb, 2) print(n1 ^ n2)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP VAR VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR STRING VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR STRING VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR VAR IF VAR VAR VAR VAR VAR VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR VAR STRING VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR STRING VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l, r = [int(c) for c in input().split()] p = l ^ r c = 0 while p: c += 1 p = p >> 1 resultado = 2**c - 1 print(resultado)
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l, r = list(map(int, input().split())) if l == r: print(0) else: x = l ^ r c = 0 while x > 0: x = x // 2 c = c + 1 print(2**c - 1)
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l, r = [int(i) for i in input().split(" ")] for i in range(70, -1, -1): if l & 1 << i == r & 1 << i: continue else: print((1 << i + 1) - 1) break else: print(0)
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR BIN_OP VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l = [int(x) for x in input().split()] l.sort() b, a = l s1 = list(bin(a)[2:]) s2 = list(bin(b)[2:]) if s1 == s2: print(0) elif len(s1) == len(s2): cont = 0 while s1[cont] == s2[cont]: s1[cont] = "0" cont += 1 for i in range(cont, len(s1)): s1[i] = "1" print(int("".join(s1), 2)) else: for i in range(len(s1)): s1[i] = "1" print(int("".join(s1), 2))
ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR ASSIGN VAR VAR STRING VAR NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL STRING VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL STRING VAR NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l, r = ["{:061b}".format(int(x)) for x in input().split()] pot = 0 for i in range(61): if l[i] != r[i]: pot = 61 - i break if pot == 0: print(0) else: print(2**pot - 2 ^ 1)
ASSIGN VAR VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR BIN_OP NUMBER VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
[l, r] = list(map(int, input().split())) if l == r: print(0) else: a = bin(l) b = bin(r) a = list(a[2:]) b = list(b[2:]) d = 0 if len(a) != len(b): d = len(b) - len(a) acta = ["0"] * d for j in a: acta.append(j) a = acta flag = 0 sol = len(b) pos = -1 for i in range(len(b) - 1, -1, -1): if a[i] != b[i]: pos = sol - i if pos != -1: sol = pos print(2**sol - 1)
ASSIGN LIST VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST STRING VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l, r = (int(x) for x in input().split()) limit = l ^ r if limit != 0: limit = len(bin(limit)) - 2 maxXor = "1" * limit print(int(maxXor, 2)) else: print(0)
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP STRING VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
lr = input() lr_list = lr.split(" ") l = int(lr_list[0]) r = int(lr_list[1]) xor = l ^ r bms = 0 while xor != 0: bms = bms + 1 xor = xor >> 1 maxxor = 0 dois = 1 while bms != 0: maxxor = maxxor + dois dois = dois << 1 bms = bms - 1 print(maxxor)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l, r = map(int, input().split()) j = bin(l ^ r) ans = 0 i = 0 while 2**i <= r - l: ans += 2**i i += 1 while 2**i <= r: if j[-i - 1] == "b": break if j[-i - 1] != "0": ans += 2**i i += 1 print(ans)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP NUMBER VAR BIN_OP VAR VAR VAR BIN_OP NUMBER VAR VAR NUMBER WHILE BIN_OP NUMBER VAR VAR IF VAR BIN_OP VAR NUMBER STRING IF VAR BIN_OP VAR NUMBER STRING VAR BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l, r = map(int, input().split()) a = bin(l) b = bin(r) a = "0" * (len(b) - len(a)) + a[2 : len(a)] b = b[2 : len(b)] c = [(0) for i in range(len(a))] flag = False for i in range(len(a)): if a[i] != b[i]: flag = True if flag: c[i] = 1 ans = 0 for j in range(len(a)): ans += c[len(a) - 1 - j] * 2**j print(ans)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
a, b = map(int, input().split()) if a == b: print(0) else: x = a ^ b c = 0 while x: x //= 2 c += 1 print(2**c - 1)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l, r = map(int, input().split()) lxr = l ^ r msb = 0 while lxr: msb += 1 lxr >>= 1 m = 0 t = 1 while msb: m += t t <<= 1 msb -= 1 print(m)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
def solve(a: int, b: int) -> int: if a > b: a, b = b, a ba = bin(a)[2:] bb = bin(b)[2:] r = "" if len(ba) != len(bb): int("1" * len(bb), 2) else: for ca, cb in zip(ba, bb): if ca == cb: r += "0" else: r += "1" break r += "1" * (len(bb) - len(r)) return int(r, 2) a, b = map(int, input().split()) print(solve(a, b))
FUNC_DEF VAR VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR STRING VAR STRING VAR BIN_OP STRING BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l, r = map(int, input().split()) al = [] ar = [] while r: p = r % 2 ar.append(p) r = r // 2 while l: p = l % 2 al.append(p) l = l // 2 if len(ar) != len(al): ans = 2 ** len(ar) - 1 else: n = len(ar) s = 0 k = 0 for i in range(n - 1, -1, -1): if ar[i] != al[i]: k = i + 1 break ans = 2**k - 1 if k == 0: ans = 0 print(ans)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST WHILE VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
def power(x, a): if a == 0: return 1 z = power(x, a // 2) z *= z if a % 2: z *= x return z [l, r] = list(map(int, input().split())) a, b = bin(l)[2:], bin(r)[2:] la, lb = len(a), len(b) mx = max(la, lb) a = "0" * (mx - la) + a b = "0" * (mx - lb) + b idx = 0 while idx < mx and not int(a[idx]) ^ int(b[idx]): idx += 1 print(power(2, mx - idx) - 1)
FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR IF BIN_OP VAR NUMBER VAR VAR RETURN VAR ASSIGN LIST VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR NUMBER BIN_OP VAR VAR NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
def main(): l, r = map(int, input().split()) if l == r: print(0) return l = bin(l)[2:] r = bin(r)[2:] if len(l) == len(r): i = 1 while l[i] == r[i]: i += 1 tam = len(l) - i else: tam = len(r) num = "" for i in range(tam): num += "1" print(int(num, 2)) main()
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l, r = map(int, input().split()) x = 64 while x >= 0 and l & 1 << x == r & 1 << x: x -= 1 print((1 << x + 1) - 1)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER BIN_OP VAR BIN_OP NUMBER VAR BIN_OP VAR BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
import sys SIZE = 105 a = SIZE * [0] b = SIZE * [0] lr = input().split() l = int(lr.pop(0)) r = int(lr.pop(0)) if l == r: print(0) else: len1 = 0 len2 = 0 while l != 0: a[len1] = l % 2 l = int(l / 2) len1 += 1 while r != 0: b[len2] = r % 2 r = int(r / 2) len2 += 1 tag = 0 for i in range(max(len1, len2) - 1, 0, -1): if b[i] == 1 and a[i] == 0: tag = i break print(pow(2, tag + 1) - 1)
IMPORT ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR LIST NUMBER ASSIGN VAR BIN_OP VAR LIST NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER WHILE VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER NUMBER IF VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l, r = map(int, input().split()) ans = 0 for i in range(63, -1, -1): if r & 1 << i > 0 and l & 1 << i == 0: ans = (1 << i + 1) - 1 break print(ans)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR NUMBER BIN_OP VAR BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l, r = map(int, input().split()) for i in range(61)[::-1]: if l >> i & 1 != r >> i & 1: print((1 << i + 1) - 1) exit() print(0)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l, r = map(int, input().split()) a = "{0:062b}".format(l) b = "{0:062b}".format(r) n = len(a) i = 0 if l == r: print(0) else: while i < n and a[i] == b[i]: i += 1 print(2 ** (62 - i) - 1)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER WHILE VAR VAR VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP NUMBER VAR NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l, r = map(int, input().split()) p = l lp = -1 while p: p = p >> 1 lp += 1 q = r rp = -1 while q: q = q >> 1 rp += 1 s = max(lp, rp) n = 0 while s >= 0: if l >> s & 1 != r >> s & 1: n |= (r >> s & 1) << s break s -= 1 s -= 1 while s >= 0: n |= 1 << s s -= 1 print(n)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR VAR NUMBER VAR NUMBER WHILE VAR NUMBER VAR BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l, r = map(int, input().split()) for i in range(63, -1, -1): mx, mn = r, l if 1 << i & l and 1 << i & r: mx = (1 << i) - 1 mx = r ^ 1 << i | mx elif 1 << i & l == 0 and 1 << i & r == 0: mn = (1 << i) - 1 mn = l & mn ^ (l | 1 << i) if mx >= l and mx <= r and mn >= l and mn <= r: r, l = mx, mn print(l ^ r)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR VAR IF BIN_OP BIN_OP NUMBER VAR VAR BIN_OP BIN_OP NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR VAR IF BIN_OP BIN_OP NUMBER VAR VAR NUMBER BIN_OP BIN_OP NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR BIN_OP NUMBER VAR IF VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
string = input() l, r = string.split() l = int(l) r = int(r) p = l ^ r x = 1 while x <= p: x = x << 1 print(x - 1)
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
input_arr = [int(i) for i in input().split()] a, b = input_arr def dec_to_bin(N): res = [0] * 64 pos = 0 while N != 0: last_bit = N & 1 res[pos] = last_bit pos += 1 N = N >> 1 return res def max_xor(a, b): a_bin = dec_to_bin(a) b_bin = dec_to_bin(b) res = "" x = "" y = "" diff_pt_found = False for i in range(len(a_bin) - 1, -1, -1): if diff_pt_found == False and a_bin[i] == b_bin[i]: x += str(a_bin[i]) y += str(b_bin[i]) if diff_pt_found == False and a_bin[i] != b_bin[i]: diff_pt_found = True x += str(a_bin[i]) y += str(b_bin[i]) res += "1" continue if diff_pt_found == True: if a_bin[i] != b_bin[i]: res += "1" x += str(a_bin[i]) y += str(b_bin[i]) elif b_bin[i] == 1: res += "1" x += str(a_bin[i]) y += str(0) elif a_bin[i] == 0: res += "1" x += str(1) y += str(b_bin[i]) return x, y, res def bin_to_dec(bin): bin = str(bin) mul = 1 res = 0 for i in range(len(bin) - 1, -1, -1): if bin[i] == "1": res += mul mul = mul * 2 return res x, y, res = max_xor(a, b) print(bin_to_dec(res))
ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR NUMBER VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR VAR VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR STRING IF VAR NUMBER IF VAR VAR VAR VAR VAR STRING VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR NUMBER VAR STRING VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER VAR STRING VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR VAR RETURN VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR VAR STRING VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l, r = map(int, input().split()) r1 = len(bin(r)) - 3 l1 = len(bin(l)) - 3 ans = 0 while l > 0: if l1 == r1: r -= 1 << l1 l -= 1 << l1 else: ans = (1 << r1 + 1) - 1 break z1 = min(l, r) z2 = max(l, r) l, r = z1, z2 r1 = len(bin(r)) - 3 l1 = len(bin(l)) - 3 if ans == 0: if l1 == r1: if r == 1: print(1) else: print(0) else: print((1 << r1 + 1) - 1) else: print(ans)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR VAR VAR BIN_OP NUMBER VAR VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER IF VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l, r = list(map(int, input().split())) i = 0 if l == r: if l == 1 and r == 1: print(0) else: print(1) else: l, r = format(l, "b"), format(r, "b") if len(l) == len(r): while l[i] == r[i]: i += 1 print((1 << len(r) - i) - 1)
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR STRING FUNC_CALL VAR VAR STRING IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR WHILE VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR VAR NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l, r = map(int, input().split()) a = bin(r)[2:] b = "0" * (len(a) - len(bin(l)[2:])) + bin(l)[2:] ans = 0 for i in range(len(a)): if a[i] != b[i]: ans = 2 ** (len(a) - i) - 1 break print(ans)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l, r = map(int, input().split()) def findbits(n): bits = [None] * 66 i = 0 for i in range(66): bits[i] = n & 1 n >>= 1 return bits bitsa = findbits(l) bitsb = findbits(r) cnt = 0 for i in range(66): if bitsa[i] != bitsb[i]: cnt = i + 1 ans = (1 << cnt) - 1 print(ans)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NONE NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
def max_xor_naive(l, r): max_xor = 0 xor = 0 for a in range(l, r + 1): for b in range(a + 1, r + 1): xor = a ^ b if xor > max_xor: max_xor = xor return max_xor def max_xor_efficient(l, r): s1 = bin(l)[2:] s2 = bin(r)[2:] l1 = len(s1) l2 = len(s2) if l1 < l2: return pow(2, l2) - 1 x = 0 for i in range(0, l1): if s1[i] != s2[i]: return pow(2, l1 - i) - 1 return 0 l, r = map(int, input().split()) ans2 = max_xor_efficient(l, r) print(ans2)
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR RETURN BIN_OP FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR VAR RETURN BIN_OP FUNC_CALL VAR NUMBER BIN_OP VAR VAR NUMBER RETURN NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
from sys import stdin as si class Solution: def bazinga(self, a, b): if a == b: return 0 z = lambda x: list(bin(x))[2:] ii = lambda x: int("".join(x), 2) a, b = z(a), z(b) a = ["0"] * (len(b) - len(a)) + a i = len(b) - 1 while i > 0: if a[i] == b[i]: if a[i] == "0": a[i] = "1" if ii(a) >= ii(b): a[i] = "0" break else: b[i] = "0" if ii(a) >= ii(b): b[i] = "1" break i -= 1 return ii(a) ^ ii(b) n, m = map(int, si.readline().strip().split()) S = Solution() print(S.bazinga(n, m))
CLASS_DEF FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP LIST STRING BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR NUMBER IF VAR VAR VAR VAR IF VAR VAR STRING ASSIGN VAR VAR STRING IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR STRING ASSIGN VAR VAR STRING IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR STRING VAR NUMBER RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
def number(pos): ans = 0 for i in range(pos + 1): ans += 2**i return ans l, r = input().split() l = int(l) r = int(r) if l == r: print(0) else: b_pos = 0 i = 0 while l > 0 or r > 0: if l % 2 != r % 2: b_pos = i l >>= 1 r >>= 1 i += 1 print(number(b_pos))
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_OP NUMBER VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
def solve(): l, r = map(int, input().split()) if l == r: print(0) return mx = str(bin(l ^ r)) x = len(mx[2:]) print(2**x - 1) solve()
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
def maxXORInRange(L, R): LXR = L ^ R msbPos = 0 while LXR: msbPos += 1 LXR >>= 1 maxXOR, two = 0, 1 while msbPos: maxXOR += two two <<= 1 msbPos -= 1 return maxXOR L, R = map(int, input().split()) print(maxXORInRange(L, R))
FUNC_DEF ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER WHILE VAR VAR VAR VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l, r = map(int, input().split()) if l == r: print(0) exit() x = 1 while x <= r: x = x << 1 x = x >> 1 k = x while x <= l or x > r: if x <= l: x += k else: x -= k k = k >> 1 print(x ^ x - 1)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR VAR VAR IF VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
def bin(a): if a <= 1: return a else: return 10 * bin(a // 2) + a % 2 def convBin(a): k, i = 0, 0 while a != 0: k += a % 10 * int(2**i) a //= 10 i += 1 return k def maxi(a, b): if a == b: return 0 elif a + 1 == b: return a ^ b elif a + 2 == b: x = a ^ a + 1 y = a ^ a + 2 z = a + 1 ^ a + 2 return max(max(x, y), z) else: x = str(bin(a ^ b)) y = "1" * len(x) return convBin(int(y)) a = list(map(int, input().split())) print(maxi(a[0], a[1]))
FUNC_DEF IF VAR NUMBER RETURN VAR RETURN BIN_OP BIN_OP NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER WHILE VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP NUMBER VAR VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF IF VAR VAR RETURN NUMBER IF BIN_OP VAR NUMBER VAR RETURN BIN_OP VAR VAR IF BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER RETURN FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP STRING FUNC_CALL VAR VAR RETURN FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l, r = map(int, input().split()) p = bin(l) p = p[2:] q = bin(r) q = q[2:] t = len(q) u = len(p) p = (t - u) * "0" + p ans = [] for i in range(len(q)): if q[i] == "1" and p[i] == "0": ans.append(1) break elif q[i] == "1" and p[i] == "1": ans.append(0) continue elif q[i] == "0" and p[i] == "1": ans.append(1) continue else: ans.append(0) for j in range(i + 1, len(p)): ans.append(1) total = 0 ans.reverse() for i in range(len(ans)): total += pow(2, i) * ans[i] print(total)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR STRING VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING EXPR FUNC_CALL VAR NUMBER IF VAR VAR STRING VAR VAR STRING EXPR FUNC_CALL VAR NUMBER IF VAR VAR STRING VAR VAR STRING EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR NUMBER VAR VAR VAR EXPR FUNC_CALL VAR VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l, r = map(int, input().split()) x = l ^ r a = 2 if l == r: print(0) else: while a <= x: a = a * 2 print(a - 1)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l, r = map(int, input().split()) a = str(bin(l)) b = str(bin(r)) count = 0 da = len(a) - 2 db = len(b) - 2 if db > da: for i in range(db): count += 2**i print(count) elif l == r: print(0) elif db == da: for i in range(3, db + 2): if int(b[i]) == 1 and int(a[i]) == 0: db = db + 2 - i break for i in range(db): count += 2**i print(count)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR FOR VAR FUNC_CALL VAR VAR VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR VAR NUMBER FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l, r = map(int, input().split()) binR = list(bin(r)[2:]) binL = list(bin(l)[2:].rjust(len(binR), "0")) f, XOR = False, "" for i, j in zip(binR, binL): if i != j: if i == "1" and not f: f = True XOR += "1" if i == j: if f: XOR += "1" else: XOR += "0" print(int(XOR, 2))
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR STRING ASSIGN VAR VAR NUMBER STRING FOR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR IF VAR STRING VAR ASSIGN VAR NUMBER VAR STRING IF VAR VAR IF VAR VAR STRING VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
a, b = map(int, input().split()) a, b = min(a, b), max(a, b) A = bin(a)[2:] B = bin(b)[2:] A = "0" * (len(B) - len(A)) + A diff = 0 for i in range(len(A)): if A[i] != B[i]: diff = len(A) - i break print(2**diff - 1)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l, r = map(int, input().split()) for i in range(64, -2, -1): if i < 0 or 1 << i & l != 1 << i & r: break print((1 << i + 1) - 1)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF VAR NUMBER BIN_OP BIN_OP NUMBER VAR VAR BIN_OP BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
def calc(n): cnt = 0 while n > 0: cnt += 1 n //= 2 return cnt def main(): l, r = map(int, input().split()) k1 = calc(l) k2 = calc(r) while k1 >= k2: l ^= 2 ** (k2 - 1) r ^= 2 ** (k1 - 1) if l == 0 and r == 0: print(0) return k1 = calc(l) k2 = calc(r) print(2 ** (k2 - 1) + 2 ** (k2 - 1) - 1) return main()
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR VAR BIN_OP NUMBER BIN_OP VAR NUMBER VAR BIN_OP NUMBER BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER RETURN EXPR FUNC_CALL VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
def main(): l, r = (format(int(s), "b") for s in input().split()) le = len(r) if len(l) == le: for i in range(le): if l[i] != r[i]: print(int("1" * (le - i), 2)) break else: print(0) else: print(int("1" * le, 2)) def __starting_point(): main() __starting_point()
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR STRING VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP STRING BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP STRING VAR NUMBER FUNC_DEF EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
a, b = input().split() if a == b: print("0") else: xor = bin(int(a) ^ int(b))[2:] a = bin(int(a))[2:] b = bin(int(b))[2:] ans = "" if a[0] == b[0]: ans += "0" else: ans += "1" for i in range(len(xor)): ans += "1" print(int(ans, 2))
ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING IF VAR NUMBER VAR NUMBER VAR STRING VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
def maximum(l, r): r = bin(r)[2:] l = bin(l)[2:].zfill(len(r)) if r[0] == "1" and l[0] == "0": return int("1" * len(l), base=2) else: if l[1:] != "": l = int(l[1:], base=2) r = int(r[1:], base=2) else: return 0 return maximum(l, r) inp = input() l, r = inp.split(" ") print(maximum(int(l), int(r)))
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR IF VAR NUMBER STRING VAR NUMBER STRING RETURN FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR NUMBER IF VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER RETURN NUMBER RETURN FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l, r = map(int, input().split()) hmm, t = l ^ r, 2**60 while hmm ^ t > hmm: t //= 2 print(2 * t - 1 if hmm != 0 else 0)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP NUMBER NUMBER WHILE BIN_OP VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
vals = list(map(int, input().split())) l = vals[0] r = vals[1] if l == r: print("0") else: i = 0 j = 0 while l > 0 or r > 0: i += 1 if l & 1 ^ r & 1 == 1: j = i l = l >> 1 r = r >> 1 ans = 1 for i in range(0, j): ans = ans * 2 ans -= 1 print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l, r = [int(x) for x in input().split()] def solve(l, r): if l == r: return 0 bits_l = "{0:b}".format(l) bits_r = "{0:b}".format(r) bits_l = "0" * (len(bits_r) - len(bits_l)) + bits_l p = len(bits_l) - next(i for i in range(len(bits_l)) if bits_l[i] != bits_r[i]) - 1 return 2 ** (p + 1) - 1 print(solve(l, r))
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR VAR NUMBER RETURN BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
import sys l, r = tuple(int(x) for x in sys.stdin.readline().split()) maximum = -1 cur_pow = 1 while cur_pow <= r: if cur_pow - 1 >= l: cur_result = cur_pow ^ cur_pow - 1 maximum = max(maximum, cur_result) cur_pow *= 2 if maximum < 0: n_ones = len(bin(l)) str1, str2 = bin(l), bin(r) index = 0 while index < len(str1) and index < len(str2) and str1[index] == str2[index]: index += 1 n_ones -= 1 if n_ones == 0: maximum = 0 else: maximum = int("1" * n_ones, 2) print(maximum)
IMPORT ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP STRING VAR NUMBER EXPR FUNC_CALL VAR VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
a, b = map(int, input().split(" ")) a, b = min(a, b), max(a, b) bina = str(bin(a))[2:] binb = str(bin(b))[2:] lena = len(bina) lenb = len(binb) ans = 0 if lena != lenb: ans = 2**lenb - 1 else: a = "0" * (lena - lenb) + bina for i in range(lenb): if bool(int(bina[i])) != bool(int(binb[i])): ans = 2 ** (lenb - i) - 1 break print(ans)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP VAR VAR VAR FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
import sys m, n = map(int, sys.stdin.readline().split()) res = m ^ n s = bin(res) s = s[2:] s = int(s) if s == 0: print(0) else: s = str(s) res = 2 ** len(s) - 1 print(res)
IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
arra = [] arrb = [] arr = [] s = "" temp = 1 value = ans = n = 0 def fill(myList=[], *args): for i in range(n): arra.insert(0, 0) def check(): for i, j in zip(arra, arrb): if i == j: return 1 else: return 0 def Engine1(num): if num > 1: Engine1(num // 2) arra.append(num % 2) def Engine2(num): if num > 1: Engine2(num // 2) arrb.append(num % 2) a, b = map(int, input().split()) Engine1(a) Engine2(b) n = abs(len(arra) - len(arrb)) if len(arra) > len(arrb): fill(arrb) if len(arra) < len(arrb): fill(arra) for i in range(len(arra)): if check() == 0: break check() arra.pop(0) arrb.pop(0) for i in range(len(arra)): ans += temp temp *= 2 print(ans)
ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR VAR VAR NUMBER FUNC_DEF LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER FUNC_DEF FOR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_DEF IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l, r = map(int, input().split()) def maxXor(low, high): highestPower = high.bit_length() - 1 if high == 1 and low == 0: return 1 if highestPower <= 0: return 0 if low < 2**highestPower: return 2 ** (highestPower + 1) - 1 return maxXor(low - 2**highestPower, high - 2**highestPower) print(maxXor(l, r))
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF VAR BIN_OP NUMBER VAR RETURN BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER RETURN FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER VAR BIN_OP VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l, r = map(int, input().split()) masks = [] for i in range(64, -1, -1): if 1 << i > r: continue masks.append(1 << i) x, y = 0, 0 for k in masks: if x < y: x += k else: y += k for j in range(64, -1, -1): if x >> j & 1 or y >> j & 1: continue if x + (1 << j) <= r: x += 1 << j if y + (1 << j) <= r: y += 1 << j if min(x, y) < l or max(x, y) > r: masks.pop() print(sum(masks))
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR IF VAR VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR VAR VAR BIN_OP NUMBER VAR IF BIN_OP VAR BIN_OP NUMBER VAR VAR VAR BIN_OP NUMBER VAR IF FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
a, b = input().split() a = int(a) b = int(b) s = a ^ b cnt = 0 while s != 0: s = int(s / 2) cnt = cnt + 1 print(2**cnt - 1)
ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal — as «xor». -----Input----- The single line contains space-separated integers l and r (1 ≤ l ≤ r ≤ 10^18). Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier. -----Output----- In a single line print a single integer — the maximum value of $a \oplus b$ for all pairs of integers a, b (l ≤ a ≤ b ≤ r). -----Examples----- Input 1 2 Output 3 Input 8 16 Output 31 Input 1 1 Output 0
l, r = map(int, input().split()) i = 1 << 60 while i & l == i & r and i != 0: i = i >> 1 ans = i while i > 0: i = i >> 1 ans += i print(ans)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER WHILE BIN_OP VAR VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR