description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
maxm = 0
for i in a:
minn = 2000000000
for j in b:
minn = min(minn, i & j)
maxm = max(maxm, minn)
l = 0
for i in a:
minn = 2000000000
for j in b:
minn = min(minn, i & j | maxm)
l = l | minn
print(l) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = list(map(int, input().split()))
ls_a = list(map(int, input().split()))
ls_b = list(map(int, input().split()))
check = True
curr_or = 0
prev_ls = []
while check:
min_ls = []
for i in ls_a:
mini = None
for j in ls_b:
if mini is None or i & j | curr_or < mini:
mini = i & j | curr_or
min_ls.append(mini)
if curr_or == max(min_ls):
check = False
else:
curr_or = max(min_ls)
print(curr_or) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR NONE FOR VAR VAR IF VAR NONE BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR IF VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | N, M = map(int, input().split())
A = list(map(int, input().split()))
B = set(map(int, input().split()))
def check(ans):
for a in A:
all_c = [(a & b) for b in range(1 << 9) if b in B]
if not any(c | ans == ans for c in all_c):
return False
return True
for ans in range(0, 1 << 9):
if check(ans):
print(ans)
break | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER VAR VAR IF FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR RETURN NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER NUMBER IF FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = input().strip().split()
n, m = int(n), int(m)
a = input().strip().split()
a = [int(x) for x in a]
b = input().strip().split()
b = [int(x) for x in b]
max_val = 1 << 9
true_ans = 1 << 9
for ans in range(max_val):
cnt = 0
for i in a:
for j in b:
if ans | i & j == ans:
cnt += 1
break
if cnt == len(a):
true_ans = ans
break
print(true_ans) | 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 FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR FOR VAR VAR IF BIN_OP VAR BIN_OP VAR VAR VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
b = set(map(int, input().split()))
max_c = 2**9
def checkNum(num, c, bin_c):
if num > c:
return False
bin_num = bin(num)
for i in range(0, len(bin_num) - 2):
if bin_num[len(bin_num) - 1 - i] == "1" and bin_c[len(bin_c) - 1 - i] == "0":
return False
return True
for c in range(0, max_c + 1):
bin_c = bin(c)
good = True
for ai in a:
found = False
for bi in b:
if checkNum(bi & ai, c, bin_c):
found = True
break
if not found:
good = False
break
if good:
print(c)
exit() | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR STRING VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER VAR STRING RETURN NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
arr = [[(0) for i in range(m)] for j in range(n)]
for i in range(n):
for j in range(m):
arr[i][j] = a[i] & b[j]
k = pow(2, 9)
for i in range(k):
t = 0
for j in range(n):
f = 0
for jj in range(m):
if arr[j][jj] | i == i:
f = 1
break
if f == 0:
t = 1
break
if t == 0:
print(i)
break | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | import sys
n, m = map(int, sys.stdin.readline().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [[x for x in b] for _ in range(n)]
sum = 0
for nob in range(9, -1, -1):
count = 0
se = set()
for i in range(n):
bit = a[i] >> nob
if bit & 1 == 0:
count += 1
continue
else:
for j in c[i]:
bit1 = j >> nob
if bit1 & 1 == 0:
se.add(i)
count += 1
break
if count != n:
sum = sum | 1 << nob
else:
for k in se:
c[k] = [x for x in c[k] if not x >> nob & 1 == 1]
print(sum) | IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER FOR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR FOR VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
matrix = []
arr = []
for i in range(n):
lis = []
for j in range(m):
lis.append(a[i] & b[j])
arr.append(min(lis))
matrix.append(lis)
num = max(arr)
ind = arr.index(num)
ans = num
for i in range(n):
if i != ind:
lis = []
for j in range(m):
lis.append(ans | matrix[i][j])
ans = min(lis)
print(ans) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = float("inf")
for i in range(2**9):
t = 1
for j in range(n):
r = 0
for k in range(m):
v = a[j] & b[k]
z = 1
for l in range(9):
if v >> l & 1 == 1 and i >> l & 1 == 0:
z = 0
break
if z == 1:
r = 1
break
if r == 0:
t = 0
break
if t == 1:
c = min(c, i)
print(c) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | from sys import stdin
input = stdin.readline
n, m = map(int, input().split())
n = [*map(int, input().split())]
m = [*map(int, input().split())]
andmap = [[(x & y) for y in m] for x in n]
greator = 0
for num in n:
minor = 1024
for pair in m:
minor = min(minor, num & pair)
greator = max(greator, minor)
new_val = []
for row in andmap:
for col in row:
new_val.append(col | greator)
greator = min(new_val)
new_val = []
print(greator) | ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST FOR VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | def ii():
return int(input())
def si():
return input().rstrip()
def mi():
return map(int, input().split())
def li():
return list(mi())
n, m = mi()
a = li()
b = li()
def fun(x):
for i in range(n):
ok = False
for j in range(m):
x1 = a[i] & b[j]
f = 0
for k in range(mx):
if x1 & 1 << k and x & 1 << k == 0:
f = 1
break
if f == 0:
ok = True
break
if ok == False:
return 0
return 1
mx = len(bin(max(a))[2:])
for i in range(1 << mx):
x = 0
for j in range(mx):
if i & 1 << j:
x |= 1 << j
if fun(x):
print(i)
exit(0) | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR BIN_OP NUMBER VAR BIN_OP VAR BIN_OP NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR BIN_OP NUMBER VAR VAR BIN_OP NUMBER VAR IF FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | na, nb = [int(_) for _ in input().split()]
a = [int(_) for _ in input().split()]
b = [int(_) for _ in input().split()]
ans = 0
for i in range(512):
hflag = True
for j in a:
flag = False
for k in b:
if j & k | i == i:
flag = True
break
hflag = hflag and flag
if hflag:
ans = i
break
print(ans) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR IF VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = list(map(int, input().split(" ")))
a = list(map(int, input().split(" ")))
b = list(map(int, input().split(" ")))
val = 2**9
a_and_b = []
for i in a:
ai = []
for j in b:
ai.append(i & j)
a_and_b.append(ai)
ans = val
for i in range(val):
cnt = 0
for j in a_and_b:
for k in j:
if k | i == i:
cnt += 1
break
else:
break
if cnt == n:
ans = min(ans, i)
print(ans) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR FOR VAR VAR IF BIN_OP VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | def isPossible(ans):
for i in range(n):
done = 0
for j in range(m):
if a[i] & b[j] | ans == ans:
done = 1
break
if not done:
return 0
return 1
n, m = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
fin = 2**9 - 1
for i in range(2**9 - 1, -1, -1):
if isPossible(i):
fin = min(fin, i)
print(fin) | FUNC_DEF FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER NUMBER NUMBER IF FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | def get_ints():
return list(map(int, list(input().split())))
n, m = get_ints()
ns = get_ints()
ms = get_ints()
for ret in range(0, 2**9):
works = True
for i in ns:
found = False
for j in ms:
if i & j | ret == ret:
found = True
break
if not found:
works = False
break
if works:
print(ret)
break | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = map(int, input().split())
a = [int(v) for v in input().split()]
b = [int(v) for v in input().split()]
j = 0
while j < 512:
k = 0
while k < n:
f = 0
for v in range(m):
if a[k] & b[v] | j == j:
f = 1
if f == 0:
j = j + 1
break
else:
k = k + 1
else:
print(j)
break | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = map(int, input().split())
list1 = list(map(int, input().split()))
list2 = list(map(int, input().split()))
ll = []
for i in range(n):
l = []
for j in range(m):
l.append(list1[i] & list2[j])
l.sort()
ll.append(l)
xx = 2**10
for i in range(0, 2**10):
x = i
ff = 0
for j in range(n):
f = 0
for k in range(m):
if x | ll[j][k] == x:
f = 1
break
if f == 0:
ff = 1
break
if ff == 0:
if x < xx:
xx = x
print(xx) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | from sys import stdin, stdout
for _ in range(1):
na, nb = list(map(int, stdin.readline().split()))
a = list(map(int, stdin.readline().split()))
b = list(map(int, stdin.readline().split()))
bits = [[] for i in range(na)]
for i in range(na):
for j in range(nb):
bits[i] += [a[i] & b[j]]
ans = 0
for num in range(1 << 9 + 1):
this = 1
for i in range(na):
flag = 0
for j in range(nb):
if num | bits[i][j] == num:
flag = 1
break
if flag == 0:
this = 0
break
if this:
ans = num
break
print(ans) | FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR LIST BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | def bitwise(n, a1, m, a2):
for i in range(0, 2**9 + 1):
for j in range(n):
c = True
for k in range(m):
if a1[j] & a2[k] | i == i:
break
elif k == m - 1:
c = False
if c == False:
break
if c:
return i
n, m = list(map(int, input().split(" ")))
a1 = list(map(int, input().split(" ")))
a2 = list(map(int, input().split(" ")))
print(bitwise(n, a1, m, a2)) | FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | def go(res):
cur = 0
for i in range(n):
for j in range(m):
f = a[i] & b[j]
if res | f == res:
cur |= f
break
else:
return False
return cur == res
n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for i in range(1 << 9):
if go(i):
exit(print(i)) | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR IF BIN_OP VAR VAR VAR VAR VAR RETURN NUMBER RETURN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER IF FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = map(int, input().split())
arr = list(map(int, input().split()))
brr = list(map(int, input().split()))
st = [set()] * 205
for i in range(n):
st[i] = set(brr)
ans = 0
for bit_pos in range(31, -1, -1):
ans = ans | 1 << bit_pos
flag2 = 1
for i in range(n):
flag = 0
for item in st[i]:
tmp = arr[i] & item
if tmp & 1 << bit_pos == 0:
flag = 1
break
if flag == 0:
flag2 = 0
break
if flag2 == 0:
continue
for i in range(n):
sttmp = set()
for item in st[i]:
tmp = arr[i] & item
if tmp & 1 << bit_pos == 0:
sttmp.add(item)
st[i] = sttmp
ans = ans & ~(1 << bit_pos)
print(ans) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF BIN_OP VAR BIN_OP NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF BIN_OP VAR BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | import sys
input = sys.stdin.readline
inp, ip = lambda: int(input()), lambda: [int(w) for w in input().split()]
n, m = ip()
a = ip()
b = ip()
ans = -1
for k in range(513):
mf = 1
for i in a:
flag = 1
for j in b:
if k & (i & j) == i & j:
flag = 0
break
if flag:
mf = 0
break
if mf:
ans = k
break
print(ans) | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR NUMBER IF VAR ASSIGN VAR NUMBER IF VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
n, m = map(int, input().split())
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))
def check(val):
for a in arr1:
flag = 0
for b in arr2:
flag |= a & b | val == val
if not flag:
return 0
return 1
for ans in range(512):
if check(ans):
print(ans)
break | IMPORT ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF FOR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR IF VAR RETURN NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | def check(s1, s2):
temp = True
for i in range(0, len(s1)):
if s1[i] == "1" and s2[i] == "0":
temp = False
break
return temp
n, m = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
BN = []
for i in range(m):
tt = bin(b[i])[2:]
BN.append(str(tt))
st = ""
for ele in range(0, 9):
flag = "0"
for i in range(0, n):
temp = 0
for j in range(m):
c = a[i] & b[j]
tt = bin(c)[2:]
tt = "0" * (9 - len(tt)) + tt
if check(tt[: len(st)], st) and tt[len(st)] == "0":
temp = 1
break
if temp == 0:
flag = "1"
break
st += flag
fnl = int(st, 2)
print(fnl) | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING ASSIGN VAR NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP NUMBER FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR STRING VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | def answer(n, m, A, B):
maxi = 0
for i in range(n):
mini = 100000
for j in range(m):
mini = min(mini, A[i] & B[j])
maxi = max(maxi, mini)
ans = maxi
d = {maxi: 1}
for i in range(n):
mini = 10000000
for j in range(m):
val = A[i] & B[j]
if ans | val < mini:
mini = ans | val
ans = mini
return ans
n, m = map(int, input().split())
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))
print(answer(n, m, arr1, arr2)) | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR DICT VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | c = 0
n, m = map(int, input().split())
al = list(map(int, input().split()))
bl = list(map(int, input().split()))
al.sort(key=lambda a: min([(a & b) for b in bl]))
al.reverse()
for a in al:
minc = pow(10, 12)
for b in bl:
minc = min(minc, c | a & b)
c = int(minc)
print(c) | ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | input()
A = list(map(int, input().split()))
B = list(map(int, input().split()))
for i in range(513):
for j in A:
f = 0
for k in B:
if j & k | i == i:
f = 1
if f != 1:
break
else:
break
print(i) | EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | def orring(fi1):
a = fi1[0]
for i in fi1:
a = a | i
return a
lis = list(map(int, input().split()))
lis1 = list(map(int, input().split()))
lis2 = list(map(int, input().split()))
fi1 = []
for i in lis1:
f = []
b = 0
for j in lis2:
b = i & j
f.append(b)
fi1.append(min(f))
fmax = max(fi1)
fi1 = []
for i in lis1:
f = []
b = 0
for j in lis2:
b = i & j
f.append(b | fmax)
fi1.append(min(f))
h = orring(fi1)
print(h) | FUNC_DEF ASSIGN VAR VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
available = {}
for x in a:
available[x] = b
for i in reversed(range(0, 10)):
bit = 2**i
can_do = True
for x in a:
if not x & bit:
continue
cur_can_do = False
for y in available[x]:
if not y & bit:
cur_can_do = True
break
if not cur_can_do:
can_do = False
break
if can_do:
for x in a:
if not x & bit:
continue
available[x] = list(filter(lambda y: not y & bit, available[x]))
c = 0
for x in a:
c |= x & list(available[x])[0]
print(c) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR IF BIN_OP VAR VAR ASSIGN VAR NUMBER IF VAR ASSIGN VAR NUMBER IF VAR FOR VAR VAR IF BIN_OP VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR BIN_OP VAR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | import sys
def input():
return sys.stdin.readline().strip()
def list2d(a, b, c):
return [([c] * b) for i in range(a)]
def list3d(a, b, c, d):
return [[([d] * c) for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e):
return [[[([e] * d) for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1):
return int(-(-x // y))
def INT():
return int(input())
def MAP():
return map(int, input().split())
def LIST(N=None):
return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes():
print("Yes")
def No():
print("No")
def YES():
print("YES")
def NO():
print("NO")
INF = 10**19
MOD = 10**9 + 7
N, M = MAP()
A = LIST()
B = LIST()
ans = INF
for bit in range(1 << 9):
good = 1
for a in A:
ok = 0
for b in B:
if bit | a & b == bit:
ok = 1
break
if not ok:
good = 0
break
if good:
ans = min(ans, bit)
print(ans) | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN BIN_OP LIST VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_DEF NUMBER RETURN FUNC_CALL VAR BIN_OP VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF NONE RETURN VAR NONE FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF EXPR FUNC_CALL VAR STRING FUNC_DEF EXPR FUNC_CALL VAR STRING FUNC_DEF EXPR FUNC_CALL VAR STRING FUNC_DEF EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR NUMBER IF VAR ASSIGN VAR NUMBER IF VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | from sys import stdin, stdout
def boboniu_and_bit_operations(n, m, a_a, b_a):
for k in range(513):
cnt = 0
for a in a_a:
for b in b_a:
if a & b | k == k:
cnt += 1
break
if cnt == n:
return k
return -1
n, m = map(int, stdin.readline().split())
a_a = list(map(int, stdin.readline().split()))
b_a = list(map(int, stdin.readline().split()))
stdout.write(str(boboniu_and_bit_operations(n, m, a_a, b_a)) + "\n") | FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FOR VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR VAR NUMBER IF VAR VAR RETURN VAR RETURN NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR STRING |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | def ans(a, b, i, n, m):
if i == n:
return 0
d = ans(a, b, i + 1, n, m)
x = a[i] & b[0] | d
for j in range(1, m):
x = min(x, a[i] & b[j] | d)
return x
n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
k = []
for i in a:
c = []
for j in b:
c.append("{0:09b}".format(i & j))
k.append(c)
c = ""
for i in range(9):
d = 0
for j in k:
for b in j:
if b[i] == "0":
d += 1
break
if d == n:
c += "0"
for j in range(n):
e = []
for b in k[j]:
if b[i] == "0":
e.append(b)
k[j] = e.copy()
else:
c += "1"
print(int(c, 2)) | FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FOR VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
for i in range(len(A)):
s = bin(A[i])[2:]
C = [0] * 9
for j in range(len(s)):
C[-j - 1] = int(s[-j - 1])
A[i] = C
for i in range(len(B)):
s = bin(B[i])[2:]
C = [0] * 9
for j in range(len(s)):
C[-j - 1] = int(s[-j - 1])
B[i] = C
Ans = 0
for i in range(len(A)):
A[i].append(list(B))
for i in range(9):
tr = False
for j in range(len(A)):
if A[j][i] == 1:
tr2 = True
for k in range(len(A[j][-1])):
if A[j][-1][k][i] == 0:
tr2 = False
break
if tr2 == True:
tr = True
break
if not tr:
for j in range(len(A)):
if A[j][i] == 1:
OOO = []
for k in range(len(A[j][-1])):
if A[j][-1][k][i] == 0:
OOO.append(A[j][-1][k])
A[j][-1] = list(OOO)
else:
Ans += 2 ** (8 - i)
print(Ans) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER VAR ASSIGN VAR VAR NUMBER FUNC_CALL VAR VAR VAR BIN_OP NUMBER BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | def check(x):
for i in a:
for j in b:
if i & j | x == x:
break
else:
return 0
return 1
n = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
for ans in range(0, 2**9):
if check(ans):
print(ans)
break | FUNC_DEF FOR VAR VAR FOR VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER NUMBER IF FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | from itertools import product
def main():
n, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
AB = []
for a in A:
q = [(a & b) for b in B]
AB.append(q)
for i in range(n):
AB[i].sort()
G = []
for i in range(9):
t = 2**i
R = [[(b & t == t) for b in ab] for ab in AB]
G.append(R)
ans = 2**10
for P in product(range(2), repeat=9):
check = True
now = 0
for i in range(n):
for j in range(m):
for k in range(9):
if P[k] == 1:
pass
elif G[k][i][j]:
break
else:
now |= AB[i][j]
break
else:
check = False
if check:
if now < ans:
ans = now
print(ans)
main() | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER IF VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR IF VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | import sys
input = sys.stdin.readline
n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
mx = 2**9
dp = [[(0) for i in range(mx)] for i in range(n + 1)]
dp[0][0] = 1
for i in range(n):
for j in range(mx):
if dp[i][j]:
for x in b:
dp[i + 1][j | a[i] & x] = 1
for i in range(mx):
if dp[n][i]:
print(i)
sys.exit(0) | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR FOR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | a, b = input().split()
a = int(a)
b = int(b)
l = [int(x) for x in input().split()]
m = [int(x) for x in input().split()]
hel = []
for i in range(a):
mini = 2**10
for j in range(b):
if l[i] & m[j] < mini:
mini = l[i] & m[j]
hel.append(mini)
oil = []
ore = max(hel)
for i in range(a):
mini = 2**10
for j in range(b):
if l[i] & m[j] | ore < mini:
mini = l[i] & m[j] | ore
alpha = l[i] & m[j]
oil.append(alpha)
sum = 0
for i in range(len(oil)):
sum |= oil[i]
print(sum) | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | from itertools import product
n, m = map(int, input().split())
ln = list(map(int, input().split()))
lm = list(map(int, input().split()))
ls = [[(u & v) for v in lm] for u in ln]
used = [([1] * m) for _ in range(n)]
res = 0
for b in range(8, -1, -1):
zero = 1
for u in range(n):
ok = any(used[u][v] and not ls[u][v] & 1 << b for v in range(m))
if not ok:
zero = 0
break
if zero:
for u, v in product(range(n), range(m)):
if used[u][v] and ls[u][v] & 1 << b:
used[u][v] = 0
res += 0 if zero else 1 << b
print(res) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR VAR IF VAR ASSIGN VAR NUMBER IF VAR FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP NUMBER VAR ASSIGN VAR VAR VAR NUMBER VAR VAR NUMBER BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
save = []
ans = []
for i in range(n):
cur = a[i]
tem = []
for y in range(m):
tt = a[i] & b[y]
cur = min(cur, tt)
tem.append(tt)
if cur == 0:
break
if cur != 0:
ans.append(cur)
save.append(tem)
biggest = 0
for e in ans:
biggest = max(biggest, e)
for i in range(len(save)):
cur = biggest | save[i][0]
for e in save[i]:
cur = min(biggest | e, cur)
biggest = cur
print(biggest) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR NUMBER FOR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = list(map(int, input().split()))
n_list = list(map(int, input().split()))
m_list = list(map(int, input().split()))
and_max = 0
for n_item in n_list:
and_min = n_item & m_list[0]
for m_item in m_list:
and_min = min(and_min, n_item & m_item)
and_max = max(and_max, and_min)
c = and_max
for n_item in n_list:
c_cyc = c | n_item & m_list[0]
for m_item in m_list:
if c | n_item & m_item < c_cyc:
c_cyc = c | n_item & m_item
c = c_cyc
print(c) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FOR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR NUMBER FOR VAR VAR IF BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
for pw in range(9, -1, -1):
x = 2**pw
p = []
for i in range(n):
if a[i] & x > 0:
p.append(a[i])
if len(p) == 0:
continue
for j in range(m):
if b[j] & x != 0:
continue
ok = False
for ai in p:
if (ai & b[j] | ans) - ans > x:
break
else:
break
else:
ans += x
print(ans) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | def get_not_in(local_arr, bit):
wrongs = []
for i in range(len(local_arr)):
if local_arr[i][bit] == "1":
wrongs.append(i)
return wrongs
n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
arr = [[(0) for i in range(m)] for j in range(n)]
for i in range(n):
for j in range(m):
x = bin(a[i] & b[j])[2:]
arr[i][j] = "0" * (10 - len(x)) + x
ans = [0] * 10
for i in range(10):
all_wrongs = []
for j in arr:
wrong_numbs = get_not_in(j, i)
all_wrongs.append(wrong_numbs)
flag = True
pos = 0
for j in all_wrongs:
if len(j) == len(arr[pos]):
ans[i] = 1
flag = False
pos += 1
if flag:
for j in range(len(all_wrongs)):
for k in range(len(all_wrongs[j])):
del arr[j][all_wrongs[j][k] - k]
ans_numb = 0
for i in range(len(ans)):
ans_numb += 2 ** (9 - i) * ans[i]
print(ans_numb) | FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR STRING EXPR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR BIN_OP BIN_OP STRING BIN_OP NUMBER FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER IF VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP NUMBER BIN_OP NUMBER VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | import sys
def rs():
return sys.stdin.readline().rstrip()
def ri():
return int(sys.stdin.readline())
def ria():
return list(map(int, sys.stdin.readline().split()))
def ws(s):
sys.stdout.write(s)
sys.stdout.write("\n")
def wi(n):
sys.stdout.write(str(n))
sys.stdout.write("\n")
def wia(a, sep=" "):
sys.stdout.write(sep.join([str(x) for x in a]))
sys.stdout.write("\n")
def main():
n, m = ria()
a = ria()
b = ria()
t = [([0] * m) for _ in range(n)]
for i in range(n):
for j in range(m):
t[i][j] = a[i] & b[j]
for ans in range(0, 513):
ok = True
for i in range(n):
j_exists = False
for j in range(m):
if t[i][j] | ans == ans:
j_exists = True
break
if not j_exists:
ok = False
break
if ok:
wi(ans)
return
main() | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING FUNC_DEF EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING FUNC_DEF STRING EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR VAR RETURN EXPR FUNC_CALL VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | from itertools import permutations
def mi():
return map(int, input().split())
def ii():
return int(input())
def li():
return list(map(int, input().split()))
def si():
return input().split()
n, m = mi()
a = li()
b = li()
dp = [[] for i in range(n)]
mi = 10**9
mi2 = 0
for i in range(n):
mi = 10**9
for j in range(m):
tmp = a[i] & b[j]
dp[i].append(tmp)
mi = min(tmp, mi)
mi2 = max(mi, mi2)
ans = mi2
for i in range(n):
tmp = ans | dp[i][0]
for j in range(m):
tmp = min(tmp, ans | dp[i][j])
ans = tmp
print(ans) | FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = map(int, input().split())
a = list(map(int, input().split()))
b = sorted(set(map(int, input().split())))
dp = []
ma = 0
r = 0
for i in range(len(a)):
temp = []
val = float("inf")
for j in b:
temp.append(a[i] & j)
val = min(val, a[i] & j)
if val > ma:
ma = val
r = i
dp.append(temp)
dp.pop(r)
for i in dp:
val = float("inf")
for j in i:
val = min(val, j | ma)
ma = val
print(ma) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR STRING FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR STRING FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | def LI():
return [int(i) for i in input().split()]
ans = 0
n, m = LI()
A = LI()
B = LI()
N = 9
dp = set([0])
for i in range(n):
a = A[i]
d = [(a & j) for j in B]
nx = []
for x in dp:
nx += [(j | x) for j in d]
dp = set(nx)
ans = min(dp)
print(ans) | FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR LIST NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR LIST FOR VAR VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = map(int, input().split())
(*a_arr,) = map(int, input().split())
(*b_arr,) = map(int, input().split())
dp = [([0] * (1 << 9)) for _ in range(n + 1)]
dp[0][0] = True
for i in range(n):
for mask in range(1 << 9):
for j in range(m):
if dp[i][mask]:
res_mask = mask | a_arr[i] & b_arr[j]
dp[i + 1][mask | a_arr[i] & b_arr[j]] = True
print(min(mask for mask in range(1 << 9) if dp[n][mask])) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER VAR VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = input().split()
s = list(map(int, input().split()))
l = list(map(int, input().split()))
for i in range(0, 2**9 + 1):
for j in range(len(s)):
c = True
for k in range(len(l)):
if s[j] & l[k] | i == i:
break
elif k == len(l) - 1:
c = False
if c == False:
break
if c:
print(i)
break | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER IF VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | import sys
input = sys.stdin.readline
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
end = False
for i in range(512):
for j in a:
restart = True
for k in b:
if j & k | i == i:
restart = False
break
if restart:
break
if restart:
continue
else:
print(i)
break | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR IF VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
S = dict()
for i, x in enumerate(a):
S[i] = set()
for y in b:
S[i].add(x & y)
for i in range(2**9 + 1):
x = 0
flag = False
for j in range(n):
flag = False
for y in S[j]:
if (x | y) ^ i | i == i:
x = x | y
flag = True
break
if flag:
continue
else:
break
if flag:
print(i)
break | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR IF BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER IF VAR IF VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | def bit_operations(n, m):
for x in range(2**9 + 1):
flag = True
for i in n:
if any(i & j | x == x for j in m):
flag = True
else:
flag = False
break
if flag:
return x
a = input()
lst1 = list(map(int, input().strip().split()))
lst2 = list(map(int, input().strip().split()))
print(bit_operations(lst1, lst2)) | FUNC_DEF FOR VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | def solve():
ans = 0
N, M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
for a in range(1 << 9):
for i in range(N):
for j in range(M):
c = A[i] & B[j]
if c & a == c:
break
else:
break
else:
return a
print(solve()) | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR IF BIN_OP VAR VAR VAR RETURN VAR EXPR FUNC_CALL VAR FUNC_CALL VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for i in range(1 << 9):
for j in a:
for k in b:
if k & j | i == i:
break
else:
break
else:
print(i)
break | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER FOR VAR VAR FOR VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = map(int, input().split(" "))
aa = list(map(int, input().split(" ")))
bb = list(map(int, input().split(" ")))
mbits = 9
absentMask = 0
for bit in reversed(range(mbits)):
mask = absentMask | 1 << bit
good = True
for a in aa:
found = False
for b in bb:
c = a & b
if c & mask == 0:
found = True
break
if not found:
good = False
break
if good:
absentMask = mask
print(2**mbits - 1 - absentMask) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR ASSIGN VAR NUMBER IF VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | import sys
sys.setrecursionlimit(10**5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II():
return int(sys.stdin.readline())
def MI():
return map(int, sys.stdin.readline().split())
def LI():
return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number):
return [LI() for _ in range(rows_number)]
def SI():
return sys.stdin.readline()[:-1]
n, m = MI()
aa = LI()
bb = LI()
atob = [bb[:] for _ in range(n)]
ans = 0
for k in range(8, -1, -1):
nb = [[] for _ in range(n)]
for i, a in enumerate(aa):
ok = True
for b in atob[i]:
if (a & b) >> k & 1 == 0:
nb[i].append(b)
if not nb[i]:
ans |= 1 << k
break
else:
atob = nb
print(ans) | IMPORT EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR IF BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR IF VAR VAR VAR BIN_OP NUMBER VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = map(int, input().split())
x = 0
q = list(map(int, input().split()))
w = list(map(int, input().split()))
s = [[(0) for j in range(m)] for i in range(n)]
for i in range(n):
for j in range(m):
s[i][j] = q[i] & w[j]
t = 2**9
used = [[(0) for j in range(m)] for i in range(n)]
while t > 0:
c = 0
for i in range(n):
p = 1
o = 0
for j in range(m):
if used[i][j] == 0:
p = min(p, s[i][j] // t)
o = 1
if o == 1:
c = max(c, p)
if c == 1:
x += t
else:
for i in range(n):
for j in range(m):
if s[i][j] >= t:
used[i][j] = 1
for i in range(n):
for j in range(m):
s[i][j] %= t
t //= 2
print(x) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR WHILE VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | def ss(a, b):
n = len(a)
m = len(b)
def check(x):
for i in a:
t = 0
for j in b:
if i & j | x == x:
t = 1
break
if t == 0:
return False
return True
for i in range(1025):
if check(i):
return i
return -1
n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
print(ss(a, b)) | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF FOR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER RETURN NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR RETURN VAR RETURN NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
initial_number = 1023
for shift in range(9, -1, -1):
local_number = initial_number ^ 1 << shift
suitable_numbers = 0
for a_i in a:
for b_i in b:
if a_i & b_i <= a_i & b_i & local_number:
suitable_numbers += 1
break
if n == suitable_numbers:
initial_number = local_number
print(initial_number) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER FOR VAR VAR FOR VAR VAR IF BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | import sys
input = sys.stdin.readline
def main():
N, M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
ans = 0
for i in range(513):
f = True
for a in A:
for b in B:
if a & b & i - (a & b) == 0:
break
else:
f = False
if not f:
break
if f:
print(i)
return
main() | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FOR VAR VAR IF BIN_OP BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR IF VAR EXPR FUNC_CALL VAR VAR RETURN EXPR FUNC_CALL VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
def solve(a, b, n, m):
for d in range(2**9):
temp = 2**9 - 1
tfound = True
for i in range(n):
found = False
for j in range(m):
if a[i] & b[j] | d == d:
found = True
break
if not found:
tfound = False
break
if tfound:
return d
return 2**9 - 1
print(solve(a, b, n, m)) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF FOR VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR ASSIGN VAR NUMBER IF VAR RETURN VAR RETURN BIN_OP BIN_OP NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
k = max(a)
c = []
l = []
c2 = 0
for i in range(n):
l1 = []
c1 = k
for j in range(m):
l1.append(a[i] & b[j])
c1 = min(c1, a[i] & b[j])
l.append(l1)
c2 = max(c2, c1)
for i in range(n):
k = c2 | l[i][0]
for j in range(1, m):
k = min(k, c2 | l[i][j])
c2 = k
print(c2) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = map(int, input().split())
a = [*map(int, input().split())]
b = [*map(int, input().split())]
ans = int()
for x in range(pow(2, 9) + 1):
flag = True
for i in a:
flag &= any(i & j | x == x for j in b)
if flag:
print(x)
exit() | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR IF VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | m, n = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.sort()
b.sort(reverse=True)
ans = []
arr = []
for i in range(0, 1000):
temp = 0
for j in range(0, m):
flag = 0
for k in range(0, n):
if a[j] & b[k] | i == i:
flag = 1
break
if flag == 0:
break
else:
temp = temp + 1
if temp == m:
print(i)
break | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | def main():
n, m = map(int, input().split())
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))
dp = [[(False) for j in range(2**9)] for i in range(n + 1)]
dp[0][0] = True
for i in range(n):
for j in range(pow(2, 9)):
if dp[i][j]:
for k in arr2:
dp[i + 1][j | arr1[i] & k] = True
for i in range(2**9):
if dp[n][i]:
print(i)
return
main() | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR VAR FOR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER IF VAR VAR VAR EXPR FUNC_CALL VAR VAR RETURN EXPR FUNC_CALL VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | import sys
LI = lambda: list(map(int, sys.stdin.readline().strip("\n").split()))
MI = lambda: map(int, sys.stdin.readline().strip("\n").split())
SI = lambda: sys.stdin.readline().strip("\n")
II = lambda: int(sys.stdin.readline().strip("\n"))
n, m = MI()
a = LI()
b = LI()
for v in range(2**10):
cnt = 0
for i in range(n):
for j in range(m):
if a[i] & b[j] | v == v:
cnt += 1
break
if cnt == n:
break
print(v) | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
candidates = []
for _ in range(n):
candidates.append(b.copy())
c = 0
for i in range(8, -1, -1):
important = True
for j in range(n):
if a[j] & 1 << i > 0:
if all(map(lambda x: x & 1 << i > 0, candidates[j])):
important = False
if important:
for j in range(n):
if a[j] & 1 << i > 0:
candidates[j] = list(filter(lambda x: x & 1 << i == 0, candidates[j]))
else:
c |= 1 << i
print(c) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR BIN_OP NUMBER VAR NUMBER IF FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER VAR NUMBER VAR VAR ASSIGN VAR NUMBER IF VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR BIN_OP NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER VAR NUMBER VAR VAR VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
track = -1
count = 0
large = 0
for i in a:
c1 = []
for j in b:
c1.append(i & j)
if 0 in c1:
continue
c1.sort()
if c1[0] > large:
large = c1[0]
track = count
c.append(c1)
count += 1
smol = large
for i in range(len(c)):
if i == track:
continue
lis = c[i]
least = -1
for elem in lis:
p = smol | elem
if least == -1:
least = p
elif p < least:
least = p
smol = least
print(smol) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR IF NUMBER VAR EXPR FUNC_CALL VAR IF VAR NUMBER VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | from sys import stdin
def inp():
return stdin.buffer.readline().rstrip().decode("utf8")
def itg():
return int(stdin.buffer.readline())
def mpint():
return map(int, stdin.buffer.readline().split())
def reduce_or(iterable):
result = 0
for item in iterable:
result |= item
return result
def reduce_and(iterable):
result = (1 << 65) - 1
for item in iterable:
result &= item
return result
def get_bit(mask: int, bit_length, index):
return mask >> bit_length - index % bit_length - 1 & 1
MAX = 10
n, m = mpint()
aa = set(mpint())
bb = set(mpint())
data = [set(a & b for b in bb) for a in aa]
ans = bit = 0
while bit <= MAX:
if not any(data):
break
mask = reduce_or([reduce_and(st) for st in data])
while get_bit(mask, MAX, bit):
ans = (ans << 1) + 1
bit += 1
for st in data:
for e in st.copy():
if get_bit(e, MAX, bit):
st.remove(e)
bit += 1
ans <<= 1
print(ans >> 1) | FUNC_DEF RETURN FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR VAR VAR VAR RETURN VAR FUNC_DEF VAR RETURN BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR NUMBER WHILE VAR VAR IF FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR WHILE FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER FOR VAR VAR FOR VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | def calc(i, cur):
if i == n:
return cur
elif dp[i][cur] != -1:
return dp[i][cur]
answer = float("inf")
for num in b:
answer = min(answer, calc(i + 1, cur | a[i] & num))
dp[i][cur] = answer
return dp[i][cur]
lst = input().split(" ")
n, m = int(lst[0]), int(lst[1])
a = [int(num) for num in input().split(" ")]
b = [int(num) for num in input().split(" ")]
dp = [[(-1) for j in range(2**9)] for i in range(n)]
print(calc(0, 0)) | FUNC_DEF IF VAR VAR RETURN VAR IF VAR VAR VAR NUMBER RETURN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR STRING FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR VAR VAR VAR RETURN VAR VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER NUMBER |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | import sys
input = sys.stdin.readline
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
best = 99999999
helpers = []
for i in range(1, 9):
c = 0
for j in range(i, -1, -1):
c += 2**j
helpers.append(c)
helpers = [i for i in range(512)]
for helper in helpers:
c = []
cnt = 0
for i in range(n):
ok = 0
for j in range(m):
x = helper | a[i] & b[j]
if x <= helper:
ok = 1
break
if ok == 1:
cnt += 1
if cnt == len(a):
ans = helper
break
print(ans) | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER FOR VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR VAR VAR IF VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER IF VAR FUNC_CALL VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | a = input().split(" ")
d = input().split(" ")
e = input().split(" ")
ans = 10000000000
p = 0
list1 = []
for i in d:
for j in e:
list1.append(int(i) & int(j))
list1 = list(set(list1))
list1.sort()
for l in list1:
dict = {l: 0}
p = l
for i in range(len(d)):
tag1 = 1000000000
q = 0
for j in e:
tag = int(d[i]) & int(j)
for x in dict:
if tag & x == tag:
q = 1
tag1 = tag
break
if q == 1:
break
else:
tag1 = min(tag, tag1)
p = p | tag1
dict[tag1] = 0
ans = min(p, ans)
print(ans) | ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FOR VAR VAR ASSIGN VAR DICT VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FOR VAR VAR IF BIN_OP VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | def works(ans, a, b):
val = 0
for i in range(len(a)):
flag = 0
for j in range(len(b)):
x = a[i] & b[j]
if x & ~ans == 0:
flag = 1
break
if flag:
val += 1
if val == len(a):
return 1
return 0
n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for i in range(2**9 + 2):
if works(i, a, b):
print(i)
break | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER IF FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | ip = input().split(" ")
n = ip[0]
m = ip[1]
a = [int(i) for i in input().split(" ")]
b = [int(i) for i in input().split(" ")]
c = []
for ai in a:
c.append([])
for bi in b:
c[-1].append(ai & bi)
for i in range(0, len(c)):
for j in range(0, len(c[i])):
num = c[i][j]
c[i][j] = ""
for t in range(0, 9):
c[i][j] += str(num % 2)
num //= 2
c[i][j] = c[i][j][::-1]
o = 0
for i in range(0, 9):
d = []
f = 0
for cc in c:
d.append([])
for e in cc:
if e[i] == "0":
d[-1].append(e)
if len(d[-1]) == 0:
d[-1] = cc
f = 1
o *= 2
o += f
if f == 0:
c = d
print(o) | ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR NUMBER BIN_OP VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR STRING FOR VAR FUNC_CALL VAR NUMBER NUMBER VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR EXPR FUNC_CALL VAR LIST FOR VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR NUMBER VAR IF FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER VAR VAR IF VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | f = input
f()
a = [*map(int, f().split())]
b = [*map(int, f().split())]
for x in range(512):
r = 1
for v in a:
r &= any(v & j | x == x for j in b)
if r:
print(x)
break | ASSIGN VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR IF VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | from itertools import product
n, m = map(int, input().split())
al = list(map(int, input().split()))
bl = list(map(int, input().split()))
abl = []
for a in al:
arow = []
for b in bl:
ab = a & b
arow.append(ab)
abl.append(arow)
ite = list(product(range(2), repeat=9))
for orval, pattern in enumerate(ite):
zeros = []
for i, v in enumerate(pattern):
if v == 0:
zeros.append(9 - i - 1)
cnt = 0
for arow in abl:
for ab in arow:
for zero_i in zeros:
if ab & 1 << zero_i > 0:
break
else:
cnt += 1
break
if cnt == n:
print(orval)
break | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FOR VAR VAR FOR VAR VAR IF BIN_OP VAR BIN_OP NUMBER VAR NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | line = input().split(" ")
n = int(line[0])
m = int(line[1])
arr1 = []
line2 = input().split(" ")
for a in line2:
arr1.append(int(a))
arr2 = []
line3 = input().split(" ")
for a in line3:
arr2.append(int(a))
endpt = 2**9
ans = endpt
for i in range(endpt):
count = 0
for n1 in arr1:
for n2 in arr2:
if n1 & n2 | i == i:
count += 1
break
if count == len(arr1):
ans = i
break
print(ans) | ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR FOR VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR VAR NUMBER IF VAR FUNC_CALL VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | def ispos(num, a, b):
for i in a:
pos = False
for j in b:
val = i & j
if val | num == num:
pos = True
break
if pos == False:
return False
return True
n, m = [int(c) for c in input().split()]
a = [int(c) for c in input().split()]
b = [int(c) for c in input().split()]
c = []
for i in range(513):
if ispos(i, a, b):
print(i)
break | FUNC_DEF FOR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | s = input()
s = input()
s1 = s.split()
a = [int(i) for i in s1]
s = input()
s1 = s.split()
b = [int(i) for i in s1]
for i in range(0, 2**9 + 1):
for j in range(len(a)):
flag = 0
for k in range(len(b)):
if a[j] & b[k] | i == i:
flag = 1
if flag == 0:
break
if flag == 1:
print(i)
break | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | from sys import stdin
la, lb = [int(x) for x in stdin.readline().split()]
arr_a = [int(x) for x in stdin.readline().split()]
arr_b = [int(x) for x in stdin.readline().split()]
arr_a.sort(reverse=True)
def f(a, pn):
if a == la:
return pn
ans = pn | arr_a[a] & arr_b[0]
for bn in arr_b:
temp = pn | arr_a[a] & bn
if temp <= ans:
ans = temp
return f(a + 1, ans)
ans = f(0, 0)
for _ in range(la):
v = arr_a.pop(0)
arr_a.append(v)
t = f(0, 0)
if t < ans:
ans = t
print(ans) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER FUNC_DEF IF VAR VAR RETURN VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR VAR IF VAR VAR ASSIGN VAR VAR RETURN FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
for i in range(0, 2**9 + 1):
ans = i
for j in range(len(a)):
elm = a[j]
for k in range(len(b)):
if elm & b[k] | ans == ans:
break
else:
break
else:
break
print(ans) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
k = {0}
for i in range(len(a)):
t = set()
for j in range(len(b)):
an = a[i] & b[j]
for v in k:
t.add(an | v)
k = t
print(min(k)) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
for_i_use_j = [([1] * m) for _ in range(n)]
result = 0
for k in range(9, -1, -1):
bit = 1 << k
can_be_zero = 1
for i, a in enumerate(A):
can_be_zero_in_a = 1
if a & bit != 0:
flag = 0
for j in range(m):
if for_i_use_j[i][j] == 1 and B[j] & bit == 0:
flag = 1
can_be_zero_in_a = flag
if can_be_zero_in_a == 0:
can_be_zero = 0
if can_be_zero == 1:
for i, a in enumerate(A):
if a & bit != 0:
for j in range(m):
if for_i_use_j[i][j] == 1 and B[j] & bit != 0:
for_i_use_j[i][j] = 0
else:
result += bit
print(result) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER BIN_OP VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER BIN_OP VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | def val(num):
chk = None
for i in a:
chk = False
for j in b:
if i & j | num == num:
chk = True
break
if not chk:
return chk
return chk
n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
checker, OR = False, -1
while not checker and OR < 512:
OR += 1
checker = val(OR)
print(OR) | FUNC_DEF ASSIGN VAR NONE FOR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR RETURN VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER WHILE VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = []
for i in range(n):
c = []
for j in range(m):
c.append(a[i] & b[j])
list(set(c)).sort()
d.append(c)
for i in range(512):
e = []
c = 0
for j in range(n):
for k in range(m):
if d[j][k] | i == i:
e.append(i)
c += 1
break
if c == n and len(set(e)) == 1:
print(e[0])
break | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = map(int, input().split())
nn = list(map(int, input().split()))
mm = list(map(int, input().split()))
l = []
for i in nn:
x = sorted([(j & i) for j in mm])
if 0 not in x:
l.append(x)
ll = [0]
for ii in l:
lll = []
for i in ii:
for j in ll:
lll.append(i | j)
lll = list(set(lll))
ll = lll
print(min(ll)) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR IF NUMBER VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST NUMBER FOR VAR VAR ASSIGN VAR LIST FOR VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | info = list(map(int, input("").split(" ")))
array1 = list(map(int, input("").split(" ")))
array2 = list(map(int, input("").split(" ")))
proc = dict((elem1, [(elem1 & elem2) for elem2 in array2]) for elem1 in array1)
for i in range(0, 2**9):
gflag = True
for j in range(len(array1)):
flag = False
for k in range(len(array2)):
if proc[array1[j]][k] | i == i:
flag = True
break
if flag == False:
gflag = False
break
if gflag == True:
print(i)
break | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = map(int, input().strip().split(" "))
a = list(map(int, input().strip().split(" ")))
b = list(map(int, input().strip().split(" ")))
dp = [[(0) for i in range(len(b))] for j in range(len(a))]
for i in range(len(a)):
for j in range(len(b)):
dp[i][j] = a[i] & b[j]
s = set(dp[0])
for i in range(1, len(a)):
ss = set()
for j in s:
for k in range(len(b)):
ss.add(dp[i][k] | j)
s = ss
print(min(s)) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
arr = []
for i in range(n):
mini = 2000
for j in range(m):
mini = min(mini, a[i] & b[j])
arr.append(mini)
maxi = max(arr)
if maxi == 0:
print(0)
else:
for i in range(n):
if arr[i] != 0 and arr[i] != maxi:
mini = 2000
p = -1
for j in range(m):
k = a[i] & b[j]
if mini > k | maxi:
mini = k | maxi
p = k
arr[i] = p
ans = 0
for i in arr:
ans = ans | i
print(ans) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR IF VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
usable_b = []
for i in range(n):
usable_b.append(range(m))
ans = 0
for d in range(9, -1, -1):
new_usable_b = []
can0 = True
for i in range(n):
usable = []
for j in usable_b[i]:
c = a[i] & b[j]
if c & 1 << d == 0:
usable.append(j)
new_usable_b.append(usable)
if len(usable) == 0:
can0 = False
if can0:
usable_b = new_usable_b
else:
ans |= 1 << d
print(ans) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR IF BIN_OP VAR BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR ASSIGN VAR VAR VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | import sys
input = sys.stdin.readline
n, m = map(int, input().split())
a = [int(item) for item in input().split()]
b = [int(item) for item in input().split()]
for target in range(2**9):
mask = ~target
all_ok = True
for ai in a:
ok = False
for bi in b:
if not ai & bi & mask:
ok = True
break
if not ok:
all_ok = False
break
if all_ok:
print(target)
exit() | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR NUMBER IF VAR ASSIGN VAR NUMBER IF VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | import sys
ii = lambda: sys.stdin.readline().strip()
idata = lambda: [int(x) for x in ii().split()]
def main():
n, m = idata()
a = idata()
b = idata()
q = []
for i in range(n):
w = []
for o in range(m):
w.append(a[i] & b[o])
q.append(w)
q.sort()
q.reverse()
ans = 0
for i in range(n):
ans = min([(ans | q[i][o]) for o in range(m)])
print(ans)
return
main() | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR RETURN EXPR FUNC_CALL VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = map(int, input().split())
ans = 0
arr1 = list(map(int, input().split()))
arr2 = list(map(int, input().split()))
se = set()
i = arr1[0]
for j in arr2:
se.add(i & j)
for i in arr1[1:]:
p = set()
for j in arr2:
p.add(i & j)
m = set()
for k in p:
m |= {(k | j) for j in se}
se = m
print(min(se)) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR FOR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
bl = len(bin(max(a + b))) - 2
ans = 0
gi = 0
for g in range(bl, -1, -1):
gi |= 1 << g
for i in [min([(ai & bj & gi | ans) for bj in b]) for ai in a]:
ans |= i
print(ans) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | from sys import stdin
inp = lambda: stdin.readline().strip()
n, m = [int(x) for x in inp().split()]
a = [int(x) for x in inp().split()]
b = [int(x) for x in inp().split()]
ans = float("inf")
for k in range(len(a)):
currAns = 0
for i in a[k:]:
curr = i & b[0]
for j in b[1:]:
if currAns | curr > currAns | i & j:
curr = i & j
currAns |= curr
for i in a[:k]:
curr = i & b[0]
for j in b[1:]:
if currAns | curr > currAns | i & j:
curr = i & j
currAns |= curr
ans = min(ans, currAns)
print(ans) | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER FOR VAR VAR NUMBER IF BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR FOR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR NUMBER FOR VAR VAR NUMBER IF BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = map(int, input().split())
arr = list(map(int, input().split()))
arr.sort(reverse=True)
brr = list(map(int, input().split()))
ans = 0
temp = 0
for i in range(n):
p = float("inf")
for j in range(m):
p = min(p, arr[i] & brr[j])
if p > temp:
temp = p
ans = i
res = temp
for i in range(n):
if i == ans:
continue
temp = float("inf")
for j in range(m):
temp = min(temp, arr[i] & brr[j] ^ res)
res |= temp
print(res) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | n, m = [int(x) for x in input().split(" ")]
a = [int(x) for x in input().split(" ")]
b = [int(x) for x in input().split(" ")]
all_a = []
for aa in a:
t = []
for bb in b:
t.append(aa & bb)
all_a.append(t)
def get_bit(n, k):
return (n & 1 << k) >> k
final = 0
for i in range(8, -1, -1):
can_get_zero = True
for a in all_a:
can_get_zero_in_a = False
for aa in a:
if get_bit(aa, i) == 0:
can_get_zero_in_a = can_get_zero_in_a or True
can_get_zero = can_get_zero and can_get_zero_in_a
if can_get_zero:
for j in range(len(all_a)):
t = []
for aa in all_a[j]:
if get_bit(aa, i) == 0:
t.append(aa)
all_a[j] = t
else:
final = final + (1 << i)
print(final) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP NUMBER VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR IF VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR VAR VAR IF FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | import sys
import time
buff_readline = sys.stdin.readline
readline = sys.stdin.readline
INF = 2**62 - 1
def read_int():
return int(buff_readline())
def read_int_n():
return list(map(int, buff_readline().split()))
def read_float():
return float(buff_readline())
def read_float_n():
return list(map(float, buff_readline().split()))
def read_str():
return readline().strip()
def read_str_n():
return readline().strip().split()
def error_print(*args):
print(*args, file=sys.stderr)
def mt(f):
import time
def wrap(*args, **kwargs):
s = time.time()
ret = f(*args, **kwargs)
e = time.time()
error_print(e - s, "sec")
return ret
return wrap
def slv(N, M, A, B):
cb = [B[:] for _ in range(N)]
ans = 0
for i in range(64, -1, -1):
ncb = []
m = (1 << i + 1) - 1
d = 1 << i
for j, a in enumerate(A):
t = []
for b in cb[j]:
if a & b & m < d:
t.append(b)
if len(t) == 0:
break
else:
ncb.append(t)
if len(ncb) == N:
cb = ncb
else:
ans |= 1 << i
return ans
def main():
N, M = read_int_n()
A = read_int_n()
B = read_int_n()
print(slv(N, M, A, B))
main() | IMPORT IMPORT ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF EXPR FUNC_CALL VAR VAR VAR FUNC_DEF IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR STRING RETURN VAR RETURN VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER VAR FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR BIN_OP NUMBER VAR RETURN VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | import sys
input = sys.stdin.readline
n, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
l = 2**9
D0 = [0] * l
for i in range(m):
D0[A[0] & B[i]] = 1
for i in range(1, n):
D1 = [0] * l
C = []
for j in range(m):
C.append(A[i] & B[j])
for j in range(len(C)):
for k in range(l):
if D0[k] == 1:
D1[k | C[j]] = 1
D0 = D1[:]
for i in range(l):
if D0[i] == 1:
print(i)
break | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | from sys import gettrace, stdin
if gettrace():
inputi = input
else:
def input():
return next(stdin)[:-1]
def inputi():
return stdin.buffer.readline()
def main():
n, m = map(int, inputi().split())
aa = [int(a) for a in inputi().split()]
bb = [int(a) for a in inputi().split()]
res = 0
while aa:
besta = -1
bestres = -1
for a in aa:
best = 2**10
for b in bb:
best = min(a & b | res, best)
if best > bestres:
besta = a
bestres = best
res = bestres
aa.remove(besta)
print(res)
main() | IF FUNC_CALL VAR ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR |
Boboniu likes bit operations. He wants to play a game with you.
Boboniu gives you two sequences of non-negative integers $a_1,a_2,\ldots,a_n$ and $b_1,b_2,\ldots,b_m$.
For each $i$ ($1\le i\le n$), you're asked to choose a $j$ ($1\le j\le m$) and let $c_i=a_i\& b_j$, where $\&$ denotes the bitwise AND operation. Note that you can pick the same $j$ for different $i$'s.
Find the minimum possible $c_1 | c_2 | \ldots | c_n$, where $|$ denotes the bitwise OR operation.
-----Input-----
The first line contains two integers $n$ and $m$ ($1\le n,m\le 200$).
The next line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0\le a_i < 2^9$).
The next line contains $m$ integers $b_1,b_2,\ldots,b_m$ ($0\le b_i < 2^9$).
-----Output-----
Print one integer: the minimum possible $c_1 | c_2 | \ldots | c_n$.
-----Examples-----
Input
4 2
2 6 4 0
2 4
Output
2
Input
7 6
1 9 1 9 8 1 0
1 1 4 5 1 4
Output
0
Input
8 5
179 261 432 162 82 43 10 38
379 357 202 184 197
Output
147
-----Note-----
For the first example, we have $c_1=a_1\& b_2=0$, $c_2=a_2\& b_1=2$, $c_3=a_3\& b_1=0$, $c_4 = a_4\& b_1=0$.Thus $c_1 | c_2 | c_3 |c_4 =2$, and this is the minimal answer we can get. | import sys
def solve(A, B):
zero_bits = [[] for _ in range(10)]
for b in B:
for i in range(10):
mask = 1 << i
if not b & mask:
zero_bits[i].append(b)
universes = [set(B) for _ in A]
soln = 0
A0 = list(A)
for i in range(9, -1, -1):
ok = True
mask = 1 << i
for j, a0 in enumerate(A0):
if a0 & mask:
U0 = universes[j].intersection(zero_bits[i])
if not U0:
ok = False
if ok:
for j, a0 in enumerate(A0):
if a0 & mask:
universes[j] = universes[j].intersection(zero_bits[i])
A0[j] ^= mask
soln = 0
for a in A0:
soln |= a
return soln
def main():
N, M = (int(i) for i in sys.stdin.readline().split())
A = [int(i) for i in sys.stdin.readline().split()]
B = set([int(i) for i in sys.stdin.readline().split()])
print(solve(A, B))
main() | IMPORT FUNC_DEF ASSIGN VAR LIST VAR FUNC_CALL VAR NUMBER FOR VAR VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR IF BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR FOR VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR ASSIGN VAR NUMBER IF VAR FOR VAR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.