description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Let a and b be binary numbers of length n (MSB to the left). The following commands may be performed: set_a idx x: Set $a[i dx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $a[i dx]$ is $\text{id}x^{\text{th}}$ least significant bit of $a$. set_b idx x: Set $b[idx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $b[idx]$ is $\text{id}x^{\text{th}}$ least significant bit of $\boldsymbol{b}$. get_c idx: Print $c[idx]$, where $c[idx]=a[idx]+b[idx]$ and $0\leq idx\leq n+1$. Given $a,b$, and a list of commands, create a string made of the results of each $\text{get_c}$ call, the only command that produces output. For example, $\boldsymbol{a}=\boldsymbol{000}$ and $b=111$ so the length of the numbers is $n=3$. Print an answer string that contains the results of all commands on one line. A series of commands and their results follow: Starting ans = '' (empty string) a b 000 111 set_a 1 1 010 111 set_b 0 1 010 111 get_c 3 a + b = 1001 ans = '1' 010 111 get_c 4 a + b = 01001 ans = '10' Note: When the command is get_c 4, $\textbf{C}$ had to be padded to the left with a $0$ to be long enough to return a value. Function Description Complete the changeBits function in the editor below. For each get_c command, it should print either a 0 or a 1 without a newline until all commands have been processed. At that point, add a newline. changeBits has the following parameters: - a, b: two integers represented as binary strings - queries[queries[0]-queries[n-1]]: an array of query strings in the format described Input Format The first line of input contains two space-separated integers, $n$ and $\textit{q}$, the length of the binary representations of $a$ and $\boldsymbol{b}$, and the number of commands, respectively. The second and third lines each contain a string representation of $a$ and $\boldsymbol{b}$. The following $\textit{q}$ lines each contain a command string $\textit{queries}[i]$ as described above. Constraints $1\leq n\leq1000000$ $1\leq q\leq5000000$ Output Format For each query of the type $\text{get_c}$, output a single digit 0 or 1. Output must be placed on a single line. Sample Input 0 5 5 00000 11111 set_a 0 1 get_c 5 get_c 1 set_b 2 0 get_c 5 Sample Output 0 100 Explanation 0 set_a 0 1 sets 00000 to 00001 C = A + B = 00001 + 11111 = 100000, so get_c[5] = 1 from the above computation get_c[1] = 0 set_b 2 0 sets 11111 to 11011 C = A + B = 00001 + 11011 = 011100, so get_c[5] = 0 The output is hence concatenation of 1, 0 and 0 = 100
n, q = map(int, input().split()) a = int(input(), 2) b = int(input(), 2) for i in range(q): cmd = input().split() if cmd[0] == "set_a": n = 1 << int(cmd[1]) if int(cmd[2]): a = a | n else: a = a & ~n elif cmd[0] == "set_b": n = 1 << int(cmd[1]) if int(cmd[2]): b = b | n else: b = b & ~n else: c = a + b print(int(bool(c & 1 << int(cmd[1]))), end="")
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER STRING ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER STRING ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER FUNC_CALL VAR VAR NUMBER STRING
Let a and b be binary numbers of length n (MSB to the left). The following commands may be performed: set_a idx x: Set $a[i dx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $a[i dx]$ is $\text{id}x^{\text{th}}$ least significant bit of $a$. set_b idx x: Set $b[idx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $b[idx]$ is $\text{id}x^{\text{th}}$ least significant bit of $\boldsymbol{b}$. get_c idx: Print $c[idx]$, where $c[idx]=a[idx]+b[idx]$ and $0\leq idx\leq n+1$. Given $a,b$, and a list of commands, create a string made of the results of each $\text{get_c}$ call, the only command that produces output. For example, $\boldsymbol{a}=\boldsymbol{000}$ and $b=111$ so the length of the numbers is $n=3$. Print an answer string that contains the results of all commands on one line. A series of commands and their results follow: Starting ans = '' (empty string) a b 000 111 set_a 1 1 010 111 set_b 0 1 010 111 get_c 3 a + b = 1001 ans = '1' 010 111 get_c 4 a + b = 01001 ans = '10' Note: When the command is get_c 4, $\textbf{C}$ had to be padded to the left with a $0$ to be long enough to return a value. Function Description Complete the changeBits function in the editor below. For each get_c command, it should print either a 0 or a 1 without a newline until all commands have been processed. At that point, add a newline. changeBits has the following parameters: - a, b: two integers represented as binary strings - queries[queries[0]-queries[n-1]]: an array of query strings in the format described Input Format The first line of input contains two space-separated integers, $n$ and $\textit{q}$, the length of the binary representations of $a$ and $\boldsymbol{b}$, and the number of commands, respectively. The second and third lines each contain a string representation of $a$ and $\boldsymbol{b}$. The following $\textit{q}$ lines each contain a command string $\textit{queries}[i]$ as described above. Constraints $1\leq n\leq1000000$ $1\leq q\leq5000000$ Output Format For each query of the type $\text{get_c}$, output a single digit 0 or 1. Output must be placed on a single line. Sample Input 0 5 5 00000 11111 set_a 0 1 get_c 5 get_c 1 set_b 2 0 get_c 5 Sample Output 0 100 Explanation 0 set_a 0 1 sets 00000 to 00001 C = A + B = 00001 + 11111 = 100000, so get_c[5] = 1 from the above computation get_c[1] = 0 set_b 2 0 sets 11111 to 11011 C = A + B = 00001 + 11011 = 011100, so get_c[5] = 0 The output is hence concatenation of 1, 0 and 0 = 100
def set_bit(binary_num, idx, bit): value = 1 << idx if bit: return binary_num | value return binary_num & ~value n, q = map(int, input().strip().split(" ")) a = int(input().strip(), 2) b = int(input().strip(), 2) for i in range(q): cmd = input().strip().split(" ") idx = int(cmd[1]) if cmd[0] == "set_a": a = set_bit(a, idx, int(cmd[2])) elif cmd[0] == "set_b": b = set_bit(b, idx, int(cmd[2])) else: c = a + b cbit = int(bool(c & 1 << idx)) print(str(cbit), end="")
FUNC_DEF ASSIGN VAR BIN_OP NUMBER VAR IF VAR RETURN BIN_OP VAR VAR RETURN BIN_OP VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR STRING
Let a and b be binary numbers of length n (MSB to the left). The following commands may be performed: set_a idx x: Set $a[i dx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $a[i dx]$ is $\text{id}x^{\text{th}}$ least significant bit of $a$. set_b idx x: Set $b[idx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $b[idx]$ is $\text{id}x^{\text{th}}$ least significant bit of $\boldsymbol{b}$. get_c idx: Print $c[idx]$, where $c[idx]=a[idx]+b[idx]$ and $0\leq idx\leq n+1$. Given $a,b$, and a list of commands, create a string made of the results of each $\text{get_c}$ call, the only command that produces output. For example, $\boldsymbol{a}=\boldsymbol{000}$ and $b=111$ so the length of the numbers is $n=3$. Print an answer string that contains the results of all commands on one line. A series of commands and their results follow: Starting ans = '' (empty string) a b 000 111 set_a 1 1 010 111 set_b 0 1 010 111 get_c 3 a + b = 1001 ans = '1' 010 111 get_c 4 a + b = 01001 ans = '10' Note: When the command is get_c 4, $\textbf{C}$ had to be padded to the left with a $0$ to be long enough to return a value. Function Description Complete the changeBits function in the editor below. For each get_c command, it should print either a 0 or a 1 without a newline until all commands have been processed. At that point, add a newline. changeBits has the following parameters: - a, b: two integers represented as binary strings - queries[queries[0]-queries[n-1]]: an array of query strings in the format described Input Format The first line of input contains two space-separated integers, $n$ and $\textit{q}$, the length of the binary representations of $a$ and $\boldsymbol{b}$, and the number of commands, respectively. The second and third lines each contain a string representation of $a$ and $\boldsymbol{b}$. The following $\textit{q}$ lines each contain a command string $\textit{queries}[i]$ as described above. Constraints $1\leq n\leq1000000$ $1\leq q\leq5000000$ Output Format For each query of the type $\text{get_c}$, output a single digit 0 or 1. Output must be placed on a single line. Sample Input 0 5 5 00000 11111 set_a 0 1 get_c 5 get_c 1 set_b 2 0 get_c 5 Sample Output 0 100 Explanation 0 set_a 0 1 sets 00000 to 00001 C = A + B = 00001 + 11111 = 100000, so get_c[5] = 1 from the above computation get_c[1] = 0 set_b 2 0 sets 11111 to 11011 C = A + B = 00001 + 11011 = 011100, so get_c[5] = 0 The output is hence concatenation of 1, 0 and 0 = 100
n, q = map(int, input().split()) A = input().strip() B = input().strip() a = int(A, 2) + int(B, 2) A = list(map(int, A))[::-1] B = list(map(int, B))[::-1] o = "" def get(l, i): try: return l[i] except IndexError: return 0 def seT(l, i, x): if len(l) <= i: l.extend([0] * (i - len(l) + 10)) l[i] = x for _ in range(q): x = input().split() if x[0].startswith("set"): l = A if x[0] == "set_a" else B x, y = map(int, x[1:]) if get(l, x) != y: seT(l, x, y) c = 1 << x if y: a += c else: a -= c else: o += str(a >> int(x[1]) & 1) print(o)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR STRING FUNC_DEF RETURN VAR VAR VAR RETURN NUMBER FUNC_DEF IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP LIST NUMBER BIN_OP BIN_OP VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR NUMBER STRING ASSIGN VAR VAR NUMBER STRING VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP NUMBER VAR IF VAR VAR VAR VAR VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR
Let a and b be binary numbers of length n (MSB to the left). The following commands may be performed: set_a idx x: Set $a[i dx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $a[i dx]$ is $\text{id}x^{\text{th}}$ least significant bit of $a$. set_b idx x: Set $b[idx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $b[idx]$ is $\text{id}x^{\text{th}}$ least significant bit of $\boldsymbol{b}$. get_c idx: Print $c[idx]$, where $c[idx]=a[idx]+b[idx]$ and $0\leq idx\leq n+1$. Given $a,b$, and a list of commands, create a string made of the results of each $\text{get_c}$ call, the only command that produces output. For example, $\boldsymbol{a}=\boldsymbol{000}$ and $b=111$ so the length of the numbers is $n=3$. Print an answer string that contains the results of all commands on one line. A series of commands and their results follow: Starting ans = '' (empty string) a b 000 111 set_a 1 1 010 111 set_b 0 1 010 111 get_c 3 a + b = 1001 ans = '1' 010 111 get_c 4 a + b = 01001 ans = '10' Note: When the command is get_c 4, $\textbf{C}$ had to be padded to the left with a $0$ to be long enough to return a value. Function Description Complete the changeBits function in the editor below. For each get_c command, it should print either a 0 or a 1 without a newline until all commands have been processed. At that point, add a newline. changeBits has the following parameters: - a, b: two integers represented as binary strings - queries[queries[0]-queries[n-1]]: an array of query strings in the format described Input Format The first line of input contains two space-separated integers, $n$ and $\textit{q}$, the length of the binary representations of $a$ and $\boldsymbol{b}$, and the number of commands, respectively. The second and third lines each contain a string representation of $a$ and $\boldsymbol{b}$. The following $\textit{q}$ lines each contain a command string $\textit{queries}[i]$ as described above. Constraints $1\leq n\leq1000000$ $1\leq q\leq5000000$ Output Format For each query of the type $\text{get_c}$, output a single digit 0 or 1. Output must be placed on a single line. Sample Input 0 5 5 00000 11111 set_a 0 1 get_c 5 get_c 1 set_b 2 0 get_c 5 Sample Output 0 100 Explanation 0 set_a 0 1 sets 00000 to 00001 C = A + B = 00001 + 11111 = 100000, so get_c[5] = 1 from the above computation get_c[1] = 0 set_b 2 0 sets 11111 to 11011 C = A + B = 00001 + 11011 = 011100, so get_c[5] = 0 The output is hence concatenation of 1, 0 and 0 = 100
def twiddle(n, line): i = int(line[1]) if line[2] == "0": return n & ~(1 << i) else: return n | 1 << i N, Q = map(int, input().split()) A = int(input(), 2) B = int(input(), 2) for q in range(Q): line = input().split() if line[0] == "set_a": A = twiddle(A, line) elif line[0] == "set_b": B = twiddle(B, line) elif line[0] == "get_c": print(A + B >> int(line[1]) & 1, end="")
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER STRING RETURN BIN_OP VAR BIN_OP NUMBER VAR RETURN BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR NUMBER NUMBER STRING
Let a and b be binary numbers of length n (MSB to the left). The following commands may be performed: set_a idx x: Set $a[i dx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $a[i dx]$ is $\text{id}x^{\text{th}}$ least significant bit of $a$. set_b idx x: Set $b[idx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $b[idx]$ is $\text{id}x^{\text{th}}$ least significant bit of $\boldsymbol{b}$. get_c idx: Print $c[idx]$, where $c[idx]=a[idx]+b[idx]$ and $0\leq idx\leq n+1$. Given $a,b$, and a list of commands, create a string made of the results of each $\text{get_c}$ call, the only command that produces output. For example, $\boldsymbol{a}=\boldsymbol{000}$ and $b=111$ so the length of the numbers is $n=3$. Print an answer string that contains the results of all commands on one line. A series of commands and their results follow: Starting ans = '' (empty string) a b 000 111 set_a 1 1 010 111 set_b 0 1 010 111 get_c 3 a + b = 1001 ans = '1' 010 111 get_c 4 a + b = 01001 ans = '10' Note: When the command is get_c 4, $\textbf{C}$ had to be padded to the left with a $0$ to be long enough to return a value. Function Description Complete the changeBits function in the editor below. For each get_c command, it should print either a 0 or a 1 without a newline until all commands have been processed. At that point, add a newline. changeBits has the following parameters: - a, b: two integers represented as binary strings - queries[queries[0]-queries[n-1]]: an array of query strings in the format described Input Format The first line of input contains two space-separated integers, $n$ and $\textit{q}$, the length of the binary representations of $a$ and $\boldsymbol{b}$, and the number of commands, respectively. The second and third lines each contain a string representation of $a$ and $\boldsymbol{b}$. The following $\textit{q}$ lines each contain a command string $\textit{queries}[i]$ as described above. Constraints $1\leq n\leq1000000$ $1\leq q\leq5000000$ Output Format For each query of the type $\text{get_c}$, output a single digit 0 or 1. Output must be placed on a single line. Sample Input 0 5 5 00000 11111 set_a 0 1 get_c 5 get_c 1 set_b 2 0 get_c 5 Sample Output 0 100 Explanation 0 set_a 0 1 sets 00000 to 00001 C = A + B = 00001 + 11111 = 100000, so get_c[5] = 1 from the above computation get_c[1] = 0 set_b 2 0 sets 11111 to 11011 C = A + B = 00001 + 11011 = 011100, so get_c[5] = 0 The output is hence concatenation of 1, 0 and 0 = 100
def getBit(num, offset): mask = 1 << offset return 1 if num & mask != 0 else 0 def setBit(num, offset, value): if value == 1: mask = 1 << offset return num | mask else: mask = ~(1 << offset) return num & mask n, q = [int(x) for x in input().split()] a = int(input(), 2) b = int(input(), 2) for _ in range(q): query = input().split() if query[0] == "set_a": a = setBit(a, int(query[1]), int(query[2])) elif query[0] == "set_b": b = setBit(b, int(query[1]), int(query[2])) else: print(getBit(a + b, int(query[1])), end="")
FUNC_DEF ASSIGN VAR BIN_OP NUMBER VAR RETURN BIN_OP VAR VAR NUMBER NUMBER NUMBER FUNC_DEF IF VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR RETURN BIN_OP VAR VAR ASSIGN VAR BIN_OP NUMBER VAR RETURN BIN_OP VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER IF VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR VAR NUMBER STRING
Let a and b be binary numbers of length n (MSB to the left). The following commands may be performed: set_a idx x: Set $a[i dx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $a[i dx]$ is $\text{id}x^{\text{th}}$ least significant bit of $a$. set_b idx x: Set $b[idx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $b[idx]$ is $\text{id}x^{\text{th}}$ least significant bit of $\boldsymbol{b}$. get_c idx: Print $c[idx]$, where $c[idx]=a[idx]+b[idx]$ and $0\leq idx\leq n+1$. Given $a,b$, and a list of commands, create a string made of the results of each $\text{get_c}$ call, the only command that produces output. For example, $\boldsymbol{a}=\boldsymbol{000}$ and $b=111$ so the length of the numbers is $n=3$. Print an answer string that contains the results of all commands on one line. A series of commands and their results follow: Starting ans = '' (empty string) a b 000 111 set_a 1 1 010 111 set_b 0 1 010 111 get_c 3 a + b = 1001 ans = '1' 010 111 get_c 4 a + b = 01001 ans = '10' Note: When the command is get_c 4, $\textbf{C}$ had to be padded to the left with a $0$ to be long enough to return a value. Function Description Complete the changeBits function in the editor below. For each get_c command, it should print either a 0 or a 1 without a newline until all commands have been processed. At that point, add a newline. changeBits has the following parameters: - a, b: two integers represented as binary strings - queries[queries[0]-queries[n-1]]: an array of query strings in the format described Input Format The first line of input contains two space-separated integers, $n$ and $\textit{q}$, the length of the binary representations of $a$ and $\boldsymbol{b}$, and the number of commands, respectively. The second and third lines each contain a string representation of $a$ and $\boldsymbol{b}$. The following $\textit{q}$ lines each contain a command string $\textit{queries}[i]$ as described above. Constraints $1\leq n\leq1000000$ $1\leq q\leq5000000$ Output Format For each query of the type $\text{get_c}$, output a single digit 0 or 1. Output must be placed on a single line. Sample Input 0 5 5 00000 11111 set_a 0 1 get_c 5 get_c 1 set_b 2 0 get_c 5 Sample Output 0 100 Explanation 0 set_a 0 1 sets 00000 to 00001 C = A + B = 00001 + 11111 = 100000, so get_c[5] = 1 from the above computation get_c[1] = 0 set_b 2 0 sets 11111 to 11011 C = A + B = 00001 + 11011 = 011100, so get_c[5] = 0 The output is hence concatenation of 1, 0 and 0 = 100
import sys first_line = sys.stdin.readline() arr = first_line.split(" ") N = int(arr[0]) Q = int(arr[1]) A = int(sys.stdin.readline(), 2) B = int(sys.stdin.readline(), 2) R = "" def set_val(number, idx, val): mask = 0 if int(val) == 1: mask = 1 << idx return number | mask else: mask = ~(1 << idx) return number & mask def set_a(idx, val): return set_val(A, idx, val) def set_b(idx, val): return set_val(B, idx, val) def get_c(idx): C = A + B return R + str(1 & C >> idx) for each in range(0, Q): line = sys.stdin.readline() tokens = line.split(" ") opp = tokens[0] idx = int(tokens[1]) if opp == "set_a": A = set_a(idx, tokens[2]) elif opp == "set_b": B = set_b(idx, tokens[2]) elif opp == "get_c": R = get_c(idx) print(R)
IMPORT 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 FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR STRING FUNC_DEF ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR RETURN BIN_OP VAR VAR ASSIGN VAR BIN_OP NUMBER VAR RETURN BIN_OP VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR VAR FUNC_DEF ASSIGN VAR BIN_OP VAR VAR RETURN BIN_OP VAR FUNC_CALL VAR BIN_OP NUMBER BIN_OP VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR STRING ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR
Let a and b be binary numbers of length n (MSB to the left). The following commands may be performed: set_a idx x: Set $a[i dx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $a[i dx]$ is $\text{id}x^{\text{th}}$ least significant bit of $a$. set_b idx x: Set $b[idx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $b[idx]$ is $\text{id}x^{\text{th}}$ least significant bit of $\boldsymbol{b}$. get_c idx: Print $c[idx]$, where $c[idx]=a[idx]+b[idx]$ and $0\leq idx\leq n+1$. Given $a,b$, and a list of commands, create a string made of the results of each $\text{get_c}$ call, the only command that produces output. For example, $\boldsymbol{a}=\boldsymbol{000}$ and $b=111$ so the length of the numbers is $n=3$. Print an answer string that contains the results of all commands on one line. A series of commands and their results follow: Starting ans = '' (empty string) a b 000 111 set_a 1 1 010 111 set_b 0 1 010 111 get_c 3 a + b = 1001 ans = '1' 010 111 get_c 4 a + b = 01001 ans = '10' Note: When the command is get_c 4, $\textbf{C}$ had to be padded to the left with a $0$ to be long enough to return a value. Function Description Complete the changeBits function in the editor below. For each get_c command, it should print either a 0 or a 1 without a newline until all commands have been processed. At that point, add a newline. changeBits has the following parameters: - a, b: two integers represented as binary strings - queries[queries[0]-queries[n-1]]: an array of query strings in the format described Input Format The first line of input contains two space-separated integers, $n$ and $\textit{q}$, the length of the binary representations of $a$ and $\boldsymbol{b}$, and the number of commands, respectively. The second and third lines each contain a string representation of $a$ and $\boldsymbol{b}$. The following $\textit{q}$ lines each contain a command string $\textit{queries}[i]$ as described above. Constraints $1\leq n\leq1000000$ $1\leq q\leq5000000$ Output Format For each query of the type $\text{get_c}$, output a single digit 0 or 1. Output must be placed on a single line. Sample Input 0 5 5 00000 11111 set_a 0 1 get_c 5 get_c 1 set_b 2 0 get_c 5 Sample Output 0 100 Explanation 0 set_a 0 1 sets 00000 to 00001 C = A + B = 00001 + 11111 = 100000, so get_c[5] = 1 from the above computation get_c[1] = 0 set_b 2 0 sets 11111 to 11011 C = A + B = 00001 + 11011 = 011100, so get_c[5] = 0 The output is hence concatenation of 1, 0 and 0 = 100
N, Q = map(int, input().rstrip().split(" ")) aStr = input().rstrip() A = 0 for a in aStr: A += int(a) A = A << 1 A = A >> 1 bStr = input().rstrip() B = 0 for b in bStr: B += int(b) B = B << 1 B = B >> 1 res = "" for _ in range(Q): cmd = input().rstrip().split(" ") if cmd[0] == "set_a": idx, x = map(int, cmd[1:]) A = A & ~(1 << idx) | x << idx elif cmd[0] == "set_b": idx, x = map(int, cmd[1:]) B = B & ~(1 << idx) | x << idx else: idx = int(cmd[1]) res += str(A + B >> idx & 1) print(res)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING IF VAR NUMBER STRING ASSIGN VAR VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR BIN_OP VAR VAR IF VAR NUMBER STRING ASSIGN VAR VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
Let a and b be binary numbers of length n (MSB to the left). The following commands may be performed: set_a idx x: Set $a[i dx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $a[i dx]$ is $\text{id}x^{\text{th}}$ least significant bit of $a$. set_b idx x: Set $b[idx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $b[idx]$ is $\text{id}x^{\text{th}}$ least significant bit of $\boldsymbol{b}$. get_c idx: Print $c[idx]$, where $c[idx]=a[idx]+b[idx]$ and $0\leq idx\leq n+1$. Given $a,b$, and a list of commands, create a string made of the results of each $\text{get_c}$ call, the only command that produces output. For example, $\boldsymbol{a}=\boldsymbol{000}$ and $b=111$ so the length of the numbers is $n=3$. Print an answer string that contains the results of all commands on one line. A series of commands and their results follow: Starting ans = '' (empty string) a b 000 111 set_a 1 1 010 111 set_b 0 1 010 111 get_c 3 a + b = 1001 ans = '1' 010 111 get_c 4 a + b = 01001 ans = '10' Note: When the command is get_c 4, $\textbf{C}$ had to be padded to the left with a $0$ to be long enough to return a value. Function Description Complete the changeBits function in the editor below. For each get_c command, it should print either a 0 or a 1 without a newline until all commands have been processed. At that point, add a newline. changeBits has the following parameters: - a, b: two integers represented as binary strings - queries[queries[0]-queries[n-1]]: an array of query strings in the format described Input Format The first line of input contains two space-separated integers, $n$ and $\textit{q}$, the length of the binary representations of $a$ and $\boldsymbol{b}$, and the number of commands, respectively. The second and third lines each contain a string representation of $a$ and $\boldsymbol{b}$. The following $\textit{q}$ lines each contain a command string $\textit{queries}[i]$ as described above. Constraints $1\leq n\leq1000000$ $1\leq q\leq5000000$ Output Format For each query of the type $\text{get_c}$, output a single digit 0 or 1. Output must be placed on a single line. Sample Input 0 5 5 00000 11111 set_a 0 1 get_c 5 get_c 1 set_b 2 0 get_c 5 Sample Output 0 100 Explanation 0 set_a 0 1 sets 00000 to 00001 C = A + B = 00001 + 11111 = 100000, so get_c[5] = 1 from the above computation get_c[1] = 0 set_b 2 0 sets 11111 to 11011 C = A + B = 00001 + 11011 = 011100, so get_c[5] = 0 The output is hence concatenation of 1, 0 and 0 = 100
def setBit(x, bit, val): if val: return x | 1 << bit return x & ~(1 << bit) n, q = map(int, input().strip().split(" ")) a = int(input().strip(), 2) b = int(input().strip(), 2) output = "" for _ in range(q): cmd = input().strip().split(" ") if cmd[0] == "set_a": a = setBit(a, int(cmd[1]), int(cmd[2])) elif cmd[0] == "set_b": b = setBit(b, int(cmd[1]), int(cmd[2])) else: output += str(int(bool(a + b & 1 << int(cmd[1])))) print(output)
FUNC_DEF IF VAR RETURN BIN_OP VAR BIN_OP NUMBER VAR RETURN BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING IF VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER IF VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
Let a and b be binary numbers of length n (MSB to the left). The following commands may be performed: set_a idx x: Set $a[i dx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $a[i dx]$ is $\text{id}x^{\text{th}}$ least significant bit of $a$. set_b idx x: Set $b[idx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $b[idx]$ is $\text{id}x^{\text{th}}$ least significant bit of $\boldsymbol{b}$. get_c idx: Print $c[idx]$, where $c[idx]=a[idx]+b[idx]$ and $0\leq idx\leq n+1$. Given $a,b$, and a list of commands, create a string made of the results of each $\text{get_c}$ call, the only command that produces output. For example, $\boldsymbol{a}=\boldsymbol{000}$ and $b=111$ so the length of the numbers is $n=3$. Print an answer string that contains the results of all commands on one line. A series of commands and their results follow: Starting ans = '' (empty string) a b 000 111 set_a 1 1 010 111 set_b 0 1 010 111 get_c 3 a + b = 1001 ans = '1' 010 111 get_c 4 a + b = 01001 ans = '10' Note: When the command is get_c 4, $\textbf{C}$ had to be padded to the left with a $0$ to be long enough to return a value. Function Description Complete the changeBits function in the editor below. For each get_c command, it should print either a 0 or a 1 without a newline until all commands have been processed. At that point, add a newline. changeBits has the following parameters: - a, b: two integers represented as binary strings - queries[queries[0]-queries[n-1]]: an array of query strings in the format described Input Format The first line of input contains two space-separated integers, $n$ and $\textit{q}$, the length of the binary representations of $a$ and $\boldsymbol{b}$, and the number of commands, respectively. The second and third lines each contain a string representation of $a$ and $\boldsymbol{b}$. The following $\textit{q}$ lines each contain a command string $\textit{queries}[i]$ as described above. Constraints $1\leq n\leq1000000$ $1\leq q\leq5000000$ Output Format For each query of the type $\text{get_c}$, output a single digit 0 or 1. Output must be placed on a single line. Sample Input 0 5 5 00000 11111 set_a 0 1 get_c 5 get_c 1 set_b 2 0 get_c 5 Sample Output 0 100 Explanation 0 set_a 0 1 sets 00000 to 00001 C = A + B = 00001 + 11111 = 100000, so get_c[5] = 1 from the above computation get_c[1] = 0 set_b 2 0 sets 11111 to 11011 C = A + B = 00001 + 11011 = 011100, so get_c[5] = 0 The output is hence concatenation of 1, 0 and 0 = 100
def setBit(num, bit): mask = 1 << bit return num | mask def clearBit(num, bit): mask = ~(1 << bit) return num & mask def testBit(num, bit): mask = 1 << bit return num & mask N, Q = map(int, input().split()) A = int(input(), 2) B = int(input(), 2) inp = [] for i in range(Q): inp = input().split() s = inp[0] if s == "set_a" or s == "set_b": an = int(inp[1]) bn = int(inp[2]) if s == "set_a" and bn == 0: A = clearBit(A, an) elif s == "set_b" and bn == 0: B = clearBit(B, an) elif s == "set_a" and bn > 0: A = setBit(A, an) elif s == "set_b" and bn > 0: B = setBit(B, an) if s == "get_c": an = int(inp[1]) if testBit(A + B, an): print(1, end="") else: print(0, end="")
FUNC_DEF ASSIGN VAR BIN_OP NUMBER VAR RETURN BIN_OP VAR VAR FUNC_DEF ASSIGN VAR BIN_OP NUMBER VAR RETURN BIN_OP VAR VAR FUNC_DEF ASSIGN VAR BIN_OP NUMBER VAR RETURN BIN_OP VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER IF VAR STRING VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR NUMBER STRING EXPR FUNC_CALL VAR NUMBER STRING
Let a and b be binary numbers of length n (MSB to the left). The following commands may be performed: set_a idx x: Set $a[i dx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $a[i dx]$ is $\text{id}x^{\text{th}}$ least significant bit of $a$. set_b idx x: Set $b[idx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $b[idx]$ is $\text{id}x^{\text{th}}$ least significant bit of $\boldsymbol{b}$. get_c idx: Print $c[idx]$, where $c[idx]=a[idx]+b[idx]$ and $0\leq idx\leq n+1$. Given $a,b$, and a list of commands, create a string made of the results of each $\text{get_c}$ call, the only command that produces output. For example, $\boldsymbol{a}=\boldsymbol{000}$ and $b=111$ so the length of the numbers is $n=3$. Print an answer string that contains the results of all commands on one line. A series of commands and their results follow: Starting ans = '' (empty string) a b 000 111 set_a 1 1 010 111 set_b 0 1 010 111 get_c 3 a + b = 1001 ans = '1' 010 111 get_c 4 a + b = 01001 ans = '10' Note: When the command is get_c 4, $\textbf{C}$ had to be padded to the left with a $0$ to be long enough to return a value. Function Description Complete the changeBits function in the editor below. For each get_c command, it should print either a 0 or a 1 without a newline until all commands have been processed. At that point, add a newline. changeBits has the following parameters: - a, b: two integers represented as binary strings - queries[queries[0]-queries[n-1]]: an array of query strings in the format described Input Format The first line of input contains two space-separated integers, $n$ and $\textit{q}$, the length of the binary representations of $a$ and $\boldsymbol{b}$, and the number of commands, respectively. The second and third lines each contain a string representation of $a$ and $\boldsymbol{b}$. The following $\textit{q}$ lines each contain a command string $\textit{queries}[i]$ as described above. Constraints $1\leq n\leq1000000$ $1\leq q\leq5000000$ Output Format For each query of the type $\text{get_c}$, output a single digit 0 or 1. Output must be placed on a single line. Sample Input 0 5 5 00000 11111 set_a 0 1 get_c 5 get_c 1 set_b 2 0 get_c 5 Sample Output 0 100 Explanation 0 set_a 0 1 sets 00000 to 00001 C = A + B = 00001 + 11111 = 100000, so get_c[5] = 1 from the above computation get_c[1] = 0 set_b 2 0 sets 11111 to 11011 C = A + B = 00001 + 11011 = 011100, so get_c[5] = 0 The output is hence concatenation of 1, 0 and 0 = 100
N, Q = input().strip().split() N, Q = int(N), int(Q) A = int(input().strip(), 2) B = int(input().strip(), 2) for q in range(Q): qu = input().strip().split() if qu[0] == "set_a": if qu[2] == "0": A = A & ~(1 << int(qu[1])) elif qu[2] == "1": A = A | 1 << int(qu[1]) elif qu[0] == "set_b": if qu[2] == "0": B = B & ~(1 << int(qu[1])) elif qu[2] == "1": B = B | 1 << int(qu[1]) elif qu[0] == "get_c": if A + B & 1 << int(qu[1]) == 0: print(0, end="") else: print(1, end="")
ASSIGN VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR IF VAR NUMBER STRING IF VAR NUMBER STRING ASSIGN VAR BIN_OP VAR BIN_OP NUMBER FUNC_CALL VAR VAR NUMBER IF VAR NUMBER STRING ASSIGN VAR BIN_OP VAR BIN_OP NUMBER FUNC_CALL VAR VAR NUMBER IF VAR NUMBER STRING IF VAR NUMBER STRING ASSIGN VAR BIN_OP VAR BIN_OP NUMBER FUNC_CALL VAR VAR NUMBER IF VAR NUMBER STRING ASSIGN VAR BIN_OP VAR BIN_OP NUMBER FUNC_CALL VAR VAR NUMBER IF VAR NUMBER STRING IF BIN_OP BIN_OP VAR VAR BIN_OP NUMBER FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER STRING EXPR FUNC_CALL VAR NUMBER STRING
Let a and b be binary numbers of length n (MSB to the left). The following commands may be performed: set_a idx x: Set $a[i dx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $a[i dx]$ is $\text{id}x^{\text{th}}$ least significant bit of $a$. set_b idx x: Set $b[idx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $b[idx]$ is $\text{id}x^{\text{th}}$ least significant bit of $\boldsymbol{b}$. get_c idx: Print $c[idx]$, where $c[idx]=a[idx]+b[idx]$ and $0\leq idx\leq n+1$. Given $a,b$, and a list of commands, create a string made of the results of each $\text{get_c}$ call, the only command that produces output. For example, $\boldsymbol{a}=\boldsymbol{000}$ and $b=111$ so the length of the numbers is $n=3$. Print an answer string that contains the results of all commands on one line. A series of commands and their results follow: Starting ans = '' (empty string) a b 000 111 set_a 1 1 010 111 set_b 0 1 010 111 get_c 3 a + b = 1001 ans = '1' 010 111 get_c 4 a + b = 01001 ans = '10' Note: When the command is get_c 4, $\textbf{C}$ had to be padded to the left with a $0$ to be long enough to return a value. Function Description Complete the changeBits function in the editor below. For each get_c command, it should print either a 0 or a 1 without a newline until all commands have been processed. At that point, add a newline. changeBits has the following parameters: - a, b: two integers represented as binary strings - queries[queries[0]-queries[n-1]]: an array of query strings in the format described Input Format The first line of input contains two space-separated integers, $n$ and $\textit{q}$, the length of the binary representations of $a$ and $\boldsymbol{b}$, and the number of commands, respectively. The second and third lines each contain a string representation of $a$ and $\boldsymbol{b}$. The following $\textit{q}$ lines each contain a command string $\textit{queries}[i]$ as described above. Constraints $1\leq n\leq1000000$ $1\leq q\leq5000000$ Output Format For each query of the type $\text{get_c}$, output a single digit 0 or 1. Output must be placed on a single line. Sample Input 0 5 5 00000 11111 set_a 0 1 get_c 5 get_c 1 set_b 2 0 get_c 5 Sample Output 0 100 Explanation 0 set_a 0 1 sets 00000 to 00001 C = A + B = 00001 + 11111 = 100000, so get_c[5] = 1 from the above computation get_c[1] = 0 set_b 2 0 sets 11111 to 11011 C = A + B = 00001 + 11011 = 011100, so get_c[5] = 0 The output is hence concatenation of 1, 0 and 0 = 100
import sys def get(a, b, bit): c = a + b return str(int(bool(c & 1 << bit))) def setbit(a, bit, val): add_ = 1 << bit if val: return a | add_ return a & ~add_ n_bits, Q = map(int, input().strip().split(" ")) A = int(input().strip(), 2) B = int(input().strip(), 2) out = "" for _ in range(Q): cmd = input().strip().split(" ") bit = int(cmd[1]) cmd.append(7) val = int(cmd[2]) if cmd[0] == "get_c": out += get(A, B, bit) elif cmd[0] == "set_a": A = setbit(A, bit, val) else: B = setbit(B, bit, val) print(out)
IMPORT FUNC_DEF ASSIGN VAR BIN_OP VAR VAR RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER VAR FUNC_DEF ASSIGN VAR BIN_OP NUMBER VAR IF VAR RETURN BIN_OP VAR VAR RETURN BIN_OP VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER STRING VAR FUNC_CALL VAR VAR VAR VAR IF VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR
Let a and b be binary numbers of length n (MSB to the left). The following commands may be performed: set_a idx x: Set $a[i dx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $a[i dx]$ is $\text{id}x^{\text{th}}$ least significant bit of $a$. set_b idx x: Set $b[idx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $b[idx]$ is $\text{id}x^{\text{th}}$ least significant bit of $\boldsymbol{b}$. get_c idx: Print $c[idx]$, where $c[idx]=a[idx]+b[idx]$ and $0\leq idx\leq n+1$. Given $a,b$, and a list of commands, create a string made of the results of each $\text{get_c}$ call, the only command that produces output. For example, $\boldsymbol{a}=\boldsymbol{000}$ and $b=111$ so the length of the numbers is $n=3$. Print an answer string that contains the results of all commands on one line. A series of commands and their results follow: Starting ans = '' (empty string) a b 000 111 set_a 1 1 010 111 set_b 0 1 010 111 get_c 3 a + b = 1001 ans = '1' 010 111 get_c 4 a + b = 01001 ans = '10' Note: When the command is get_c 4, $\textbf{C}$ had to be padded to the left with a $0$ to be long enough to return a value. Function Description Complete the changeBits function in the editor below. For each get_c command, it should print either a 0 or a 1 without a newline until all commands have been processed. At that point, add a newline. changeBits has the following parameters: - a, b: two integers represented as binary strings - queries[queries[0]-queries[n-1]]: an array of query strings in the format described Input Format The first line of input contains two space-separated integers, $n$ and $\textit{q}$, the length of the binary representations of $a$ and $\boldsymbol{b}$, and the number of commands, respectively. The second and third lines each contain a string representation of $a$ and $\boldsymbol{b}$. The following $\textit{q}$ lines each contain a command string $\textit{queries}[i]$ as described above. Constraints $1\leq n\leq1000000$ $1\leq q\leq5000000$ Output Format For each query of the type $\text{get_c}$, output a single digit 0 or 1. Output must be placed on a single line. Sample Input 0 5 5 00000 11111 set_a 0 1 get_c 5 get_c 1 set_b 2 0 get_c 5 Sample Output 0 100 Explanation 0 set_a 0 1 sets 00000 to 00001 C = A + B = 00001 + 11111 = 100000, so get_c[5] = 1 from the above computation get_c[1] = 0 set_b 2 0 sets 11111 to 11011 C = A + B = 00001 + 11011 = 011100, so get_c[5] = 0 The output is hence concatenation of 1, 0 and 0 = 100
def set_bit(number, bit, value): if value: return number + (1 << bit) else: return number - (1 << bit) def test(number, bit): return number >> bit & 1 n, q = input().split() n, q = int(n), int(q) a, b = int(input(), 2), int(input(), 2) c = a + b for i in range(q): op, *args = input().split() bit, value = int(args[0]), int(args[1]) if len(args) > 1 else None if op == "set_a": if test(a, bit) != value: a = set_bit(a, bit, value) c = set_bit(c, bit, value) elif op == "set_b": if test(b, bit) != value: b = set_bit(b, bit, value) c = set_bit(c, bit, value) else: print("1" if test(c, bit) else "0", end="")
FUNC_DEF IF VAR RETURN BIN_OP VAR BIN_OP NUMBER VAR RETURN BIN_OP VAR BIN_OP NUMBER VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER NONE IF VAR STRING IF FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR STRING IF FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR STRING STRING STRING
Let a and b be binary numbers of length n (MSB to the left). The following commands may be performed: set_a idx x: Set $a[i dx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $a[i dx]$ is $\text{id}x^{\text{th}}$ least significant bit of $a$. set_b idx x: Set $b[idx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $b[idx]$ is $\text{id}x^{\text{th}}$ least significant bit of $\boldsymbol{b}$. get_c idx: Print $c[idx]$, where $c[idx]=a[idx]+b[idx]$ and $0\leq idx\leq n+1$. Given $a,b$, and a list of commands, create a string made of the results of each $\text{get_c}$ call, the only command that produces output. For example, $\boldsymbol{a}=\boldsymbol{000}$ and $b=111$ so the length of the numbers is $n=3$. Print an answer string that contains the results of all commands on one line. A series of commands and their results follow: Starting ans = '' (empty string) a b 000 111 set_a 1 1 010 111 set_b 0 1 010 111 get_c 3 a + b = 1001 ans = '1' 010 111 get_c 4 a + b = 01001 ans = '10' Note: When the command is get_c 4, $\textbf{C}$ had to be padded to the left with a $0$ to be long enough to return a value. Function Description Complete the changeBits function in the editor below. For each get_c command, it should print either a 0 or a 1 without a newline until all commands have been processed. At that point, add a newline. changeBits has the following parameters: - a, b: two integers represented as binary strings - queries[queries[0]-queries[n-1]]: an array of query strings in the format described Input Format The first line of input contains two space-separated integers, $n$ and $\textit{q}$, the length of the binary representations of $a$ and $\boldsymbol{b}$, and the number of commands, respectively. The second and third lines each contain a string representation of $a$ and $\boldsymbol{b}$. The following $\textit{q}$ lines each contain a command string $\textit{queries}[i]$ as described above. Constraints $1\leq n\leq1000000$ $1\leq q\leq5000000$ Output Format For each query of the type $\text{get_c}$, output a single digit 0 or 1. Output must be placed on a single line. Sample Input 0 5 5 00000 11111 set_a 0 1 get_c 5 get_c 1 set_b 2 0 get_c 5 Sample Output 0 100 Explanation 0 set_a 0 1 sets 00000 to 00001 C = A + B = 00001 + 11111 = 100000, so get_c[5] = 1 from the above computation get_c[1] = 0 set_b 2 0 sets 11111 to 11011 C = A + B = 00001 + 11011 = 011100, so get_c[5] = 0 The output is hence concatenation of 1, 0 and 0 = 100
def set_bit(val, i, bit): num = 1 << i if bit: return val | num return val & ~num NQ = input() two_ints = NQ.split() N, Q = int(two_ints[0]), int(two_ints[1]) A = int(input(), 2) B = int(input(), 2) output = [] for i in range(Q): input_line = input() split_input = input_line.split() query = split_input[0] index = int(split_input[1]) if query == "set_a": val = int(split_input[2]) A = set_bit(A, index, val) elif query == "set_b": val = int(split_input[2]) B = set_bit(B, index, val) elif query == "get_c": C = A + B C_bit = int(bool(C & 1 << index)) output.append(str(C_bit)) print("".join(output))
FUNC_DEF ASSIGN VAR BIN_OP NUMBER VAR IF VAR RETURN BIN_OP VAR VAR RETURN BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR STRING ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING VAR
Let a and b be binary numbers of length n (MSB to the left). The following commands may be performed: set_a idx x: Set $a[i dx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $a[i dx]$ is $\text{id}x^{\text{th}}$ least significant bit of $a$. set_b idx x: Set $b[idx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $b[idx]$ is $\text{id}x^{\text{th}}$ least significant bit of $\boldsymbol{b}$. get_c idx: Print $c[idx]$, where $c[idx]=a[idx]+b[idx]$ and $0\leq idx\leq n+1$. Given $a,b$, and a list of commands, create a string made of the results of each $\text{get_c}$ call, the only command that produces output. For example, $\boldsymbol{a}=\boldsymbol{000}$ and $b=111$ so the length of the numbers is $n=3$. Print an answer string that contains the results of all commands on one line. A series of commands and their results follow: Starting ans = '' (empty string) a b 000 111 set_a 1 1 010 111 set_b 0 1 010 111 get_c 3 a + b = 1001 ans = '1' 010 111 get_c 4 a + b = 01001 ans = '10' Note: When the command is get_c 4, $\textbf{C}$ had to be padded to the left with a $0$ to be long enough to return a value. Function Description Complete the changeBits function in the editor below. For each get_c command, it should print either a 0 or a 1 without a newline until all commands have been processed. At that point, add a newline. changeBits has the following parameters: - a, b: two integers represented as binary strings - queries[queries[0]-queries[n-1]]: an array of query strings in the format described Input Format The first line of input contains two space-separated integers, $n$ and $\textit{q}$, the length of the binary representations of $a$ and $\boldsymbol{b}$, and the number of commands, respectively. The second and third lines each contain a string representation of $a$ and $\boldsymbol{b}$. The following $\textit{q}$ lines each contain a command string $\textit{queries}[i]$ as described above. Constraints $1\leq n\leq1000000$ $1\leq q\leq5000000$ Output Format For each query of the type $\text{get_c}$, output a single digit 0 or 1. Output must be placed on a single line. Sample Input 0 5 5 00000 11111 set_a 0 1 get_c 5 get_c 1 set_b 2 0 get_c 5 Sample Output 0 100 Explanation 0 set_a 0 1 sets 00000 to 00001 C = A + B = 00001 + 11111 = 100000, so get_c[5] = 1 from the above computation get_c[1] = 0 set_b 2 0 sets 11111 to 11011 C = A + B = 00001 + 11011 = 011100, so get_c[5] = 0 The output is hence concatenation of 1, 0 and 0 = 100
N, Q = map(int, input().split()) A = int(input(), 2) B = int(input(), 2) output = "" for _ in range(Q): inputLine = list(input().split()) if inputLine[0] == "set_a": idx = int(inputLine[1]) x = int(inputLine[2]) A &= ~(1 << idx) A |= x << idx elif inputLine[0] == "set_b": idx = int(inputLine[1]) x = int(inputLine[2]) B &= ~(1 << idx) B |= x << idx elif inputLine[0] == "get_c": idx = int(inputLine[1]) output += str(A + B >> idx & 1) print(output)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR BIN_OP NUMBER VAR VAR BIN_OP VAR VAR IF VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR BIN_OP NUMBER VAR VAR BIN_OP VAR VAR IF VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
Let a and b be binary numbers of length n (MSB to the left). The following commands may be performed: set_a idx x: Set $a[i dx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $a[i dx]$ is $\text{id}x^{\text{th}}$ least significant bit of $a$. set_b idx x: Set $b[idx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $b[idx]$ is $\text{id}x^{\text{th}}$ least significant bit of $\boldsymbol{b}$. get_c idx: Print $c[idx]$, where $c[idx]=a[idx]+b[idx]$ and $0\leq idx\leq n+1$. Given $a,b$, and a list of commands, create a string made of the results of each $\text{get_c}$ call, the only command that produces output. For example, $\boldsymbol{a}=\boldsymbol{000}$ and $b=111$ so the length of the numbers is $n=3$. Print an answer string that contains the results of all commands on one line. A series of commands and their results follow: Starting ans = '' (empty string) a b 000 111 set_a 1 1 010 111 set_b 0 1 010 111 get_c 3 a + b = 1001 ans = '1' 010 111 get_c 4 a + b = 01001 ans = '10' Note: When the command is get_c 4, $\textbf{C}$ had to be padded to the left with a $0$ to be long enough to return a value. Function Description Complete the changeBits function in the editor below. For each get_c command, it should print either a 0 or a 1 without a newline until all commands have been processed. At that point, add a newline. changeBits has the following parameters: - a, b: two integers represented as binary strings - queries[queries[0]-queries[n-1]]: an array of query strings in the format described Input Format The first line of input contains two space-separated integers, $n$ and $\textit{q}$, the length of the binary representations of $a$ and $\boldsymbol{b}$, and the number of commands, respectively. The second and third lines each contain a string representation of $a$ and $\boldsymbol{b}$. The following $\textit{q}$ lines each contain a command string $\textit{queries}[i]$ as described above. Constraints $1\leq n\leq1000000$ $1\leq q\leq5000000$ Output Format For each query of the type $\text{get_c}$, output a single digit 0 or 1. Output must be placed on a single line. Sample Input 0 5 5 00000 11111 set_a 0 1 get_c 5 get_c 1 set_b 2 0 get_c 5 Sample Output 0 100 Explanation 0 set_a 0 1 sets 00000 to 00001 C = A + B = 00001 + 11111 = 100000, so get_c[5] = 1 from the above computation get_c[1] = 0 set_b 2 0 sets 11111 to 11011 C = A + B = 00001 + 11011 = 011100, so get_c[5] = 0 The output is hence concatenation of 1, 0 and 0 = 100
def set_bit(k, idx, x): bit = 1 << idx result = k | bit if x == 1 else k & ~bit return result def changeBits(a, b, queries): a = int(a, 2) b = int(b, 2) result = "" for q in queries: command, *args = q.split(" ") args = [int(k) for k in args] if command == "set_a": idx, x = args a = set_bit(a, idx, x) elif command == "set_b": idx, x = args b = set_bit(b, idx, x) elif command == "get_c": [idx] = args bit = 1 << idx c = a + b result += "0" if c & bit == 0 else "1" print(result) first_multiple_input = input().rstrip().split() ab_size = int(first_multiple_input[0]) queries_size = int(first_multiple_input[1]) a = input() b = input() queries = [] for _ in range(queries_size): queries_item = input() queries.append(queries_item) changeBits(a, b, queries)
FUNC_DEF ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR VAR NUMBER BIN_OP VAR VAR BIN_OP VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING FOR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR STRING ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR STRING ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR STRING ASSIGN LIST VAR VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR NUMBER STRING STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR
Let a and b be binary numbers of length n (MSB to the left). The following commands may be performed: set_a idx x: Set $a[i dx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $a[i dx]$ is $\text{id}x^{\text{th}}$ least significant bit of $a$. set_b idx x: Set $b[idx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $b[idx]$ is $\text{id}x^{\text{th}}$ least significant bit of $\boldsymbol{b}$. get_c idx: Print $c[idx]$, where $c[idx]=a[idx]+b[idx]$ and $0\leq idx\leq n+1$. Given $a,b$, and a list of commands, create a string made of the results of each $\text{get_c}$ call, the only command that produces output. For example, $\boldsymbol{a}=\boldsymbol{000}$ and $b=111$ so the length of the numbers is $n=3$. Print an answer string that contains the results of all commands on one line. A series of commands and their results follow: Starting ans = '' (empty string) a b 000 111 set_a 1 1 010 111 set_b 0 1 010 111 get_c 3 a + b = 1001 ans = '1' 010 111 get_c 4 a + b = 01001 ans = '10' Note: When the command is get_c 4, $\textbf{C}$ had to be padded to the left with a $0$ to be long enough to return a value. Function Description Complete the changeBits function in the editor below. For each get_c command, it should print either a 0 or a 1 without a newline until all commands have been processed. At that point, add a newline. changeBits has the following parameters: - a, b: two integers represented as binary strings - queries[queries[0]-queries[n-1]]: an array of query strings in the format described Input Format The first line of input contains two space-separated integers, $n$ and $\textit{q}$, the length of the binary representations of $a$ and $\boldsymbol{b}$, and the number of commands, respectively. The second and third lines each contain a string representation of $a$ and $\boldsymbol{b}$. The following $\textit{q}$ lines each contain a command string $\textit{queries}[i]$ as described above. Constraints $1\leq n\leq1000000$ $1\leq q\leq5000000$ Output Format For each query of the type $\text{get_c}$, output a single digit 0 or 1. Output must be placed on a single line. Sample Input 0 5 5 00000 11111 set_a 0 1 get_c 5 get_c 1 set_b 2 0 get_c 5 Sample Output 0 100 Explanation 0 set_a 0 1 sets 00000 to 00001 C = A + B = 00001 + 11111 = 100000, so get_c[5] = 1 from the above computation get_c[1] = 0 set_b 2 0 sets 11111 to 11011 C = A + B = 00001 + 11011 = 011100, so get_c[5] = 0 The output is hence concatenation of 1, 0 and 0 = 100
def set_bit(n, i, x): if x == 1: return n | 1 << i else: return n & ~(1 << i) def get_bit(n, i): return (n >> i) - (n >> i + 1 << 1) _, q = map(int, input().split(" ")) a = int(input(), 2) b = int(input(), 2) set_a = lambda i, x: set_bit(a, i, x) set_b = lambda i, x: set_bit(b, i, x) get_c = lambda i: print(get_bit(a + b, i), end="") for _ in range(q): action, *args = input().split(" ") if action[0] == "s" and action[4] == "a": a = set_a(int(args[0]), int(args[1])) elif action[0] == "s" and action[4] == "b": b = set_b(int(args[0]), int(args[1])) elif action[0] == "g": get_c(int(args[0]))
FUNC_DEF IF VAR NUMBER RETURN BIN_OP VAR BIN_OP NUMBER VAR RETURN BIN_OP VAR BIN_OP NUMBER VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR NUMBER STRING VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER IF VAR NUMBER STRING VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER IF VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER
Let a and b be binary numbers of length n (MSB to the left). The following commands may be performed: set_a idx x: Set $a[i dx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $a[i dx]$ is $\text{id}x^{\text{th}}$ least significant bit of $a$. set_b idx x: Set $b[idx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $b[idx]$ is $\text{id}x^{\text{th}}$ least significant bit of $\boldsymbol{b}$. get_c idx: Print $c[idx]$, where $c[idx]=a[idx]+b[idx]$ and $0\leq idx\leq n+1$. Given $a,b$, and a list of commands, create a string made of the results of each $\text{get_c}$ call, the only command that produces output. For example, $\boldsymbol{a}=\boldsymbol{000}$ and $b=111$ so the length of the numbers is $n=3$. Print an answer string that contains the results of all commands on one line. A series of commands and their results follow: Starting ans = '' (empty string) a b 000 111 set_a 1 1 010 111 set_b 0 1 010 111 get_c 3 a + b = 1001 ans = '1' 010 111 get_c 4 a + b = 01001 ans = '10' Note: When the command is get_c 4, $\textbf{C}$ had to be padded to the left with a $0$ to be long enough to return a value. Function Description Complete the changeBits function in the editor below. For each get_c command, it should print either a 0 or a 1 without a newline until all commands have been processed. At that point, add a newline. changeBits has the following parameters: - a, b: two integers represented as binary strings - queries[queries[0]-queries[n-1]]: an array of query strings in the format described Input Format The first line of input contains two space-separated integers, $n$ and $\textit{q}$, the length of the binary representations of $a$ and $\boldsymbol{b}$, and the number of commands, respectively. The second and third lines each contain a string representation of $a$ and $\boldsymbol{b}$. The following $\textit{q}$ lines each contain a command string $\textit{queries}[i]$ as described above. Constraints $1\leq n\leq1000000$ $1\leq q\leq5000000$ Output Format For each query of the type $\text{get_c}$, output a single digit 0 or 1. Output must be placed on a single line. Sample Input 0 5 5 00000 11111 set_a 0 1 get_c 5 get_c 1 set_b 2 0 get_c 5 Sample Output 0 100 Explanation 0 set_a 0 1 sets 00000 to 00001 C = A + B = 00001 + 11111 = 100000, so get_c[5] = 1 from the above computation get_c[1] = 0 set_b 2 0 sets 11111 to 11011 C = A + B = 00001 + 11011 = 011100, so get_c[5] = 0 The output is hence concatenation of 1, 0 and 0 = 100
def set_bit(val, idx, bit): mask = 1 << idx if bit: return val | mask return val & ~mask def get_bit(val, idx): mask = 1 << idx return int(bool(val & mask)) n, q = map(int, input().strip().split(" ")) a = int(input().strip(), 2) b = int(input().strip(), 2) for i in range(q): cmd = input().strip().split(" ") idx = int(cmd[1]) if cmd[0] == "set_a": bit = int(cmd[2]) a = set_bit(a, idx, bit) elif cmd[0] == "set_b": bit = int(cmd[2]) b = set_bit(b, idx, bit) else: c = a + b cbit = get_bit(c, idx) print(cbit, end="")
FUNC_DEF ASSIGN VAR BIN_OP NUMBER VAR IF VAR RETURN BIN_OP VAR VAR RETURN BIN_OP VAR VAR FUNC_DEF ASSIGN VAR BIN_OP NUMBER VAR RETURN FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR STRING
Let a and b be binary numbers of length n (MSB to the left). The following commands may be performed: set_a idx x: Set $a[i dx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $a[i dx]$ is $\text{id}x^{\text{th}}$ least significant bit of $a$. set_b idx x: Set $b[idx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $b[idx]$ is $\text{id}x^{\text{th}}$ least significant bit of $\boldsymbol{b}$. get_c idx: Print $c[idx]$, where $c[idx]=a[idx]+b[idx]$ and $0\leq idx\leq n+1$. Given $a,b$, and a list of commands, create a string made of the results of each $\text{get_c}$ call, the only command that produces output. For example, $\boldsymbol{a}=\boldsymbol{000}$ and $b=111$ so the length of the numbers is $n=3$. Print an answer string that contains the results of all commands on one line. A series of commands and their results follow: Starting ans = '' (empty string) a b 000 111 set_a 1 1 010 111 set_b 0 1 010 111 get_c 3 a + b = 1001 ans = '1' 010 111 get_c 4 a + b = 01001 ans = '10' Note: When the command is get_c 4, $\textbf{C}$ had to be padded to the left with a $0$ to be long enough to return a value. Function Description Complete the changeBits function in the editor below. For each get_c command, it should print either a 0 or a 1 without a newline until all commands have been processed. At that point, add a newline. changeBits has the following parameters: - a, b: two integers represented as binary strings - queries[queries[0]-queries[n-1]]: an array of query strings in the format described Input Format The first line of input contains two space-separated integers, $n$ and $\textit{q}$, the length of the binary representations of $a$ and $\boldsymbol{b}$, and the number of commands, respectively. The second and third lines each contain a string representation of $a$ and $\boldsymbol{b}$. The following $\textit{q}$ lines each contain a command string $\textit{queries}[i]$ as described above. Constraints $1\leq n\leq1000000$ $1\leq q\leq5000000$ Output Format For each query of the type $\text{get_c}$, output a single digit 0 or 1. Output must be placed on a single line. Sample Input 0 5 5 00000 11111 set_a 0 1 get_c 5 get_c 1 set_b 2 0 get_c 5 Sample Output 0 100 Explanation 0 set_a 0 1 sets 00000 to 00001 C = A + B = 00001 + 11111 = 100000, so get_c[5] = 1 from the above computation get_c[1] = 0 set_b 2 0 sets 11111 to 11011 C = A + B = 00001 + 11011 = 011100, so get_c[5] = 0 The output is hence concatenation of 1, 0 and 0 = 100
def setat(a, i, val): if val: return a | 1 << i return a & ~(1 << i) n, q = map(int, input().strip().split(" ")) a = int(input(), 2) b = int(input(), 2) for _ in range(q): l = input().strip().split(" ") i = int(l[1]) if l[0] == "set_a": value = int(l[2]) a = setat(a, i, value) elif l[0] == "set_b": value = int(l[2]) b = setat(b, i, value) elif a + b & 1 << i: print("1", end="") else: print("0", end="")
FUNC_DEF IF VAR RETURN BIN_OP VAR BIN_OP NUMBER VAR RETURN BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF BIN_OP BIN_OP VAR VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR STRING STRING EXPR FUNC_CALL VAR STRING STRING
Let a and b be binary numbers of length n (MSB to the left). The following commands may be performed: set_a idx x: Set $a[i dx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $a[i dx]$ is $\text{id}x^{\text{th}}$ least significant bit of $a$. set_b idx x: Set $b[idx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $b[idx]$ is $\text{id}x^{\text{th}}$ least significant bit of $\boldsymbol{b}$. get_c idx: Print $c[idx]$, where $c[idx]=a[idx]+b[idx]$ and $0\leq idx\leq n+1$. Given $a,b$, and a list of commands, create a string made of the results of each $\text{get_c}$ call, the only command that produces output. For example, $\boldsymbol{a}=\boldsymbol{000}$ and $b=111$ so the length of the numbers is $n=3$. Print an answer string that contains the results of all commands on one line. A series of commands and their results follow: Starting ans = '' (empty string) a b 000 111 set_a 1 1 010 111 set_b 0 1 010 111 get_c 3 a + b = 1001 ans = '1' 010 111 get_c 4 a + b = 01001 ans = '10' Note: When the command is get_c 4, $\textbf{C}$ had to be padded to the left with a $0$ to be long enough to return a value. Function Description Complete the changeBits function in the editor below. For each get_c command, it should print either a 0 or a 1 without a newline until all commands have been processed. At that point, add a newline. changeBits has the following parameters: - a, b: two integers represented as binary strings - queries[queries[0]-queries[n-1]]: an array of query strings in the format described Input Format The first line of input contains two space-separated integers, $n$ and $\textit{q}$, the length of the binary representations of $a$ and $\boldsymbol{b}$, and the number of commands, respectively. The second and third lines each contain a string representation of $a$ and $\boldsymbol{b}$. The following $\textit{q}$ lines each contain a command string $\textit{queries}[i]$ as described above. Constraints $1\leq n\leq1000000$ $1\leq q\leq5000000$ Output Format For each query of the type $\text{get_c}$, output a single digit 0 or 1. Output must be placed on a single line. Sample Input 0 5 5 00000 11111 set_a 0 1 get_c 5 get_c 1 set_b 2 0 get_c 5 Sample Output 0 100 Explanation 0 set_a 0 1 sets 00000 to 00001 C = A + B = 00001 + 11111 = 100000, so get_c[5] = 1 from the above computation get_c[1] = 0 set_b 2 0 sets 11111 to 11011 C = A + B = 00001 + 11011 = 011100, so get_c[5] = 0 The output is hence concatenation of 1, 0 and 0 = 100
import sys def set_bit(n, i, val): part = 1 << i if int(val) == 1: return n | part elif n & part > 0: return n - part else: return n len_a, len_b = (int(i) for i in input().split()) a = int(input(), 2) b = int(input(), 2) for line in sys.stdin: parts = line.split() if parts[0] == "set_a": a = set_bit(a, int(parts[1]), int(parts[2])) elif parts[0] == "set_b": b = set_bit(b, int(parts[1]), int(parts[2])) else: i = int(parts[1]) print("1" if a + b & 1 << i else "0", end="")
IMPORT FUNC_DEF ASSIGN VAR BIN_OP NUMBER VAR IF FUNC_CALL VAR VAR NUMBER RETURN BIN_OP VAR VAR IF BIN_OP VAR VAR NUMBER RETURN BIN_OP VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER IF VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR BIN_OP NUMBER VAR STRING STRING STRING
Let a and b be binary numbers of length n (MSB to the left). The following commands may be performed: set_a idx x: Set $a[i dx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $a[i dx]$ is $\text{id}x^{\text{th}}$ least significant bit of $a$. set_b idx x: Set $b[idx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $b[idx]$ is $\text{id}x^{\text{th}}$ least significant bit of $\boldsymbol{b}$. get_c idx: Print $c[idx]$, where $c[idx]=a[idx]+b[idx]$ and $0\leq idx\leq n+1$. Given $a,b$, and a list of commands, create a string made of the results of each $\text{get_c}$ call, the only command that produces output. For example, $\boldsymbol{a}=\boldsymbol{000}$ and $b=111$ so the length of the numbers is $n=3$. Print an answer string that contains the results of all commands on one line. A series of commands and their results follow: Starting ans = '' (empty string) a b 000 111 set_a 1 1 010 111 set_b 0 1 010 111 get_c 3 a + b = 1001 ans = '1' 010 111 get_c 4 a + b = 01001 ans = '10' Note: When the command is get_c 4, $\textbf{C}$ had to be padded to the left with a $0$ to be long enough to return a value. Function Description Complete the changeBits function in the editor below. For each get_c command, it should print either a 0 or a 1 without a newline until all commands have been processed. At that point, add a newline. changeBits has the following parameters: - a, b: two integers represented as binary strings - queries[queries[0]-queries[n-1]]: an array of query strings in the format described Input Format The first line of input contains two space-separated integers, $n$ and $\textit{q}$, the length of the binary representations of $a$ and $\boldsymbol{b}$, and the number of commands, respectively. The second and third lines each contain a string representation of $a$ and $\boldsymbol{b}$. The following $\textit{q}$ lines each contain a command string $\textit{queries}[i]$ as described above. Constraints $1\leq n\leq1000000$ $1\leq q\leq5000000$ Output Format For each query of the type $\text{get_c}$, output a single digit 0 or 1. Output must be placed on a single line. Sample Input 0 5 5 00000 11111 set_a 0 1 get_c 5 get_c 1 set_b 2 0 get_c 5 Sample Output 0 100 Explanation 0 set_a 0 1 sets 00000 to 00001 C = A + B = 00001 + 11111 = 100000, so get_c[5] = 1 from the above computation get_c[1] = 0 set_b 2 0 sets 11111 to 11011 C = A + B = 00001 + 11011 = 011100, so get_c[5] = 0 The output is hence concatenation of 1, 0 and 0 = 100
n, q = map(int, input().split(" ")) a = int(input(), 2) b = int(input(), 2) out = "" for i in range(q): query = input().strip().split(" ") cmd = query[0] i = int(query[1]) if cmd == "set_a": bit = int(query[2]) if bit: a |= 1 << i else: a &= ~(1 << i) elif cmd == "set_b": bit = int(query[2]) if bit: b |= 1 << i else: b &= ~(1 << i) else: c = a + b out += str(int(bool(c & 1 << i))) print(out)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR BIN_OP NUMBER VAR VAR BIN_OP NUMBER VAR IF VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR BIN_OP NUMBER VAR VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR
Let a and b be binary numbers of length n (MSB to the left). The following commands may be performed: set_a idx x: Set $a[i dx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $a[i dx]$ is $\text{id}x^{\text{th}}$ least significant bit of $a$. set_b idx x: Set $b[idx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $b[idx]$ is $\text{id}x^{\text{th}}$ least significant bit of $\boldsymbol{b}$. get_c idx: Print $c[idx]$, where $c[idx]=a[idx]+b[idx]$ and $0\leq idx\leq n+1$. Given $a,b$, and a list of commands, create a string made of the results of each $\text{get_c}$ call, the only command that produces output. For example, $\boldsymbol{a}=\boldsymbol{000}$ and $b=111$ so the length of the numbers is $n=3$. Print an answer string that contains the results of all commands on one line. A series of commands and their results follow: Starting ans = '' (empty string) a b 000 111 set_a 1 1 010 111 set_b 0 1 010 111 get_c 3 a + b = 1001 ans = '1' 010 111 get_c 4 a + b = 01001 ans = '10' Note: When the command is get_c 4, $\textbf{C}$ had to be padded to the left with a $0$ to be long enough to return a value. Function Description Complete the changeBits function in the editor below. For each get_c command, it should print either a 0 or a 1 without a newline until all commands have been processed. At that point, add a newline. changeBits has the following parameters: - a, b: two integers represented as binary strings - queries[queries[0]-queries[n-1]]: an array of query strings in the format described Input Format The first line of input contains two space-separated integers, $n$ and $\textit{q}$, the length of the binary representations of $a$ and $\boldsymbol{b}$, and the number of commands, respectively. The second and third lines each contain a string representation of $a$ and $\boldsymbol{b}$. The following $\textit{q}$ lines each contain a command string $\textit{queries}[i]$ as described above. Constraints $1\leq n\leq1000000$ $1\leq q\leq5000000$ Output Format For each query of the type $\text{get_c}$, output a single digit 0 or 1. Output must be placed on a single line. Sample Input 0 5 5 00000 11111 set_a 0 1 get_c 5 get_c 1 set_b 2 0 get_c 5 Sample Output 0 100 Explanation 0 set_a 0 1 sets 00000 to 00001 C = A + B = 00001 + 11111 = 100000, so get_c[5] = 1 from the above computation get_c[1] = 0 set_b 2 0 sets 11111 to 11011 C = A + B = 00001 + 11011 = 011100, so get_c[5] = 0 The output is hence concatenation of 1, 0 and 0 = 100
class BitCalculator: def __init__(self, a, b): self.a = a self.b = b def set_a(self, idx, x): if x == "0": self.a &= ~(1 << int(idx)) else: self.a |= 1 << int(idx) def set_b(self, idx, x): if x == "0": self.b &= ~(1 << int(idx)) else: self.b |= 1 << int(idx) def get_c(self, idx): c = self.a + self.b return c >> int(idx) & 1 n, q = map(int, input().split()) first = int(input(), 2) second = int(input(), 2) calc = BitCalculator(first, second) result = [] for i in range(q): command = input().split() if command[0] == "set_a": calc.set_a(command[1], command[2]) elif command[0] == "set_b": calc.set_b(command[1], command[2]) else: result.append(calc.get_c(command[1])) print("".join(map(str, result)))
CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF IF VAR STRING VAR BIN_OP NUMBER FUNC_CALL VAR VAR VAR BIN_OP NUMBER FUNC_CALL VAR VAR FUNC_DEF IF VAR STRING VAR BIN_OP NUMBER FUNC_CALL VAR VAR VAR BIN_OP NUMBER FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR BIN_OP VAR VAR RETURN BIN_OP BIN_OP VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER STRING EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER IF VAR NUMBER STRING EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR
Let a and b be binary numbers of length n (MSB to the left). The following commands may be performed: set_a idx x: Set $a[i dx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $a[i dx]$ is $\text{id}x^{\text{th}}$ least significant bit of $a$. set_b idx x: Set $b[idx]$ to $\boldsymbol{x}$, where $0\leq idx<n$ and $b[idx]$ is $\text{id}x^{\text{th}}$ least significant bit of $\boldsymbol{b}$. get_c idx: Print $c[idx]$, where $c[idx]=a[idx]+b[idx]$ and $0\leq idx\leq n+1$. Given $a,b$, and a list of commands, create a string made of the results of each $\text{get_c}$ call, the only command that produces output. For example, $\boldsymbol{a}=\boldsymbol{000}$ and $b=111$ so the length of the numbers is $n=3$. Print an answer string that contains the results of all commands on one line. A series of commands and their results follow: Starting ans = '' (empty string) a b 000 111 set_a 1 1 010 111 set_b 0 1 010 111 get_c 3 a + b = 1001 ans = '1' 010 111 get_c 4 a + b = 01001 ans = '10' Note: When the command is get_c 4, $\textbf{C}$ had to be padded to the left with a $0$ to be long enough to return a value. Function Description Complete the changeBits function in the editor below. For each get_c command, it should print either a 0 or a 1 without a newline until all commands have been processed. At that point, add a newline. changeBits has the following parameters: - a, b: two integers represented as binary strings - queries[queries[0]-queries[n-1]]: an array of query strings in the format described Input Format The first line of input contains two space-separated integers, $n$ and $\textit{q}$, the length of the binary representations of $a$ and $\boldsymbol{b}$, and the number of commands, respectively. The second and third lines each contain a string representation of $a$ and $\boldsymbol{b}$. The following $\textit{q}$ lines each contain a command string $\textit{queries}[i]$ as described above. Constraints $1\leq n\leq1000000$ $1\leq q\leq5000000$ Output Format For each query of the type $\text{get_c}$, output a single digit 0 or 1. Output must be placed on a single line. Sample Input 0 5 5 00000 11111 set_a 0 1 get_c 5 get_c 1 set_b 2 0 get_c 5 Sample Output 0 100 Explanation 0 set_a 0 1 sets 00000 to 00001 C = A + B = 00001 + 11111 = 100000, so get_c[5] = 1 from the above computation get_c[1] = 0 set_b 2 0 sets 11111 to 11011 C = A + B = 00001 + 11011 = 011100, so get_c[5] = 0 The output is hence concatenation of 1, 0 and 0 = 100
n, q = list(map(int, input().split())) a = int(input(), 2) b = int(input(), 2) output = "" for i in range(q): cmd = input().split() idx = int(cmd[1]) mask = 1 << idx if "set" in cmd[0]: val = int(cmd[2]) if "_a" in cmd[0]: a &= ~mask if val == 1: a |= mask elif "_b" in cmd[0]: b &= ~mask if val == 1: b |= mask else: c = a + b if c < 1 << idx: output += "0" elif c & mask: output += "1" else: output += "0" print(output)
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR IF STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF STRING VAR NUMBER VAR VAR IF VAR NUMBER VAR VAR IF STRING VAR NUMBER VAR VAR IF VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR BIN_OP NUMBER VAR VAR STRING IF BIN_OP VAR VAR VAR STRING VAR STRING EXPR FUNC_CALL VAR VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
for _ in range(int(input())): x, y = [int(i) for i in input().split()] if x % 2 == 0: b = 2 ^ y c = b ^ x elif y % 2 == 0: b = 2 ^ x c = b ^ y else: b = 2 ^ x c = 2 ^ y print(" ".join(["2", str(min(b, c)), str(max(b, c))]))
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL STRING LIST STRING FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
tests = int(input()) for i in range(tests): x, y = map(int, input().split()) a = 2 c = x ^ y ^ 2 if x & 1 and y & 1: b = 2 ^ x c = 2 ^ y elif x & 1: b = 2 ^ x else: b = 2 ^ y total = a + b + c minimum = min(a, b, c) maximum = max(a, b, c) print(minimum, total - minimum - maximum, maximum)
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 NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP NUMBER VAR IF BIN_OP VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
for _ in range(int(input())): x, y = map(int, input().split()) z = x ^ y arr = [] if x % 2 == 0: arr = [2, y ^ 2, z ^ 2] elif y % 2 == 0: arr = [x ^ 2, 2, z ^ 2] elif z % 2 == 0: arr = [x ^ 2, y ^ 2, 2] arr.sort() for i in arr: print(i, end=" ") print()
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 BIN_OP VAR VAR ASSIGN VAR LIST IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR LIST BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
t = int(input()) for _ in range(t): x, y = map(int, input().split()) z = x ^ y a = 2 if x % 2 != 0: b = x ^ 2 if y % 2 != 0: c = y ^ 2 else: c = y ^ b elif y % 2 != 0: b = y ^ 2 c = x ^ b else: b = z ^ 2 c = x ^ b ans = [a, b, c] ans.sort() for v in ans: print(v, end=" ") print()
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 BIN_OP VAR VAR ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
for h in range(int(input())): x, y = map(int, input().split(" ")) a = 2 arr = [x, y] ar = [2] if 2 ^ (2 ^ x) in arr and (2 ^ x) % 2: b = 2 ^ x ar.append(b) if (a ^ (a ^ y) == y or b ^ (a ^ y) == y) and (a ^ y) % 2: ar.append(a ^ y) if (a ^ (b ^ y) == y or b ^ (b ^ y) == y) and (b ^ y) % 2: ar.append(b ^ y) elif 2 ^ (2 ^ y) in arr and (2 ^ y) % 2: b = 2 ^ y ar.append(b) if (a ^ (a ^ x) == x or b ^ (a ^ x) == x) and (a ^ x) % 2: ar.append(a ^ x) if (a ^ (b ^ x) == x or b ^ (b ^ x) == x) and (b ^ x) % 2: ar.append(b ^ x) ar.sort() print(*ar)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR LIST VAR VAR ASSIGN VAR LIST NUMBER IF BIN_OP NUMBER BIN_OP NUMBER VAR VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR IF BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR IF BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR IF BIN_OP NUMBER BIN_OP NUMBER VAR VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR IF BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR IF BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
def isprime(num): n = int(num, 2) tof = True for i in range(2, int(n ** (1 / 2) // 1) + 1): if n % i == 0: tof = False break return tof def bx(a, b): k = "0" n = max(len(a), len(b)) a = a.zfill(n) b = b.zfill(n) for i in range(n): k += str((int(a[i]) + int(b[i])) % 2) return k t = int(input()) for i in range(t): x, y = input().split(" ") x = int(x) y = int(y) if x % 2 == 0 and y % 2 == 1: x = bin(x)[2:] y = bin(y)[2:] c = "10" b = bx(y, c) a = bx(x, b) a = int(a, 2) b = int(b, 2) c = int(c, 2) arr = [a, b, c] arr.sort() for z in arr: print(z, end=" ") elif x % 2 == 1 and y % 2 == 1: x = bin(x)[2:] y = bin(y)[2:] b = "10" c = bx(y, b) a = bx(x, b) a = int(a, 2) b = int(b, 2) c = int(c, 2) arr = [a, b, c] arr.sort() for z in arr: print(z, end=" ") elif x % 2 == 1 and y % 2 == 0: x = bin(x)[2:] y = bin(y)[2:] a = "10" b = bx(x, a) c = bx(y, b) a = int(a, 2) b = int(b, 2) c = int(c, 2) arr = [a, b, c] arr.sort() for z in arr: print(z, end=" ") print()
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP NUMBER NUMBER NUMBER NUMBER IF BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
T = int(input()) vector = lambda x, t: [t(num) for num in x.split()] for _ in range(T): x, y = vector(input(), int) z = x ^ y if x & 1 and y & 1: b = 2 a = 2 ^ x c = z ^ a ans = sorted([a, b, c]) print(*ans) elif y & 1 and z & 1: c = 2 a = z ^ c b = y ^ c ans = sorted([a, b, c]) print(*ans) elif x & 1 and z & 1: a = 2 c = z ^ a b = y ^ c ans = sorted([a, b, c]) print(*ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
t = int(input()) while t: x, y = map(int, input().split()) z = x ^ y l = [2, 2, 2] if x & 1: l[0] = x ^ 2 if y & 1: l[1] = y ^ 2 if z & 1: l[2] = z ^ 2 l.sort() for i in l: print(i, end=" ") print() t = t - 1
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
tc = int(input().strip()) for t in range(tc): x, y = map(int, input().split()) z = x ^ y abc = [2] if x % 2 == 1: abc.append(x ^ 2) if y % 2 == 1: abc.append(y ^ 2) if z % 2 == 1: abc.append(z ^ 2) abc.sort() print(*abc)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR LIST NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
def solution(): x, y = list(map(int, input().split())) z = x ^ y ans = [2, 2, 2] if x & 1: ans[0] = x ^ 2 if y & 1: ans[1] = y ^ 2 if z & 1: ans[2] = z ^ 2 ans.sort() print(ans[0], ans[1], ans[2]) n = int(input()) for i in range(n): solution()
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
for _ in range(int(input())): x, y = map(int, input().split()) a = 2 if x % 2 == 0: print(*sorted([2, y ^ 2, x ^ y ^ 2])) elif y % 2 == 0: print(*sorted([2, x ^ 2, y ^ x ^ 2])) else: print(*sorted([2, x ^ 2, y ^ 2]))
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 BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR LIST NUMBER BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR LIST NUMBER BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR LIST NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
for _ in range(int(input())): x, y = map(int, input().split()) z = x ^ y l = [x, y, z] a = [] for i in range(3): if l[i] & 1 == 1: a.append(l[i] ^ 2) print("2", str(min(a)), str(max(a)))
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 BIN_OP VAR VAR ASSIGN VAR LIST VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR STRING FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
t = int(input()) for i in range(t): xy = list(map(int, input().split())) x = xy[0] y = xy[1] if x % 2 == 0 and y % 2 == 1: c = 2 b = y ^ 2 a = x ^ b print(c, min(b, a), max(b, a)) elif x % 2 == 1 and y % 2 == 0: a = 2 b = x ^ 2 c = y ^ b print(a, min(b, c), max(b, c)) else: b = 2 a = x ^ 2 c = y ^ 2 print(b, min(c, a), max(c, a))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
t = int(input()) for _ in range(t): x, y = [int(x) for x in input().split()] res = [2] * 3 z = x ^ y if x & 1: res[0] = x ^ 2 if y & 1: res[1] = y ^ 2 if z & 1: res[2] = z ^ 2 res.sort() for val in res: print(val, end=" ") print()
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
for _ in range(int(input())): x, y = map(int, input().split()) if x % 2 == 1 and y % 2 == 1: a = x ^ 2 b = 2 c = y ^ 2 elif y % 2 == 1: a = x ^ y ^ 2 b = y ^ 2 c = 2 else: a = 2 b = x ^ 2 c = x ^ y ^ 2 l = sorted([a, b, c]) print(*l)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
T = int(input()) for tc in range(T): x, y = map(int, input().split(" ")) z = x ^ y prime = [2] for alphabet in [z, x, y]: if alphabet % 2 == 1: if alphabet % 4 == 1: prime.append(alphabet + 2) else: prime.append(alphabet - 2) prime.sort() print(*prime)
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 STRING ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR LIST NUMBER FOR VAR LIST VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
for _ in range(int(input())): x, y = map(int, input().split()) z = x ^ y if x % 2 == 0: c = 2 b = y ^ c a = z ^ c elif y % 2 == 0: a = 2 c = z ^ a b = x ^ a elif z % 2 == 0: b = 2 c = y ^ b a = x ^ b print(*sorted([a, b, c]))
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 BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR LIST VAR VAR VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
for _ in range(int(input())): x, y = map(int, input().split()) z = x ^ y start = [x, y, z] if x % 2 == 0: c = 2 b = y ^ 2 a = z ^ 2 elif y % 2 == 0: a = 2 b = x ^ 2 c = z ^ 2 elif z % 2 == 0: b = 2 a = x ^ 2 c = y ^ 2 ans = [a, b, c] ans = sorted(ans) print(" ".join([str(i) for i in ans]))
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 BIN_OP VAR VAR ASSIGN VAR LIST VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
for _ in range(int(input())): x, y = map(int, input().split(" ")) ans = [] if x % 2 != 0 and y % 2 != 0: b = 2 c = y ^ b a = x ^ b ans.append(a) ans.append(b) ans.append(c) elif x % 2 == 0 and y % 2 != 0: c = 2 b = y ^ c a = x ^ b ans.append(a) ans.append(b) ans.append(c) elif x % 2 == 0 and y % 2 == 0: b = 2 c = y ^ b a = x ^ b ans.append(a) ans.append(b) ans.append(c) else: a = 2 b = x ^ a c = y ^ b ans.append(a) ans.append(b) ans.append(c) ans.sort() print(" ".join(str(x) for x in ans))
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
for _ in range(int(input())): x, y = map(int, input().split()) z = x ^ y if x % 2 == 1 and y % 2 == 1: b = 2 a = x ^ b c = y ^ b elif x % 2 == 1 and z % 2 == 1: a = 2 b = x ^ a c = z ^ a elif y % 2 == 1 and z % 2 == 1: c = 2 b = y ^ c a = x ^ b ans = sorted([a, b, c]) print(*ans)
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 BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
for _ in range(int(input())): lst = [2] x, y = map(int, input().split()) if x % 2 != 0: ans = 2 ^ x lst.append(ans) if y % 2 != 0: ans = 2 ^ y lst.append(ans) if x % 2 == 0: ans = lst[-1] ^ x lst.append(ans) if y % 2 == 0: ans = lst[-1] ^ y lst.append(ans) lst.sort() print(*lst)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
def fill(): bit = [] for i in range(30): bit.append(0) return bit def gen(num, bit, n=1): bit[30 - n] = num % 2 num = num // 2 if num == 0: return bit else: n += 1 return gen(num, bit, n) def xor(bit_m, bit_n): bit_p = fill() p = 0 for i in range(30): if not bit_m[i] == bit_n[i]: bit_p[i] = 1 p += 2 ** (29 - i) return p def asc(b, c): if b > c: print("2 " + str(c) + " " + str(b)) else: print("2 " + str(b) + " " + str(c)) a = 2 bit_a = gen(a, fill()) t = int(input()) for i in range(t): m = input() m = m.split(" ") x = int(m[0]) bit_x = gen(x, fill()) y = int(m[1]) bit_y = gen(y, fill()) if x % 2 == 1 and y % 2 == 0: b = xor(bit_x, bit_a) bit_b = gen(b, fill()) c = xor(bit_y, bit_b) elif x % 2 == 0 and y % 2 == 1: b = xor(bit_y, bit_a) bit_b = gen(b, fill()) c = xor(bit_x, bit_b) else: b = xor(bit_y, bit_a) c = xor(bit_x, bit_a) asc(b, c)
FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN VAR FUNC_DEF NUMBER ASSIGN VAR BIN_OP NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER RETURN VAR VAR NUMBER RETURN FUNC_CALL VAR VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR VAR NUMBER VAR BIN_OP NUMBER BIN_OP NUMBER VAR RETURN VAR FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP STRING FUNC_CALL VAR VAR STRING FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP STRING FUNC_CALL VAR VAR STRING FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
for i in range(int(input())): x, y = map(int, input().split()) x1 = list(bin(x).replace("0b", "")) y1 = list(bin(y).replace("0b", "")) if x == 1: x1 = ["0"] + x1 if y == 1: y1 = ["0"] + y1 if x % 2 == 1: if x1[len(x1) - 2] == "0": x1[len(x1) - 2] = "1" else: x1[len(x1) - 2] = "0" x1 = "".join(x1) x1 = int(x1, 2) if y % 2 == 1: if y1[len(y1) - 2] == "0": y1[len(y1) - 2] = "1" else: y1[len(y1) - 2] = "0" y1 = "".join(y1) y1 = int(y1, 2) if x % 2 == 0: x1 = y1 ^ x if y % 2 == 0: y1 = x1 ^ y k = sorted([2, x1, y1]) print(k[0], k[1], k[2], sep=" ")
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 FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR VAR STRING STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR VAR STRING STRING IF VAR NUMBER ASSIGN VAR BIN_OP LIST STRING VAR IF VAR NUMBER ASSIGN VAR BIN_OP LIST STRING VAR IF BIN_OP VAR NUMBER NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER STRING ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER STRING ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR LIST NUMBER VAR VAR EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER STRING
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
ri = lambda: int(input()) rl = lambda: list(map(int, input().split())) rs = lambda: input() def solve(): x, y = rl() z = x ^ y ans = [2] if x % 2 == 0: ans.append(y ^ 2) ans.append(z ^ 2) elif y % 2 == 0: ans.append(x ^ 2) ans.append(z ^ 2) elif z % 2 == 0: ans.append(x ^ 2) ans.append(y ^ 2) ans.sort() return ans def main(): for _ in range(ri()): print(*solve()) main()
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR LIST NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR RETURN VAR FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
for case in range(int(input())): X, Y = map(int, input().split()) if X % 2 and Y % 2: li = [2, X ^ 2, Y ^ 2] elif X % 2: li = [2, X ^ 2, Y ^ X ^ 2] else: li = [2, Y ^ 2, X ^ Y ^ 2] li.sort() print(*li)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR LIST NUMBER BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR LIST NUMBER BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
for _ in range(int(input())): X, Y = [int(x) for x in input().split()] ans = [2] for x in [X, Y, X ^ Y]: if (2 ^ x) % 2: ans.append(2 ^ x) print(*sorted(ans[:3]))
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR LIST VAR VAR BIN_OP VAR VAR IF BIN_OP BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
for i in range(int(input())): x, y = map(int, input().split()) x1, y1 = x, y if x % 2 == 1: x1 = x1 ^ 2 if y % 2 == 1: y1 = y1 ^ 2 if x % 2 == 0: x1 = y1 ^ x if y % 2 == 0: y1 = x1 ^ y k = sorted([2, x1, y1]) print(k[0], k[1], k[2], sep=" ")
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR LIST NUMBER VAR VAR EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER STRING
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
def solution(): x, y = map(int, input().split()) z = x ^ y ans = [2, 2, 2] if x & 1: ans[0] = x ^ 2 if y & 1: ans[1] = y ^ 2 if z & 1: ans[2] = z ^ 2 ans.sort() return ans t = int(input()) for test in range(t): print(" ".join(str(char) for char in solution()))
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR FUNC_CALL VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
t = int(input()) for tc in range(t): x, y = map(int, input().split()) z = x ^ y l = [] if x % 2 != 0 and y % 2 == 0: l.append(x ^ 2) l.append(2) l.append(z ^ 2) if x % 2 == 0 and y % 2 != 0: l.append(y ^ 2) l.append(2) l.append(z ^ 2) if x % 2 != 0 and y % 2 != 0: l.append(x ^ 2) l.append(y ^ 2) l.append(2) l.sort() for i in l: print(i, end=" ") print()
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 BIN_OP VAR VAR ASSIGN VAR LIST IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
def solve(): X, Y = map(int, input().split()) Z = X ^ Y ans = [2, 2, 2] if X & 1: ans[0] = X ^ 2 if Y & 1: ans[1] = Y ^ 2 if Z & 1: ans[2] = Z ^ 2 ans.sort() print(ans[0], end=" ") print(ans[1], end=" ") print(ans[2]) t = int(input()) while t > 0: solve() t = t - 1
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR NUMBER STRING EXPR FUNC_CALL VAR VAR NUMBER STRING EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
l = -1 m = -1 n = l + m for i in range(int(input())): a1, b1 = [int(x) for x in input().split()] if a1 % 2 == 0: b = 2 ^ b1 c = b ^ a1 elif b1 % 2 == 0: b = 2 ^ a1 c = b ^ b1 else: b = 2 ^ a1 c = 2 ^ b1 print("%d %d %d" % (2, min(b, c), max(b, c)))
ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP STRING NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
n = int(input()) for i in range(n): x, y = map(int, input().split()) l = [2] if x & 1 and y & 1: l.append(x ^ 2) l.append(y ^ 2) elif x & 1: l.append(x ^ 2) l.append(l[-1] ^ y) else: l.append(y ^ 2) l.append(l[-1] ^ x) l.sort() print(*l)
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 LIST NUMBER IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
for _ in range(int(input())): x, y = map(int, input().split()) z = x ^ y a = [] a.append(2) if x & 1 != 0: a.append(2 ^ x) if y & 1 != 0: a.append(2 ^ y) else: a.append(2 ^ z) else: a.append(2 ^ y) a.append(2 ^ z) a.sort() print(*a)
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 BIN_OP VAR VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
i = int(input()) listk = [] for _ in range(i): kk2 = input().split() kk = [] tot = [] for ele in kk2: kk.append(int(ele)) if (kk[0] ^ kk[1]) % 2 == 1: tot.append(2) k0 = "" if kk[0] % 2 == 1: tot.append(kk[0] ^ 2) tot.append(kk[0] ^ 2 ^ kk[1]) if kk[0] % 2 == 0: tot.append(kk[1] ^ 2) tot.append(kk[0] ^ 2 ^ kk[1]) if (kk[0] ^ kk[1]) % 2 == 0: tot.append(2) tot.append(2 ^ kk[0]) tot.append(2 ^ kk[1]) tot.sort() ans = "" for ele in tot: if ele == tot[-1]: ans = ans + str(ele) else: ans = ans + str(ele) + " " listk.append(ans) for ele in listk: print(ele)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR STRING IF BIN_OP VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR STRING FOR VAR VAR IF VAR VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
def solve(): x, y = map(int, input().split()) res = [2] if x & 1 and y & 1: res.append(2 ^ x) res.append(2 ^ y) elif x & 1: res.append(2 ^ x) res.append(res[-1] ^ y) else: res.append(2 ^ y) res.append(res[-1] ^ x) print(" ".join(map(str, sorted(res)))) for _ in range(int(input())): solve()
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP NUMBER VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
I = lambda: input() IN = lambda: int(input()) M = lambda: map(int, input().strip().split()) L = lambda: list(map(int, input().strip().split())) LCHR = lambda: [i for i in input()] LW = lambda: [i for i in input().split()] for _ in range(IN()): x, y = M() l = [2] if x % 2 == 1 and y % 2 == 1: l.extend([x ^ 2, y ^ 2]) if x % 2 == 1 and y % 2 == 0: l.extend([x ^ 2, y ^ (x ^ 2)]) if x % 2 == 0 and y % 2 == 1: l.extend([x ^ (y ^ 2), y ^ 2]) print(*sorted(l))
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR LIST BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR LIST BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR LIST BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
testcases = int(input()) for eachcase in range(testcases): x, y = map(int, input().split()) z = x ^ y arr = [2, 2, 2] if x & 1: arr[0] = x ^ 2 if y & 1: arr[1] = y ^ 2 if z & 1: arr[2] = z ^ 2 arr.sort() print(*arr)
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 BIN_OP VAR VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
for _ in range(int(input())): X, Y = map(int, input().split()) Z = X ^ Y A = 2 if X % 2 != 0: B = 2 ^ X if Y % 2 != 0: C = 2 ^ Y else: C = 2 ^ Z else: B = 2 ^ Y C = 2 ^ Z print(" ".join(map(str, sorted([A, B, C]))))
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 BIN_OP VAR VAR ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR FUNC_CALL VAR LIST VAR VAR VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
n = int(input()) for i in range(n): x, y = map(int, input().split()) z = x ^ y q = [x, y, z] for i in range(3): if q[i] % 2 == 0: q[i] = 2 else: q[i] ^= 2 print(*sorted(q))
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 BIN_OP VAR VAR ASSIGN VAR LIST VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
def function(X, Y): Z = X ^ Y if X % 2 == 0: C = 2 B = Y ^ C A = X ^ B arr = sorted([A, B, C]) return " ".join(str(i) for i in arr) elif Y % 2 == 0: A = 2 B = X ^ A C = Z ^ A arr = sorted([A, B, C]) return " ".join(str(i) for i in arr) else: B = 2 A = X ^ B C = Y ^ B arr = sorted([A, B, C]) return " ".join(str(i) for i in arr) def main(): T = int(input()) for _ in range(T): X, Y = list(map(int, input().split(" "))) val = function(X, Y) print(val) main()
FUNC_DEF ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR LIST VAR VAR VAR RETURN FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR LIST VAR VAR VAR RETURN FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR LIST VAR VAR VAR RETURN FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
for _ in range(int(input())): x, y = map(int, input().split()) z = x ^ y ans = [2] for n in (x, y, z): if n % 2: ans.append(n ^ 2) print(*sorted(ans))
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 BIN_OP VAR VAR ASSIGN VAR LIST NUMBER FOR VAR VAR VAR VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
t = int(input()) for x in range(t): x, y = map(int, input().split()) z = x ^ y a = [2] if x % 2 == 0: a.append(a[0] ^ y) a.append(a[0] ^ z) elif y % 2 == 0: a.append(a[0] ^ z) a.append(a[0] ^ x) elif z % 2 == 0: a.append(a[0] ^ y) a.append(a[0] ^ x) a = sorted(a) print(str(a[0]) + " " + str(a[1]) + " " + str(a[2]))
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 BIN_OP VAR VAR ASSIGN VAR LIST NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER STRING FUNC_CALL VAR VAR NUMBER STRING FUNC_CALL VAR VAR NUMBER
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
t = int(input()) for _ in range(t): x, y = map(int, input().split()) z = x ^ y lst = [2] if x % 2 == 1: a = 2 b = x ^ 2 lst.append(b) if y % 2 == 1: b = 2 c = y ^ 2 lst.append(c) if z % 2 == 1: c = 2 a = z ^ 2 lst.append(a) lst.sort() print(*lst)
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 BIN_OP VAR VAR ASSIGN VAR LIST NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
t = int(input()) for i in range(t): l = input().split() x = int(l[0]) y = int(l[1]) z = x ^ y a = [2, 2, 2] if x % 2 != 0: a[0] = x ^ 2 if y % 2 == 1: a[1] = y ^ 2 if z % 2 == 1: a[2] = z ^ 2 a.sort() for j in range(3): print(a[j], end=" ") print()
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR VAR STRING EXPR FUNC_CALL VAR
For 3 distinct prime integers A, B, and C (1 < A,B,C < 2^{30}), we define positive integers X, Y, and Z as: X = A\oplus B, Y = B\oplus C, and Z = C\oplus A, where \oplus denotes the [bitwise XOR] operation. Given only two integers X and Y and the fact that at least one integer amongst X, Y, and Z is odd, find the values of A, B, and C. Note: You need to print the integers A, B, and C in ascending order. It is guaranteed in the input that a unique answer exists. ------ Input Format ------ - The first line contains one integer T β€” the number of test cases. Then T test cases follow. - Each test case consists of one line which contains 2 integers X and Y. ------ Output Format ------ - For each test case, print 3 integers β€” A , B, and C in ascending order where (1 < A,B,C < 2^{30}). ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $1 ≀ X, Y< 2^{30}$ ----- Sample Input 1 ------ 2 1 6 9 15 ----- Sample Output 1 ------ 2 3 5 2 11 13 ----- explanation 1 ------ Test Case $1$: The answer is $A=2, B=3, C=5$. Thus, $X=2\oplus 3 = 1, Y = 3\oplus 5 = 6, Z = 2\oplus 5 = 7$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Z$ are odd. Test Case $2$: The answer is $A=11, B=2, C=13$. Thus, $X=11\oplus 2 = 9, Y = 2\oplus 13 = 15, Z = 11\oplus 13 = 6$. Note that $X$ and $Y$ are same as mentioned in input and the values $X$ as well as $Y$ are odd. Thus, the values of $A, B,$ and $C$ in ascending order are $2, 11,$ and $13$.
for i in range(int(input())): x, y = [int(x) for x in input().split()] ans = [] if x % 2 == 1: ans.append(x ^ 2) if y % 2 == 1: ans.append(y ^ 2) else: ans.append(y ^ ans[0]) else: ans.append(y ^ 2) ans.append(ans[0] ^ x) ans.append(2) ans.sort() print(*ans)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. In Chefland, there are $N$ cities (numbered $1$ through $N$). Initially, there are no roads between them. The Mayor of Chefland has ordered engineers to build roads across Chefland in such a way that each city is reachable from all other cities. For each pair of distinct cities $i$ and $j$, the cost of building a road between these cities is equal to ($i \wedge j$), where $\wedge$ denotes the bitwise AND operation. However, leaders of the cities have a weird condition ― they only allow roads with positive costs to be built from their cities. Help the Mayor find the minimum cost of building roads in the required way or determine that it is impossible. ------ Input ------ The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows. The first and only line of each test case contains a single integer $N$. ------ Output ------ For each test case, print a single line containing one integer ― the minimum cost of building the roads or $-1$ if it is impossible. ------ Constraints ------ $1 ≀ T ≀ 2 \cdot 10^{5}$ $2 ≀ N ≀ 10^{9}$ ----- Sample Input 1 ------ 2 3 5 ----- Sample Output 1 ------ 3 8 ----- explanation 1 ------ Example case 1: We can connect city $1$ with city $3$ by a road with cost $1$ and city $3$ with city $2$ by a road with cost $2$.
l1 = int(input()) for _ in range(l1): n = int(input()) sumi = 0 if n & n - 1 == 0: print(-1) else: sumi += (n - 1) // 2 i = 2 while i <= n: temp = n // i temp2 = temp + 1 temp3 = temp2 // 2 sumi += i * temp3 i *= 2 print(sumi)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. In Chefland, there are $N$ cities (numbered $1$ through $N$). Initially, there are no roads between them. The Mayor of Chefland has ordered engineers to build roads across Chefland in such a way that each city is reachable from all other cities. For each pair of distinct cities $i$ and $j$, the cost of building a road between these cities is equal to ($i \wedge j$), where $\wedge$ denotes the bitwise AND operation. However, leaders of the cities have a weird condition ― they only allow roads with positive costs to be built from their cities. Help the Mayor find the minimum cost of building roads in the required way or determine that it is impossible. ------ Input ------ The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows. The first and only line of each test case contains a single integer $N$. ------ Output ------ For each test case, print a single line containing one integer ― the minimum cost of building the roads or $-1$ if it is impossible. ------ Constraints ------ $1 ≀ T ≀ 2 \cdot 10^{5}$ $2 ≀ N ≀ 10^{9}$ ----- Sample Input 1 ------ 2 3 5 ----- Sample Output 1 ------ 3 8 ----- explanation 1 ------ Example case 1: We can connect city $1$ with city $3$ by a road with cost $1$ and city $3$ with city $2$ by a road with cost $2$.
pow2 = [1] for i in range(1, 31): pow2.append((pow2[-1] << 1) + 1) pow21 = [1] for i in range(1, 32): pow21.append(pow21[-1] << 1) def cost(n): if n == 0: return 0 idx = 0 for i in range(31): if pow2[i] > n: idx = i - 1 break tmp = pow2[idx] ans = int((tmp + 1) // 2) * (idx + 1) if n > tmp: ans += tmp + 1 ansnew = 0 if n > tmp: ansnew = cost(n - tmp - 1) return ans + ansnew for i in range(int(input())): n = int(input()) if n in pow21: print(-1) else: idx = 0 for i in range(31): if pow2[i] > n: idx = i - 1 break tmp = pow2[idx] if n == tmp + 1: print(cost(n)) else: print(cost(n) - 1)
ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER RETURN BIN_OP VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. In Chefland, there are $N$ cities (numbered $1$ through $N$). Initially, there are no roads between them. The Mayor of Chefland has ordered engineers to build roads across Chefland in such a way that each city is reachable from all other cities. For each pair of distinct cities $i$ and $j$, the cost of building a road between these cities is equal to ($i \wedge j$), where $\wedge$ denotes the bitwise AND operation. However, leaders of the cities have a weird condition ― they only allow roads with positive costs to be built from their cities. Help the Mayor find the minimum cost of building roads in the required way or determine that it is impossible. ------ Input ------ The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows. The first and only line of each test case contains a single integer $N$. ------ Output ------ For each test case, print a single line containing one integer ― the minimum cost of building the roads or $-1$ if it is impossible. ------ Constraints ------ $1 ≀ T ≀ 2 \cdot 10^{5}$ $2 ≀ N ≀ 10^{9}$ ----- Sample Input 1 ------ 2 3 5 ----- Sample Output 1 ------ 3 8 ----- explanation 1 ------ Example case 1: We can connect city $1$ with city $3$ by a road with cost $1$ and city $3$ with city $2$ by a road with cost $2$.
def isPowerOfTwo(x): return x and not x & x - 1 def dp(n): if isPowerOfTwo(n): return -1 b = bin(n)[2:] c = 0 for i in range(1, len(b)): mul = int(b[:i], 2) + 1 if b[i] == "0": mul -= 1 c += mul * pow(2, len(b) - 1 - i) c += pow(2, len(b) - 1) return c - 1 t = int(input()) for _ in range(t): n = int(input()) print(dp(n))
FUNC_DEF RETURN VAR BIN_OP VAR BIN_OP VAR NUMBER FUNC_DEF IF FUNC_CALL VAR VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER IF VAR VAR STRING VAR NUMBER VAR BIN_OP VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER RETURN BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. In Chefland, there are $N$ cities (numbered $1$ through $N$). Initially, there are no roads between them. The Mayor of Chefland has ordered engineers to build roads across Chefland in such a way that each city is reachable from all other cities. For each pair of distinct cities $i$ and $j$, the cost of building a road between these cities is equal to ($i \wedge j$), where $\wedge$ denotes the bitwise AND operation. However, leaders of the cities have a weird condition ― they only allow roads with positive costs to be built from their cities. Help the Mayor find the minimum cost of building roads in the required way or determine that it is impossible. ------ Input ------ The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows. The first and only line of each test case contains a single integer $N$. ------ Output ------ For each test case, print a single line containing one integer ― the minimum cost of building the roads or $-1$ if it is impossible. ------ Constraints ------ $1 ≀ T ≀ 2 \cdot 10^{5}$ $2 ≀ N ≀ 10^{9}$ ----- Sample Input 1 ------ 2 3 5 ----- Sample Output 1 ------ 3 8 ----- explanation 1 ------ Example case 1: We can connect city $1$ with city $3$ by a road with cost $1$ and city $3$ with city $2$ by a road with cost $2$.
case = int(input()) for r in range(case): n = int(input()) if n == 2: print(-1) continue if n & n - 1 == 0: print(-1) continue summ = n - 1 - n // 2 pw = 1 while pow(2, pw) <= n: pw += 1 for i in range(1, pw): nu = pow(2, i) summ += ((n - nu) // (2 * nu) + 1) * nu print(summ)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE FUNC_CALL VAR NUMBER VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP NUMBER VAR NUMBER VAR EXPR FUNC_CALL VAR VAR
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. In Chefland, there are $N$ cities (numbered $1$ through $N$). Initially, there are no roads between them. The Mayor of Chefland has ordered engineers to build roads across Chefland in such a way that each city is reachable from all other cities. For each pair of distinct cities $i$ and $j$, the cost of building a road between these cities is equal to ($i \wedge j$), where $\wedge$ denotes the bitwise AND operation. However, leaders of the cities have a weird condition ― they only allow roads with positive costs to be built from their cities. Help the Mayor find the minimum cost of building roads in the required way or determine that it is impossible. ------ Input ------ The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows. The first and only line of each test case contains a single integer $N$. ------ Output ------ For each test case, print a single line containing one integer ― the minimum cost of building the roads or $-1$ if it is impossible. ------ Constraints ------ $1 ≀ T ≀ 2 \cdot 10^{5}$ $2 ≀ N ≀ 10^{9}$ ----- Sample Input 1 ------ 2 3 5 ----- Sample Output 1 ------ 3 8 ----- explanation 1 ------ Example case 1: We can connect city $1$ with city $3$ by a road with cost $1$ and city $3$ with city $2$ by a road with cost $2$.
import sys from sys import stdin, stdout for _ in range(int(stdin.readline())): n = int(stdin.readline()) if n == 2: print(-1) continue if n == 3: print(3) continue if n % 2 == 0: x = n // 2 else: x = n // 2 + 1 ans = x - 1 bn = bin(n) if bn.count("1") == 1: print(-1) continue p = 2 while p <= n: q = n // p if q % 2 == 0: l = q // 2 else: l = q // 2 + 1 ans += l * p p *= 2 print(ans)
IMPORT FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. In Chefland, there are $N$ cities (numbered $1$ through $N$). Initially, there are no roads between them. The Mayor of Chefland has ordered engineers to build roads across Chefland in such a way that each city is reachable from all other cities. For each pair of distinct cities $i$ and $j$, the cost of building a road between these cities is equal to ($i \wedge j$), where $\wedge$ denotes the bitwise AND operation. However, leaders of the cities have a weird condition ― they only allow roads with positive costs to be built from their cities. Help the Mayor find the minimum cost of building roads in the required way or determine that it is impossible. ------ Input ------ The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows. The first and only line of each test case contains a single integer $N$. ------ Output ------ For each test case, print a single line containing one integer ― the minimum cost of building the roads or $-1$ if it is impossible. ------ Constraints ------ $1 ≀ T ≀ 2 \cdot 10^{5}$ $2 ≀ N ≀ 10^{9}$ ----- Sample Input 1 ------ 2 3 5 ----- Sample Output 1 ------ 3 8 ----- explanation 1 ------ Example case 1: We can connect city $1$ with city $3$ by a road with cost $1$ and city $3$ with city $2$ by a road with cost $2$.
T = int(input()) for i in range(T): n = int(input()) ans = -1 curr = 1 while True: if curr == n: ans = -1 break elif curr > n: break ans += curr * ((n + curr) // (2 * curr)) curr *= 2 print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF VAR VAR ASSIGN VAR NUMBER IF VAR VAR VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. In Chefland, there are $N$ cities (numbered $1$ through $N$). Initially, there are no roads between them. The Mayor of Chefland has ordered engineers to build roads across Chefland in such a way that each city is reachable from all other cities. For each pair of distinct cities $i$ and $j$, the cost of building a road between these cities is equal to ($i \wedge j$), where $\wedge$ denotes the bitwise AND operation. However, leaders of the cities have a weird condition ― they only allow roads with positive costs to be built from their cities. Help the Mayor find the minimum cost of building roads in the required way or determine that it is impossible. ------ Input ------ The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows. The first and only line of each test case contains a single integer $N$. ------ Output ------ For each test case, print a single line containing one integer ― the minimum cost of building the roads or $-1$ if it is impossible. ------ Constraints ------ $1 ≀ T ≀ 2 \cdot 10^{5}$ $2 ≀ N ≀ 10^{9}$ ----- Sample Input 1 ------ 2 3 5 ----- Sample Output 1 ------ 3 8 ----- explanation 1 ------ Example case 1: We can connect city $1$ with city $3$ by a road with cost $1$ and city $3$ with city $2$ by a road with cost $2$.
for _ in range(int(input())): n = int(input()) answer = 0 if n % 2 == 0: answer += n // 2 - 1 else: answer += n // 2 x = 2 while 1: if x == n: answer = -1 break else: q = n // x if q == 0: break if q % 2 == 0: answer += x * (q // 2) else: answer += x * (q // 2 + 1) x = x * 2 print(answer)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. In Chefland, there are $N$ cities (numbered $1$ through $N$). Initially, there are no roads between them. The Mayor of Chefland has ordered engineers to build roads across Chefland in such a way that each city is reachable from all other cities. For each pair of distinct cities $i$ and $j$, the cost of building a road between these cities is equal to ($i \wedge j$), where $\wedge$ denotes the bitwise AND operation. However, leaders of the cities have a weird condition ― they only allow roads with positive costs to be built from their cities. Help the Mayor find the minimum cost of building roads in the required way or determine that it is impossible. ------ Input ------ The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows. The first and only line of each test case contains a single integer $N$. ------ Output ------ For each test case, print a single line containing one integer ― the minimum cost of building the roads or $-1$ if it is impossible. ------ Constraints ------ $1 ≀ T ≀ 2 \cdot 10^{5}$ $2 ≀ N ≀ 10^{9}$ ----- Sample Input 1 ------ 2 3 5 ----- Sample Output 1 ------ 3 8 ----- explanation 1 ------ Example case 1: We can connect city $1$ with city $3$ by a road with cost $1$ and city $3$ with city $2$ by a road with cost $2$.
def sol(n): i = 1 ans = 0 while i <= n: ans += (n - i) // (i << 1) * i i <<= 1 i = 2 while i < n: ans += i i <<= 1 return ans t = int(input()) for i in range(t): n = int(input()) if n & n - 1 == 0: print(-1) else: print(sol(n))
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. In Chefland, there are $N$ cities (numbered $1$ through $N$). Initially, there are no roads between them. The Mayor of Chefland has ordered engineers to build roads across Chefland in such a way that each city is reachable from all other cities. For each pair of distinct cities $i$ and $j$, the cost of building a road between these cities is equal to ($i \wedge j$), where $\wedge$ denotes the bitwise AND operation. However, leaders of the cities have a weird condition ― they only allow roads with positive costs to be built from their cities. Help the Mayor find the minimum cost of building roads in the required way or determine that it is impossible. ------ Input ------ The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows. The first and only line of each test case contains a single integer $N$. ------ Output ------ For each test case, print a single line containing one integer ― the minimum cost of building the roads or $-1$ if it is impossible. ------ Constraints ------ $1 ≀ T ≀ 2 \cdot 10^{5}$ $2 ≀ N ≀ 10^{9}$ ----- Sample Input 1 ------ 2 3 5 ----- Sample Output 1 ------ 3 8 ----- explanation 1 ------ Example case 1: We can connect city $1$ with city $3$ by a road with cost $1$ and city $3$ with city $2$ by a road with cost $2$.
for t in range(int(input())): n = int(input()) b_n = bin(n)[2:] if b_n.count("1") == 1: print(-1) continue a = n // 2 - (n % 2 == 0) q = 2 while q <= n: x = n // q - n // (2 * q) a += q * x q = q * 2 print(a)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR BIN_OP NUMBER VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. In Chefland, there are $N$ cities (numbered $1$ through $N$). Initially, there are no roads between them. The Mayor of Chefland has ordered engineers to build roads across Chefland in such a way that each city is reachable from all other cities. For each pair of distinct cities $i$ and $j$, the cost of building a road between these cities is equal to ($i \wedge j$), where $\wedge$ denotes the bitwise AND operation. However, leaders of the cities have a weird condition ― they only allow roads with positive costs to be built from their cities. Help the Mayor find the minimum cost of building roads in the required way or determine that it is impossible. ------ Input ------ The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows. The first and only line of each test case contains a single integer $N$. ------ Output ------ For each test case, print a single line containing one integer ― the minimum cost of building the roads or $-1$ if it is impossible. ------ Constraints ------ $1 ≀ T ≀ 2 \cdot 10^{5}$ $2 ≀ N ≀ 10^{9}$ ----- Sample Input 1 ------ 2 3 5 ----- Sample Output 1 ------ 3 8 ----- explanation 1 ------ Example case 1: We can connect city $1$ with city $3$ by a road with cost $1$ and city $3$ with city $2$ by a road with cost $2$.
def main(): T = int(input()) for _ in range(T): N = int(input()) if N & N - 1 == 0: print(-1) else: counter = (N + 1) // 2 - 1 nextCost = 2 while nextCost < N: counter += (N - nextCost) // (2 * nextCost) * nextCost + nextCost nextCost <<= 1 print(counter) main()
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP NUMBER VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. In Chefland, there are $N$ cities (numbered $1$ through $N$). Initially, there are no roads between them. The Mayor of Chefland has ordered engineers to build roads across Chefland in such a way that each city is reachable from all other cities. For each pair of distinct cities $i$ and $j$, the cost of building a road between these cities is equal to ($i \wedge j$), where $\wedge$ denotes the bitwise AND operation. However, leaders of the cities have a weird condition ― they only allow roads with positive costs to be built from their cities. Help the Mayor find the minimum cost of building roads in the required way or determine that it is impossible. ------ Input ------ The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows. The first and only line of each test case contains a single integer $N$. ------ Output ------ For each test case, print a single line containing one integer ― the minimum cost of building the roads or $-1$ if it is impossible. ------ Constraints ------ $1 ≀ T ≀ 2 \cdot 10^{5}$ $2 ≀ N ≀ 10^{9}$ ----- Sample Input 1 ------ 2 3 5 ----- Sample Output 1 ------ 3 8 ----- explanation 1 ------ Example case 1: We can connect city $1$ with city $3$ by a road with cost $1$ and city $3$ with city $2$ by a road with cost $2$.
t = int(input()) for xx in range(t): n = int(input()) if n & n - 1 == 0: print(-1) continue res = 0 if n % 2 == 1: res += (n - 1) // 2 n = res else: res += n // 2 - 1 n = n // 2 i = 2 while n != 1: if n % 2 == 1: res += (n + 1) // 2 * i else: res += n // 2 * i n = n // 2 i = i * 2 res += i print(res)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER VAR VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. In Chefland, there are $N$ cities (numbered $1$ through $N$). Initially, there are no roads between them. The Mayor of Chefland has ordered engineers to build roads across Chefland in such a way that each city is reachable from all other cities. For each pair of distinct cities $i$ and $j$, the cost of building a road between these cities is equal to ($i \wedge j$), where $\wedge$ denotes the bitwise AND operation. However, leaders of the cities have a weird condition ― they only allow roads with positive costs to be built from their cities. Help the Mayor find the minimum cost of building roads in the required way or determine that it is impossible. ------ Input ------ The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows. The first and only line of each test case contains a single integer $N$. ------ Output ------ For each test case, print a single line containing one integer ― the minimum cost of building the roads or $-1$ if it is impossible. ------ Constraints ------ $1 ≀ T ≀ 2 \cdot 10^{5}$ $2 ≀ N ≀ 10^{9}$ ----- Sample Input 1 ------ 2 3 5 ----- Sample Output 1 ------ 3 8 ----- explanation 1 ------ Example case 1: We can connect city $1$ with city $3$ by a road with cost $1$ and city $3$ with city $2$ by a road with cost $2$.
for _ in range(int(input())): n = int(input()) l = [] now = 1 while now < n: l.append(now) now = now << 1 l.append(now << 1) if now == n: print(-1) continue ans = 0 for i in range(len(l) - 1): ans += l[i] * ((n - l[i]) // l[i + 1]) ans += l[i] & l[i] + 1 print(ans)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. In Chefland, there are $N$ cities (numbered $1$ through $N$). Initially, there are no roads between them. The Mayor of Chefland has ordered engineers to build roads across Chefland in such a way that each city is reachable from all other cities. For each pair of distinct cities $i$ and $j$, the cost of building a road between these cities is equal to ($i \wedge j$), where $\wedge$ denotes the bitwise AND operation. However, leaders of the cities have a weird condition ― they only allow roads with positive costs to be built from their cities. Help the Mayor find the minimum cost of building roads in the required way or determine that it is impossible. ------ Input ------ The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows. The first and only line of each test case contains a single integer $N$. ------ Output ------ For each test case, print a single line containing one integer ― the minimum cost of building the roads or $-1$ if it is impossible. ------ Constraints ------ $1 ≀ T ≀ 2 \cdot 10^{5}$ $2 ≀ N ≀ 10^{9}$ ----- Sample Input 1 ------ 2 3 5 ----- Sample Output 1 ------ 3 8 ----- explanation 1 ------ Example case 1: We can connect city $1$ with city $3$ by a road with cost $1$ and city $3$ with city $2$ by a road with cost $2$.
ipnl = lambda n: [int(input()) for _ in range(n)] inp = lambda: int(input()) ip = lambda: [int(w) for w in input().split()] for _ in range(inp()): n = inp() if n and not n & n - 1: print(-1) continue cost = -1 i = 0 while n: ct = (n - 1) // 2 + 1 cost += ct * pow(2, i) n //= 2 i += 1 print(cost)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR BIN_OP VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER VAR BIN_OP VAR FUNC_CALL VAR NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. In Chefland, there are $N$ cities (numbered $1$ through $N$). Initially, there are no roads between them. The Mayor of Chefland has ordered engineers to build roads across Chefland in such a way that each city is reachable from all other cities. For each pair of distinct cities $i$ and $j$, the cost of building a road between these cities is equal to ($i \wedge j$), where $\wedge$ denotes the bitwise AND operation. However, leaders of the cities have a weird condition ― they only allow roads with positive costs to be built from their cities. Help the Mayor find the minimum cost of building roads in the required way or determine that it is impossible. ------ Input ------ The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows. The first and only line of each test case contains a single integer $N$. ------ Output ------ For each test case, print a single line containing one integer ― the minimum cost of building the roads or $-1$ if it is impossible. ------ Constraints ------ $1 ≀ T ≀ 2 \cdot 10^{5}$ $2 ≀ N ≀ 10^{9}$ ----- Sample Input 1 ------ 2 3 5 ----- Sample Output 1 ------ 3 8 ----- explanation 1 ------ Example case 1: We can connect city $1$ with city $3$ by a road with cost $1$ and city $3$ with city $2$ by a road with cost $2$.
li = [pow(2, x) for x in range(32)] T = int(input()) for i in range(T): n = int(input()) x = 30 val = 0 flag = 1 prev = n // li[x + 1] while x > 0: if li[x] == n: print(-1) flag = 0 break now = n // li[x] val = val + li[x] * (now - prev) prev = now x -= 1 if n % 2 == 0: val = val + n // 2 - 1 else: val = val + n // 2 if flag != 0: print(val)
ASSIGN VAR FUNC_CALL VAR NUMBER VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR BIN_OP VAR NUMBER WHILE VAR NUMBER IF VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. In Chefland, there are $N$ cities (numbered $1$ through $N$). Initially, there are no roads between them. The Mayor of Chefland has ordered engineers to build roads across Chefland in such a way that each city is reachable from all other cities. For each pair of distinct cities $i$ and $j$, the cost of building a road between these cities is equal to ($i \wedge j$), where $\wedge$ denotes the bitwise AND operation. However, leaders of the cities have a weird condition ― they only allow roads with positive costs to be built from their cities. Help the Mayor find the minimum cost of building roads in the required way or determine that it is impossible. ------ Input ------ The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows. The first and only line of each test case contains a single integer $N$. ------ Output ------ For each test case, print a single line containing one integer ― the minimum cost of building the roads or $-1$ if it is impossible. ------ Constraints ------ $1 ≀ T ≀ 2 \cdot 10^{5}$ $2 ≀ N ≀ 10^{9}$ ----- Sample Input 1 ------ 2 3 5 ----- Sample Output 1 ------ 3 8 ----- explanation 1 ------ Example case 1: We can connect city $1$ with city $3$ by a road with cost $1$ and city $3$ with city $2$ by a road with cost $2$.
t = int(input()) while t: t = t - 1 n = int(input()) pw = 1 ans = 0 if n & n - 1 == 0: print(-1) continue while pw <= n: ans = ans + (int(n / pw) - int(n / (2 * pw))) * pw pw = pw * 2 print(ans - 1)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER VAR VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. In Chefland, there are $N$ cities (numbered $1$ through $N$). Initially, there are no roads between them. The Mayor of Chefland has ordered engineers to build roads across Chefland in such a way that each city is reachable from all other cities. For each pair of distinct cities $i$ and $j$, the cost of building a road between these cities is equal to ($i \wedge j$), where $\wedge$ denotes the bitwise AND operation. However, leaders of the cities have a weird condition ― they only allow roads with positive costs to be built from their cities. Help the Mayor find the minimum cost of building roads in the required way or determine that it is impossible. ------ Input ------ The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows. The first and only line of each test case contains a single integer $N$. ------ Output ------ For each test case, print a single line containing one integer ― the minimum cost of building the roads or $-1$ if it is impossible. ------ Constraints ------ $1 ≀ T ≀ 2 \cdot 10^{5}$ $2 ≀ N ≀ 10^{9}$ ----- Sample Input 1 ------ 2 3 5 ----- Sample Output 1 ------ 3 8 ----- explanation 1 ------ Example case 1: We can connect city $1$ with city $3$ by a road with cost $1$ and city $3$ with city $2$ by a road with cost $2$.
t = int(input()) answer = "" for _ in range(t): n = int(input()) if not n & n - 1: answer += "-1\n" continue oddNumCnt = (n + 1) // 2 cost = oddNumCnt - 1 currCost = 2 while currCost < n: cost += (n - currCost) // (2 * currCost) * currCost + currCost currCost <<= 1 answer += str(cost) + "\n" print(answer)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR BIN_OP VAR NUMBER VAR STRING ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP NUMBER VAR VAR VAR VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR VAR
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. In Chefland, there are $N$ cities (numbered $1$ through $N$). Initially, there are no roads between them. The Mayor of Chefland has ordered engineers to build roads across Chefland in such a way that each city is reachable from all other cities. For each pair of distinct cities $i$ and $j$, the cost of building a road between these cities is equal to ($i \wedge j$), where $\wedge$ denotes the bitwise AND operation. However, leaders of the cities have a weird condition ― they only allow roads with positive costs to be built from their cities. Help the Mayor find the minimum cost of building roads in the required way or determine that it is impossible. ------ Input ------ The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows. The first and only line of each test case contains a single integer $N$. ------ Output ------ For each test case, print a single line containing one integer ― the minimum cost of building the roads or $-1$ if it is impossible. ------ Constraints ------ $1 ≀ T ≀ 2 \cdot 10^{5}$ $2 ≀ N ≀ 10^{9}$ ----- Sample Input 1 ------ 2 3 5 ----- Sample Output 1 ------ 3 8 ----- explanation 1 ------ Example case 1: We can connect city $1$ with city $3$ by a road with cost $1$ and city $3$ with city $2$ by a road with cost $2$.
dp = [] x = 2 while x <= 10**9: dp.append(x) x = x << 1 for T in range(int(input())): n = int(input()) if n in dp: print(-1) else: res = 0 for i in range(len(dp)): if dp[i] > n: break num = n // dp[i] if num % 2 == 0: gr = num // 2 else: gr = (num + 1) // 2 res += gr * dp[i] if n % 2 == 0: e = n // 2 - 1 else: e = n // 2 print(res + e)
ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. In Chefland, there are $N$ cities (numbered $1$ through $N$). Initially, there are no roads between them. The Mayor of Chefland has ordered engineers to build roads across Chefland in such a way that each city is reachable from all other cities. For each pair of distinct cities $i$ and $j$, the cost of building a road between these cities is equal to ($i \wedge j$), where $\wedge$ denotes the bitwise AND operation. However, leaders of the cities have a weird condition ― they only allow roads with positive costs to be built from their cities. Help the Mayor find the minimum cost of building roads in the required way or determine that it is impossible. ------ Input ------ The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows. The first and only line of each test case contains a single integer $N$. ------ Output ------ For each test case, print a single line containing one integer ― the minimum cost of building the roads or $-1$ if it is impossible. ------ Constraints ------ $1 ≀ T ≀ 2 \cdot 10^{5}$ $2 ≀ N ≀ 10^{9}$ ----- Sample Input 1 ------ 2 3 5 ----- Sample Output 1 ------ 3 8 ----- explanation 1 ------ Example case 1: We can connect city $1$ with city $3$ by a road with cost $1$ and city $3$ with city $2$ by a road with cost $2$.
for _ in range(int(input())): n = int(input()) x = 1 if n & n - 1 == 0: print(-1) else: tot = 0 while x <= n: m = n // x t = (m + 1) // 2 if x > 1: c = t * x else: c = (t - 1) * x tot += c x <<= 1 print(tot)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. In Chefland, there are $N$ cities (numbered $1$ through $N$). Initially, there are no roads between them. The Mayor of Chefland has ordered engineers to build roads across Chefland in such a way that each city is reachable from all other cities. For each pair of distinct cities $i$ and $j$, the cost of building a road between these cities is equal to ($i \wedge j$), where $\wedge$ denotes the bitwise AND operation. However, leaders of the cities have a weird condition ― they only allow roads with positive costs to be built from their cities. Help the Mayor find the minimum cost of building roads in the required way or determine that it is impossible. ------ Input ------ The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows. The first and only line of each test case contains a single integer $N$. ------ Output ------ For each test case, print a single line containing one integer ― the minimum cost of building the roads or $-1$ if it is impossible. ------ Constraints ------ $1 ≀ T ≀ 2 \cdot 10^{5}$ $2 ≀ N ≀ 10^{9}$ ----- Sample Input 1 ------ 2 3 5 ----- Sample Output 1 ------ 3 8 ----- explanation 1 ------ Example case 1: We can connect city $1$ with city $3$ by a road with cost $1$ and city $3$ with city $2$ by a road with cost $2$.
for _ in range(int(input())): n = int(input()) if not n & n - 1: print(-1) else: count = (n - 1) // 2 i = 1 while True: m = 2**i if m < n: v = (n - m) // (2 * m) + 1 count += v * m i += 1 else: break print(count)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR BIN_OP NUMBER VAR IF VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP NUMBER VAR NUMBER VAR BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. In Chefland, there are $N$ cities (numbered $1$ through $N$). Initially, there are no roads between them. The Mayor of Chefland has ordered engineers to build roads across Chefland in such a way that each city is reachable from all other cities. For each pair of distinct cities $i$ and $j$, the cost of building a road between these cities is equal to ($i \wedge j$), where $\wedge$ denotes the bitwise AND operation. However, leaders of the cities have a weird condition ― they only allow roads with positive costs to be built from their cities. Help the Mayor find the minimum cost of building roads in the required way or determine that it is impossible. ------ Input ------ The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows. The first and only line of each test case contains a single integer $N$. ------ Output ------ For each test case, print a single line containing one integer ― the minimum cost of building the roads or $-1$ if it is impossible. ------ Constraints ------ $1 ≀ T ≀ 2 \cdot 10^{5}$ $2 ≀ N ≀ 10^{9}$ ----- Sample Input 1 ------ 2 3 5 ----- Sample Output 1 ------ 3 8 ----- explanation 1 ------ Example case 1: We can connect city $1$ with city $3$ by a road with cost $1$ and city $3$ with city $2$ by a road with cost $2$.
t = int(input()) arr = [(2**i) for i in range(1, 32)] for _ in range(t): d = int(input()) if d in arr: print(-1) elif d == 3: print(3) else: sum = (d - 1) // 2 i = 2 while i < d: m = d // i sum += (m + 1) // 2 * i i = i * 2 print(sum)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. In Chefland, there are $N$ cities (numbered $1$ through $N$). Initially, there are no roads between them. The Mayor of Chefland has ordered engineers to build roads across Chefland in such a way that each city is reachable from all other cities. For each pair of distinct cities $i$ and $j$, the cost of building a road between these cities is equal to ($i \wedge j$), where $\wedge$ denotes the bitwise AND operation. However, leaders of the cities have a weird condition ― they only allow roads with positive costs to be built from their cities. Help the Mayor find the minimum cost of building roads in the required way or determine that it is impossible. ------ Input ------ The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows. The first and only line of each test case contains a single integer $N$. ------ Output ------ For each test case, print a single line containing one integer ― the minimum cost of building the roads or $-1$ if it is impossible. ------ Constraints ------ $1 ≀ T ≀ 2 \cdot 10^{5}$ $2 ≀ N ≀ 10^{9}$ ----- Sample Input 1 ------ 2 3 5 ----- Sample Output 1 ------ 3 8 ----- explanation 1 ------ Example case 1: We can connect city $1$ with city $3$ by a road with cost $1$ and city $3$ with city $2$ by a road with cost $2$.
from sys import * t = int(stdin.readline()) for _ in range(t): n = int(stdin.readline()) a = bin(n) if a.count("1") == 1: print(-1) continue if n == 2: print(-1) continue if n == 3: print(3) continue if n % 2 == 0: x = n // 2 else: x = n // 2 + 1 count = x - 1 i = 2 while i <= n: l = 0 k = n // i if k % 2 == 0: l = k // 2 else: l = k // 2 + 1 count = count + i * l i = i * 2 print(count)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. In Chefland, there are $N$ cities (numbered $1$ through $N$). Initially, there are no roads between them. The Mayor of Chefland has ordered engineers to build roads across Chefland in such a way that each city is reachable from all other cities. For each pair of distinct cities $i$ and $j$, the cost of building a road between these cities is equal to ($i \wedge j$), where $\wedge$ denotes the bitwise AND operation. However, leaders of the cities have a weird condition ― they only allow roads with positive costs to be built from their cities. Help the Mayor find the minimum cost of building roads in the required way or determine that it is impossible. ------ Input ------ The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows. The first and only line of each test case contains a single integer $N$. ------ Output ------ For each test case, print a single line containing one integer ― the minimum cost of building the roads or $-1$ if it is impossible. ------ Constraints ------ $1 ≀ T ≀ 2 \cdot 10^{5}$ $2 ≀ N ≀ 10^{9}$ ----- Sample Input 1 ------ 2 3 5 ----- Sample Output 1 ------ 3 8 ----- explanation 1 ------ Example case 1: We can connect city $1$ with city $3$ by a road with cost $1$ and city $3$ with city $2$ by a road with cost $2$.
L = [(1 << i) for i in range(31)] for _ in range(int(input())): n = int(input()) t = n c = 0 while t: c += 1 t = t & t - 1 if c > 1: break if c == 1: print(-1) continue res, t, k = 0, 0, 0 while L[t] < n: t += 1 for l in range(t - 1, -1, -1): res += L[l] * (int(n / L[l]) - k) k = int(n / L[l]) print(res - 1)
ASSIGN VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER WHILE VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER VAR BIN_OP VAR VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. In Chefland, there are $N$ cities (numbered $1$ through $N$). Initially, there are no roads between them. The Mayor of Chefland has ordered engineers to build roads across Chefland in such a way that each city is reachable from all other cities. For each pair of distinct cities $i$ and $j$, the cost of building a road between these cities is equal to ($i \wedge j$), where $\wedge$ denotes the bitwise AND operation. However, leaders of the cities have a weird condition ― they only allow roads with positive costs to be built from their cities. Help the Mayor find the minimum cost of building roads in the required way or determine that it is impossible. ------ Input ------ The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows. The first and only line of each test case contains a single integer $N$. ------ Output ------ For each test case, print a single line containing one integer ― the minimum cost of building the roads or $-1$ if it is impossible. ------ Constraints ------ $1 ≀ T ≀ 2 \cdot 10^{5}$ $2 ≀ N ≀ 10^{9}$ ----- Sample Input 1 ------ 2 3 5 ----- Sample Output 1 ------ 3 8 ----- explanation 1 ------ Example case 1: We can connect city $1$ with city $3$ by a road with cost $1$ and city $3$ with city $2$ by a road with cost $2$.
import sys input = sys.stdin.readline for _ in range(int(input())): n = int(input()) if not n & n - 1: print(-1) continue count = (n - 1) // 2 i = 2 while i < n: count += ((n - i) // (2 * i) + 1) * i i <<= 1 print(count)
IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP NUMBER VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. In Chefland, there are $N$ cities (numbered $1$ through $N$). Initially, there are no roads between them. The Mayor of Chefland has ordered engineers to build roads across Chefland in such a way that each city is reachable from all other cities. For each pair of distinct cities $i$ and $j$, the cost of building a road between these cities is equal to ($i \wedge j$), where $\wedge$ denotes the bitwise AND operation. However, leaders of the cities have a weird condition ― they only allow roads with positive costs to be built from their cities. Help the Mayor find the minimum cost of building roads in the required way or determine that it is impossible. ------ Input ------ The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows. The first and only line of each test case contains a single integer $N$. ------ Output ------ For each test case, print a single line containing one integer ― the minimum cost of building the roads or $-1$ if it is impossible. ------ Constraints ------ $1 ≀ T ≀ 2 \cdot 10^{5}$ $2 ≀ N ≀ 10^{9}$ ----- Sample Input 1 ------ 2 3 5 ----- Sample Output 1 ------ 3 8 ----- explanation 1 ------ Example case 1: We can connect city $1$ with city $3$ by a road with cost $1$ and city $3$ with city $2$ by a road with cost $2$.
l = [(2**x) for x in range(32)] t = int(input()) for i in range(t): n = int(input()) x = 30 v = 0 f = 1 while x > 0: if l[x] == n: print(-1) f = 0 break v += l[x] * (n // l[x] - n // l[x + 1]) x -= 1 if n % 2 == 0: v += n // 2 - 1 else: v += n // 2 if f != 0: print(v)
ASSIGN VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. In Chefland, there are $N$ cities (numbered $1$ through $N$). Initially, there are no roads between them. The Mayor of Chefland has ordered engineers to build roads across Chefland in such a way that each city is reachable from all other cities. For each pair of distinct cities $i$ and $j$, the cost of building a road between these cities is equal to ($i \wedge j$), where $\wedge$ denotes the bitwise AND operation. However, leaders of the cities have a weird condition ― they only allow roads with positive costs to be built from their cities. Help the Mayor find the minimum cost of building roads in the required way or determine that it is impossible. ------ Input ------ The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows. The first and only line of each test case contains a single integer $N$. ------ Output ------ For each test case, print a single line containing one integer ― the minimum cost of building the roads or $-1$ if it is impossible. ------ Constraints ------ $1 ≀ T ≀ 2 \cdot 10^{5}$ $2 ≀ N ≀ 10^{9}$ ----- Sample Input 1 ------ 2 3 5 ----- Sample Output 1 ------ 3 8 ----- explanation 1 ------ Example case 1: We can connect city $1$ with city $3$ by a road with cost $1$ and city $3$ with city $2$ by a road with cost $2$.
def roads(n): res = 0 if n % 2 == 1: res += n // 2 else: res += n // 2 - 1 i = 2 while n > 0: n //= 2 if n % 2 == 0: res += i * (n // 2) else: res += i * (n // 2 + 1) i <<= 1 return res t = int(input()) while t > 0: n = int(input()) k, c = n, 0 while k > 0: if k & 1 == 1: c += 1 k = k >> 1 if c == 1: print(-1) else: print(roads(n)) t -= 1
FUNC_DEF ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. In Chefland, there are $N$ cities (numbered $1$ through $N$). Initially, there are no roads between them. The Mayor of Chefland has ordered engineers to build roads across Chefland in such a way that each city is reachable from all other cities. For each pair of distinct cities $i$ and $j$, the cost of building a road between these cities is equal to ($i \wedge j$), where $\wedge$ denotes the bitwise AND operation. However, leaders of the cities have a weird condition ― they only allow roads with positive costs to be built from their cities. Help the Mayor find the minimum cost of building roads in the required way or determine that it is impossible. ------ Input ------ The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows. The first and only line of each test case contains a single integer $N$. ------ Output ------ For each test case, print a single line containing one integer ― the minimum cost of building the roads or $-1$ if it is impossible. ------ Constraints ------ $1 ≀ T ≀ 2 \cdot 10^{5}$ $2 ≀ N ≀ 10^{9}$ ----- Sample Input 1 ------ 2 3 5 ----- Sample Output 1 ------ 3 8 ----- explanation 1 ------ Example case 1: We can connect city $1$ with city $3$ by a road with cost $1$ and city $3$ with city $2$ by a road with cost $2$.
power = [] val = 1 while val < 1000000000: power.append(val) val *= 2 power.append(val) t = int(input()) for T in range(t): n = int(input()) bn = bin(n)[2:] if bn.count("1") == 1: print(-1) continue ans = 0 for i in range(len(power)): if power[i] > n: break ans += power[i] * ((n + power[i]) // (2 * power[i])) print(ans - 1)
ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER
Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well. In Chefland, there are $N$ cities (numbered $1$ through $N$). Initially, there are no roads between them. The Mayor of Chefland has ordered engineers to build roads across Chefland in such a way that each city is reachable from all other cities. For each pair of distinct cities $i$ and $j$, the cost of building a road between these cities is equal to ($i \wedge j$), where $\wedge$ denotes the bitwise AND operation. However, leaders of the cities have a weird condition ― they only allow roads with positive costs to be built from their cities. Help the Mayor find the minimum cost of building roads in the required way or determine that it is impossible. ------ Input ------ The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows. The first and only line of each test case contains a single integer $N$. ------ Output ------ For each test case, print a single line containing one integer ― the minimum cost of building the roads or $-1$ if it is impossible. ------ Constraints ------ $1 ≀ T ≀ 2 \cdot 10^{5}$ $2 ≀ N ≀ 10^{9}$ ----- Sample Input 1 ------ 2 3 5 ----- Sample Output 1 ------ 3 8 ----- explanation 1 ------ Example case 1: We can connect city $1$ with city $3$ by a road with cost $1$ and city $3$ with city $2$ by a road with cost $2$.
t = int(input()) ans = [] for ti in range(t): n = int(input()) ansi = 0 lsb = 1 fake_n = n while fake_n % 2 == 0: fake_n //= 2 lsb *= 2 if lsb == n: ans.append(-1) else: fake_n = n msb = 1 while fake_n > 1: msb *= 2 fake_n //= 2 ansi += (n + 1) // 2 - 1 x = 2 while x <= msb: y = (n - x) // (2 * x) + 1 ansi += y * x x *= 2 ans.append(ansi) for ansi in ans: print(ansi)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER VAR NUMBER VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP NUMBER VAR NUMBER VAR BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR
You are given non-negative integers A, B and C. Does there exist a non-negative integer X such that A \oplus X+ B \oplus X = C \oplus X? As a reminder, \oplus denotes the [bitwise XOR operation]. ------ Input Format ------ - The first line of input will contain a single integer T, denoting the number of test cases. - The only line of each test case contains three space-separated non-negative integers A, B and C. ------ Output Format ------ For each test case, print on a new line the answer: YES if valid X exists, and NO otherwise. Each character of the output may be printed in either uppercase or lowercase, i.e, the strings Yes, YES, yes, yEs will all be treated as identical. ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $0 ≀ A, B, C < 2^{27}$ ----- Sample Input 1 ------ 5 2 5 7 2 3 13 7 0 7 2 7 6 1 6 6 ----- Sample Output 1 ------ YES NO YES YES YES ----- explanation 1 ------ Test case $1$: $X=0$ satisfies the equation. Test case $2$: It can be proved that there does not exist a non-negative integer $X$ which satisfies the equation. Test case $3$: $X=0$ satisfies the equation. Test case $4$: $X=3$ satisfies the equation. Test case $5$: $X=1$ satisfies the equation.
def bit_gen(x): l = [(0) for _ in range(27)] for i in range(1, 28): l[-i] = x % 2 x = x // 2 return l for _ in range(int(input())): a, b, c = map(int, input().split()) a, b, c = bin(a)[2:], bin(b)[2:], bin(c)[2:] m = max(len(a), len(b), len(c)) a = "0" * (m - len(a)) + a b = "0" * (m - len(b)) + b c = "0" * (m - len(c)) + c f = 0 ans = True for i in range(1, m + 1): if a[-i] + b[-i] + c[-i] == "001" or a[-i] + b[-i] + c[-i] == "110": f = not f if not f: print("YES") continue print("NO")
FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR STRING BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR STRING ASSIGN VAR VAR IF VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING
You are given non-negative integers A, B and C. Does there exist a non-negative integer X such that A \oplus X+ B \oplus X = C \oplus X? As a reminder, \oplus denotes the [bitwise XOR operation]. ------ Input Format ------ - The first line of input will contain a single integer T, denoting the number of test cases. - The only line of each test case contains three space-separated non-negative integers A, B and C. ------ Output Format ------ For each test case, print on a new line the answer: YES if valid X exists, and NO otherwise. Each character of the output may be printed in either uppercase or lowercase, i.e, the strings Yes, YES, yes, yEs will all be treated as identical. ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $0 ≀ A, B, C < 2^{27}$ ----- Sample Input 1 ------ 5 2 5 7 2 3 13 7 0 7 2 7 6 1 6 6 ----- Sample Output 1 ------ YES NO YES YES YES ----- explanation 1 ------ Test case $1$: $X=0$ satisfies the equation. Test case $2$: It can be proved that there does not exist a non-negative integer $X$ which satisfies the equation. Test case $3$: $X=0$ satisfies the equation. Test case $4$: $X=3$ satisfies the equation. Test case $5$: $X=1$ satisfies the equation.
import sys sys.setrecursionlimit(10**8) for _ in range(int(input())): a, b, c = map(int, input().split()) p = 1 cnt = 0 for i in range(30): if ( a & p == 0 and b & p == 0 and c & p != 0 or a & p != 0 and b & p != 0 and c & p == 0 ): cnt += 1 p *= 2 if cnt % 2 == 0: print("YES") else: print("NO")
IMPORT EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING
You are given non-negative integers A, B and C. Does there exist a non-negative integer X such that A \oplus X+ B \oplus X = C \oplus X? As a reminder, \oplus denotes the [bitwise XOR operation]. ------ Input Format ------ - The first line of input will contain a single integer T, denoting the number of test cases. - The only line of each test case contains three space-separated non-negative integers A, B and C. ------ Output Format ------ For each test case, print on a new line the answer: YES if valid X exists, and NO otherwise. Each character of the output may be printed in either uppercase or lowercase, i.e, the strings Yes, YES, yes, yEs will all be treated as identical. ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $0 ≀ A, B, C < 2^{27}$ ----- Sample Input 1 ------ 5 2 5 7 2 3 13 7 0 7 2 7 6 1 6 6 ----- Sample Output 1 ------ YES NO YES YES YES ----- explanation 1 ------ Test case $1$: $X=0$ satisfies the equation. Test case $2$: It can be proved that there does not exist a non-negative integer $X$ which satisfies the equation. Test case $3$: $X=0$ satisfies the equation. Test case $4$: $X=3$ satisfies the equation. Test case $5$: $X=1$ satisfies the equation.
for _ in range(int(input())): a, b, c = map(int, input().split()) carry = 0 for i in range(30): x, y, z = a >> i & 1, b >> i & 1, c >> i & 1 carry ^= x == y and y != z print("YES" if not carry else "NO")
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR STRING STRING
You are given non-negative integers A, B and C. Does there exist a non-negative integer X such that A \oplus X+ B \oplus X = C \oplus X? As a reminder, \oplus denotes the [bitwise XOR operation]. ------ Input Format ------ - The first line of input will contain a single integer T, denoting the number of test cases. - The only line of each test case contains three space-separated non-negative integers A, B and C. ------ Output Format ------ For each test case, print on a new line the answer: YES if valid X exists, and NO otherwise. Each character of the output may be printed in either uppercase or lowercase, i.e, the strings Yes, YES, yes, yEs will all be treated as identical. ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $0 ≀ A, B, C < 2^{27}$ ----- Sample Input 1 ------ 5 2 5 7 2 3 13 7 0 7 2 7 6 1 6 6 ----- Sample Output 1 ------ YES NO YES YES YES ----- explanation 1 ------ Test case $1$: $X=0$ satisfies the equation. Test case $2$: It can be proved that there does not exist a non-negative integer $X$ which satisfies the equation. Test case $3$: $X=0$ satisfies the equation. Test case $4$: $X=3$ satisfies the equation. Test case $5$: $X=1$ satisfies the equation.
for _ in range(int(input())): a, b, c = map(int, input().split()) carry = 0 for bits in range(28): x = a >> bits & 1 y = b >> bits & 1 z = c >> bits & 1 if x == y and y != z: carry += 1 if bits > a and bits > b and bits > c: break if carry % 2 == 0: print("YES") else: print("NO")
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER IF VAR VAR VAR VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING
You are given non-negative integers A, B and C. Does there exist a non-negative integer X such that A \oplus X+ B \oplus X = C \oplus X? As a reminder, \oplus denotes the [bitwise XOR operation]. ------ Input Format ------ - The first line of input will contain a single integer T, denoting the number of test cases. - The only line of each test case contains three space-separated non-negative integers A, B and C. ------ Output Format ------ For each test case, print on a new line the answer: YES if valid X exists, and NO otherwise. Each character of the output may be printed in either uppercase or lowercase, i.e, the strings Yes, YES, yes, yEs will all be treated as identical. ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $0 ≀ A, B, C < 2^{27}$ ----- Sample Input 1 ------ 5 2 5 7 2 3 13 7 0 7 2 7 6 1 6 6 ----- Sample Output 1 ------ YES NO YES YES YES ----- explanation 1 ------ Test case $1$: $X=0$ satisfies the equation. Test case $2$: It can be proved that there does not exist a non-negative integer $X$ which satisfies the equation. Test case $3$: $X=0$ satisfies the equation. Test case $4$: $X=3$ satisfies the equation. Test case $5$: $X=1$ satisfies the equation.
from sys import stdin input = stdin.readline MAX = 30 def solve(A, B, C): carry = 0 for bit in range(MAX): a = A >> bit & 1 b = B >> bit & 1 c = C >> bit & 1 if (a, b, c) in [(0, 0, 1), (1, 1, 0)]: carry = 1 - carry if carry == 0: return "YES" else: return "NO" T = int(input().strip()) for problem in range(1, T + 1): A, B, C = [int(x) for x in input().strip().split()] print(solve(A, B, C))
ASSIGN VAR VAR ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER VAR IF VAR NUMBER RETURN STRING RETURN STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR
You are given non-negative integers A, B and C. Does there exist a non-negative integer X such that A \oplus X+ B \oplus X = C \oplus X? As a reminder, \oplus denotes the [bitwise XOR operation]. ------ Input Format ------ - The first line of input will contain a single integer T, denoting the number of test cases. - The only line of each test case contains three space-separated non-negative integers A, B and C. ------ Output Format ------ For each test case, print on a new line the answer: YES if valid X exists, and NO otherwise. Each character of the output may be printed in either uppercase or lowercase, i.e, the strings Yes, YES, yes, yEs will all be treated as identical. ------ Constraints ------ $1 ≀ T ≀ 10^{5}$ $0 ≀ A, B, C < 2^{27}$ ----- Sample Input 1 ------ 5 2 5 7 2 3 13 7 0 7 2 7 6 1 6 6 ----- Sample Output 1 ------ YES NO YES YES YES ----- explanation 1 ------ Test case $1$: $X=0$ satisfies the equation. Test case $2$: It can be proved that there does not exist a non-negative integer $X$ which satisfies the equation. Test case $3$: $X=0$ satisfies the equation. Test case $4$: $X=3$ satisfies the equation. Test case $5$: $X=1$ satisfies the equation.
def bit_gen(x): l = [(0) for _ in range(27)] for i in range(1, 28): l[-i] = x % 2 x = x // 2 return l t = int(input()) for _ in range(t): a, b, c = map(int, input().split()) carry = 0 a_ = bit_gen(a) b_ = bit_gen(b) c_ = bit_gen(c) for i in range(1, 28): if ( a_[-i] == 0 and b_[-i] == 0 and c_[-i] == 1 or a_[-i] == 1 and b_[-i] == 1 and c_[-i] == 0 ): carry = not carry if carry == 1: print("NO") else: print("YES")
FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING