description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
It is a complicated version of problem F1. The difference between them is the constraints (F1: $k \le 2$, F2: $k \le 10$).
You are given an integer $n$. Find the minimum integer $x$ such that $x \ge n$ and the number $x$ is $k$-beautiful.
A number is called $k$-beautiful if its decimal representation having no leadin... | def brute(n, k):
for i in range(int(n), 10 ** len(n)):
if len(set(str(i))) <= k:
return i
def strange(n, k):
if len(set(n)) <= k:
return int(n)
str_n = n
n = list(map(int, list(n)))
minn = float("inf")
for i in range(len(n) - 1, -1, -1):
rp = len(n) - 1 - i
... | FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP NUMBER FUNC_CALL VAR VAR IF FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR RETURN VAR FUNC_DEF IF FUNC_CALL VAR FUNC_CALL VAR VAR VAR RETURN FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR S... |
It is a complicated version of problem F1. The difference between them is the constraints (F1: $k \le 2$, F2: $k \le 10$).
You are given an integer $n$. Find the minimum integer $x$ such that $x \ge n$ and the number $x$ is $k$-beautiful.
A number is called $k$-beautiful if its decimal representation having no leadin... | l = len
_, *t = open(0)
for p in t:
x, k = p.split()
k = int(k)
n = x
while l(set(x)) > k:
x = str(int(x) + 1).strip("0")
print(x + (l(n) - l(x)) * min(x + "0" * (l(set(x)) < k))) | ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR NUMBER FOR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR WHILE FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER STRING EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP FUNC_CALL VAR VAR FUNC_C... |
It is a complicated version of problem F1. The difference between them is the constraints (F1: $k \le 2$, F2: $k \le 10$).
You are given an integer $n$. Find the minimum integer $x$ such that $x \ge n$ and the number $x$ is $k$-beautiful.
A number is called $k$-beautiful if its decimal representation having no leadin... | def one(n: str, lili: dict):
sel = n[0]
def have_greater_in_lili_or_sel(digit: str) -> bool:
for li, exists in lili.items():
if exists and li > digit:
return True
return sel > digit
for digit in n[1:]:
if have_greater_in_lili_or_sel(digit):
b... | FUNC_DEF VAR VAR ASSIGN VAR VAR NUMBER FUNC_DEF VAR FOR VAR VAR FUNC_CALL VAR IF VAR VAR VAR RETURN NUMBER RETURN VAR VAR VAR FOR VAR VAR NUMBER IF FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR ASSIGN VAR STRING NUMBER ASSIGN VAR VAR NUMBER F... |
It is a complicated version of problem F1. The difference between them is the constraints (F1: $k \le 2$, F2: $k \le 10$).
You are given an integer $n$. Find the minimum integer $x$ such that $x \ge n$ and the number $x$ is $k$-beautiful.
A number is called $k$-beautiful if its decimal representation having no leadin... | def int_(l):
return int("".join(str(kk) for kk in l))
def f(n, k):
if k == 1:
fdig = n[0]
ff = int_([fdig] * len(n))
nn = int_(n)
if ff >= nn:
return ff
else:
return int_([fdig + 1] * len(n))
digs = set()
ii = -1
for i in range(len(n)... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR FUNC_DEF IF VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP LIST VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR RETURN VAR RETURN FUNC_CALL VAR BIN_OP LIST BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VA... |
It is a complicated version of problem F1. The difference between them is the constraints (F1: $k \le 2$, F2: $k \le 10$).
You are given an integer $n$. Find the minimum integer $x$ such that $x \ge n$ and the number $x$ is $k$-beautiful.
A number is called $k$-beautiful if its decimal representation having no leadin... | import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
n, k = input()[:-1].split()
k = int(k)
ni = int(n)
t = ""
ans = 10**18
for i in range(len(n)):
for j in range(1, 10):
c = len(set(t + str(int(n[i]) + j)))
if c > k:
continue... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASS... |
It is a complicated version of problem F1. The difference between them is the constraints (F1: $k \le 2$, F2: $k \le 10$).
You are given an integer $n$. Find the minimum integer $x$ such that $x \ge n$ and the number $x$ is $k$-beautiful.
A number is called $k$-beautiful if its decimal representation having no leadin... | def _measure_k(x):
return len(set(str(x)))
tests_n = int(input())
for i_test in range(tests_n):
n, k = map(int, input().split())
prefix = n
while _measure_k(prefix) > k:
if prefix % 10 == 0:
prefix //= 10
else:
prefix += 1
prefix = str(prefix)
tail_digit... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR 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 VAR WHILE FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUN... |
It is a complicated version of problem F1. The difference between them is the constraints (F1: $k \le 2$, F2: $k \le 10$).
You are given an integer $n$. Find the minimum integer $x$ such that $x \ge n$ and the number $x$ is $k$-beautiful.
A number is called $k$-beautiful if its decimal representation having no leadin... | for i in range(int(input())):
n, k, x, tt = map(int, input().split() * 2)
while len(set(str(x))) > k:
x = x // 10 if not x % 10 else x + 1
print(
str(x)
+ ("0" if len(set(str(x))) < k else min(str(x))) * (len(str(n)) - len(str(x)))
) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL FUNC_CALL VAR NUMBER WHILE FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR FUNC_... |
It is a complicated version of problem F1. The difference between them is the constraints (F1: $k \le 2$, F2: $k \le 10$).
You are given an integer $n$. Find the minimum integer $x$ such that $x \ge n$ and the number $x$ is $k$-beautiful.
A number is called $k$-beautiful if its decimal representation having no leadin... | T = int(input())
for t in range(T):
n, k = map(int, input().split())
s = str(n)
if k == 1:
t = s[0] * len(s)
if t >= s:
print(t)
else:
t = chr(ord(s[0]) + 1) * len(s)
print(t)
else:
cur, cnt = s[0], 0
ans = ""
ans += s[0... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER FUN... |
It is a complicated version of problem F1. The difference between them is the constraints (F1: $k \le 2$, F2: $k \le 10$).
You are given an integer $n$. Find the minimum integer $x$ such that $x \ge n$ and the number $x$ is $k$-beautiful.
A number is called $k$-beautiful if its decimal representation having no leadin... | import sys
input = sys.stdin.readline
t = int(input())
for tests in range(t):
n, k = map(int, input().split())
S = str(n)
x = ""
ANS = int(str(min(9, int(S[0]) + 1)) * len(S))
for i in range(len(S)):
x += S[i]
if len(set(x)) > k:
break
if i == len(S) - 1:
... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER FUNC_CALL VAR VAR FOR V... |
It is a complicated version of problem F1. The difference between them is the constraints (F1: $k \le 2$, F2: $k \le 10$).
You are given an integer $n$. Find the minimum integer $x$ such that $x \ge n$ and the number $x$ is $k$-beautiful.
A number is called $k$-beautiful if its decimal representation having no leadin... | def upList(s, i):
left = s[:i]
right = s[i:]
left = list(str(int("".join(left)) + 1))
return left + right
def jg(x, val):
y = set(i for i in x if i >= val)
if len(y) == 0:
return None
return min(y)
for _ in range(int(input())):
n, k = map(int, input().split())
s = list(st... | FUNC_DEF ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR FUNC_CALL STRING VAR NUMBER RETURN BIN_OP VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER RETURN NONE RETURN FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CAL... |
This is an easier version of the next problem. The difference is only in constraints.
You are given a rectangular $n \times m$ matrix $a$. In one move you can choose any column and cyclically shift elements in this column. You can perform this operation as many times as you want (possibly zero). You can perform this o... | t = int(input())
def maxsa(A):
ans = 0
for i in range(n):
cur_maxx = 0
for j in range(4):
cur_maxx = max(cur_maxx, A[j][i])
ans += cur_maxx
return ans
def fu(A):
answer = 0
for j in range(n):
A[0] = A[0][1:] + A[0][:1]
for i in range(n):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER BIN_OP VAR NUMBER NUMBER VAR NUMBER NUMBER FOR VAR... |
This is an easier version of the next problem. The difference is only in constraints.
You are given a rectangular $n \times m$ matrix $a$. In one move you can choose any column and cyclically shift elements in this column. You can perform this operation as many times as you want (possibly zero). You can perform this o... | import sys
input = sys.stdin.readline
t = int(input())
for testcases in range(t):
n, m = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(n)]
B = []
for j in range(m):
B.append([A[i][j] for i in range(n)])
B.sort(key=lambda x: max(x), reverse=True)
B =... | IMPORT ASSIGN VAR VAR 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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR ... |
This is an easier version of the next problem. The difference is only in constraints.
You are given a rectangular $n \times m$ matrix $a$. In one move you can choose any column and cyclically shift elements in this column. You can perform this operation as many times as you want (possibly zero). You can perform this o... | from sys import stdin
def f(lst, num):
new = lst[num:] + lst[:num]
return new
t = int(stdin.readline())
for i in range(t):
row, col = tuple(int(x) for x in stdin.readline().split())
lst = list([int(x)] for x in stdin.readline().split())
for j in range(row - 1):
line = tuple(int(x) for x ... | FUNC_DEF ASSIGN VAR BIN_OP VAR VAR VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR LIST FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR... |
This is an easier version of the next problem. The difference is only in constraints.
You are given a rectangular $n \times m$ matrix $a$. In one move you can choose any column and cyclically shift elements in this column. You can perform this operation as many times as you want (possibly zero). You can perform this o... | q = int(input())
for rquer in range(q):
c, r = list(map(int, input().split()))
matt = [list(map(int, input().split())) for i in range(c)]
mat = [[matt[i][j] for i in range(c)] for j in range(r)]
for i in range(r):
mat[i].append(max(mat[i]))
mat[i].reverse()
mat.sort()
mat.reverse... | 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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EX... |
This is an easier version of the next problem. The difference is only in constraints.
You are given a rectangular $n \times m$ matrix $a$. In one move you can choose any column and cyclically shift elements in this column. You can perform this operation as many times as you want (possibly zero). You can perform this o... | t = int(input())
for i in range(t):
n, m = [int(item) for item in input().split()]
mat = []
col = [[] for _ in range(m)]
for j in range(n):
line = [int(item) for item in input().split()]
for k, item in enumerate(line):
col[k].append(item)
mat.append(line)
colmax =... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ... |
This is an easier version of the next problem. The difference is only in constraints.
You are given a rectangular $n \times m$ matrix $a$. In one move you can choose any column and cyclically shift elements in this column. You can perform this operation as many times as you want (possibly zero). You can perform this o... | rnd_mod = 1234567890133
rnd_x = 987654321098
def rnd():
nonlocal rnd_x
rnd_x = rnd_x**2 % rnd_mod
return (rnd_x >> 5) % (1 << 20)
def randrange(a):
return rnd() % a
T = int(input())
for _ in range(T):
N, M = list(map(int, input().split()))
X = []
for __ in range(N):
X.append([i... | ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR RETURN BIN_OP BIN_OP VAR NUMBER BIN_OP NUMBER NUMBER FUNC_DEF RETURN BIN_OP FUNC_CALL VAR VAR 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 ASSIG... |
This is an easier version of the next problem. The difference is only in constraints.
You are given a rectangular $n \times m$ matrix $a$. In one move you can choose any column and cyclically shift elements in this column. You can perform this operation as many times as you want (possibly zero). You can perform this o... | for _ in range(int(input())):
N, M = map(int, input().split())
X = [[int(a) for a in input().split()] for _ in range(N)]
Y = [[X[i][j] for i in range(N)] for j in range(M)]
ma = 0
dp = [([0] * (1 << N)) for _ in range(M + 1)]
for j in range(M):
for mask in range(1 << N):
mask... | 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 VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP NUMBER VAR V... |
This is an easier version of the next problem. The difference is only in constraints.
You are given a rectangular $n \times m$ matrix $a$. In one move you can choose any column and cyclically shift elements in this column. You can perform this operation as many times as you want (possibly zero). You can perform this o... | def solve(matrix, col, N, M):
if col == M:
ans = 0
for row in matrix:
if len(row) == 1:
ans += row[0]
else:
ans += max(*row)
return ans
if N == 1:
return solve(matrix, col + 1, N, M)
ans = solve(matrix, col + 1, N, M)
... | FUNC_DEF IF VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR VAR NUMBER VAR FUNC_CALL VAR VAR RETURN VAR IF VAR NUMBER RETURN FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER VAR FOR VAR ... |
This is an easier version of the next problem. The difference is only in constraints.
You are given a rectangular $n \times m$ matrix $a$. In one move you can choose any column and cyclically shift elements in this column. You can perform this operation as many times as you want (possibly zero). You can perform this o... | def main():
t = int(input())
for _ in range(t):
n, m = map(int, input().split())
l = []
board = []
for i in range(n):
li = list(map(int, input().split()))
board.append(li)
for j in range(m):
l.append((li[j], j))
l.sort(k... | FUNC_DEF 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 VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL ... |
This is an easier version of the next problem. The difference is only in constraints.
You are given a rectangular $n \times m$ matrix $a$. In one move you can choose any column and cyclically shift elements in this column. You can perform this operation as many times as you want (possibly zero). You can perform this o... | for _ in range(int(input())):
n, m = map(int, input().split())
a = [[int(x) for x in input().split()] for j in range(n)]
x = [[a[i][j] for i in range(n)] for j in range(m)]
x.sort(key=lambda xx: -max(xx))
dp = [[(0) for i in range(1 << n)] for j in range(m + 1)]
an = 0
for i in range(m):
... | 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 VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CAL... |
Igor is in 11th grade. Tomorrow he will have to write an informatics test by the strictest teacher in the school, Pavel Denisovich.
Igor knows how the test will be conducted: first of all, the teacher will give each student two positive integers $a$ and $b$ ($a < b$). After that, the student can apply any of the follo... | for _ in range(int(input())):
x, y = map(int, input().split())
c, d = x, y
a = 0
b = 0
while x != y:
if x | y == y:
a += 1
break
a += 1
x += 1
while c != d:
if c | d == d:
b += 1
break
b += 1
d += 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 VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER WHILE VAR VAR IF BIN_OP VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL V... |
Igor is in 11th grade. Tomorrow he will have to write an informatics test by the strictest teacher in the school, Pavel Denisovich.
Igor knows how the test will be conducted: first of all, the teacher will give each student two positive integers $a$ and $b$ ($a < b$). After that, the student can apply any of the follo... | def solve():
a, b = map(int, input().split())
if abs(a - b) == 1 or a | b == b:
print(1)
return
store_a = a
ans = min(abs(a - b), abs((a | b) - b) + 1)
count = 0
while a <= b:
count += 1
temp = abs((a | b) - b) + count
if temp < ans:
ans = temp... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR BIN_OP VAR VAR NUMBER BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMB... |
Igor is in 11th grade. Tomorrow he will have to write an informatics test by the strictest teacher in the school, Pavel Denisovich.
Igor knows how the test will be conducted: first of all, the teacher will give each student two positive integers $a$ and $b$ ($a < b$). After that, the student can apply any of the follo... | def s(a, b):
c, d = a, b
ans1 = ans2 = 1
ans3 = b - a
while a | b != b:
a += 1
ans1 += 1
while c | d != d:
d += 1
ans2 += 1
print(min(ans1, ans2, ans3))
for _ in range(int(input())):
a, b = map(int, input().split())
s(a, b) | FUNC_DEF ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR WHILE BIN_OP VAR VAR VAR VAR NUMBER VAR NUMBER WHILE BIN_OP VAR VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CAL... |
Igor is in 11th grade. Tomorrow he will have to write an informatics test by the strictest teacher in the school, Pavel Denisovich.
Igor knows how the test will be conducted: first of all, the teacher will give each student two positive integers $a$ and $b$ ($a < b$). After that, the student can apply any of the follo... | import sys
def f(a, b):
if a == b:
return 0
if a | b == b:
return 1
for i in range(29, -1, -1):
if b >> i & 1 == 0 and a >> i & 1 == 1:
for j in range(i + 1, 30):
if b >> j & 1 == 1 and a >> j & 1 == 0:
x = (a | (1 << j) - 1) + 1
... | IMPORT FUNC_DEF IF VAR VAR RETURN NUMBER IF BIN_OP VAR VAR VAR RETURN NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER BIN_OP BIN_OP VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASS... |
Igor is in 11th grade. Tomorrow he will have to write an informatics test by the strictest teacher in the school, Pavel Denisovich.
Igor knows how the test will be conducted: first of all, the teacher will give each student two positive integers $a$ and $b$ ($a < b$). After that, the student can apply any of the follo... | def main2():
def gen():
r = 1
while True:
r += 1
l = 1
while l < r:
yield l, r
l += 1
for i, x in enumerate(gen()):
if i > 100:
break
print(i + 1, x)
quit()
for _ in range(int(input())):
a... | FUNC_DEF FUNC_DEF ASSIGN VAR NUMBER WHILE NUMBER VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR EXPR VAR VAR VAR NUMBER FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CA... |
Igor is in 11th grade. Tomorrow he will have to write an informatics test by the strictest teacher in the school, Pavel Denisovich.
Igor knows how the test will be conducted: first of all, the teacher will give each student two positive integers $a$ and $b$ ($a < b$). After that, the student can apply any of the follo... | for _ in range(int(input())):
a, b = map(int, input().split())
if a | b == b:
print(1)
else:
n1 = b - a
c = 1
b1 = b
while a | b != b:
b = b + 1
c = c + 1
c1 = 1
while a | b1 != b1:
a = a + 1
c1 = c1 + 1
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE... |
Igor is in 11th grade. Tomorrow he will have to write an informatics test by the strictest teacher in the school, Pavel Denisovich.
Igor knows how the test will be conducted: first of all, the teacher will give each student two positive integers $a$ and $b$ ($a < b$). After that, the student can apply any of the follo... | for _ in range(int(input())):
a, b = map(int, input().split(" "))
ans = b - a
for i in range(b):
if b == b | i:
ans = min(ans, 1 + abs(i - a))
print(ans) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP NUMBER FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR |
Igor is in 11th grade. Tomorrow he will have to write an informatics test by the strictest teacher in the school, Pavel Denisovich.
Igor knows how the test will be conducted: first of all, the teacher will give each student two positive integers $a$ and $b$ ($a < b$). After that, the student can apply any of the follo... | t = int(input())
for i in range(t):
q = input().split(" ")
a = int(q[0])
b = int(q[1])
k1 = 0
while a <= b:
if b == a:
break
if b == a | b:
k1 += 1
break
else:
k1 += 1
a += 1
a = int(q[0])
b = int(q[1])
k... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR IF VAR BIN_OP VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN ... |
Igor is in 11th grade. Tomorrow he will have to write an informatics test by the strictest teacher in the school, Pavel Denisovich.
Igor knows how the test will be conducted: first of all, the teacher will give each student two positive integers $a$ and $b$ ($a < b$). After that, the student can apply any of the follo... | import sys
input = sys.stdin.readline
t = int(input().strip())
for _ in range(t):
a, b = map(int, input().split())
ret = b - a
tmp = a
while tmp | b != b:
tmp += 1
ret = min(ret, 1 + tmp - a)
tmp = b
while a | tmp != tmp:
tmp += 1
ret = min(ret, 1 + tmp - b)
print(re... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR WHILE BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP NUMBER VAR VAR ASSIGN VAR VAR WHILE BIN_OP VAR... |
Igor is in 11th grade. Tomorrow he will have to write an informatics test by the strictest teacher in the school, Pavel Denisovich.
Igor knows how the test will be conducted: first of all, the teacher will give each student two positive integers $a$ and $b$ ($a < b$). After that, the student can apply any of the follo... | try:
for _ in range(int(input())):
a, b = map(int, input().split())
minimum = []
if a == b:
print(0)
elif a | b == a or a | b == b:
print(1)
else:
diff = abs(a - b)
minimum.append(diff)
steps = 0
mini = m... | 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 IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR F... |
Igor is in 11th grade. Tomorrow he will have to write an informatics test by the strictest teacher in the school, Pavel Denisovich.
Igor knows how the test will be conducted: first of all, the teacher will give each student two positive integers $a$ and $b$ ($a < b$). After that, the student can apply any of the follo... | a = "001101110101100110"
b = "101000001001000110"
c = "101101111101100110"
ans = "101101100100001"
def main():
a, b = map(int, input().split())
k1 = 0
a1, b1 = a, b
while a1 | b1 != b1:
a1 += 1
k1 += 1
if a1 != b1:
k1 += 1
k2 = 0
a2, b2 = a, b
while a2 | b2 != b... | ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR STRING FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR WHILE BIN_OP VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR WHILE BIN_OP VAR VAR VAR VAR NU... |
Igor is in 11th grade. Tomorrow he will have to write an informatics test by the strictest teacher in the school, Pavel Denisovich.
Igor knows how the test will be conducted: first of all, the teacher will give each student two positive integers $a$ and $b$ ($a < b$). After that, the student can apply any of the follo... | for i in range(int(input())):
a, b = map(int, input().split())
q, w = a, b
k = 1
r = 1
o = min(b - a, (b | a) - b + 1)
while a | b > b:
b += 1
k += 1
while q | w > w:
q += 1
r += 1
print(min(o, k, 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 VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER WHILE BIN_OP VAR VAR VAR VAR NUMBER VAR NUMBER WHILE BIN_OP VAR VAR VAR VA... |
Igor is in 11th grade. Tomorrow he will have to write an informatics test by the strictest teacher in the school, Pavel Denisovich.
Igor knows how the test will be conducted: first of all, the teacher will give each student two positive integers $a$ and $b$ ($a < b$). After that, the student can apply any of the follo... | t = int(input())
for T in range(t):
a, b = [int(x) for x in input().split()]
x = a
y = b
n = b
ans = b - a
while n > 0:
n -= 1
if x | y == y:
ans = min(ans, b - n)
break
x += 1
n = b
x = a
y = b
while n > 0:
n -= 1
i... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR WHILE VAR NUMBER VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR VAR ASS... |
Igor is in 11th grade. Tomorrow he will have to write an informatics test by the strictest teacher in the school, Pavel Denisovich.
Igor knows how the test will be conducted: first of all, the teacher will give each student two positive integers $a$ and $b$ ($a < b$). After that, the student can apply any of the follo... | for _ in range(int(input())):
a, b = map(int, input().split())
c = int(a)
d = int(b)
c1 = 0
c2 = 0
while a != b:
if a | b == b:
c1 += 1
a = a | b
else:
a += 1
c1 += 1
while c != d:
if c | d == d:
c2 += 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 ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR NUMBER VAR NUMBER WHILE VAR VAR IF BIN_OP ... |
Igor is in 11th grade. Tomorrow he will have to write an informatics test by the strictest teacher in the school, Pavel Denisovich.
Igor knows how the test will be conducted: first of all, the teacher will give each student two positive integers $a$ and $b$ ($a < b$). After that, the student can apply any of the follo... | t = int(input())
def steps(a, b):
if a == b:
print(0)
return
if b == b | a:
print(1)
return
ans1 = b - a
ans2 = 0
for i in range(a, b):
ans2 = ans2 + 1
if i | b == b:
break
ans3 = (a | b) - b + 1
ans4 = 0
while True:
b... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR NUMBER RETURN IF VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMB... |
Igor is in 11th grade. Tomorrow he will have to write an informatics test by the strictest teacher in the school, Pavel Denisovich.
Igor knows how the test will be conducted: first of all, the teacher will give each student two positive integers $a$ and $b$ ($a < b$). After that, the student can apply any of the follo... | t = int(input())
for _ in range(t):
a, b = map(int, input().split())
for i in range(a + b):
if a + i | b == b or a | b + i == b + i:
break
print(min(i + 1, b - a)) | 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 FOR VAR FUNC_CALL VAR BIN_OP VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP VAR BIN_OP VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR |
Igor is in 11th grade. Tomorrow he will have to write an informatics test by the strictest teacher in the school, Pavel Denisovich.
Igor knows how the test will be conducted: first of all, the teacher will give each student two positive integers $a$ and $b$ ($a < b$). After that, the student can apply any of the follo... | def check(a, b):
mn = abs(a - b)
tmp = a
while tmp | b != b:
tmp += 1
mn = min(mn, 1 + tmp - a)
tmp = b
while a | tmp != tmp:
tmp += 1
mn = min(mn, 1 + tmp - b)
return mn
t = int(input())
for _ in range(t):
a, b = map(int, input().split())
print(check(a, b)) | FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR WHILE BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP NUMBER VAR VAR ASSIGN VAR VAR WHILE BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP NUMBER VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR... |
Igor is in 11th grade. Tomorrow he will have to write an informatics test by the strictest teacher in the school, Pavel Denisovich.
Igor knows how the test will be conducted: first of all, the teacher will give each student two positive integers $a$ and $b$ ($a < b$). After that, the student can apply any of the follo... | t = int(input())
for _ in range(t):
a, b = map(int, input().split())
cnt = 1
ta, tb = a, b
while cnt < b - a:
if ta | tb == tb:
break
tb += 1
cnt += 1
cnt2 = 1
ta, tb = a, b
while cnt2 < b - a:
if ta | tb == tb:
break
ta += 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 NUMBER ASSIGN VAR VAR VAR VAR WHILE VAR BIN_OP VAR VAR IF BIN_OP VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR WHILE VAR BIN_OP VAR VAR IF BIN_OP VAR VAR VAR ... |
Igor is in 11th grade. Tomorrow he will have to write an informatics test by the strictest teacher in the school, Pavel Denisovich.
Igor knows how the test will be conducted: first of all, the teacher will give each student two positive integers $a$ and $b$ ($a < b$). After that, the student can apply any of the follo... | import sys
input = sys.stdin.readline
for _ in range(int(input())):
a, b = map(int, input().split())
best = b - a
for i in range(b - a):
a1 = a + i | b
best = min(best, i + 1 + a1 - b)
b1 = b + i
a1 = a | b1
best = min(best, i + 1 + a1 - b1)
if i > best - 1:
... | IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR ... |
Igor is in 11th grade. Tomorrow he will have to write an informatics test by the strictest teacher in the school, Pavel Denisovich.
Igor knows how the test will be conducted: first of all, the teacher will give each student two positive integers $a$ and $b$ ($a < b$). After that, the student can apply any of the follo... | t = int(input())
while t != 0:
t = t - 1
c = 0
a, b = map(int, input().split())
test = b
d = 0
ans1 = (a | b) - b + 1
if a | b == b:
print("1")
continue
ans2 = b - a
for i in range(a, b):
c = c + 1
if i | b == b:
break
ans3 = c
whil... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR VAR FO... |
Igor is in 11th grade. Tomorrow he will have to write an informatics test by the strictest teacher in the school, Pavel Denisovich.
Igor knows how the test will be conducted: first of all, the teacher will give each student two positive integers $a$ and $b$ ($a < b$). After that, the student can apply any of the follo... | def answer(a, b):
c = min(b - a, (b | a) - b + 1)
k = 1
m = a
n = b
k1 = 1
while a | b > b:
b += 1
k += 1
while m | n > n:
m += 1
k1 += 1
return min(c, k1, k)
t = int(input())
for k in range(t):
inp = input().split()
a = int(inp[0])
b = int(i... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR VAR NUMBER VAR NUMBER WHILE BIN_OP VAR VAR VAR VAR NUMBER VAR NUMBER RETURN FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR... |
Igor is in 11th grade. Tomorrow he will have to write an informatics test by the strictest teacher in the school, Pavel Denisovich.
Igor knows how the test will be conducted: first of all, the teacher will give each student two positive integers $a$ and $b$ ($a < b$). After that, the student can apply any of the follo... | n = int(input())
for _ in range(n):
a, b = map(int, input().split())
ans = b - a
ans1 = 1
ans2 = 1
c, d = a, b
while a | b != b:
a += 1
ans1 += 1
while c | d != d:
d += 1
ans2 += 1
print(min(ans2, ans1, ans)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR WHILE BIN_OP VAR VAR VAR VAR NUMBER VAR NUMBER WHILE BIN_OP VAR VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR ... |
Igor is in 11th grade. Tomorrow he will have to write an informatics test by the strictest teacher in the school, Pavel Denisovich.
Igor knows how the test will be conducted: first of all, the teacher will give each student two positive integers $a$ and $b$ ($a < b$). After that, the student can apply any of the follo... | for _ in range(int(input())):
a, b = map(int, input().split())
ans = b - a
for i in range(0, a + 1):
if a + i | b == b:
ans = min(ans, i + 1)
break
for i in range(b + 1):
if b + i | a == b + i:
ans = min(ans, i + 1)
break
print(ans) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR... |
Igor is in 11th grade. Tomorrow he will have to write an informatics test by the strictest teacher in the school, Pavel Denisovich.
Igor knows how the test will be conducted: first of all, the teacher will give each student two positive integers $a$ and $b$ ($a < b$). After that, the student can apply any of the follo... | t = int(input())
def solve(a, b):
res = min(b - a, (b | a) - b + 1)
u, v = a, b
tmp1, tmp2 = 0, 0
while b | a > b:
b += 1
tmp1 += 1
while u | v > v:
u += 1
tmp2 += 1
return min(res, tmp1 + 1, tmp2 + 1)
for _ in range(t):
a, b = map(int, input().split())
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR NUMBER NUMBER WHILE BIN_OP VAR VAR VAR VAR NUMBER VAR NUMBER WHILE BIN_OP VAR VAR VAR VAR NUMBER VAR NUMBER RETURN FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN... |
Read problem statements in [Russian] and [Mandarin Chinese].
Find the minimum integer K such that sum of bits present on odd positions in binary representation of all integers from 1 to K is greater than or equal to N.
The bits are enumerated from left to right starting from the leftmost set bit i.e. the most signifi... | def check(x):
ans = 0
for i in range(31):
a = 1 << i
if x < a:
break
if x == a:
ans += 1
break
if x < a * 2 - 1:
ans += x - a + 1
f = 0
s = 0
if i & 1:
s = 1
e = i - 1
... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR IF VAR VAR IF VAR VAR VAR NUMBER IF VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE BIN_OP BIN_OP NUMBER... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef is very happy today because he got an offer from Gordon Ramsay himself to work for him in London. Chef wants to prepare a delicious cake for Gordon to impress him, but he does not know that Gordon Ramsay is not... | def group(S, k):
if k == 1:
return sum(S)
firstPiece = 0
answer = 0
dynamic = {}
for i in range(len(S) - k + 1):
firstPiece += S[i]
answer = max(groupWithPattern(S[i + 1 :], k - 1, firstPiece, dynamic), answer)
return answer
def groupWithPattern(S, k, p, dynamic):
i... | FUNC_DEF IF VAR NUMBER RETURN FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR VAR VAR RETURN VAR FUNC_DEF IF VAR NUMBER RETURN BIN_OP FUNC... |
Read problem statements in [Hindi], [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.
Chef is very happy today because he got an offer from Gordon Ramsay himself to work for him in London. Chef wants to prepare a delicious cake for Gordon to impress him, but he does not know that Gordon Ramsay is not... | n = int(input())
a = list(map(int, input().split()))
q = int(input())
for _ in range(q):
k = int(input())
slices = list(
filter(
lambda x: x, map(lambda x: x[0] * x[1], zip(a, map(int, input().split())))
)
)
nn = len(slices)
if k > nn:
print(0)
continue
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER FUNC_CALL VAR VAR FUNC_C... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | for _ in range(int(input())):
n, k = map(int, input().split())
s = list(input())
key = 0
ct0 = 0
flag = 0
ct1 = s.count("1")
solo = 0
if n < k:
print("NO")
elif k == 1:
print("YES")
elif k == 2:
if ct1 % 2 == 1:
print("NO")
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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR ... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | __author__ = "nograhol"
def even_substr_max(S):
st = 0
ans = 0
for i in range(len(S)):
if st == 0 and S[i] == "0":
ans += 1
elif st == 0 and S[i] == "1":
st = 1
elif st == 1 and S[i] == "1":
st = 0
ans += 1
return ans
T = int(in... | ASSIGN VAR STRING FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR VAR STRING VAR NUMBER IF VAR NUMBER VAR VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER VAR VAR STRING ASSIGN VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR ... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | for _ in range(int(input())):
n, k = map(int, input().split())
k1 = k
s = input()
o = s.count("1")
o1 = o
p1 = 0
while k1 > 0 and p1 < n:
if s[p1] == "1":
k1 -= 1
o1 -= 1
p1 += 1
if k1 == 0 and o1 % 2 == 0:
print("YES")
else:
p1... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER BIN_OP VAR NUMBER ... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | for _ in range(int(input())):
n, k = map(int, input().split())
s = input()
ones = s.count("1")
zeroes = s.count("0")
t0 = 0
i = 0
summ = 0
flag0 = 1
while i < len(s):
if (summ + int(s[i])) % 2 == 0:
t0 += 1
summ = 0
else:
summ += in... | 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 ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR FUN... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | from sys import stdin
input = stdin.readline
def solve(N, K, S):
if K == 1:
return "YES"
ones = sum(1 for s in S if s == "1")
if ones % 2 == 0:
k = 0
count = 0
for i in range(N):
if S[i] == "0" and count == 0:
k += 1
elif S[i] == "0"... | ASSIGN VAR VAR FUNC_DEF IF VAR NUMBER RETURN STRING ASSIGN VAR FUNC_CALL VAR NUMBER VAR VAR VAR STRING IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR ... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | t = int(input())
for _ in range(t):
n, x = map(int, input().split())
a = input()
fl = 0
now = 0
tobe = 0
k = x
ind = -1
for i in range(n):
now ^= int(a[i])
if tobe == now:
k -= 1
if k == 0:
ind = i
break
... | 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR NUMBER IF VAR NUMBE... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | t = int(input())
for i in range(t):
p = list(map(int, input().split()))
n = p[0]
k = p[1]
s = input()
count0 = 0
count1 = 0
f = 0
res = 0
for x in s:
res ^= ord(x) - 48
if res == 0:
count0 += 1
if count0 >= k and res != 1:
f = 1
print("... | 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | for i in range(int(input())):
n, k = map(int, input().split())
a = input()
l = []
x = 0
for i in range(n):
x ^= int(a[i])
l.append(x)
c = 0
ci = 0
ll = 0
for i in range(n):
if l[i] == 0:
c += 1
if l[i] != ll:
ll = l[i]
... | 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 ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | for _ in range(int(input())):
n, k = map(int, input().split())
s = input()
one = s.count("1")
if one >= k:
count = 0
for i in range(n):
if s[i] == "1":
count += 1
if count == k:
break
if count == k and one - k & 1 == 0:
... | 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 ASSIGN VAR FUNC_CALL VAR STRING IF VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR IF VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | t = int(input())
for _ in range(t):
n, k = [int(s) for s in input().split(" ")]
s = input()
a = [int(b) for b in s]
val = 0
cnt = 0
for i in range(n):
val ^= a[i]
if val == 0:
cnt += 1
val = 0
if val != 1 and cnt >= k:
print("YES")
cont... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR N... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | t = input()
for i in range(int(t)):
n, k = map(int, input().split())
s = input()
x = 0
j = 0
zeros = 0
ones = 0
while j < n and zeros < k - 1:
x ^= int(s[j])
j += 1
if x == 0:
zeros += 1
x = 0
x = 0
z = 0
while z < n and ones < k - ... | ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR NUMBER IF VAR NUMBER VAR NUMBER ASS... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | t = int(input())
for _ in range(t):
n, k = map(int, input().split())
s = input()
o = 0
z = 0
for i in range(n):
if s[i] == "1":
o += 1
else:
z += 1
if o % 2 == 0 and o // 2 + z >= k:
c = 0
cur = 0
flag = 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 VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER VAR VAR ASSIGN VAR... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | def ispos(s, k):
ss = ""
xor = 0
for i in s:
xor ^= int(i)
ss += str(xor)
s = ss
if s[-1] == "0" and s.count("0") >= k or k == 1:
return "YES"
else:
if k % 2 == 0 and 1 == int(s[-1]):
return "NO"
elif k % 2 == 1 and 0 == int(s[-1]):
... | FUNC_DEF ASSIGN VAR STRING ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR IF VAR NUMBER STRING FUNC_CALL VAR STRING VAR VAR NUMBER RETURN STRING IF BIN_OP VAR NUMBER NUMBER NUMBER FUNC_CALL VAR VAR NUMBER RETURN STRING IF BIN_OP VAR NUMBER NUMBER NUMBER FUNC_CALL VAR VAR NUMBER... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | T = int(input())
for _ in range(T):
N, K = [int(x) for x in input().split()]
S = input()
s = sum(c == "1" for c in S)
if not K & 1 and s & 1:
print("NO")
elif K & 1:
s = s & 1
cnt = 0
curr = 0
works = False
for c in S:
curr += c == "1"
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR STRING VAR VAR IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR STRING IF BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | t = int(input())
for _ in range(0, t):
inputs = [int(num) for num in input().split()]
n = inputs[0]
k = inputs[1]
s = input()
ones = 0
zeros = 0
for i in range(0, len(s)):
if s[i] == "0":
zeros += 1
else:
ones += 1
if k % 2 == 1:
min1 = 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | ans = {(True): "YES", (False): "NO"}
def can_split(S, K):
N = len(S)
ones = S.count("1")
if ones == 0:
return ans[K <= N]
elif 1 == ones % 2:
return ans[1 == K % 2 and ones >= K]
elif 0 == K % 2 and ones >= K:
return "YES"
else:
inpair = False
for c in S... | ASSIGN VAR DICT NUMBER NUMBER STRING STRING FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER RETURN VAR VAR VAR IF NUMBER BIN_OP VAR NUMBER RETURN VAR NUMBER BIN_OP VAR NUMBER VAR VAR IF NUMBER BIN_OP VAR NUMBER VAR VAR RETURN STRING ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING IF VAR ... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | import sys
f = sys.stdin
next(f)
for k, s in zip(f, f):
k = int(k.split()[1])
i = j = 0
for x in s[:-1]:
if x == "1":
i += 1
if i & 1 ^ 1:
j += 1
print("YNEOS"[max((i ^ k) & 1 ^ 1 and i, i & 1 ^ 1 and j) < k :: 2]) | IMPORT ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR VAR NUMBER IF VAR STRING VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER ... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | def main():
n, k = map(int, input().split())
b = list(map(int, list(input())))
if k == 1:
return "YES"
one = 0
for z in b:
if z:
one += 1
if one % 2 and k % 2 == 0:
return "NO"
if one % 2 and k % 2:
if one >= k:
return "YES"
ret... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER RETURN STRING ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR NUMBER IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER RETURN STRING IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF VAR V... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | for _ in range(int(input())):
n, k = map(int, input().split())
s = input()
ones = 0
zeros = 0
xor = 0
for i in s:
if i == "1":
xor ^= 1
if xor == 0:
zeros += 1
if xor != ones % 2:
ones += 1
if xor == 0 and zeros >= k or ones >= k an... | 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER VAR VAR VAR VAR BIN_OP... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | T = int(input())
for t in range(1, T + 1):
inp = input().split()
N = int(inp[0])
K = int(inp[1])
S = input()
Slist = []
Slist[:0] = S
Slist = list(map(int, Slist))
num_0 = 0
num_1 = 0
xor_0 = xor_1 = 0
for i, s in enumerate(Slist):
xor_0 = xor_0 ^ s
xor_1 = xo... | 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 ASSIGN VAR LIST ASSIGN VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | from itertools import *
for _ in range(int(input())):
n, k = map(int, input().split())
s = input()
z = s.count("0")
o = n - z
s1 = "NO"
if k == 1 or k == n and o in [0, n]:
s1 = "YES"
elif k <= o and (o - k) % 2 == 0:
s1 = "YES"
else:
x = 0
co = 0
... | 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 ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR STRING IF VAR NUMBER VAR VAR VAR LIST NUMBER VAR ASSIGN VAR STRING IF VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIG... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | import sys
def f(l, n, f):
a = 0
x = n - 1
while a <= x:
m = a + (x - a) // 2
if l[m] == f:
return m
elif l[m] > f:
x = m - 1
else:
a = m + 1
return None
for _ in range(int(sys.stdin.readline())):
n, x = map(int, sys.stdin.readl... | IMPORT FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR RETURN VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN NONE FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VA... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | def count0(s, n):
c = 0
x = 0
for i in s:
if i == "0":
if x == 0:
c += 1
elif x == 1:
c += 1
x = 0
else:
x = 1
if x == 1:
return 0
return c
def count1(s):
c = 0
for i in s:
if i == "1":
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING IF VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER RETURN NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR NUMBER RETURN NUMBER RETURN VAR ASSIGN VAR FUNC_CALL ... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | for _ in range(int(input())):
n, k = map(int, input().split())
l = list(map(int, input()))
part = 0
flag = 0
i = 0
while i < n:
if l[i] == 1:
part += 1
if part == k - 1:
i += 1
break
i += 1
c = 0
while i < n:
if l[i] == ... | 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 VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR N... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | def solve():
n = l[0]
k = l[1]
xor = 0
for i in range(n):
if k == 1:
if i == n - 1:
if s[i] == "1":
print("YES")
return
elif x(s[i:]) == 1:
print("YES")
return
xor ^= int(s[i])... | FUNC_DEF ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR BIN_OP VAR NUMBER IF VAR VAR STRING EXPR FUNC_CALL VAR STRING RETURN IF FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | tc = int(input())
for _ in range(tc):
n, k = map(int, input().split())
s = input()
ones = s.count("1")
zeros = n - ones
yes, no = "YES", "NO"
if ones % 2 == 1:
if k % 2 == 1 and ones >= k:
print(yes)
else:
print(no)
elif k % 2 == 0 and ones % 2 == 0 an... | 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 ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR STRING STRING IF BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER VAR VAR EXPR FUNC_CALL VAR VAR... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | for T in range(int(input())):
N, K = map(int, input().split())
S = input()
ZeroCount = 0
ZP = False
OneCount = 0
prev = " "
for ch in S:
if prev == " " and ch == "0":
ZeroCount += 1
prev = "0"
elif prev == " " and ch == "1":
prev = "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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR STRING FOR VAR VAR IF VAR STRING VAR STRING VAR NUMBER ASSIGN VAR STRING IF VAR STRING VAR STRING ASSIGN VAR STRING IF VAR ... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | def cal_xor(c: int):
z = K
flag = xor = 0
for i in range(N):
xor ^= int(s[i])
if z == 1:
flag = 1
z -= 1
if not flag and xor == c:
z -= 1
xor = 0
if xor == c and z == 0:
return 1
return 0
def calculate():
a = cal_x... | FUNC_DEF VAR ASSIGN VAR VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER RETURN V... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | ans = ""
for _ in range(int(input())):
n, k = list(map(int, input().split()))
s = input()
evenSub = 0
oddSub = 0
cnt1 = 0
cnt2 = 0
oneCount = 0
for i in range(n):
if s[i] == "1":
oneCount += 1
cnt1 += 1
cnt2 += 1
if cnt1 % 2 == 0:
... | ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER ... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | for _ in range(int(input())):
n, k = map(int, input().split())
s = input()
x, c1 = 0, 0
for i in s:
x ^= int(i)
if x == 0:
c1 += 1
if c1 >= k and x != 1:
print("YES")
else:
y, c2 = 0, 0
for i in s:
y ^= int(i)
if y == 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 ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER NUMBER FOR VAR VAR VAR FUNC_CA... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | def f():
x, c = 0, 0
for i in range(n):
x ^= l[i] == "1"
if x == 1 and c < k - 1 and i != n - 1:
c += 1
x = 0
if c == k - 1 and x == 1:
return "YES"
x, c = 0, 0
for i in range(n):
x ^= l[i] == "1"
if x == 0 and c < k - 1 and i != n - 1:... | FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR STRING IF VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR NUMBER RETURN STRING ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR STRING IF VAR NUMBER VAR BIN_OP V... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | for _ in range(int(input())):
n, k = map(int, input().split())
s = list(input())
if n == k:
if s.count("1") == n or s.count("1") == 0:
print("YES")
else:
print("NO")
else:
f = True
if s.count("1") % 2:
f = False
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 IF VAR VAR IF FUNC_CALL VAR STRING VAR FUNC_CALL VAR STRING NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF BIN_OP FUNC_CALL VAR STRING NUMBER... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | def count(s):
n = len(s)
i = 0
ans = 0
while i < n:
if s[i] == "0":
ans += 1
i += 1
else:
i += 1
while i < n and s[i] != "1":
i += 1
ans += 1
i += 1
return ans
for _ in range(int(input())):
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL F... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | t = int(input())
for i in range(t):
n, k = map(int, input().split())
s = input()
xor = [(0) for i in range(n)]
xor[0] = int(s[0])
cnt = 0
if s[0] == "0":
cnt += 1
for i in range(1, n):
xor[i] = xor[i - 1] ^ int(s[i])
if xor[i] == 0:
cnt += 1
if xor[-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 ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER STRING VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN ... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | for _ in range(int(input())):
n, k = map(int, input().split())
s = input()
sum = 0
x = True
m = 0
for i in s:
if i == "1":
sum += 1
if sum % 2 == 1:
x = False
else:
x = True
if x:
if i == "0":
... | 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR IF VAR STRING VAR NUMBER I... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | t = int(input())
for i in range(t):
n, k = map(int, input().split())
s = input()
e = 0
ind = 0
c = 0
h = 0
lst1 = []
while True:
if ind > n - 1 or h == k - 1:
break
else:
if s[ind] == "1":
c += 1
if c % 2 == 0:
... | 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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE NUMBER IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER IF VAR VAR STRING VAR NUM... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | t = int(input())
for _ in range(t):
n, k = map(int, input().split())
s = input()
zc = s.count("0")
oc = s.count("1")
ttl_xor = 0
for i in s:
ttl_xor ^= int(i)
xor = 0
count = 0
for i in s:
u = int(i)
xor ^= u
if xor == 0:
count += 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 ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VA... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | T = int(input())
for _ in range(T):
N, K = map(int, input().split())
binary_str = input()
int_str = []
arr = []
cur = 0
count = {(0): 0, (1): 0}
int_count = {(0): 0, (1): 0}
for c in binary_str:
cur = int(c) ^ cur
arr.append(cur)
count[cur] += 1
int_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 ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER ASSIGN VAR DICT NUMBER NUMBER NUMBER NUMBER FOR VAR VAR ASSIGN VAR BIN_OP FUNC_... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | for _ in range(int(input())):
n, k = map(int, input().split())
s = input()
if k == 1:
print("YES")
else:
ones = s.count("1")
zeroes = len(s) - ones
if ones % 2 == 1:
if k % 2 == 1 and k <= ones:
print("YES")
continue
eli... | 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 IF VAR NUMBER EXPR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER VAR VAR EXPR FUNC_CA... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | def zxor(k):
c = 0
pos = 0
while k > 0 and pos < n:
if s[pos] == "1":
c += 1
elif c == 0:
k -= 1
if c == 2:
k -= 1
c = 0
pos += 1
if k == 0:
break
c = 0
if k > 0:
return False
for j in ran... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR VAR VAR IF VAR VAR STRING VAR NUMBER RETURN BIN_OP VAR NUMBE... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | t = int(input())
for test in range(t):
n, k = map(int, input().split())
s = input()
n1 = s.count("1")
c1 = n1 + 0
g = k + 0
if k <= n1:
c1 = c1 - k + 1
if c1 % 2 == 1:
print("YES")
continue
if n1 % 2 == 1:
pass
else:
twis = 0
... | 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 ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | for _ in range(int(input())):
n, k = map(int, input().split())
s = list(input())
count = 0
u = 0
for i in range(n):
u = u ^ int(s[i])
if u == 0:
count += 1
v = 0
count2 = 0
for i in range(n):
if s[i] == "1" and count2 != k:
count2 += 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 FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | for _ in range(int(input())):
n, k = map(int, input().split())
s = input()
cnt = [0, 0]
a = 0
b = 0
for i in range(n):
if s[i] == "1":
a += 1
b += 1
if a == 1:
cnt[0] += 1
a = 0
if s[i] == "0" and b % 2 == 0 or b == 2:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER NUMBER ASSIGN VAR NUMBER IF VAR... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | T = int(input())
for _ in range(T):
N, X = map(int, input().split())
s = input()
x = 0
for i in s:
if i == "1":
x += 1
y = 0
a = 0
for i in s:
if a == 0:
if i == "0":
y += 1
else:
a = 1 - a
elif 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 FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER IF VAR STRING VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR IF... |
Chef has a binary string S of length N. He wonders if it is possible to divide S into exactly K non-empty [substrings] such that each S_{i} belongs to exactly one substring and the \texttt{XOR} of each substring is the same. Can you help Chef to determine if it is possible to do so?
Note: \texttt{XOR} of substring S_{... | def solve(N, K, S):
count0 = 0
count1 = 0
if len(S) < K:
print("NO")
return
if K == 1:
print("YES")
return
found0 = 0
found1 = 0
count1 = 0
i = 0
while i < len(S):
if S[i] == "0":
found0 += 1
i += 1
else:
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING RETURN IF VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER WHILE VA... |
You are given n integers a_1, a_2, β¦, a_n and an integer k. Find the maximum value of i β
j - k β
(a_i | a_j) over all pairs (i, j) of integers with 1 β€ i < j β€ n. Here, | is the [bitwise OR operator](https://en.wikipedia.org/wiki/Bitwise_operation#OR).
Input
The first line contains a single integer t (1 β€ t β€ 10 000... | import sys
input = sys.stdin.buffer.readline
def solve_tc():
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = float("-inf")
for i in range(max(0, n - 110), n):
for j in range(i + 1, n):
ans = max(ans, (i + 1) * (j + 1) - k * (a[i] | a[j]))
retur... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR... |
You are given n integers a_1, a_2, β¦, a_n and an integer k. Find the maximum value of i β
j - k β
(a_i | a_j) over all pairs (i, j) of integers with 1 β€ i < j β€ n. Here, | is the [bitwise OR operator](https://en.wikipedia.org/wiki/Bitwise_operation#OR).
Input
The first line contains a single integer t (1 β€ t β€ 10 000... | for _ in range(int(input())):
n, k = list(map(int, input().split()))
l = list(map(int, input().split()))
c = float("-inf")
m = max(n - 2 * k, 0)
for i in range(m, n):
for j in range(i + 1, n):
c = max(c, (i + 1) * (j + 1) - k * (l[i] | l[j]))
print(c) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FOR VAR F... |
You are given n integers a_1, a_2, β¦, a_n and an integer k. Find the maximum value of i β
j - k β
(a_i | a_j) over all pairs (i, j) of integers with 1 β€ i < j β€ n. Here, | is the [bitwise OR operator](https://en.wikipedia.org/wiki/Bitwise_operation#OR).
Input
The first line contains a single integer t (1 β€ t β€ 10 000... | for test in range(int(input())):
def solve():
n, k = map(int, input().split())
arr = list(map(int, input().split()))
ar = arr[-101:]
k1 = len(ar)
ans = -9999999999999
add = n - k1 + 1
for i in range(k1):
for j in range(i + 1, k1):
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR FO... |
You are given n integers a_1, a_2, β¦, a_n and an integer k. Find the maximum value of i β
j - k β
(a_i | a_j) over all pairs (i, j) of integers with 1 β€ i < j β€ n. Here, | is the [bitwise OR operator](https://en.wikipedia.org/wiki/Bitwise_operation#OR).
Input
The first line contains a single integer t (1 β€ t β€ 10 000... | import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
n, k = map(int, input().split())
a = list(map(int, input().split()))
r = n
l = max(0, r - 2 * k - 5)
ans = -1145141919810
for i in range(l, r):
ai = a[i]
for j in range(i + 1, r):
aj = a[j]
... | IMPORT ASSIGN VAR VAR 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 ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR BIN_OP NUMBER VAR NUMBER ASSIGN VAR NUMBER F... |
You are given n integers a_1, a_2, β¦, a_n and an integer k. Find the maximum value of i β
j - k β
(a_i | a_j) over all pairs (i, j) of integers with 1 β€ i < j β€ n. Here, | is the [bitwise OR operator](https://en.wikipedia.org/wiki/Bitwise_operation#OR).
Input
The first line contains a single integer t (1 β€ t β€ 10 000... | import sys
input = sys.stdin.buffer.readline
for _ in range(int(input())):
n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = -1000000000.0
l = 1
while l * l < k * n:
l += 1
l += 5
for i in range(max(0, n - l), n):
for j in range(i + 1, n):
... | IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR BIN_OP VAR VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CAL... |
You are given n integers a_1, a_2, β¦, a_n and an integer k. Find the maximum value of i β
j - k β
(a_i | a_j) over all pairs (i, j) of integers with 1 β€ i < j β€ n. Here, | is the [bitwise OR operator](https://en.wikipedia.org/wiki/Bitwise_operation#OR).
Input
The first line contains a single integer t (1 β€ t β€ 10 000... | def solve(n, k, a):
x = n * (n - 1) - k * (a[-1] | a[-2])
r = list(reversed(range(n)))
for i in r:
for j in r:
if (i + 1) * (j + 1) < x:
break
if j >= i:
continue
y = (i + 1) * (j + 1) - k * (a[i] | a[j])
x = max(x, y)
... | FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR VAR FOR VAR VAR IF BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR IF VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR... |
You are given n integers a_1, a_2, β¦, a_n and an integer k. Find the maximum value of i β
j - k β
(a_i | a_j) over all pairs (i, j) of integers with 1 β€ i < j β€ n. Here, | is the [bitwise OR operator](https://en.wikipedia.org/wiki/Bitwise_operation#OR).
Input
The first line contains a single integer t (1 β€ t β€ 10 000... | import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
n, k = map(int, input().split())
a = list(map(int, input().split()))[::-1]
ans = -float("inf")
b = a[0 : min(n, 200)]
l = len(b)
for i in range(l):
for j in range(i + 1, l):
ans = max(ans, (n - i) * (n... | IMPORT ASSIGN VAR VAR 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 NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VA... |
You are given n integers a_1, a_2, β¦, a_n and an integer k. Find the maximum value of i β
j - k β
(a_i | a_j) over all pairs (i, j) of integers with 1 β€ i < j β€ n. Here, | is the [bitwise OR operator](https://en.wikipedia.org/wiki/Bitwise_operation#OR).
Input
The first line contains a single integer t (1 β€ t β€ 10 000... | def main():
N, K = map(int, input().split())
A = list(map(int, input().split()))
Ans = -1001001001
L = max(1, N - 2 * K - 1)
for i in range(L, N + 1):
for j in range(i + 1, N + 1):
Value = i * j - K * (A[i - 1] | A[j - 1])
if Ans < Value:
Ans = Value
... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR BIN_OP NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.