description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
You are given a binary string $s$ (recall that a string is binary if each character is either $0$ or $1$).
Let $f(t)$ be the decimal representation of integer $t$ written in binary form (possibly with leading zeroes). For example $f(011) = 3, f(00101) = 5, f(00001) = 1, f(10) = 2, f(000) = 0$ and $f(000100) = 4$.
The... | t = int(input())
for _ in range(t):
s = list(str(input()))
n = len(s)
nxt = [-1] * n
for i in range(n):
if s[i] == "1":
nxt[i] = i
elif i != 0:
nxt[i] = nxt[i - 1]
res = 0
for r in range(n):
sum_ = 0
for l in range(r, -1, -1):
i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR VAR IF VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR... |
You are given a binary string $s$ (recall that a string is binary if each character is either $0$ or $1$).
Let $f(t)$ be the decimal representation of integer $t$ written in binary form (possibly with leading zeroes). For example $f(011) = 3, f(00101) = 5, f(00001) = 1, f(10) = 2, f(000) = 0$ and $f(000100) = 4$.
The... | t = int(input())
for _ in range(t):
ln = [int(x) for x in input()]
sz, zc, ans = len(ln), 0, 0
for i in range(sz):
if ln[i] == 1:
num, rl = 0, min(i + 20, sz)
for j in range(i, rl):
num = num * 2 + ln[j]
if j - i + 1 + zc >= num:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP ... |
You are given a binary string $s$ (recall that a string is binary if each character is either $0$ or $1$).
Let $f(t)$ be the decimal representation of integer $t$ written in binary form (possibly with leading zeroes). For example $f(011) = 3, f(00101) = 5, f(00001) = 1, f(10) = 2, f(000) = 0$ and $f(000100) = 4$.
The... | for _ in range(int(input())):
s = [int(x) for x in list(input().strip())]
n = len(s)
an = 0
c = 0
for i in range(n):
if s[i] == 1:
p = 0
for j in range(18):
if i + j == n:
break
else:
p = p << 1
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR... |
You are given a binary string $s$ (recall that a string is binary if each character is either $0$ or $1$).
Let $f(t)$ be the decimal representation of integer $t$ written in binary form (possibly with leading zeroes). For example $f(011) = 3, f(00101) = 5, f(00001) = 1, f(10) = 2, f(000) = 0$ and $f(000100) = 4$.
The... | R = lambda: map(int, input().split())
for _ in range(int(input())):
s = [i for i in input()]
l = len(s)
L = [(0) for i in range(l)]
c = 0
for i in range(l):
if s[i] == "1":
L[i] = c
c = 0
else:
c += 1
i = l - 1
res = 0
while i >= 0:
... | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR VAR VAR ASSIGN VAR NUMBER VAR NUMBER ASSIG... |
You are given a binary string $s$ (recall that a string is binary if each character is either $0$ or $1$).
Let $f(t)$ be the decimal representation of integer $t$ written in binary form (possibly with leading zeroes). For example $f(011) = 3, f(00101) = 5, f(00001) = 1, f(10) = 2, f(000) = 0$ and $f(000100) = 4$.
The... | from sys import stdin, stdout
t = int(stdin.readline())
for _ in range(t):
s = stdin.readline()
s = s[:-1]
n = len(s)
precomp = []
for i in range(len(s)):
if i == 0 and s[i] == "0":
precomp.append(-1)
elif s[i] == "1":
precomp.append(i)
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR VAR STRING EXPR FUNC_CALL VAR NUMBER IF VAR VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR NUMB... |
You are given a binary string $s$ (recall that a string is binary if each character is either $0$ or $1$).
Let $f(t)$ be the decimal representation of integer $t$ written in binary form (possibly with leading zeroes). For example $f(011) = 3, f(00101) = 5, f(00001) = 1, f(10) = 2, f(000) = 0$ and $f(000100) = 4$.
The... | import sys
inf = 2 * 10**5
inf_bin = len(bin(inf)[2:])
def pre_calculate_amount_of_zero_left(s):
prefix = [0] * len(s)
cur_amount = 0
for i in range(0, len(s)):
if s[i] == "0":
cur_amount += 1
elif s[i] == "1":
prefix[i] = cur_amount
cur_amount = 0
... | IMPORT ASSIGN VAR BIN_OP NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING ASSIGN VAR VAR VAR ASSIGN VAR NUMBER RETURN VAR ... |
You are given a binary string $s$ (recall that a string is binary if each character is either $0$ or $1$).
Let $f(t)$ be the decimal representation of integer $t$ written in binary form (possibly with leading zeroes). For example $f(011) = 3, f(00101) = 5, f(00001) = 1, f(10) = 2, f(000) = 0$ and $f(000100) = 4$.
The... | for i in range(int(input())):
s = input()
n = len(s)
prev = 0
ans = 0
dp = [-1] * (n + 1)
se = set()
for i in range(n):
if s[i] == "1":
dp[i + 1] = i
else:
dp[i + 1] = dp[i]
for i in range(n):
for j in range(i + 1, min(n + 1, i + 19)):
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER V... |
You are given a binary string $s$ (recall that a string is binary if each character is either $0$ or $1$).
Let $f(t)$ be the decimal representation of integer $t$ written in binary form (possibly with leading zeroes). For example $f(011) = 3, f(00101) = 5, f(00001) = 1, f(10) = 2, f(000) = 0$ and $f(000100) = 4$.
The... | from sys import stdin, stdout
t = int(stdin.readline().strip())
for caso in range(t):
s = stdin.readline().strip()
n = len(s)
ans = 0
z = [(0) for i in range(n)]
for i in range(n):
if s[i] == "0":
z[i] += 1
if i > 0:
z[i] += z[i - 1]
if s[i] == "1":
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR NUMBER IF VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER IF VAR VAR STRING AS... |
You are given a binary string $s$ (recall that a string is binary if each character is either $0$ or $1$).
Let $f(t)$ be the decimal representation of integer $t$ written in binary form (possibly with leading zeroes). For example $f(011) = 3, f(00101) = 5, f(00001) = 1, f(10) = 2, f(000) = 0$ and $f(000100) = 4$.
The... | ll = lambda: list(map(int, input().split()))
testcases = 1
[testcases] = ll()
for _ in range(testcases):
s = input()
n = len(s)
dp = [0] * (n + 1)
dp[0] = int(s[0] == "0")
for i in range(1, n):
if s[i] == "1":
dp[i] = 0
else:
dp[i] = dp[i - 1] + 1
ans = 0
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN LIST VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER STRING FOR VAR FUNC_CALL VAR NUMBE... |
You are given a binary string $s$ (recall that a string is binary if each character is either $0$ or $1$).
Let $f(t)$ be the decimal representation of integer $t$ written in binary form (possibly with leading zeroes). For example $f(011) = 3, f(00101) = 5, f(00001) = 1, f(10) = 2, f(000) = 0$ and $f(000100) = 4$.
The... | t = int(input())
for _ in range(t):
s = [int(i) for i in input().strip()]
n = len(s)
left_distance = [0] * n
left_distance[0] = int(not s[0])
for i in range(1, n):
if not s[i]:
left_distance[i] = left_distance[i - 1] + 1
ct = 0
for i in range(n):
if s[i]:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMB... |
You are given a binary string $s$ (recall that a string is binary if each character is either $0$ or $1$).
Let $f(t)$ be the decimal representation of integer $t$ written in binary form (possibly with leading zeroes). For example $f(011) = 3, f(00101) = 5, f(00001) = 1, f(10) = 2, f(000) = 0$ and $f(000100) = 4$.
The... | for _ in range(int(input())):
s = input()
block = min(20, len(s))
zeros = [0] * len(s)
count = 0
ans = 0
for i in range(len(s)):
zeros[i] = count
if s[i] == "1":
count = -1
count += 1
for r in range(len(s) - 1, -1, -1):
for l in range(r, r - block,... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR VAR STRING ASSIGN VAR NUMBER VAR NUMBER FOR V... |
You are given a binary string $s$ (recall that a string is binary if each character is either $0$ or $1$).
Let $f(t)$ be the decimal representation of integer $t$ written in binary form (possibly with leading zeroes). For example $f(011) = 3, f(00101) = 5, f(00001) = 1, f(10) = 2, f(000) = 0$ and $f(000100) = 4$.
The... | def decimal(ss):
ans = 0
c = 0
for i in range(len(ss) - 1, -1, -1):
if ss[i] == "1":
ans += 2**c
c += 1
return ans
for _ in range(int(input())):
s = input()
ll = len(s)
zer = [0] * (ll + 1)
s += "#"
for i in range(ll):
if s[i] == "0":
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR VAR STRING VAR BIN_OP NUMBER VAR VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR ... |
You are given a binary string $s$ (recall that a string is binary if each character is either $0$ or $1$).
Let $f(t)$ be the decimal representation of integer $t$ written in binary form (possibly with leading zeroes). For example $f(011) = 3, f(00101) = 5, f(00001) = 1, f(10) = 2, f(000) = 0$ and $f(000100) = 4$.
The... | for _ in range(int(input())):
s = input()
num_zero = 0
ans = 0
length = len(s)
for i in range(length):
if s[i] == "0":
num_zero += 1
else:
act_num = 1
j = i
is_right = True
while j < length and is_right:
if a... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR IF BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER VAR VAR NUMBE... |
You are given a binary string $s$ (recall that a string is binary if each character is either $0$ or $1$).
Let $f(t)$ be the decimal representation of integer $t$ written in binary form (possibly with leading zeroes). For example $f(011) = 3, f(00101) = 5, f(00001) = 1, f(10) = 2, f(000) = 0$ and $f(000100) = 4$.
The... | t = int(input())
for _ in [0] * t:
s = input()
stack = []
zero_count = 0
ans = 0
for c in map(int, s):
new_stack = []
append = new_stack.append
if c:
append((c, zero_count))
ans += 1
zero_count = 0
else:
zero_count += 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR BIN_OP LIST NUMBER VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR VAR IF VAR EXPR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER FOR VAR VAR VAR ASSIGN VAR BIN_OP BIN_... |
You are given a binary string $s$ (recall that a string is binary if each character is either $0$ or $1$).
Let $f(t)$ be the decimal representation of integer $t$ written in binary form (possibly with leading zeroes). For example $f(011) = 3, f(00101) = 5, f(00001) = 1, f(10) = 2, f(000) = 0$ and $f(000100) = 4$.
The... | t = int(input())
for i in range(t):
a = [int(x) for x in list(input())]
n = len(a)
zero = 0
arr = 0
for i in range(n):
if a[i] == 1:
size = 2
num = 1
arr += 1
if i != n - 1:
j = i + 1
if a[j] == 1:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR BI... |
You are given a binary string $s$ (recall that a string is binary if each character is either $0$ or $1$).
Let $f(t)$ be the decimal representation of integer $t$ written in binary form (possibly with leading zeroes). For example $f(011) = 3, f(00101) = 5, f(00001) = 1, f(10) = 2, f(000) = 0$ and $f(000100) = 4$.
The... | def decimal(s, e, k):
a = 0
m = 1
for j in range(e, s - 1, -1):
a += k[j] * m
m *= 2
return a
for _ in range(int(input())):
k = [int(i) for i in input()]
n = len(k)
zer = [0] * n
for i in range(1, n):
if k[i - 1] == 0:
zer[i] = zer[i - 1] + 1
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR VAR VAR VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL V... |
You are given a binary string $s$ (recall that a string is binary if each character is either $0$ or $1$).
Let $f(t)$ be the decimal representation of integer $t$ written in binary form (possibly with leading zeroes). For example $f(011) = 3, f(00101) = 5, f(00001) = 1, f(10) = 2, f(000) = 0$ and $f(000100) = 4$.
The... | import sys
def main():
t = int(sys.stdin.readline().strip())
for _ in range(t):
s = sys.stdin.readline().strip()
c0 = ord("0")
s = [(ord(c) - c0) for c in s]
res = 0
n = len(s)
zeros = 0
for i in range(n):
if s[i] == 0:
zeros ... | IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR N... |
You are given a binary string $s$ (recall that a string is binary if each character is either $0$ or $1$).
Let $f(t)$ be the decimal representation of integer $t$ written in binary form (possibly with leading zeroes). For example $f(011) = 3, f(00101) = 5, f(00001) = 1, f(10) = 2, f(000) = 0$ and $f(000100) = 4$.
The... | a = int(input())
for i in range(a):
s = input()
cnt = 1
ans = []
index = 0
for i in range(1, len(s)):
if s[i] == s[i - 1]:
cnt += 1
else:
ans.append([cnt, s[i - 1], index])
cnt = 1
index = i
ans.append([cnt, s[-1], index])
total... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR LIST VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ... |
You are given a binary string $s$ (recall that a string is binary if each character is either $0$ or $1$).
Let $f(t)$ be the decimal representation of integer $t$ written in binary form (possibly with leading zeroes). For example $f(011) = 3, f(00101) = 5, f(00001) = 1, f(10) = 2, f(000) = 0$ and $f(000100) = 4$.
The... | t = int(input())
ans = []
for _ in range(t):
s = input()
n = len(s)
count = 0
la = []
prev = -1
for i in range(n):
st = []
for j in range(i, min(i + 18, n)):
st.append(s[j])
z = int("".join(st), 2)
if z >= len(st) and st[0] == "1":
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR VAR AS... |
You are given a binary string $s$ (recall that a string is binary if each character is either $0$ or $1$).
Let $f(t)$ be the decimal representation of integer $t$ written in binary form (possibly with leading zeroes). For example $f(011) = 3, f(00101) = 5, f(00001) = 1, f(10) = 2, f(000) = 0$ and $f(000100) = 4$.
The... | def f(l, r):
a = u[l : r + 1]
m = len(a)
m1 = 0
for i in range(m):
m1 += a[i] * 2 ** (m - i - 1)
return m1 == m
for _ in range(int(input())):
s = input()
u = list(map(int, list(s)))
n = len(u)
ans = 0
for a in range(1, min(19, n) + 1):
p = 0
for i in ran... | FUNC_DEF ASSIGN VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR BIN_OP NUMBER BIN_OP BIN_OP VAR VAR NUMBER RETURN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_C... |
You are given a binary string $s$ (recall that a string is binary if each character is either $0$ or $1$).
Let $f(t)$ be the decimal representation of integer $t$ written in binary form (possibly with leading zeroes). For example $f(011) = 3, f(00101) = 5, f(00001) = 1, f(10) = 2, f(000) = 0$ and $f(000100) = 4$.
The... | import sys
input = sys.stdin.readline
def getInt():
return int(input())
def getVars():
return map(int, input().split())
def getList():
return list(map(int, input().split()))
def getStr():
return input().strip()
def addDictList(d, key, val):
if key not in d:
d[key] = []
d[key].... | IMPORT ASSIGN 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 RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR VAR ASSIGN VAR VAR LIST EXPR FUNC_CALL VAR VAR VAR FUNC_DEF IF VAR V... |
You are given a binary string $s$ (recall that a string is binary if each character is either $0$ or $1$).
Let $f(t)$ be the decimal representation of integer $t$ written in binary form (possibly with leading zeroes). For example $f(011) = 3, f(00101) = 5, f(00001) = 1, f(10) = 2, f(000) = 0$ and $f(000100) = 4$.
The... | import sys
D = {}
m = 18
for i in range(1, 1 << m):
D[bin(i)[2:]] = i
for _ in range(int(input())):
S = sys.stdin.readline().rstrip()
s = 0
N = len(S)
ans = 0
for i in range(N):
if S[i] == "1":
for j in range(1, min(m, N - i) + 1):
k = D[S[i : i + j]]
... | IMPORT ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRIN... |
You are given a binary string $s$ (recall that a string is binary if each character is either $0$ or $1$).
Let $f(t)$ be the decimal representation of integer $t$ written in binary form (possibly with leading zeroes). For example $f(011) = 3, f(00101) = 5, f(00001) = 1, f(10) = 2, f(000) = 0$ and $f(000100) = 4$.
The... | ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
si = lambda: input()
msi = lambda: map(int, stdin.readline().split())
lsi = lambda: list(msi())
t = ii()
for _ in range(t):
s = si()
n = len(s)
c = 0
ans = 0
for i in range(n):
if s[i] == "0":
... | 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 ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL ... |
You are given a binary string $s$ (recall that a string is binary if each character is either $0$ or $1$).
Let $f(t)$ be the decimal representation of integer $t$ written in binary form (possibly with leading zeroes). For example $f(011) = 3, f(00101) = 5, f(00001) = 1, f(10) = 2, f(000) = 0$ and $f(000100) = 4$.
The... | t = int(input())
nm = {}
for i in range(1, 200001):
nm[format(i, "b")] = i
while t > 0:
s = input()
sm = [0]
for c in s:
sm.append(sm[-1] + (1 if c == "1" else 0))
ans = 0
for sz in range(1, 20):
for i in range(0, len(s) - sz + 1):
if s[i : i + sz] in nm:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR STRING VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR STRING NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUM... |
You are given a binary string $s$ (recall that a string is binary if each character is either $0$ or $1$).
Let $f(t)$ be the decimal representation of integer $t$ written in binary form (possibly with leading zeroes). For example $f(011) = 3, f(00101) = 5, f(00001) = 1, f(10) = 2, f(000) = 0$ and $f(000100) = 4$.
The... | for _ in range(int(input())):
s = input()
a = [-1] + [i for i, j in enumerate(s) if j == "1"]
ans = 0
for i, v in enumerate(a[1:], 1):
ans += 1
val = 1
for j in range(v + 1, len(s)):
val = (val << 1) + (s[j] == "1")
if val - (j - v + 1) <= v - a[i - 1] - 1... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR VAR VAR FUNC_CALL VAR VAR VAR STRING ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP ... |
Chef was impressed by an array A of N non-negative integers. But, he was asked to solve the following problem in order to get this array.
Given a non-negative integer k, find the number of pairs (i, j) (1 β€ i < j β€ N) such that the following condition holds true:
(A_{i} | A_{j}) + (A_{i} \oplus A_{j}) + (A_{i} \& A_... | for _ in range(int(input())):
n, k = map(int, input().split())
s = [int(i) for i in input().split()]
ans = 0
n1 = max(s)
d = dict()
for i in range(n):
t1 = k - s[i] ^ s[i]
if s[i] in d:
ans += d[s[i]]
if t1 in d:
d[t1] += 1
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 FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR IF VAR VAR VA... |
Chef was impressed by an array A of N non-negative integers. But, he was asked to solve the following problem in order to get this array.
Given a non-negative integer k, find the number of pairs (i, j) (1 β€ i < j β€ N) such that the following condition holds true:
(A_{i} | A_{j}) + (A_{i} \oplus A_{j}) + (A_{i} \& A_... | t = int(input())
while t > 0:
t -= 1
n, k = input().split()
n = int(n)
k = int(k)
a = [int(x) for x in input().split()]
d = {}
c = 0
for i in range(n):
x = a[i]
x = x ^ k - x
if a[i] in d.keys():
c += d[a[i]]
if x in d.keys():
d[x] ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER 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 DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VA... |
Chef was impressed by an array A of N non-negative integers. But, he was asked to solve the following problem in order to get this array.
Given a non-negative integer k, find the number of pairs (i, j) (1 β€ i < j β€ N) such that the following condition holds true:
(A_{i} | A_{j}) + (A_{i} \oplus A_{j}) + (A_{i} \& A_... | t = int(input())
for _ in range(t):
a, b = map(int, input().split())
c = list(map(int, input().split()))
dict_ = {}
ans = 0
for i in range(a):
if c[i] in dict_.keys():
ans += dict_[c[i]]
if b >= c[i]:
dict_1 = b - c[i] ^ c[i]
if dict_1 in dict_.key... | 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 DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR VAR ASSIGN VAR BIN_... |
Chef was impressed by an array A of N non-negative integers. But, he was asked to solve the following problem in order to get this array.
Given a non-negative integer k, find the number of pairs (i, j) (1 β€ i < j β€ N) such that the following condition holds true:
(A_{i} | A_{j}) + (A_{i} \oplus A_{j}) + (A_{i} \& A_... | t = int(input())
for i in range(t):
n, k = list(map(int, input().split()))
d = dict()
a = list(map(int, input().split()))
b = []
for i in range(n):
b.append(k - a[i])
if a[i] in d:
d[a[i]] += 1
else:
d[a[i]] = 1
ans = 0
for i in range(n):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR IF VAR VAR V... |
Chef was impressed by an array A of N non-negative integers. But, he was asked to solve the following problem in order to get this array.
Given a non-negative integer k, find the number of pairs (i, j) (1 β€ i < j β€ N) such that the following condition holds true:
(A_{i} | A_{j}) + (A_{i} \oplus A_{j}) + (A_{i} \& A_... | t = int(input())
for _ in range(t):
n, k = map(int, input().split())
a = list(map(int, input().split()))
memo, count = {}, 0
for i in a:
count += memo.get(i, 0)
memo[k - i ^ i] = memo.get(k - i ^ i, 0) + 1
print(count) | 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 DICT NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP FUNC_CALL VAR BIN_O... |
Chef was impressed by an array A of N non-negative integers. But, he was asked to solve the following problem in order to get this array.
Given a non-negative integer k, find the number of pairs (i, j) (1 β€ i < j β€ N) such that the following condition holds true:
(A_{i} | A_{j}) + (A_{i} \oplus A_{j}) + (A_{i} \& A_... | for _ in range(int(input())):
n, x = map(int, input().split())
a = list(map(int, input().split()))
d = dict()
ans = 0
for i in range(n - 1, -1, -1):
re = x - a[i] ^ a[i]
if re in d.keys():
ans += d[re]
if a[i] in d.keys():
d[a[i]] += 1
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 FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR IF V... |
Chef was impressed by an array A of N non-negative integers. But, he was asked to solve the following problem in order to get this array.
Given a non-negative integer k, find the number of pairs (i, j) (1 β€ i < j β€ N) such that the following condition holds true:
(A_{i} | A_{j}) + (A_{i} \oplus A_{j}) + (A_{i} \& A_... | t = int(input())
for _ in range(t):
n, k = map(int, input().split())
arr = list(map(int, input().split()))
d = {}
ans = 0
for x in arr:
try:
ans += d[x]
except:
pass
if x <= k:
ele = x ^ k - x
try:
d[ele] += 1
... | 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 DICT ASSIGN VAR NUMBER FOR VAR VAR VAR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR... |
Chef was impressed by an array A of N non-negative integers. But, he was asked to solve the following problem in order to get this array.
Given a non-negative integer k, find the number of pairs (i, j) (1 β€ i < j β€ N) such that the following condition holds true:
(A_{i} | A_{j}) + (A_{i} \oplus A_{j}) + (A_{i} \& A_... | t = int(input())
for _ in range(t):
lis = list(map(int, input().split()))
n, k = lis[0], lis[1]
a = list(map(int, input().split()))
count = 0
dic = {}
if n == 1:
print(0)
else:
for i in range(n):
aux = a[i] ^ k - a[i]
if a[i] in dic:
co... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR DICT IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FU... |
Chef was impressed by an array A of N non-negative integers. But, he was asked to solve the following problem in order to get this array.
Given a non-negative integer k, find the number of pairs (i, j) (1 β€ i < j β€ N) such that the following condition holds true:
(A_{i} | A_{j}) + (A_{i} \oplus A_{j}) + (A_{i} \& A_... | for _ in range(int(input())):
n, k = map(int, input().rstrip().split())
l = list(map(int, input().rstrip().split()))
d = dict()
ans = 0
for ele in l:
ans += d.get(ele, 0)
if k >= ele:
x = k - ele ^ ele
d[x] = d.get(x, 0) + 1
print(ans) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VA... |
Chef was impressed by an array A of N non-negative integers. But, he was asked to solve the following problem in order to get this array.
Given a non-negative integer k, find the number of pairs (i, j) (1 β€ i < j β€ N) such that the following condition holds true:
(A_{i} | A_{j}) + (A_{i} \oplus A_{j}) + (A_{i} \& A_... | t = int(input())
for _ in range(t):
n, k = map(int, input().split(" "))
arr = list(map(int, input().split(" ")))
dict_count = {}
for idx in range(n):
if arr[idx] in dict_count:
dict_count[arr[idx]] += 1
else:
dict_count[arr[idx]] = 1
res = 0
for idx 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 STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMB... |
Chef was impressed by an array A of N non-negative integers. But, he was asked to solve the following problem in order to get this array.
Given a non-negative integer k, find the number of pairs (i, j) (1 β€ i < j β€ N) such that the following condition holds true:
(A_{i} | A_{j}) + (A_{i} \oplus A_{j}) + (A_{i} \& A_... | q = int(input())
for _ in range(q):
inp = list(map(int, input().split()))
n = inp[0]
k = inp[1]
a = list(map(int, input().split()))
f = {}
count = 0
for i in range(n):
b_i = k - a[i] ^ a[i]
count += f.get(a[i], 0)
if b_i in f:
f[b_i] += 1
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP... |
Chef was impressed by an array A of N non-negative integers. But, he was asked to solve the following problem in order to get this array.
Given a non-negative integer k, find the number of pairs (i, j) (1 β€ i < j β€ N) such that the following condition holds true:
(A_{i} | A_{j}) + (A_{i} \oplus A_{j}) + (A_{i} \& A_... | T = int(input())
for t in range(1, T + 1):
inp = input().split()
N = int(inp[0])
K = int(inp[1])
A = list(map(int, input().split()))
cnt = 0
freq = {}
for a in A:
if a in freq.keys():
cnt += freq[a]
val = K - a ^ a
if val in freq.keys():
freq[v... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP 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 FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR DICT FOR VAR VAR IF VAR FUNC_CA... |
Chef was impressed by an array A of N non-negative integers. But, he was asked to solve the following problem in order to get this array.
Given a non-negative integer k, find the number of pairs (i, j) (1 β€ i < j β€ N) such that the following condition holds true:
(A_{i} | A_{j}) + (A_{i} \oplus A_{j}) + (A_{i} \& A_... | def xor(a, k):
return k - a ^ a
def ans(arr, k):
d = {}
answer = 0
for y in arr:
if y in d.keys():
answer += d[y]
t = xor(y, k)
if t in d.keys():
d[t] += 1
else:
d[t] = 1
return answer
test_cases = int(input())
while test_cases ... | FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR VAR FUNC_DEF ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR VAR IF VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CA... |
Chef was impressed by an array A of N non-negative integers. But, he was asked to solve the following problem in order to get this array.
Given a non-negative integer k, find the number of pairs (i, j) (1 β€ i < j β€ N) such that the following condition holds true:
(A_{i} | A_{j}) + (A_{i} \oplus A_{j}) + (A_{i} \& A_... | T = int(input())
for i in range(T):
Nk = str(input()).split(" ")
N = int(Nk[0])
k = int(Nk[1])
A = str(input()).split(" ")
dicto = {}
total = 0
for j in range(N):
total = total + dicto.get(int(A[j]), 0)
dicto[k - int(A[j]) ^ int(A[j])] = dicto.get(k - int(A[j]) ^ int(A[j]), 0... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR STRING ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR ... |
Chef was impressed by an array A of N non-negative integers. But, he was asked to solve the following problem in order to get this array.
Given a non-negative integer k, find the number of pairs (i, j) (1 β€ i < j β€ N) such that the following condition holds true:
(A_{i} | A_{j}) + (A_{i} \oplus A_{j}) + (A_{i} \& A_... | for t in range(int(input())):
N, k = map(int, input().split())
A = list(map(int, input().split()))
A.reverse()
count = 0
d = dict()
for i in A:
count += d.get(k - i ^ i, 0)
if i not in d:
d[i] = 1
else:
d[i] += 1
print(count) | 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 EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VAR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR... |
Chef and his friends would like to attend a large New Year's party in Goa. However, their teacher has given them an assignment to complete. Chef asked for your help to complete the assignment quickly so that he can attend the party with complete freedom.
Chef was given an array A = [A_{1}, A_{2}, \ldots, A_{N}] of len... | def func():
n, m, p = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
dicti = {}
for i in B:
dicti[i] = dicti.get(i, 0) + 1
ans = 0
for ai in A:
if ai % p != 0:
modinv = pow(ai, p - 2, p)
b = ai ^ modin... | FUNC_DEF ASSIGN VAR 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 BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF B... |
Chef and his friends would like to attend a large New Year's party in Goa. However, their teacher has given them an assignment to complete. Chef asked for your help to complete the assignment quickly so that he can attend the party with complete freedom.
Chef was given an array A = [A_{1}, A_{2}, \ldots, A_{N}] of len... | for tc in range(int(input())):
ls = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
p = ls[-1]
ct = 0
dis = dict()
for x in b:
dis[x] = 1 if dis.get(x) is None else dis[x] + 1
for x in a:
if x % p:
minv =... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_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 ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR ... |
Chef and his friends would like to attend a large New Year's party in Goa. However, their teacher has given them an assignment to complete. Chef asked for your help to complete the assignment quickly so that he can attend the party with complete freedom.
Chef was given an array A = [A_{1}, A_{2}, \ldots, A_{N}] of len... | from sys import stdin
input = stdin.readline
def answer():
d = dict()
for i in range(m):
d[b[i]] = d.get(b[i], 0) + 1
ans = 0
for i in range(n):
if a[i] % p == 0:
continue
x = pow(a[i], p - 2, p)
ans += d.get(a[i] ^ x, 0)
return ans
for T in range(int... | ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER RETURN VAR ... |
Chef and his friends would like to attend a large New Year's party in Goa. However, their teacher has given them an assignment to complete. Chef asked for your help to complete the assignment quickly so that he can attend the party with complete freedom.
Chef was given an array A = [A_{1}, A_{2}, \ldots, A_{N}] of len... | for _ in range(int(input())):
n, m, p = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xb = [[b[i], i] for i in range(m)]
xb = sorted(xb)
b = [xb[0][0], 1]
for i in range(1, m):
if xb[i][0] == xb[i - 1][0]:
b[-1] += 1
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR 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 VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | t = int(input())
for i in range(t):
a = input()
b = input()
a_ = []
b_ = []
if len(a) > len(b):
c = 0
while len(b) + c != len(a):
b_.append("0")
c += 1
elif len(a) < len(b):
d = 0
while len(a) + d != len(b):
a_.append("0")
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING VAR NUMBER IF FUNC_CALL VAR VAR FUNC_... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | from sys import stdin
t = int(stdin.readline())
while t:
a = stdin.readline().strip()
b = stdin.readline().strip()
if b == "0":
print(0)
else:
la, lb = len(a), len(b)
l = 0
if la > lb:
b = "0" * (la - lb) + b
l = la
else:
a = "... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | t = int(input())
while t > 0:
t -= 1
a = input()
b = input()
k = int(b, 2)
if k == 0:
print(0)
continue
c = ""
if len(a) > len(b):
b = c.zfill(len(a) - len(b)) + b
else:
a = c.zfill(len(b) - len(a)) + a
mx = 1
i = len(a) - 1
while i >= 0:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR STRING IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | def solve(X, Y):
if Y == "0":
return 0
n = max(len(X), len(Y))
c = ""
for i in range(abs(len(X) - len(Y))):
c += "0"
if len(X) < len(Y):
X = c + X
else:
Y = c + Y
ans = 1
for i in range(n - 1, -1, -1):
if X[i] == "1" and Y[i] == "1":
cu... | FUNC_DEF IF VAR STRING RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR STRING IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR V... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | t = int(input())
while t > 0:
s1 = str(input())
s2 = str(input())
t -= 1
if "1" not in s2:
print(0)
else:
if len(s2) < len(s1):
for i in range(abs(len(s2) - len(s1))):
s2 = "0" + s2
else:
for i in range(abs(len(s2) - len(s1))):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF STRING VAR EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | def alt_add(A, B):
C = int(A, 2)
D = int(B, 2)
if D == 0:
return 0
x = C & D
y = C ^ D
p = len(A)
q = len(B)
maxi = q
if p > q:
maxi = p
x = bin(x)[2:].zfill(maxi)
y = bin(y)[2:].zfill(maxi)
maxi = 0
max_till = 0
for i in range(len(y)):
if ... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | T = int(input())
for k in range(T):
a = input()
b = input()
if b == "0":
print("0")
elif a == "0":
print("1")
else:
if len(a) > len(b):
b = "0" * (len(a) - len(b)) + b
else:
a = "0" * (len(b) - len(a)) + a
mx = 1
flag = -1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR STRING EXPR FUNC_CALL VAR STRING IF VAR STRING EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR ASSIGN ... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | def samelength(n, p, ln, lp):
if lp == ln:
return n, p, ln, lp
elif lp > ln:
for _ in range(lp - ln):
n = "0" + n
ln = lp
else:
for _ in range(ln - lp):
p = "0" + p
lp = ln
return n, p, ln, lp
def addb(a, b, c):
if a == b and b == c a... | FUNC_DEF IF VAR VAR RETURN VAR VAR VAR VAR IF VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR VAR RETURN VAR VAR VAR VAR FUNC_DEF IF VAR VAR VAR VAR VAR STRING RETURN STRING STRING IF VAR VAR VAR VAR VA... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | try:
t = int(input())
for _ in range(t):
A = input()
B = input()
fcount = 0
flag = 1
DecimalA = int(A, 2)
DecimalB = int(B, 2)
if DecimalB == 0:
print(0)
continue
if DecimalA == 0 and DecimalB != 0:
print(1)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | t = int(input())
for _ in range(t):
a = input()
b = input()
if "1" not in b:
print(0)
elif "1" not in a:
print(1)
else:
n = max(len(a), len(b))
a = a.zfill(n)
b = b.zfill(n)
count = 1
for i in range(n):
if a[i] == "1" and b[i] == "1... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF STRING VAR EXPR FUNC_CALL VAR NUMBER IF STRING VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | for _ in range(int(input())):
a = input()
b = input()
if b == "0":
print(0)
continue
la = len(a)
lb = len(b)
l = la
if la > lb:
b = "0" * (la - lb) + b
elif la < lb:
a = "0" * (lb - la) + a
l = lb
a = "0" + a
b = "0" + b
ans = 0
cou... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR IF VAR VAR ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP VAR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP BIN_OP STRING BI... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | t = int(input())
for j in range(t):
a = int(input(), 2)
b = int(input(), 2)
i = 0
while b > 0:
u = a ^ b
v = a & b
a = u
b = 2 * v
i += 1
print(i) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VA... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | t = int(input())
for _ in range(t):
A = input()
B = input()
a = int(A, 2)
b = int(B, 2)
A = list(A)
B = list(B)
ans = 0
if len(A) > len(B):
B = B[::-1]
while len(B) != len(A):
B.append("0")
B = B[::-1]
if len(A) < len(B):
A = A[::-1]
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUM... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | T = int(input())
for i in range(T):
A = input()
B = input()
if B == "0":
print("0")
else:
if len(A) > len(B):
B = B.zfill(len(A))
else:
A = A.zfill(len(B))
ans = 1
for i in range(len(A) - 1, -1, -1):
if A[i] == "1" and B[i] == "... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR STRING EXPR FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR ... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | from sys import stdin, stdout
__author__ = "Ronald Kaiser"
__email__ = "raios dot catodicos at gmail dot com"
rline = lambda: stdin.readline().strip()
def solve():
global A, B
if not "1" in B:
return 0
diff = len(A) - len(B)
if diff > 0:
B = "0" * diff + B
else:
A = "0" * ... | ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF STRING VAR RETURN NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING VAR VAR ASSIGN VAR BIN_OP BIN_OP STRING VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | t = int(input())
for i in range(t):
first_string = input()
second_string = input()
if int(second_string, 2) == 0:
print(0)
elif int(first_string, 2) == 0:
print(1)
else:
n1 = len(first_string)
n2 = len(second_string)
if n1 > n2:
temp_string = ""
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR STR... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | for _ in range(int(input())):
a = "0" + input()
b = "0" + input()
n = len(a)
m = len(b)
if b == "00":
print(0)
continue
elif a == "00":
print(1)
continue
if n < m:
a = "0" * (m - n) + a
elif n > m:
b = "0" * (n - m) + b
m = 0
for i ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP STRING FUNC_CALL VAR ASSIGN VAR BIN_OP STRING FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR STRING EXPR FUNC_CALL VAR NUMBER IF VAR STRING EXPR FUNC_CALL VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP VAR ... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | t = int(input())
while t > 0:
a = input()
b = input()
l1 = len(a)
l2 = len(b)
l = 0
if l1 > l2:
l += l1
else:
l += l2
a = a.zfill(l)
b = b.zfill(l)
cnt = 0
k = 0
for i in range(0, l):
if a[i] == "1" and b[i] == "1":
cnt += 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | def test(a, b):
if int(b) == 0:
return 0
l = max(len(a), len(b))
st_a = len(a)
st_b = len(b)
s = "0" * 10**5
if st_a > st_b:
b = s[: st_a - st_b] + b
else:
a = s[: st_b - st_a] + a
a = a[::-1]
b = b[::-1]
i = 0
ans = 1
while i < l:
if a[i] ... | FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP STRING BIN_OP NUMBER NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR ... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | t = int(input())
for _ in range(t):
a = input()
b = input()
cnt = 0
a = a[::-1]
b = b[::-1]
if b == "0":
print("0\n")
elif a == "0":
print("1\n")
else:
while len(a) < len(b):
a = a + "0"
while len(b) < len(a):
b = b + "0"
a ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR STRING EXPR FUNC_CALL VAR STRING IF VAR STRING EXPR FUNC_CALL VAR STRING WHILE FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | def add(A, B):
cnt = 0
while B > 0:
cnt += 1
U = A ^ B
B = (A & B) << 1
A = U
print(cnt)
def newfun(A, B):
if len(A) > len(B):
diff = len(A) - len(B)
B = "0" * diff + B
elif len(B) > len(A):
diff = len(B) - len(A)
A = "0" * diff + A
... | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR FUNC_DEF IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP STRING VAR VAR IF FUNC_CALL VAR VA... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | t = int(input())
ans = []
for _ in range(t):
temp1 = input()
temp2 = input()
if len(temp1) <= 50000 and len(temp2) <= 50000:
count = 0
a = int(temp1, 2)
b = int(temp2, 2)
while b > 0:
u = a ^ b
v = a & b
a = u
b = v << 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASS... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | t = int(input())
while t != 0:
A = input()
B = input()
C = int(A, 2)
D = int(B, 2)
x = C & D
y = C ^ D
p = len(A)
q = len(B)
maxi = 0
if p > q:
maxi = p
else:
maxi = q
x = bin(x)[2:].zfill(maxi)
y = bin(y)[2:].zfill(maxi)
maxi = 0
max_till = 0
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR VAR ASS... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | def binaryToDecimal(binary):
binary1 = binary
decimal, i, n = 0, 0, 0
while binary != 0:
dec = binary % 10
decimal = decimal + dec * pow(2, i)
binary = binary // 10
i += 1
return decimal
def add(a, b):
count = 0
u = 0
v = 0
while b > 0:
u = a ^ b... | FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | t = int(input())
while t > 0:
t -= 1
a = input().strip()
b = input().strip()
if len(b) == 1 and b[0] == "0":
print(0)
continue
if len(a) > len(b):
b = "0" * (len(a) - len(b)) + b
else:
a = "0" * (len(b) - len(a)) + a
max_l = 0
for i in range(len(a)):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER VAR NUMBER STRING EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR V... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | def fn2(a, b):
print("-" * 30)
ct = 0
while b > 0:
ct += 1
lenMax = max(len(bin(a)[2:]), len(bin(b)[2:]))
lena = len(bin(a)[2:])
lenb = len(bin(b)[2:])
print(
"0" * (lenMax - lena) + bin(a)[2:],
"\n" + "0" * (lenMax - lenb) + bin(b)[2:],
... | FUNC_DEF EXPR FUNC_CALL VAR BIN_OP STRING NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | for i in range(int(input())):
C = "0"
A = input()
B = input()
if len(A) < len(B):
B = C + B
C *= len(B) - len(A)
A = C + A
elif len(B) < len(A):
A = C + A
C *= len(A) - len(B)
B = C + B
else:
A = C + A
B = C + B
a = 0
dat = ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | for t in range(int(input())):
a, b = input(), input()
if int(b, 2) == 0:
print(0)
continue
l = max(len(a), len(b)) + 1
a, b = a.rjust(l, "0"), b.rjust(l, "0")
p, ans, c = "0", 0, 0
for i in range(1, l + 1):
if p == "1":
c += 1
ans = max(ans, c)
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR STRING FUNC_CALL VAR VAR STRING ASSIGN VAR VAR VAR STRING ... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | def add(A, B):
cnt = 0
while B > 0:
cnt += 1
U = A ^ B
V = A & B
A = U
B = V * 2
return cnt
for _ in range(int(input().strip())):
print(add(int(input().strip(), 2), int(input().strip(), 2))) | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR NUMBER FUNC_CALL VAR FUNC_C... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | tc = int(input())
for i in range(tc):
a = input()
b = input()
l = 0
l1 = len(a)
l2 = len(b)
if l1 > l2:
l = l1
else:
l = l2
a = a.zfill(l)
b = b.zfill(l)
temp = int(b, 2)
if temp == 0:
print(0)
else:
maxc = 0
count = 0
for i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR N... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | for _ in range(int(input())):
A, B, count, res, flag = str(input()), str(input()), 0, 1, 0
if int(B) == 0:
print(0)
else:
A, B = A.zfill(max(len(A), len(B))), B.zfill(max(len(A), len(B)))
for i, j in zip(A[::-1], B[::-1]):
if i == j:
if i == "1":
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | TESTCASES = int(input())
for i in range(0, TESTCASES):
A = input().strip()[::-1]
B = input().strip()[::-1]
if "1" not in B:
print("0")
continue
while len(A) < len(B):
A += "0"
while len(B) < len(A):
B += "0"
LL = 1
CC = False
JJ = 0
for i in range(0, l... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR NUMBER IF STRING VAR EXPR FUNC_CALL VAR STRING WHILE FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR STRING WHILE FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR STRING ASSIGN VAR NUMBER ... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | turn = int(input())
for _ in range(turn):
flag = 0
c = 0
max = -1
a = input()
b = input()
l = len(a) if len(a) > len(b) else len(b)
a = a.zfill(l)
b = b.zfill(l)
if int(b, 2) == 0:
print(0)
continue
m = len(a) - len(b)
for i in range(len(a), 0, -1):
if... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CA... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | def main(debug=False):
for _ in range(int(input())):
a = input().strip()
b = input().strip()
a = a[::-1]
b = b[::-1]
while len(a) < len(b):
a += "0"
while len(b) < len(a):
b += "0"
if debug:
print(a, b)
carry, ans, c... | FUNC_DEF NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER WHILE FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR STRING WHILE FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR STRING IF VAR EXPR FUNC_CALL VAR VAR VAR ... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | for _ in range(int(input())):
a = "0b" + input()
b = "0b" + input()
a = int(a, 2)
b = int(b, 2)
cnt = 0
while b:
U = a ^ b
V = a & b
a = U
b = V * 2
cnt += 1
print(cnt) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP STRING FUNC_CALL VAR ASSIGN VAR BIN_OP STRING FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUM... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | from sys import stdin, stdout
for i in range(int(stdin.readline())):
stra = int(stdin.readline(), 2)
strb = int(stdin.readline(), 2)
count = 0
while strb != 0:
stra, strb = [stra ^ strb, (stra & strb) * 2]
count += 1
print(count) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR VAR LIST BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | t = int(input())
for i in range(t):
A = input()
B = input()
arr = []
lenA = len(A)
lenB = len(B)
if lenA < lenB:
A = (lenB - lenA) * "0" + A
else:
B = (lenA - lenB) * "0" + B
for j in range(max(lenA, lenB)):
arr.append(int(A[j]) + int(B[j]))
j = len(arr) - 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR STRING VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR STRING VAR FOR VAR FUNC_CALL ... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | t = int(input())
while t > 0:
t -= 1
a = input().strip()
b = input().strip()
a = a[::-1]
b = b[::-1]
if b == "0":
value = 0
else:
while len(a) < len(b):
a += "0"
while len(b) < len(a):
b += "0"
carry = 0
cnt = 0
value = ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR STRING ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR STRING WHILE FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR STRING A... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | for _ in range(int(input())):
a = input()
b = input()
x = int(a, 2)
y = int(b, 2)
if y == 0:
print(0)
elif x == 0 and y != 0:
print(1)
else:
ans = [0]
count = 0
f = 0
if len(a) + len(b) > 100000:
if len(a) < len(b):
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBE... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | def addition(a, b, a1, b1):
c = 0
while b > 0:
u = a ^ b
v = a & b
a = u
b = v * 2
c += 1
if c > 100:
sol(a1, b1)
return
print(c)
def binaryToDecimal(n):
return int(n, 2)
def sol(a, b):
a = list(a)
b = list(b)
if len... | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR RETURN EXPR FUNC_CALL VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CAL... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | t = int(input())
for j in range(t):
a = input()
b = input()
n = len(a)
n1 = len(b)
A = int(a, 2)
B = int(b, 2)
c = 0
max = 0
if n - 1 > 500 or n1 - 1 > 500:
s = "0" * abs(n - n1)
if n > n1:
b = s + b
else:
a = s + a
a1 = a[::-1]... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR ... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | t = int(input())
for i in range(t):
a1 = input()
b1 = input()
val1 = 0
val2 = 0
u = 0
v = 0
def gen(m):
val1 = int(a1, 2)
val2 = int(b1, 2)
c = 0
while m > 0:
c += 1
u = val1 ^ m
v = val1 & m
val1 = u
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER ASSIGN... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | def ones(n):
c = 0
while n:
n = n & n - 1
c += 1
if c == 1:
return True
return False
def cc(a, b):
a = bin(a)[2:]
b = bin(b)[2:]
sa = len(a)
sb = len(b)
ind = -1
qq = abs(sa - sb)
y = 0
if qq == 0:
ind = 0
qq += 1
y += 1
... | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP V... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | def make_eqlength(A, B):
if len(A) < len(B):
while len(A) < len(B):
A = "0" + A
else:
while len(B) < len(A):
B = "0" + B
return A, B
t = int(input())
while t > 0:
A = input()
B = input()
count = 0
res = 1
if int(B) == 0:
print(0)
... | FUNC_DEF IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR WHILE FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP STRING VAR WHILE FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP STRING VAR RETURN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VA... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | t = input()
for _ in range(int(t)):
a = input()
b = input()
carry = 0
car_range = 0
car_start = -1
if int(b) == 0:
print(0)
continue
c = a if len(a) > len(b) else b
o = b if len(a) > len(b) else a
c = c[::-1]
o = o[::-1]
for i, x in enumerate(c):
y = 0... | ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | T = int(input())
while T:
A = input()
B = input()
if B == "0":
print(0)
else:
if len(A) < len(B):
add = ""
for i in range(len(B) - len(A)):
add += "0"
A = add + A
elif len(B) < len(A):
add = ""
for i in r... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR STRING EXPR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR STRING ASSIGN VAR BIN_OP VAR VAR IF FUNC_CALL VAR VAR F... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | T = int(input())
for i in range(T):
a = input()
b = input()
al = len(a)
bl = len(b)
if al > 450 and bl > 450:
x = max(al, bl)
if al > bl:
for i in range(al - bl):
b = "0" + b[:]
elif al < bl:
for i in range(bl - al):
a =... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP STRING VAR IF VAR VAR F... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | def add(a, b):
count = 0
u = 0
v = 0
while b > 0:
u = a ^ b
v = a & b
a = u
b = v * 2
count = count + 1
return count
def bruteforce(a, b):
anum = int(a, 2)
bnum = int(b, 2)
print(add(anum, bnum))
t = int(input())
while t > 0:
t = t - 1
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | for r in range(int(input())):
x = input()
y = input()
m = 0
na = len(x)
nb = len(y)
if na - 1 > 500 or nb - 1 > 500:
if na > nb:
y = (na - nb) * "0" + y
elif nb > na:
x = (nb - na) * "0" + x
f = 0
s = 0
for i in range(len(x) - 1, -1... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER IF VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR STRING VAR IF VAR VAR ASSIGN VAR BIN_OP ... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | def loji_hogya(a, b):
count = 0
while b > 0:
u = a ^ b
v = a & b
a = u
b = v * 2
count = count + 1
return count
n = int(input())
while n != 0:
a = input()
b = input()
a = int(a, 2)
b = int(b, 2)
print(loji_hogya(a, b))
n = n - 1 | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBE... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | t = int(input())
for i in range(t):
a = list(input())
b = list(input())
c = []
x, y = len(a), len(b)
if x > y:
c[: x - y + 1] = ["0"] * (x - y)
c[x - y + 1 :] = b[:]
b = c
z = x
else:
c[: y - x + 1] = ["0"] * (y - x)
c[y - x + 1 :] = a[:]
a... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP LIST STRING BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP ... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | for _ in range(0, int(input())):
a = input()
b = input()
def f(a, b):
y = 0
while b > 0:
u = a ^ b
v = a & b
a = u
b = v * 2
y += 1
return y
print(f(int(a, 2), int(b, 2))) | FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR ... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | for _ in range(int(input())):
a = input()
b = input()
m = len(a)
n = len(b)
if m > n:
for i in range(m - n):
b = "0" + b
elif n > m:
for i in range(n - m):
a = "0" + a
m = n
l = [(-1) for i in range(m)]
for i in range(m - 1, -1, -1):
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP STRING VAR IF VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP STRING VAR ASSIGN V... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | for i in range(0, int(input())):
m = input()
n = input()
if n == "0":
print(0)
elif n != "0":
if len(m) > len(n):
diff = len(m) - len(n)
for j in range(diff):
n = "0" + n
elif len(n) > len(m):
diff = len(n) - len(m)
... | FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR STRING EXPR FUNC_CALL VAR NUMBER IF VAR STRING IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP STRING VAR IF FUNC_CAL... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | t = int(input())
for i in range(t):
a1 = input()
b1 = input()
val1 = 0
val2 = 0
c = 0
u = 0
v = 0
val1 = int(a1, 2)
val2 = int(b1, 2)
while val2 > 0:
c += 1
u = val1 ^ val2
v = val1 & val2
val1 = u
val2 = 2 * v
print(c) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER WHILE VAR NUMBER VAR NUMBER ASSIGN VAR BIN_... |
Recently, Chef studied the binary numeral system and noticed that it is extremely simple to perform bitwise operations like AND, XOR or bit shift on non-negative integers, while it is much more complicated to perform arithmetic operations (e.g. addition, multiplication or division).
After playing with binary operations... | t = int(input())
for _ in range(t):
a = input()
b = input()
al = []
suma = 0
bl = []
sumb = 0
for i in range(len(a)):
c = int(a[len(a) - i - 1])
al.append(c)
suma += c
for i in range(len(b)):
c = int(b[len(b) - i - 1])
bl.append(c)
sumb += ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VA... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.