description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | def call(n, m, matrix):
res = [([-1] * m) for i in range(n)]
row = [0] * n
col = [0] * m
for i in range(n):
for j in range(m):
if matrix[i][j]:
row[i] = 1
col[j] = 1
if sum(row) + sum(col) != 0:
for i in range(n):
for j in range... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR V... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | T = int(input())
for i in range(0, T):
inputs = input().split()
inputs = list(map(int, inputs))
N = inputs[0]
M = inputs[1]
matrix = []
output_matrix = [[(-1) for q in range(0, M)] for p in range(0, N)]
impossible = True
for j in range(0, N):
row = list(input())
row = lis... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | mod = 1000000007
read_int = lambda: int(input().strip())
read_str = lambda: input().strip()
read_str_arr = lambda: input().strip().split()
read_int_arr = lambda: [int(x) for x in input().strip().split()]
def solve():
N, M = read_int_arr()
r = set()
c = set()
rc = set()
for i in range(N):
r... | ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL 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 FUNC_CA... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | for _ in range(int(input())):
n, m = map(int, input().split())
arr = []
for _ in range(n):
s = input()
arr.append(s)
res = [([-1] * m) for i in range(n)]
r = [0] * n
col = [0] * m
for i in range(n):
for j in range(m):
if arr[i][j] == "1":
r... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | t = int(input())
for _ in range(t):
flag = 0
n, m = [int(x) for x in input().split()]
A = [None] * n
for i in range(n):
sint = input()
inp = [None] * m
for j in range(m):
inp[j] = int(sint[j])
A[i] = inp
B = [[(-1) for j in range(m)] for i in range(n)]
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NONE VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NONE VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VA... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | mod = 1000000007
def integer_list():
return list(map(int, input().split()))
t = int(input())
for _ in range(t):
r, c = integer_list()
matix = [list(input()) for i in range(r)]
row_ones = set()
col_ones = set()
for i in range(r):
for j in range(c):
if matix[i][j] == "1":
... | ASSIGN VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | T = int(input())
for _ in range(T):
N, M = map(int, input().split())
R = [(False) for i in range(N)]
C = [(False) for i in range(M)]
mat = []
for n in range(N):
r = list(input().strip())
for m in range(M):
if r[m] == "1":
R[n] = True
C[m] =... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR I... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | for _ in range(int(input())):
r, c = map(int, input().split())
a = []
s = 0
for i in range(r):
b = list(input())
a.append(b)
s += b.count("1")
if s == 0:
for i in range(r):
for j in range(c):
print("-1", end=" ")
print()
els... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | t = input()
t = int(t)
while t:
t = t - 1
n_m = input()
n_m = n_m.split(" ")
n = int(n_m[0])
m = int(n_m[1])
matrix = []
for i in range(n):
row = input()
row = list(row)
row = list(map(int, row))
matrix.append(row)
v_rows = [False] * n
v_cols = [False]... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR AS... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | def findcol(j):
for _ in range(N):
if r[_][j] == "1":
return 1
return 0
def findrow(i):
for _ in range(M):
if r[i][_] == "1":
return 1
return 0
T = int(input())
while T:
T = T - 1
l = input().split()
N, M = int(l[0]), int(l[1])
ans = [[(0) for ... | FUNC_DEF FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR STRING RETURN NUMBER RETURN NUMBER FUNC_DEF FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR STRING RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMB... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | t = int(input())
for _ in range(t):
n, m = map(int, input().split())
mx = []
r = []
c = []
z = 0
for i in range(n):
a = list(input())
z += a.count("1")
r.append(a.count("1"))
mx.append(a)
for i in range(m):
for j in range(n):
if mx[j][i] ==... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR STRING EX... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | for t in range(int(input())):
l = []
n, m = map(int, input().split())
for i in range(n):
x = input()
l.append(x)
row = [0] * (n + 1)
col = [0] * (m + 1)
fl = 0
for i in range(n):
for j in range(m):
if int(l[i][j]):
row[i] = 1
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR F... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | t = int(input())
while t:
dim = input().split()
n = int(dim[0])
m = int(dim[1])
a = []
for i in range(n):
temp = []
s = input()
for j in range(m):
temp.append(int(s[j]))
a.append(temp)
res = [[(0) for i in range(m)] for j in range(n)]
row = [0] * n... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | t = int(input())
for _ in range(t):
n, m = map(int, input().split())
arr = []
result = []
for _ in range(n):
temp = list(input())
result_temp = [0] * len(temp)
arr.append(temp)
result.append(result_temp)
flag = 0
for i in range(n):
for j in range(m):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN ... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | for _ in range(int(input())):
x, y = map(int, input().split())
l = [[int(x) for x in input().strip()] for y in range(x)]
ans = [([2] * y) for k in range(x)]
temp = 0
rows = set()
col = set()
for i in range(x):
for j in range(y):
if l[i][j] == 1:
temp = 1
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FU... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | t = int(input())
while t > 0:
t -= 1
n, m = input().split(" ")
n, m = int(n), int(m)
a = []
for i in range(n):
row = input()
r = list(row)
for i in range(m):
r[i] = int(r[i])
a.append(r)
s = 0
r = []
c = []
for i in range(n):
r.appe... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR V... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | t = int(input())
for _ in range(t):
n, m = map(int, input().split())
matrix = []
colCheck = [False] * m
rowCheck = [False] * n
atleast1 = False
for i in range(n):
rows = [int(i) for i in list(input())]
if 1 in rows:
rowCheck[i] = True
atleast1 = True
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR IF NUMBER... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | t = int(input())
while t > 0:
t -= 1
n, m = [int(x) for x in input().split()]
row = [0] * n
col = [0] * m
arr = []
for i in range(n):
temp = [0] * m
arr.append([0] * m)
s = str(input())
for j in range(m):
p = int(s[j])
arr[i][j] = p
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR EXPR FUNC_CALL VAR BIN_OP LIST NUMBER VAR ASSIGN... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | for _ in range(int(input())):
n, m = map(int, input().split())
l = ["0"] * n
check = 0
for t in range(n):
l1 = list(str(input()))
l[t] = l1
hello = set(l1)
if "1" in hello:
check = 1
if check == 0:
main = [["-1"] * m] * n
for t in main:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST STRING VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF STRING VAR ASSIGN VAR NUMBER IF... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | for t in range(int(input())):
n, m = map(int, input().split())
a = []
for i in range(n):
a.append(input())
s = list(set(a))
if len(s) == 1 and "1" not in s[0]:
for i in range(n):
for i in range(m):
print("-1", end=" ")
print()
else:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER STRING VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR V... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | for _ in range(int(input())):
n, m = map(int, input().split())
arr = []
for _ in range(n):
lst = list(input())
arr.append(lst)
row = [0] * n
col = [0] * m
flag = 0
for i in range(n):
for j in range(m):
if arr[i][j] == "1":
flag = 1
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR V... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | t = int(input())
while t > 0:
n, m = map(int, input().split(" "))
matrix = [[(0) for i in range(m)] for j in range(n)]
fin = [[(0) for i in range(m)] for j in range(n)]
check = [[(0) for i in range(m)] for j in range(n)]
go = [[(0) for i in range(m)] for j in range(n)]
res = []
ans = []
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUM... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | t = int(input())
while t > 0:
a = input().split()
n = int(a[0])
m = int(a[1])
l = []
for i in range(n):
a = input()
l.append(a)
k = [[int(0) for i in range(m)] for j in range(n)]
flag = 1
cols = [(False) for i in range(m)]
rows = [(False) for i in range(n)]
for i ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | t = int(input())
while t:
n, m = map(int, input().split(" "))
a = []
b = []
c = []
e = 0
f = []
g = []
for i in range(n):
a.append(input())
b = []
if int(a[i]) > 0:
f.append(1)
else:
f.append(0)
for j in range(m):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST IF FUNC_CALL VAR VAR VAR NUMBER EX... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | for _ in range(int(input())):
n, m = map(int, input().split())
a = {}
b = {}
l = []
for i in range(n):
a[i] = 0
for i in range(m):
b[i] = 0
for i in range(n):
l.append(input())
for i in range(n):
for j in range(m):
if l[i][j] == "1":
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FU... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | for t in range(int(input())):
n, m = map(int, input().split(" "))
l1 = []
l = []
l2 = []
flag = 0
for i in range(n):
l1 = list(map(int, input()))
l2.append([-1] * m)
l.append(l1)
for i in l:
if 1 in i:
flag = 1
break
if flag == 0:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP LIST NUMBER VAR EXPR FUNC_CALL ... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | for _ in range(int(input())):
N, M = map(int, input().split())
all_zero = True
cols = [(0) for _ in range(M)]
rows = [(0) for _ in range(N)]
res = [["1" for _ in range(M)] for _ in range(N)]
for i in range(N):
A_row = input()
for j in range(M):
if A_row[j] == "1":
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR STRING VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FO... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | for _ in range(int(input())):
n, m = map(int, input().split())
dp = [[(0) for i in range(m)] for i in range(n)]
f = 0
mat = []
for i in range(n):
l = list(input())
l = [int(i) for i in l]
mat.append(l)
if 1 in l:
f = 1
if f == 0:
for i in range... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL ... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | t = int(input())
while t > 0:
t = t - 1
n, m = map(int, input().split())
L = []
for i in range(n):
L.append([int(j) for j in input()])
p = []
q = []
res = [[-1] * m] * n
for i in range(n):
if 1 in L[i]:
res[i] = [1] * m
for i in range(m):
if 1 in [... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR 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 VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST BIN_OP LIST NUMBER VAR VAR... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | t = int(input())
for _ in range(t):
n, m = map(int, input().split())
l = []
ans = []
flag = 0
for i in range(n):
k = list(input())
z = list(map(int, k))
l.append(z)
if 1 in z and flag == 0:
flag = 1
hash_rows = {}
hash_columns = {}
for i in ran... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR IF NUMBER VAR... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | GI = lambda: int(input())
GIS = lambda: map(int, input().split())
LGIS = lambda: list(GIS())
def main():
for t in range(GI()):
n, m = GIS()
mat = [[int(c) for c in input()] for _ in range(n)]
cr = [int(any(x for x in row)) for row in mat]
cc = [int(any(x for x in col)) for col in z... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | def findS(s, N, M):
rows = []
cols = []
for i in range(M):
temp = 0
for j in range(N):
temp = temp | s[j][i]
cols.append(temp)
for i in s:
temp = 0
for j in i:
temp = temp | j
rows.append(temp)
y = []
d = {(0): 1, (1): 0}
... | FUNC_DEF ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER I... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | t = int(input())
for i in range(t):
a = []
n, m = map(int, input().split())
for k in range(n):
s = input()
b = []
for j in s:
b.append(int(j))
a.append(b)
r = [(0) for j in range(n)]
c = [(0) for j in range(m)]
flag = 0
res = [[(0) for j in range(m... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASS... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | t = int(input())
for i in range(t):
n, m = map(int, input().split())
l = []
for j in range(n):
mat = list(input())
for k in range(len(mat)):
mat[k] = int(mat[k])
l.append(mat)
l1 = []
q1 = []
q2 = []
for j in range(n):
q1.append(sum(l[j]))
for ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST A... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | for _ in range(int(input())):
arr = []
N, M = list(map(int, input().split()))
for i in range(N):
Z = input()
arr.append(Z)
ans = [([-1] * M) for _ in range(N)]
r = set()
c = set()
for i in range(N):
for j in range(M):
if arr[i][j] == "1":
r... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | t = int(input())
while t:
t -= 1
n, m = map(int, input().split())
a = [[int(d) for d in input()] for i in range(n)]
if sum(sum(i) for i in a):
sol = [[2] * m] * n
for i in range(n):
if 1 in a[i]:
sol[i] = [1] * m
for j in range(m):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP LIST BIN_OP LIST NUMBER VAR VAR FOR VAR FUNC_CALL VAR VAR IF NUMBER VAR V... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | for _ in range(int(input())):
n, m = [int(i) for i in input().split()]
a = []
for i in range(n):
a.append([int(i) for i in input()])
r = []
c = []
for i in range(n):
for j in range(m):
if a[i][j] == 1:
r.append(i)
break
for j in ran... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER EXPR F... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | t = int(input())
for _ in range(t):
n, m = map(int, input().split())
a = [list(map(int, input())) for _ in range(n)]
if all(a[i][j] == 0 for i in range(n) for j in range(m)):
for i in range(n):
print(*([-1] * m))
else:
b = [([2] * m) for _ in range(n)]
rows = set(i fo... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CAL... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | t = int(input())
while t > 0:
t -= 1
n, m = [int(x) for x in input().split()]
matrix = []
cnt = 0
for i in range(n):
s = list(input())
cnt += s.count("0")
matrix.append(s)
matrix2 = []
for i in range(m):
temp = []
for j in range(n):
temp.ap... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASS... |
You are given a matrix of integers $A$ with $N$ rows (numbered $1$ through $N$) and $M$ columns (numbered $1$ through $M$). Each element of this matrix is either $0$ or $1$.
A move consists of the following steps:
- Choose two different rows $r_1$ and $r_2$ or two different columns $c_1$ and $c_2$.
- Apply the bitwise ... | def modifyMatrix(mat):
row = [0] * R
col = [0] * C
for i in range(0, R):
row[i] = 0
for i in range(0, C):
col[i] = 0
for i in range(0, R):
for j in range(0, C):
if mat[i][j] == 1:
row[i] = 1
col[j] = 1
for i in range(0, R):
... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER F... |
Given two integers dividend and divisor. Find the quotient after dividing dividend by divisor without using multiplication, division and mod operator.
Example 1:
Input:
a = 10, b= 3
Output: 3
Exaplanation:
10/3 gives quotient as 3
and remainder as 1.
Example 2:
Input:
a = 43, b = -8
Output: -5
Explanation:
43/-8 gives... | class Solution:
def divide(self, a, b):
sign = -1 if a >= 0 and b < 0 or a < 0 and b >= 0 else 1
a = abs(a)
b = abs(b)
result = len(range(0, a - b + 1, b))
if sign == -1:
result *= -1
negative_limit = -(2**31)
positive_limit = 2**31 - 1
re... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER... |
Given two integers dividend and divisor. Find the quotient after dividing dividend by divisor without using multiplication, division and mod operator.
Example 1:
Input:
a = 10, b= 3
Output: 3
Exaplanation:
10/3 gives quotient as 3
and remainder as 1.
Example 2:
Input:
a = 43, b = -8
Output: -5
Explanation:
43/-8 gives... | class Solution:
def divide(self, A: int, B: int) -> int:
if A == -2147483648 and B == -1:
return 2147483647
ans, sign = 0, 1
if A < 0:
A, sign = -A, -sign
if B < 0:
B, sign = -B, -sign
if A == B:
return sign
while A >= ... | CLASS_DEF FUNC_DEF VAR VAR IF VAR NUMBER VAR NUMBER RETURN NUMBER ASSIGN VAR VAR NUMBER NUMBER IF VAR NUMBER ASSIGN VAR VAR VAR VAR IF VAR NUMBER ASSIGN VAR VAR VAR VAR IF VAR VAR RETURN VAR WHILE VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR VAR NUMBER VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP NUMBER BIN_OP VAR... |
Given two integers dividend and divisor. Find the quotient after dividing dividend by divisor without using multiplication, division and mod operator.
Example 1:
Input:
a = 10, b= 3
Output: 3
Exaplanation:
10/3 gives quotient as 3
and remainder as 1.
Example 2:
Input:
a = 43, b = -8
Output: -5
Explanation:
43/-8 gives... | class Solution:
def divide(self, a, b):
tmp, q = 0, 0
sign = 1 if (a < 0) ^ (b < 0) == 0 else -1
a = abs(a)
b = abs(b)
for i in range(31, -1, -1):
if tmp + (b << i) <= a:
tmp += b << i
q |= 1 << i
return q * sign | CLASS_DEF FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP VAR BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP NUMBER VAR RETURN BIN_OP VAR VAR |
Given two integers dividend and divisor. Find the quotient after dividing dividend by divisor without using multiplication, division and mod operator.
Example 1:
Input:
a = 10, b= 3
Output: 3
Exaplanation:
10/3 gives quotient as 3
and remainder as 1.
Example 2:
Input:
a = 43, b = -8
Output: -5
Explanation:
43/-8 gives... | class Solution:
def divide(self, a, b):
minus_sign = (a < 0) != (b < 0)
a = abs(a)
b = abs(b)
c, _ = self.itter(a, b, 1)
return -c if minus_sign else c
def itter(self, a, b2, c):
if b2 > a:
return 0, a
c2, remainder = self.itter(a, b2 + b2, c... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR NUMBER RETURN VAR VAR VAR FUNC_DEF IF VAR VAR RETURN NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR IF VAR VAR RETURN VAR VAR RETURN BIN_OP VAR VA... |
Given two integers dividend and divisor. Find the quotient after dividing dividend by divisor without using multiplication, division and mod operator.
Example 1:
Input:
a = 10, b= 3
Output: 3
Exaplanation:
10/3 gives quotient as 3
and remainder as 1.
Example 2:
Input:
a = 43, b = -8
Output: -5
Explanation:
43/-8 gives... | def solve(a, b):
if b > a:
return 0
else:
k = 0
while 2**k * b <= a:
k += 1
k -= 1
ans = 2**k + solve(a - 2**k * b, b)
return ans
class Solution:
def divide(self, a, b):
if a < 0 and b < 0 or a > 0 and b > 0:
sign = 1
... | FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR NUMBER WHILE BIN_OP BIN_OP NUMBER VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP NUMBER VAR VAR VAR RETURN VAR CLASS_DEF FUNC_DEF IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ... |
Given two integers dividend and divisor. Find the quotient after dividing dividend by divisor without using multiplication, division and mod operator.
Example 1:
Input:
a = 10, b= 3
Output: 3
Exaplanation:
10/3 gives quotient as 3
and remainder as 1.
Example 2:
Input:
a = 43, b = -8
Output: -5
Explanation:
43/-8 gives... | class Solution:
def divide(self, a, b):
if b == 0:
return 4294967295
div = abs(a) // abs(b)
if (a < 0 or b < 0) and not (a < 0 and b < 0):
return -div
return div | CLASS_DEF FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR RETURN VAR |
Given two integers dividend and divisor. Find the quotient after dividing dividend by divisor without using multiplication, division and mod operator.
Example 1:
Input:
a = 10, b= 3
Output: 3
Exaplanation:
10/3 gives quotient as 3
and remainder as 1.
Example 2:
Input:
a = 43, b = -8
Output: -5
Explanation:
43/-8 gives... | class Solution:
def divide(self, dividend, divisor):
sngl = False
if dividend < 0 and divisor < 0:
pass
elif dividend < 0 or divisor < 0:
sngl = True
dividend = abs(dividend)
divisor = abs(divisor)
if divisor > dividend:
return 0
... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR IF VAR RETURN VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP... |
Given two integers dividend and divisor. Find the quotient after dividing dividend by divisor without using multiplication, division and mod operator.
Example 1:
Input:
a = 10, b= 3
Output: 3
Exaplanation:
10/3 gives quotient as 3
and remainder as 1.
Example 2:
Input:
a = 43, b = -8
Output: -5
Explanation:
43/-8 gives... | class Solution:
def divide(self, a, b):
neg = -1 if (a < 0) ^ (b < 0) else 1
a = abs(a)
b = abs(b)
quotent = 0
temp = 0
for i in range(31, -1, -1):
if temp + (b << i) <= a:
temp += b << i
quotent |= 1 << i
return ne... | CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP VAR BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP NUMBER VAR RETURN BIN_OP VAR VAR |
Given two integers dividend and divisor. Find the quotient after dividing dividend by divisor without using multiplication, division and mod operator.
Example 1:
Input:
a = 10, b= 3
Output: 3
Exaplanation:
10/3 gives quotient as 3
and remainder as 1.
Example 2:
Input:
a = 43, b = -8
Output: -5
Explanation:
43/-8 gives... | class Solution:
def divide(self, a, b):
c = 1
if a < 0:
c = -1 * c
a = -a
if b < 0:
b = -b
c = -1 * c
n = len(range(b, a + 1, b))
return n * c | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR VAR IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR RETURN BIN_OP VAR VAR |
Given two integers dividend and divisor. Find the quotient after dividing dividend by divisor without using multiplication, division and mod operator.
Example 1:
Input:
a = 10, b= 3
Output: 3
Exaplanation:
10/3 gives quotient as 3
and remainder as 1.
Example 2:
Input:
a = 43, b = -8
Output: -5
Explanation:
43/-8 gives... | class Solution:
def divide(self, a, b):
if a == 0:
return 0
if b == 0:
return -1
sign = 1
if a < 0:
a = -a
sign = -sign
if b < 0:
b = -b
sign = -sign
if a == b:
return sign
qu... | CLASS_DEF FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR IF VAR VAR RETURN VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR BIN_OP VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR BI... |
Given two integers dividend and divisor. Find the quotient after dividing dividend by divisor without using multiplication, division and mod operator.
Example 1:
Input:
a = 10, b= 3
Output: 3
Exaplanation:
10/3 gives quotient as 3
and remainder as 1.
Example 2:
Input:
a = 43, b = -8
Output: -5
Explanation:
43/-8 gives... | class Solution:
def divide(self, a, b):
ans = 0
flag = False
if a < 0 and b > 0 or a > 0 and b < 0:
flag = True
a = max(a, -1 * a)
b = max(b, -1 * b)
a, b = max(a, -1 * a), max(b, -1 * b)
while a >= b:
for i in range(32):
... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR BIN_OP NUMBER VAR FUNC_CALL VAR VAR BIN_OP NUMBER VAR WHILE VAR VAR FOR V... |
Given two integers dividend and divisor. Find the quotient after dividing dividend by divisor without using multiplication, division and mod operator.
Example 1:
Input:
a = 10, b= 3
Output: 3
Exaplanation:
10/3 gives quotient as 3
and remainder as 1.
Example 2:
Input:
a = 43, b = -8
Output: -5
Explanation:
43/-8 gives... | class Solution:
def divide(self, a, b):
temp = 0
ans = 0
neg = False
if (a < 0) ^ (b < 0):
neg = True
if a < 0:
a = -a
if b < 0:
b = -b
for i in range(31, -1, -1):
if temp + (b << i) <= a:
temp =... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BIN_... |
Given two integers dividend and divisor. Find the quotient after dividing dividend by divisor without using multiplication, division and mod operator.
Example 1:
Input:
a = 10, b= 3
Output: 3
Exaplanation:
10/3 gives quotient as 3
and remainder as 1.
Example 2:
Input:
a = 43, b = -8
Output: -5
Explanation:
43/-8 gives... | class Solution:
def divide(self, a, b):
sign = 1
if a < 0:
sign *= -1
a = -a
if b < 0:
sign *= -1
b = -b
return a // b * sign | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR RETURN BIN_OP BIN_OP VAR VAR VAR |
Given two integers dividend and divisor. Find the quotient after dividing dividend by divisor without using multiplication, division and mod operator.
Example 1:
Input:
a = 10, b= 3
Output: 3
Exaplanation:
10/3 gives quotient as 3
and remainder as 1.
Example 2:
Input:
a = 43, b = -8
Output: -5
Explanation:
43/-8 gives... | class Solution:
def divide(self, a, b):
x, y = abs(a), abs(b)
if a < 0 and b > 0 or a > 0 and b < 0:
return -1 * (x // y)
return x // y | CLASS_DEF FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER RETURN BIN_OP NUMBER BIN_OP VAR VAR RETURN BIN_OP VAR VAR |
Given two integers dividend and divisor. Find the quotient after dividing dividend by divisor without using multiplication, division and mod operator.
Example 1:
Input:
a = 10, b= 3
Output: 3
Exaplanation:
10/3 gives quotient as 3
and remainder as 1.
Example 2:
Input:
a = 43, b = -8
Output: -5
Explanation:
43/-8 gives... | class Solution:
def divide(self, dividend, divisor):
INT_MIN = -2147483647 - 1
INT_MAX = 2147483647
if dividend == INT_MIN and divisor == -1:
return INT_MAX
dvd = abs(dividend)
dvs = abs(divisor)
ans = 0
sign = -1 if (dividend > 0) ^ (divisor > 0)... | CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER NUMBER NUMBER WHILE VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER VAR VAR NUMBER VA... |
Given two integers dividend and divisor. Find the quotient after dividing dividend by divisor without using multiplication, division and mod operator.
Example 1:
Input:
a = 10, b= 3
Output: 3
Exaplanation:
10/3 gives quotient as 3
and remainder as 1.
Example 2:
Input:
a = 43, b = -8
Output: -5
Explanation:
43/-8 gives... | class Solution:
def divide(self, a, b):
flag = 0
if a < 0:
flag = 1
a = abs(a)
if b < 0:
if flag == 1:
flag = 0
else:
flag = 1
b = abs(b)
t = 0
q = 0
for i in range(31, -1, -1... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP VAR BIN_OP VAR VAR VAR VAR BIN_OP VAR VA... |
Given two integers dividend and divisor. Find the quotient after dividing dividend by divisor without using multiplication, division and mod operator.
Example 1:
Input:
a = 10, b= 3
Output: 3
Exaplanation:
10/3 gives quotient as 3
and remainder as 1.
Example 2:
Input:
a = 43, b = -8
Output: -5
Explanation:
43/-8 gives... | class Solution:
def divide(self, a, b):
if a == b:
return 1
boolean = (a >= 0) == (b >= 0)
a = abs(a)
b = abs(b)
res = 0
while a >= b:
count = 0
while a >= b << 1 + count:
count += 1
res += 1 << count
... | CLASS_DEF FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR BIN_OP NUMBER VAR VAR NUMBER VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR IF VAR RETURN VAR RETURN V... |
Given two integers dividend and divisor. Find the quotient after dividing dividend by divisor without using multiplication, division and mod operator.
Example 1:
Input:
a = 10, b= 3
Output: 3
Exaplanation:
10/3 gives quotient as 3
and remainder as 1.
Example 2:
Input:
a = 43, b = -8
Output: -5
Explanation:
43/-8 gives... | class Solution:
def divide(self, a, b):
if a * b < 1:
if a / b == int(a / b):
return a // b
return a // b + 1
return a // b | CLASS_DEF FUNC_DEF IF BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR RETURN BIN_OP VAR VAR RETURN BIN_OP BIN_OP VAR VAR NUMBER RETURN BIN_OP VAR VAR |
Given two integers dividend and divisor. Find the quotient after dividing dividend by divisor without using multiplication, division and mod operator.
Example 1:
Input:
a = 10, b= 3
Output: 3
Exaplanation:
10/3 gives quotient as 3
and remainder as 1.
Example 2:
Input:
a = 43, b = -8
Output: -5
Explanation:
43/-8 gives... | class Solution:
def divide(self, a, b):
if b == 0:
return float("inf") if a >= 0 else float("-inf")
if a == 0:
return 0
sign = -1 if (a < 0) ^ (b < 0) else 1
dividend, divisor = abs(a), abs(b)
quotient = 0
temp = 0
for i in range(31, -... | CLASS_DEF FUNC_DEF IF VAR NUMBER RETURN VAR NUMBER FUNC_CALL VAR STRING FUNC_CALL VAR STRING IF VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP VAR B... |
Given two integers dividend and divisor. Find the quotient after dividing dividend by divisor without using multiplication, division and mod operator.
Example 1:
Input:
a = 10, b= 3
Output: 3
Exaplanation:
10/3 gives quotient as 3
and remainder as 1.
Example 2:
Input:
a = 43, b = -8
Output: -5
Explanation:
43/-8 gives... | class Solution:
def divide(self, a, b):
divident = a
divisor = b
if divident == 0 or divisor == 0:
return 0
if divident > 0 and divisor > 0 or divident < 0 and divisor < 0:
sign = 1
elif divident < 0 and divisor > 0 or divident > 0 and divisor < 0:
... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR N... |
Given two integers dividend and divisor. Find the quotient after dividing dividend by divisor without using multiplication, division and mod operator.
Example 1:
Input:
a = 10, b= 3
Output: 3
Exaplanation:
10/3 gives quotient as 3
and remainder as 1.
Example 2:
Input:
a = 43, b = -8
Output: -5
Explanation:
43/-8 gives... | class Solution:
def divide(self, A, B):
if A == -2147483648 and B == -1:
return 2147483647
a, b, res = abs(A), abs(B), 0
for x in range(32)[::-1]:
if (a >> x) - b >= 0:
res += 1 << x
a -= b << x
return res if (A > 0) == (B > 0)... | CLASS_DEF FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP BIN_OP VAR VAR VAR NUMBER VAR BIN_OP NUMBER VAR VAR BIN_OP VAR VAR RETURN VAR NUMBER VAR NUMBER VAR VAR |
Given two integers dividend and divisor. Find the quotient after dividing dividend by divisor without using multiplication, division and mod operator.
Example 1:
Input:
a = 10, b= 3
Output: 3
Exaplanation:
10/3 gives quotient as 3
and remainder as 1.
Example 2:
Input:
a = 43, b = -8
Output: -5
Explanation:
43/-8 gives... | class Solution:
def divide(self, a, b):
sign = -1 if (a < 0) ^ (b < 0) else 1
divident, divisor = a, b
divident = abs(divident)
divisor = abs(divisor)
q = 0
for i in range(32, -1, -1):
if divisor << i <= divident:
divident -= divisor << i
... | CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR IF VAR NUMBER RETURN VAR... |
Given two integers dividend and divisor. Find the quotient after dividing dividend by divisor without using multiplication, division and mod operator.
Example 1:
Input:
a = 10, b= 3
Output: 3
Exaplanation:
10/3 gives quotient as 3
and remainder as 1.
Example 2:
Input:
a = 43, b = -8
Output: -5
Explanation:
43/-8 gives... | class Solution:
def divide(self, di, d):
a = abs(di)
b = abs(d)
ans = 0
while a >= b:
sum = b
count = 1
while sum <= a - sum:
sum += sum
count += count
ans += count
a -= sum
if di < 0... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR RETURN VAR |
Given two integers dividend and divisor. Find the quotient after dividing dividend by divisor without using multiplication, division and mod operator.
Example 1:
Input:
a = 10, b= 3
Output: 3
Exaplanation:
10/3 gives quotient as 3
and remainder as 1.
Example 2:
Input:
a = 43, b = -8
Output: -5
Explanation:
43/-8 gives... | class Solution:
def divide(self, a, b):
if b < 0 and a > 0:
return a // (b * -1) * -1
elif b > 0 and a < 0:
return a * -1 // b * -1
else:
return a // b | CLASS_DEF FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER IF VAR NUMBER VAR NUMBER RETURN BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER RETURN BIN_OP VAR VAR |
Given two integers dividend and divisor. Find the quotient after dividing dividend by divisor without using multiplication, division and mod operator.
Example 1:
Input:
a = 10, b= 3
Output: 3
Exaplanation:
10/3 gives quotient as 3
and remainder as 1.
Example 2:
Input:
a = 43, b = -8
Output: -5
Explanation:
43/-8 gives... | class Solution:
def divide(self, a, b):
c = 1
a1 = a
b1 = b
if a < 0:
a = -a
if b < 0:
b = -b
n = len(range(b, a + 1, b))
if a1 < 0 and b1 > 0 or a1 > 0 and b1 < 0:
return -n
return n | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR IF VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR RETURN VAR |
Given two integers dividend and divisor. Find the quotient after dividing dividend by divisor without using multiplication, division and mod operator.
Example 1:
Input:
a = 10, b= 3
Output: 3
Exaplanation:
10/3 gives quotient as 3
and remainder as 1.
Example 2:
Input:
a = 43, b = -8
Output: -5
Explanation:
43/-8 gives... | class Solution:
def divide(self, a, b):
q = 0
a1 = a
b1 = b
if a < 0 and b > 0:
a = -a
if b < 0 and a > 0:
b = -b
if a < 0 and b < 0:
a = -a
b = -b
while a >= b:
for i in range(pow(10, 3)):
... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR WHILE VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP VAR VAR VAR VAR BIN_OP VAR BIN_OP VAR NUMBER... |
Given two integers dividend and divisor. Find the quotient after dividing dividend by divisor without using multiplication, division and mod operator.
Example 1:
Input:
a = 10, b= 3
Output: 3
Exaplanation:
10/3 gives quotient as 3
and remainder as 1.
Example 2:
Input:
a = 43, b = -8
Output: -5
Explanation:
43/-8 gives... | class Solution:
def divide(self, a, b):
limit = 2**31
res = int(a / b)
if res > limit - 1:
return limit - 1
if res < -limit:
return -limit
return res | CLASS_DEF FUNC_DEF ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR IF VAR BIN_OP VAR NUMBER RETURN BIN_OP VAR NUMBER IF VAR VAR RETURN VAR RETURN VAR |
Given two integers dividend and divisor. Find the quotient after dividing dividend by divisor without using multiplication, division and mod operator.
Example 1:
Input:
a = 10, b= 3
Output: 3
Exaplanation:
10/3 gives quotient as 3
and remainder as 1.
Example 2:
Input:
a = 43, b = -8
Output: -5
Explanation:
43/-8 gives... | class Solution:
def divide(self, a, b):
if a == 0 or b == 0:
if b == 0:
if a >= 0:
return 4294967295
return -4294967295
else:
return 0
ans = 0
sign = 1
if a < 0 and b > 0 or a > 0 and b < 0:
... | CLASS_DEF FUNC_DEF IF VAR NUMBER VAR NUMBER IF VAR NUMBER IF VAR NUMBER RETURN NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VA... |
Given two integers dividend and divisor. Find the quotient after dividing dividend by divisor without using multiplication, division and mod operator.
Example 1:
Input:
a = 10, b= 3
Output: 3
Exaplanation:
10/3 gives quotient as 3
and remainder as 1.
Example 2:
Input:
a = 43, b = -8
Output: -5
Explanation:
43/-8 gives... | class Solution:
def divide(self, A, B):
isNeg = 1
if (A < 0 or B < 0) and not (A < 0 and B < 0):
isNeg = -1
A = abs(A)
B = abs(B)
i = 31
temp = 0
q = 0
while i >= 0:
if (B << i) + temp <= A:
temp = (B << i) + te... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP NUMBER V... |
Given two integers dividend and divisor. Find the quotient after dividing dividend by divisor without using multiplication, division and mod operator.
Example 1:
Input:
a = 10, b= 3
Output: 3
Exaplanation:
10/3 gives quotient as 3
and remainder as 1.
Example 2:
Input:
a = 43, b = -8
Output: -5
Explanation:
43/-8 gives... | class Solution:
def divide(self, a, b):
result = 0
sign = 1
if a < 0 and b < 0:
sign = 1
elif a < 0 or b < 0:
sign = -1
a, b = abs(a), abs(b)
while a - b >= 0:
count = 0
while a - (b << 1 << count) >= 0:
... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR BIN_OP NUMBER ... |
Given two integers dividend and divisor. Find the quotient after dividing dividend by divisor without using multiplication, division and mod operator.
Example 1:
Input:
a = 10, b= 3
Output: 3
Exaplanation:
10/3 gives quotient as 3
and remainder as 1.
Example 2:
Input:
a = 43, b = -8
Output: -5
Explanation:
43/-8 gives... | class Solution:
def divide(self, a, b):
s = 0
k = b
l = a
if b < 0:
b = abs(b)
if a < 0:
a = abs(a)
p = len(str(a))
q = 10 ** (p - 1)
z = b * q
i = 1
while a >= b:
if z <= a:
a = a - ... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR ASSIGN VAR B... |
Given two integers dividend and divisor. Find the quotient after dividing dividend by divisor without using multiplication, division and mod operator.
Example 1:
Input:
a = 10, b= 3
Output: 3
Exaplanation:
10/3 gives quotient as 3
and remainder as 1.
Example 2:
Input:
a = 43, b = -8
Output: -5
Explanation:
43/-8 gives... | class Solution:
def divide(self, a, b):
i = 31
ans = 0
t = 0
sign = -1 if (a < 0) ^ (b < 0) else 1
a = abs(a)
b = abs(b)
while i >= 0:
if t + (b << i) <= a:
ans += 1 << i
t += b << i
i -= 1
if si... | CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR NUMBER IF BIN_OP VAR BIN_OP VAR VAR VAR VAR BIN_OP NUMBER VAR VAR BIN_OP VAR VAR VAR NUMBER IF VAR NUMBER VAR NUMBER RETURN V... |
Given two integers dividend and divisor. Find the quotient after dividing dividend by divisor without using multiplication, division and mod operator.
Example 1:
Input:
a = 10, b= 3
Output: 3
Exaplanation:
10/3 gives quotient as 3
and remainder as 1.
Example 2:
Input:
a = 43, b = -8
Output: -5
Explanation:
43/-8 gives... | class Solution:
def divide(self, a, b):
sign = -1 if a < 0 or b < 0 else 1
if a < 0 and b < 0:
sign = 1
a = abs(a)
b = abs(b)
result = 0
for i in range(31, -1, -1):
if b << i <= a:
result += 1 << i
a -= b << i
... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR NUMBER VAR NUMBER NUMBER NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP VAR VAR VAR VAR BIN_OP NUMBER VAR VAR BIN_OP VAR VAR RETURN BIN_OP VAR VAR |
Given two integers dividend and divisor. Find the quotient after dividing dividend by divisor without using multiplication, division and mod operator.
Example 1:
Input:
a = 10, b= 3
Output: 3
Exaplanation:
10/3 gives quotient as 3
and remainder as 1.
Example 2:
Input:
a = 43, b = -8
Output: -5
Explanation:
43/-8 gives... | class Solution:
def divide(self, a, b):
if a // b > 0:
return a // b
else:
if int(a / b) == a // b:
return a // b
return a // b + 1 | CLASS_DEF FUNC_DEF IF BIN_OP VAR VAR NUMBER RETURN BIN_OP VAR VAR IF FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR RETURN BIN_OP VAR VAR RETURN BIN_OP BIN_OP VAR VAR NUMBER |
Given two integers dividend and divisor. Find the quotient after dividing dividend by divisor without using multiplication, division and mod operator.
Example 1:
Input:
a = 10, b= 3
Output: 3
Exaplanation:
10/3 gives quotient as 3
and remainder as 1.
Example 2:
Input:
a = 43, b = -8
Output: -5
Explanation:
43/-8 gives... | class Solution:
def divide(self, a, b):
a_neg, b_neg = False, False
if a < 0:
a_neg = True
if b < 0:
b_neg = True
a = abs(a)
b = abs(b)
q = 0
while a >= b:
c = 0
while a >= b << c:
c += 1
... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR BI... |
Given two integers dividend and divisor. Find the quotient after dividing dividend by divisor without using multiplication, division and mod operator.
Example 1:
Input:
a = 10, b= 3
Output: 3
Exaplanation:
10/3 gives quotient as 3
and remainder as 1.
Example 2:
Input:
a = 43, b = -8
Output: -5
Explanation:
43/-8 gives... | class Solution:
def divide(self, dividend, divisor):
dd = dividend
ds = divisor
is_neg = False
if dd < 0 and ds >= 0:
is_neg = True
elif dd >= 0 and ds < 0:
is_neg = True
dd = abs(dd)
ds = abs(ds)
original = ds
total = ... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN ... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef is really interested in the XOR operation. He wants to take a sequence $A_{0}, A_{1}, \ldots, A_{N-1}$ and for each $i$ from $0$ to $K-1$ inclusive (in this order, one by one), perform the following operation:
... | n = int(input())
for i in range(n):
m, k = map(int, input().split())
l = list(map(int, input().split()))
if k >= m * 3:
k = m * 3 + k % (m * 3)
for j in range(k):
r = j % m
a = l[r]
b = l[m - r - 1]
l[r] = a ^ b
print(*l) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef is really interested in the XOR operation. He wants to take a sequence $A_{0}, A_{1}, \ldots, A_{N-1}$ and for each $i$ from $0$ to $K-1$ inclusive (in this order, one by one), perform the following operation:
... | t = int(input())
while t > 0:
n, k = list(map(int, input().split()))
l = list(map(int, input().split()))
i = 0
if k >= n * 3:
k = n * 3 + k % (n * 3)
while i < k:
a = l[i % n]
b = l[n - i % n - 1]
l[i % n] = a ^ b
i += 1
for i in l:
print(i, " ", e... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE 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 NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER WHILE VAR VAR ASSI... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef is really interested in the XOR operation. He wants to take a sequence $A_{0}, A_{1}, \ldots, A_{N-1}$ and for each $i$ from $0$ to $K-1$ inclusive (in this order, one by one), perform the following operation:
... | t = int(input())
for i in range(0, t):
n, k = list(map(int, input().split()))
l = list(map(int, input().split()))
if k > n and n % 2 == 1:
l[n // 2] = 0
num = k // n % 3
for j in range(0, num):
for x in range(0, n):
a = l[x % n]
b = l[n - x % n - 1]
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER 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 IF VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBE... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef is really interested in the XOR operation. He wants to take a sequence $A_{0}, A_{1}, \ldots, A_{N-1}$ and for each $i$ from $0$ to $K-1$ inclusive (in this order, one by one), perform the following operation:
... | t = int(input())
for i in range(t):
n, k = map(int, input().split())
ar = list(map(int, input().split()))
b = n * 3
if k > b:
k = k % b + b
for i in range(0, k):
ar[i % n] = ar[i % n] ^ ar[n - i % n - 1]
print(*ar) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef is really interested in the XOR operation. He wants to take a sequence $A_{0}, A_{1}, \ldots, A_{N-1}$ and for each $i$ from $0$ to $K-1$ inclusive (in this order, one by one), perform the following operation:
... | def sol(n, k, arr):
if k >= n * 3:
k = n * 3 + k % (n * 3)
for i in range(k):
arr[i % n] = arr[i % n] ^ arr[n - i % n - 1]
return arr
y = int(input())
for i in range(y):
n, k = map(int, input().split())
arr = list(map(int, input().split()))
print(*sol(n, k, arr)) | FUNC_DEF IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CAL... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef is really interested in the XOR operation. He wants to take a sequence $A_{0}, A_{1}, \ldots, A_{N-1}$ and for each $i$ from $0$ to $K-1$ inclusive (in this order, one by one), perform the following operation:
... | for i in range(int(input())):
n, k = map(int, input().split())
a = list(map(int, input().split()))
if k >= n and n % 2 == 1:
a[n // 2] = 0
x = k // n % 3
for j in range(x):
for i in range(n):
b = a[i]
c = a[n - i - 1]
a[i] = b ^ c
y = k % n
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR ... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef is really interested in the XOR operation. He wants to take a sequence $A_{0}, A_{1}, \ldots, A_{N-1}$ and for each $i$ from $0$ to $K-1$ inclusive (in this order, one by one), perform the following operation:
... | n = int(input())
for i in range(n):
N, K = map(int, input().split())
lst = list(map(int, input().split()))
a = lst[0]
if K > N * 3:
K = K % (N * 3) + N * 3
for i in range(K):
a = lst[i % N]
b = lst[N - i % N - 1]
out = a ^ b
a = out
lst[i % N] = out
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL V... |
With respect to a given puzzle string, a word is valid if both the following conditions are satisfied:
word contains the first letter of puzzle.
For each letter in word, that letter is in puzzle.
For example, if the puzzle is "abcdefg", then valid words are "faced", "cabbage", and "baggage"; while invalid word... | class Solution:
wdMap = {}
def findNumOfValidWords(self, words: List[str], puzzles: List[str]) -> List[int]:
res = []
self.wdMap = self.hashwords(words)
for puzzle in puzzles:
res.append(self.checkValidWord(puzzle, 0, 0))
return res
def checkValidWord(self, puzz... | CLASS_DEF ASSIGN VAR DICT FUNC_DEF VAR VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER RETURN VAR VAR VAR FUNC_DEF IF VAR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_... |
With respect to a given puzzle string, a word is valid if both the following conditions are satisfied:
word contains the first letter of puzzle.
For each letter in word, that letter is in puzzle.
For example, if the puzzle is "abcdefg", then valid words are "faced", "cabbage", and "baggage"; while invalid word... | class Puzzle:
def __init__(self, puzzle):
self.first_letter = puzzle[0]
self.puzzle = set(puzzle)
class Solution:
def findNumOfValidWords(self, words: List[str], puzzles: List[str]) -> List[int]:
cnt = collections.Counter(frozenset(w) for w in words)
res = [0] * len(puzzles)
... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL V... |
With respect to a given puzzle string, a word is valid if both the following conditions are satisfied:
word contains the first letter of puzzle.
For each letter in word, that letter is in puzzle.
For example, if the puzzle is "abcdefg", then valid words are "faced", "cabbage", and "baggage"; while invalid word... | class Solution:
def findNumOfValidWords(self, words: List[str], puzzles: List[str]) -> List[int]:
orda = ord("a")
mask = defaultdict(int)
for w in words:
m = 0
for c in w:
m |= 1 << ord(c) - orda
mask[m] += 1
res = []
for p... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR VAR AS... |
With respect to a given puzzle string, a word is valid if both the following conditions are satisfied:
word contains the first letter of puzzle.
For each letter in word, that letter is in puzzle.
For example, if the puzzle is "abcdefg", then valid words are "faced", "cabbage", and "baggage"; while invalid word... | def to_mask(word):
ret = 0
for c in word:
ret |= 1 << ord(c) - 97
return ret
def get_good_masks(word):
BASE = 1 << ord(word[0]) - 97
ret = []
for choice in range(64):
mask = BASE
for i in range(6):
if 1 << i & choice:
mask |= 1 << ord(word[i ... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR VAR BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP NUMBER VAR VAR VAR BIN_OP NUMBER BIN_OP F... |
With respect to a given puzzle string, a word is valid if both the following conditions are satisfied:
word contains the first letter of puzzle.
For each letter in word, that letter is in puzzle.
For example, if the puzzle is "abcdefg", then valid words are "faced", "cabbage", and "baggage"; while invalid word... | class Solution:
def findNumOfValidWords(self, words: List[str], puzzles: List[str]) -> List[int]:
ans = []
cnt = Counter()
for w in words:
w = set(w)
if len(w) > 7:
continue
w_bit = 0
for c in w:
w_bit |= 1 << o... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING VAR VAR NUMBER FOR VAR VAR ASSIGN VAR LIST BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR... |
With respect to a given puzzle string, a word is valid if both the following conditions are satisfied:
word contains the first letter of puzzle.
For each letter in word, that letter is in puzzle.
For example, if the puzzle is "abcdefg", then valid words are "faced", "cabbage", and "baggage"; while invalid word... | class Solution:
def findNumOfValidWords(self, words: List[str], puzzles: List[str]) -> List[int]:
def helper(mask, pIdx, i):
str1 = puzzles[pIdx]
if i >= len(str1):
return
mask2 = mask
mask2 |= 1 << ord(str1[i]) - ord("a")
if mask... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR FUNC_DEF ASSIGN VAR VAR VAR IF VAR FUNC_CALL VAR VAR RETURN ASSIGN VAR VAR VAR BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING IF BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER ASSIGN ... |
With respect to a given puzzle string, a word is valid if both the following conditions are satisfied:
word contains the first letter of puzzle.
For each letter in word, that letter is in puzzle.
For example, if the puzzle is "abcdefg", then valid words are "faced", "cabbage", and "baggage"; while invalid word... | class Solution(object):
def findNumOfValidWords(self, words, puzzles):
def get_bit(word):
x = 0
for ch in word:
x |= 1 << ord(ch) - ord("a")
return x
bitdic = collections.defaultdict(int)
words = [set(list(x)) for x in words]
for... | CLASS_DEF VAR FUNC_DEF FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR VAR BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING RETURN VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FOR VAR VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR N... |
With respect to a given puzzle string, a word is valid if both the following conditions are satisfied:
word contains the first letter of puzzle.
For each letter in word, that letter is in puzzle.
For example, if the puzzle is "abcdefg", then valid words are "faced", "cabbage", and "baggage"; while invalid word... | class Solution:
def findNumOfValidWords(self, words: List[str], puzzles: List[str]) -> List[int]:
res = []
counter = collections.defaultdict(int)
for word in words:
mask = 0
for c in word:
mask |= 1 << ord(c) - ord("a")
counter[mask] += 1
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING VAR VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING ASSIGN VAR BI... |
With respect to a given puzzle string, a word is valid if both the following conditions are satisfied:
word contains the first letter of puzzle.
For each letter in word, that letter is in puzzle.
For example, if the puzzle is "abcdefg", then valid words are "faced", "cabbage", and "baggage"; while invalid word... | class Solution:
def findNumOfValidWords(self, words: List[str], puzzles: List[str]) -> List[int]:
res = []
cnt = collections.Counter("".join(sorted(set(w))) for w in words)
for p in puzzles:
bfs = [p[0]]
for c in p[1:]:
bfs += [(s + c) for s in bfs]
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FOR VAR VAR ASSIGN VAR LIST VAR NUMBER FOR VAR VAR NUMBER VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR RETURN VAR VAR VAR |
With respect to a given puzzle string, a word is valid if both the following conditions are satisfied:
word contains the first letter of puzzle.
For each letter in word, that letter is in puzzle.
For example, if the puzzle is "abcdefg", then valid words are "faced", "cabbage", and "baggage"; while invalid word... | class Solution:
def findNumOfValidWords(self, words: List[str], puzzles: List[str]) -> List[int]:
def wordToInt(word: str) -> int:
n = 0
ls = 0
for c in word:
cn = 1 << ord(c) - 97
ls += 1 if cn & n == 0 else 0
if ls > 7:
... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR FUNC_DEF VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP VAR VAR NUMBER NUMBER NUMBER IF VAR NUMBER RETURN NONE VAR VAR RETURN VAR VAR FUNC_DEF VAR RETURN FUNC_CALL VAR VAR VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR... |
With respect to a given puzzle string, a word is valid if both the following conditions are satisfied:
word contains the first letter of puzzle.
For each letter in word, that letter is in puzzle.
For example, if the puzzle is "abcdefg", then valid words are "faced", "cabbage", and "baggage"; while invalid word... | class Solution:
def findNumOfValidWords(self, words, puzzles):
count = collections.Counter()
for w in words:
if len(set(w)) > 7:
continue
m = 0
for c in w:
m |= 1 << ord(c) - 97
count[m] += 1
res = []
fo... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR LIST BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR VAR NUMBER VAR BIN_OP ... |
With respect to a given puzzle string, a word is valid if both the following conditions are satisfied:
word contains the first letter of puzzle.
For each letter in word, that letter is in puzzle.
For example, if the puzzle is "abcdefg", then valid words are "faced", "cabbage", and "baggage"; while invalid word... | class Solution:
def findNumOfValidWords(self, words, puzzles):
count = collections.Counter(frozenset(w) for w in words)
res = []
for p in puzzles:
cur = 0
for k in range(7):
for c in itertools.combinations(p[1:], k):
cur += count[f... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER VAR VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR EXPR FUNC_CALL VAR VAR RETURN VAR |
With respect to a given puzzle string, a word is valid if both the following conditions are satisfied:
word contains the first letter of puzzle.
For each letter in word, that letter is in puzzle.
For example, if the puzzle is "abcdefg", then valid words are "faced", "cabbage", and "baggage"; while invalid word... | class Node:
def __init__(self):
self.ch = {}
self.cnt = 0
def build(self, words):
for w in words:
n = self
for c in w:
if c not in n.ch:
n.ch[c] = Node()
n = n.ch[c]
n.cnt += 1
def search(self,... | CLASS_DEF FUNC_DEF ASSIGN VAR DICT ASSIGN VAR NUMBER FUNC_DEF FOR VAR VAR ASSIGN VAR VAR FOR VAR VAR IF VAR VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER IF VAR VAR VAR FOR VAR VAR IF VAR VAR IF VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR RET... |
With respect to a given puzzle string, a word is valid if both the following conditions are satisfied:
word contains the first letter of puzzle.
For each letter in word, that letter is in puzzle.
For example, if the puzzle is "abcdefg", then valid words are "faced", "cabbage", and "baggage"; while invalid word... | class Solution:
def findNumOfValidWords(self, words: List[str], puzzles: List[str]) -> List[int]:
cnt = Counter(frozenset(w) for w in words if len(set(w)) <= 7)
ans = []
for p in puzzles:
cur = 0
for k in range(7):
for i in itertools.combinations(p[1:... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR RETURN VAR VAR V... |
With respect to a given puzzle string, a word is valid if both the following conditions are satisfied:
word contains the first letter of puzzle.
For each letter in word, that letter is in puzzle.
For example, if the puzzle is "abcdefg", then valid words are "faced", "cabbage", and "baggage"; while invalid word... | class Puzzle:
def __init__(self, puzzle):
self.first_letter = puzzle[0]
self.puzzle = set(puzzle)
class Solution:
def findNumOfValidWords(self, words: List[str], puzzles: List[str]) -> List[int]:
cnt = collections.Counter(frozenset(w) for w in words)
res = [0] * len(puzzles)
... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR CLASS_DEF FUNC_DEF VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR NUMBER FOR VAR VAR NUMBER VAR BIN_OP VAR VAR VAR VAR VAR VAR FUNC_... |
With respect to a given puzzle string, a word is valid if both the following conditions are satisfied:
word contains the first letter of puzzle.
For each letter in word, that letter is in puzzle.
For example, if the puzzle is "abcdefg", then valid words are "faced", "cabbage", and "baggage"; while invalid word... | class Solution:
def findNumOfValidWords(self, words: List[str], puzzles: List[str]) -> List[int]:
def getNum(s: str) -> int:
res = 0
for c in s:
res |= 1 << ord(c) - 97
return res
counter = Counter([getNum(set(word)) for word in words if len(set... | CLASS_DEF FUNC_DEF VAR VAR VAR VAR FUNC_DEF VAR ASSIGN VAR NUMBER FOR VAR VAR VAR BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER RETURN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FOR VAR VAR ASSIGN VAR LIST BIN_... |
With respect to a given puzzle string, a word is valid if both the following conditions are satisfied:
word contains the first letter of puzzle.
For each letter in word, that letter is in puzzle.
For example, if the puzzle is "abcdefg", then valid words are "faced", "cabbage", and "baggage"; while invalid word... | def gist(word):
ans = 0
for ch in word:
ans |= 1 << ord(ch) - ord("a")
return ans
def subsets(arr, start=0, progress=0):
if start == len(arr):
yield progress
else:
yield from subsets(arr, start + 1, progress | arr[start])
yield from subsets(arr, start + 1, progress)... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR VAR BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING RETURN VAR FUNC_DEF NUMBER NUMBER IF VAR FUNC_CALL VAR VAR EXPR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR VA... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.