description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
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... | from sys import stdin, stdout
input = stdin.readline
t = int(input())
for _ in range(t):
n, k = map(int, input().split())
a = [int(x) for x in input().split()]
ans = -float("inf")
for i in range(max(n - 400, 0), n):
for j in range(i + 1, n):
ans = max(ans, (i + 1) * (j + 1) - k * (a... | 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 VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP ... |
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())
arr = [0] + list(map(int, input().split()))
r = n
maxi = -float("inf")
while r >= 1:
if r * r < maxi:
break
l = r - 1
while l >= 1:
if r * l < ... | 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 LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR STRING WHILE VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP V... |
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... | n = int(input())
for i in range(n):
l, k = list(map(int, input().split()))
finalnum = -1e18
arr = list(map(int, input().split()))
for m in range(max(0, l - 101), l):
for z in range(m + 1, l):
num = (z + 1) * (m + 1) - k * (arr[z] | arr[m])
if num > finalnum:
... | 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 NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR N... |
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
def solve():
n, k = map(int, input().split())
a = list(map(int, input().split()))
z = n
b = 0
while z > 0:
b |= z
z //= 2
r = int(-1000000000.0)
for j in range(n - 1, -1, -1):
for i in range(j - 1, -1, -1):
if (i + ... | IMPORT ASSIGN VAR 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 ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER FOR VAR FU... |
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 read_ints():
return [int(x) for x in input().split()]
outs = []
def prnt(s):
outs.append(str(s))
def flush():
print("\n".join(outs))
t = read_ints()[0]
while t:
t -= 1
n, k = read_ints()
x = read_ints()
jwb = -1000000000000.0
for i in range(min(n, 2 * k)):
for j in ra... | FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_DEF EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_DEF EXPR FUNC_CALL VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL VAR NUMBER WHILE VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL 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 i in range(int(input())):
n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = -(10**10)
for i in range(n - 1, max(0, n - 1 - 200), -1):
for j in range(i - 1, max(-1, n - 2 - 200), -1):
ans = max(ans, (i + 1) * (j + 1) - k * (a[i] | a[j]))
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 FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER FOR VAR FUNC_C... |
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
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II():
return int(sys.stdin.readline())
def LI():
return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number):
return [LI() for _ in range(rows_number)]
def LI1():
return list(map(int1, sys.stdin.readline... | IMPORT ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL 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... | t = int(input())
otv = list()
for i in range(t):
n, k = map(int, input().split())
sp = list(map(int, input().split()))
it = -100000000000000000
for j in range(n, 0, -1):
pred = sp[j - 1] * k
for o in range(j - 1, 0, -1):
if j * o - pred < it:
break
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN 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 NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR FOR ... |
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... | t = int(input())
for xx in range(t):
[n, k] = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
start = 0
if n > 100:
start = n - k - 4
ans = float("-inf")
for i in range(start, len(a)):
for j in range(i + 1, len(a)):
ans = max(ans, (i + 1) * (j ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN LIST VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR FU... |
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... | t = int(input())
for tc in range(t):
n, k = map(int, input().split())
a = list(map(int, input().split()))
best = -float("inf")
i = max(0, n - 203)
while i < n:
j = i + 1
while j < n:
if (i + 1) * (j + 1) - k * (a[i] | a[j]) > best:
best = (i + 1) * (j + 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 FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE ... |
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... | q = int(input())
for _ in range(q):
n = [int(x) for x in input().split()]
k = n[1]
n = n[0]
a = [int(x) for x in input().split()]
m = 2 - k * (a[0] | a[1])
for i in range(max(n - 200, 0), n):
for j in range(i + 1, n):
x = (i + 1) * (j + 1) - k * (a[i] | a[j])
if m... | 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 VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL ... |
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... | t = int(input())
for _ in range(t):
n, k = [int(i) for i in input().split()]
s = [int(i) for i in input().split()]
m = n - 2 * k - 1
_s = s[m:]
mat = []
mx = -(10**9)
if m >= 0:
for i in range(2 * k + 1):
for j in range(i + 1, 2 * k + 1):
val = (m + i + 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 VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP NUMBER NUMBER IF VAR NUMBER 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... | t = int(input())
while t > 0:
n, k = map(int, input().split())
a = list(map(int, input().split()))
if n <= 1000:
m = -99999999999999999999999
for i in range(n - 1):
for j in range(i + 1, n):
if (i + 1) * (j + 1) - k * (a[i] | a[j]) > m:
m = (i ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP BIN_OP BIN_OP ... |
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... | from sys import gettrace, stdin
if gettrace():
def inputi():
return input()
else:
def input():
return next(stdin)[:-1]
def inputi():
return stdin.buffer.readline()
def solve():
n, k = map(int, input().split())
aa = [int(a) for a in input().split()]
mnv = n * (n - 1... | IF FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP BIN_OP NUMBER VAR VAR FUN... |
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... | from sys import stdin
_input = stdin.readline
_max, _range, _int, _str = max, range, int, str
def solution():
for _ in _range(_int(_input())):
n, k = [_int(i) for i in _input().split()]
arr = [0] + [_int(i) for i in _input().rstrip("\n").split()]
ans = -(n * n)
for i in _range(n, ... | ASSIGN VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR N... |
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... | t = int(input())
while t > 0:
t -= 1
n, k = map(int, input().split())
a = list(map(int, input().split()))
m = -1000000000.0
x = max(0, n - 200)
for i in range(x, n):
for j in range(i + 1, n):
d = (i + 1) * (j + 1) - k * (a[i] | a[j])
m = max(m, d)
print(m) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP 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... | for _ in range(int(input())):
n, k = [int(x) for x in input().split()]
numbers = [int(x) for x in input().split()]
summe = 2 - k * (numbers[0] | numbers[1])
for i in range(n - 1, 0, -1):
if (i + 1) * i <= summe:
break
for i2 in range(i - 1, -1, -1):
if (i + 1) * (... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP BIN_OP VAR NUMBER VAR V... |
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,) = map(int, input().split())
for _ in range(T):
N, k = map(int, input().split())
X = list(map(int, input().split()))
c = len(bin(N * (N - 1))) - 2
mm = 1 << len(bin(N)) - 2
R = -(10**18)
for i in range(N, max(0, N - 401), -1):
for j in range(i -... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR 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 FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BI... |
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 = map(int, input().split())
l = list(map(int, input().split()))
t = float("-inf")
i = n - 1
j = 0
mx = max(0, n - 500)
while i >= mx:
j = i - 1
while j >= mx:
t = max(t, (i + 1) * (j + 1) - k * (l[i] | l[j]))
j -= 1
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER WHILE VAR VAR ASS... |
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... | p = ""
for _ in range(int(input())):
n, k = map(int, input().split())
l = list(map(int, input().split()))
ans = -1e18
for i in range(max(0, n - 101), n):
for j in range(i + 1, n):
ans = max(ans, (i + 1) * (j + 1) - k * (l[i] | l[j]))
p += str(ans) + "\n"
print(p) | ASSIGN VAR STRING 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 FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR A... |
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 = map(int, input().split())
a = [0] + list(map(int, input().split()))
p = n * (n - 1) - k * n * 2
ans = float("-inf")
for j in range(n, 0, -1):
for i in range(j - 1, 0, -1):
if i * j < p:
break
ans = max(ans, i * j - ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL V... |
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 = map(int, input().split())
arr = list(map(int, input().split()))
tempy = arr[:]
temparr = tempy[-110:]
l = len(temparr)
out = -1e20
i = 0
while i < l:
j = i + 1
while j < l:
flag = (n - l + 1 + i) * (n - l + 1 + j) - k * (te... | 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 VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR NUMBER W... |
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... | t = int(input())
for tc in range(t):
n, k = map(int, input().split())
arr = [int(z) for z in input().split()]
left = max(0, n - 2 * k - 1)
res = -(10**18)
for i in range(left, n):
for j in range(i + 1, n):
r = (i + 1) * (j + 1) - k * (arr[i] | arr[j])
res = max(res, r... | 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 VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR FOR ... |
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 = map(int, input().split())
arr = list(map(int, input().split()))
maxx = -100000
for i in range(max(1, n - 200), n + 1):
for j in range(i + 1, n + 1):
maxx = max(maxx, j * i - k * (arr[i - 1] | arr[j - 1]))
print(maxx) | 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 FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP 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.readline
def inp():
return int(input())
def inlt():
return list(map(int, input().split()))
def insr():
s = input()
return list(s[: len(s) - 1])
def invr():
return map(int, input().split())
def main():
numTestCases = int(input())
for _ in range(numTestC... | IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR RETURN FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL 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... | def fun(i, j):
global ar, k
return (i + 1) * (j + 1) - k * (ar[i] | ar[j])
for _ in range(int(input())):
n, k = map(int, input().split())
ar = list(map(int, input().split()))
ans = -float("inf")
for i in range(n - 1, max(-1, n - 1 - 400), -1):
for j in range(i - 1, max(-1, n - 1 - 400)... | FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR BIN_OP 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_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_C... |
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 f(x, y):
if y in x:
return x
if x[0] <= y:
return y, x[0]
elif x[1] <= y:
return x[0], y
return x[0], x[1]
for t in range(int(input())):
N, K = map(int, input().split())
A = list(map(int, input().split()))
L = N.bi... | IMPORT ASSIGN VAR VAR FUNC_DEF IF VAR VAR RETURN VAR IF VAR NUMBER VAR RETURN VAR VAR NUMBER IF VAR NUMBER VAR RETURN VAR NUMBER VAR RETURN VAR NUMBER VAR NUMBER 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_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... | for _ in range(int(input())):
n, k = map(int, input().split())
a = list(map(int, input().split()))
max_val = -(10**7)
for i in range(n, 0, -1):
for j in range(i - 1, 0, -1):
if i * j < max_val:
break
elif i * j - k * (a[i - 1] | a[j - 1]) > max_val:
... | 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 BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP VAR VAR 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... | for _ in range(int(input())):
n, k = map(int, input().split(" "))
arr = [int(w) for w in input().split(" ")]
ans = -(10**18)
temp = []
cnt = 0
for i in range(n - 1, -1, -1):
temp.append((arr[i], i))
cnt += 1
if cnt == 300:
break
for i in range(len(temp)):
... | 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 FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR VAR... |
Petya is a math teacher. n of his students has written a test consisting of m questions. For each student, it is known which questions he has answered correctly and which he has not.
If the student answers the j-th question correctly, he gets p_j points (otherwise, he gets 0 points). Moreover, the points for the quest... | I = lambda: [*map(int, input().split())]
r = range
s = sum
for _ in [0] * I()[0]:
n, m = I()
e = I()
M = [[*map(int, [*input().strip()])] for i in r(n)]
o = [bin(i).count("1") for i in r(1 << n)]
q = [s(1 << i for i in r(n) if M[i][j]) for j in r(m)]
b = -1
for i in r(1 << n):
c = [0... | ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR FOR VAR BIN_OP LIST NUMBER FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR LIST FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR STRING... |
It is a simplified version of problem F2. 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 leading... | def F1(s, k):
siz = len(s)
pivot = s[0]
index = 1
while index < siz:
if s[index] != pivot:
break
else:
index += 1
if index == siz:
return s
elif pivot > s[index]:
res = s[:index]
return replaceF(res, pivot, index, siz)
else:
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR VAR NUMBER IF VAR VAR RETURN VAR IF VAR VAR VAR ASSIGN VAR VAR VAR RETURN FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER RETURN FUNC_CALL VAR VAR VAR NUMBE... |
It is a simplified version of problem F2. 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 leading... | def get_input():
al = []
for c in range(int(input())):
t = input().split(" ")
el = [t[0], int(t[1])]
al.append(el)
return al
def find_best(n, j, s):
b = ":"
m = ":"
for k in s:
if k < m:
m = k
if n[j] < k and k < b:
b = k
if b... | FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR STRING ASSIGN VAR STRING FOR VAR VAR IF VAR VAR ASSIGN VAR VAR IF VAR VAR VAR VAR VAR ASSIGN VAR ... |
It is a simplified version of problem F2. 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 leading... | def recurs(i, n, dist, nw, k, orig):
if dist > k:
return ""
if nw[0:i] < orig[0:i]:
return ""
if i >= n:
return nw
c = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
for item in c:
nw = nw[:i] + item + nw[i + 1 :]
f = False
for j in range(i):
... | FUNC_DEF IF VAR VAR RETURN STRING IF VAR NUMBER VAR VAR NUMBER VAR RETURN STRING IF VAR VAR RETURN VAR ASSIGN VAR LIST STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING FOR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR A... |
It is a simplified version of problem F2. 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 leading... | import sys
input = sys.stdin.readline
ans1 = set()
ans2 = set()
for a in range(10):
ans = a
for i in range(10):
ans1.add(ans)
ans = ans * 10 + a
for a in range(10):
for b in range(10):
for k in range(2, 11):
for bit in range(2**k):
x = 0
f... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL ... |
It is a simplified version of problem F2. 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 leading... | import sys
t = int(input())
for i in range(t):
n, k = sys.stdin.readline().split()
n = n.lstrip("000000000")
k = int(k)
L = [n[0]]
for s in n:
if s not in L:
L.append(s)
if len(L) <= k:
print(n)
elif k == 1:
if L[1] < L[0]:
print(L[0] * len(n)... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR NUMBER FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR IF VAR NUMBER IF VAR NUMBER... |
It is a simplified version of problem F2. 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 leading... | t = int(input())
results = []
for i in range(t):
n, k = input().split()
k = int(k)
if k == 1:
digits = len(n)
important_num = int(digits * "1")
n = int(n)
for j in range(1, 10):
if important_num * j >= n:
results.append(important_num * j)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP VAR VAR VA... |
It is a simplified version of problem F2. 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 leading... | def solve(num, k):
count = 0
tab = [(-1) for _ in range(int(k))]
idx = 0
rem = -1
rem_idx = -1
for x in num:
if int(x) not in tab:
if count < int(k):
tab[count] = int(x)
count += 1
else:
rem = int(x)
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR VAR IF VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_... |
It is a simplified version of problem F2. 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 leading... | def check(s, k, t, n):
z = set()
for i in range(len(s)):
if i == len(s) - 1:
z.add(t)
else:
z.add(int(s[i]))
if len(z) <= k:
needed = len(str(n)) - len(s)
arr = []
min_val = 9
for i in range(len(s)):
if i == len(s) - 1:
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CAL... |
It is a simplified version of problem F2. 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 leading... | def nearest_k_number(a, k):
c = 0
ta = a
while ta != 0:
ta = ta // 10
c += 1
numbers = set()
counter = 0
while c != 0:
c = c - 1
if c != 0:
cur = a // 10**c
else:
cur = a
cur = cur % 10
if cur not in numbers:
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR NUMBER IF VAR VAR R... |
It is a simplified version of problem F2. 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 leading... | def getBeautiful(num, k):
if len(set(str(num))) <= k:
return num
unstableIdx = k
st = str(num)
set_ = set(st[: unstableIdx + 1])
while len(set_) <= k:
set_.add(st[unstableIdx + 1])
unstableIdx += 1
digits = set(map(int, set(st[:unstableIdx])))
n = int(st[unstableIdx])... | FUNC_DEF IF FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR RETURN VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER WHILE FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR ... |
It is a simplified version of problem F2. 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 leading... | t = int(input())
k1 = [0]
for i in range(1, 10):
for j in range(1, 11):
e = str(i) * j
e = int(e)
k1.append(e)
k1 = sorted(k1)
k2 = []
def ad(i, j, s):
if len(s) == 10:
if s != s[0] * len(s):
k2.append(int(s))
else:
if s != "" and s != s[0] * len(s):
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FUNC_DEF IF FUNC_CALL VAR VAR NUMBER IF VAR BIN_O... |
It is a simplified version of problem F2. 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 leading... | def nr_distinct(n):
return len(set(list(n)))
def get(n, idx, k):
if n[idx] == "9":
return -1
digs = set(list(n[:idx]))
if len(digs) > k:
return -1
if len(digs) == k:
x = chr(ord("9") + 1)
y = x
for ch in digs:
if ord(ch) > ord(n[idx]) and ord(ch)... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_DEF IF VAR VAR STRING RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR VAR RETURN NUMBER IF FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR STRING NUMBER ASSIGN VAR VAR FOR VAR VAR IF FUNC_CALL VAR VA... |
It is a simplified version of problem F2. 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 leading... | import sys
input = sys.stdin.readline
bits = [[] for _ in range(11)]
for bit in range(1 << 10):
se = set()
for i in range(10):
if bit >> i & 1:
se.add(i)
bits[len(se)].append(se)
def main():
n, k = input().strip().split()
k = int(k)
l = len(n)
times = (10**l - 1) // 9
... | IMPORT ASSIGN VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN... |
It is a simplified version of problem F2. 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 leading... | for _ in range(int(input())):
n, k = map(int, input().split())
l = n
while len(set(str(n))) > k:
if n % 10 == 0:
n = n // 10
else:
n += 1
end = str(min(str(n))) * (len(str(l)) - len(str(n)))
print(int(str(n) + end)) | 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 WHILE FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP FUN... |
It is a simplified version of problem F2. 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 leading... | a = []
for i in range(10):
for j in range(i, 10):
for m in range(1, 11):
for k in range(2**m):
b = bin(k)[2:]
b = "0" * (m - len(b)) + b
y = ""
for l in b:
if l == "0":
y += str(i)
... | ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP VAR FUNC_CALL VAR VAR VAR ASSIGN VAR STRING FOR VAR VAR IF VAR STRING VAR FUNC_CALL VAR VAR... |
It is a simplified version of problem F2. 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 leading... | import sys
input = lambda: sys.stdin.readline().strip()
def solve():
n, k = map(int, input().split())
s = str(n)
if len(set(s)) <= k:
return n
L = len(s)
def helper(a, b):
i = 0
while i < len(s) and s[i] in a + b:
i += 1
if s[i] > b:
j = i ... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR VAR NUMBER IF VAR VAR VAR ... |
It is a simplified version of problem F2. 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 leading... | for _ in range(int(input())):
n, m = map(int, input().split())
if m == 1:
s = str(n)
if n <= int(s[0] * len(s)):
print(int(s[0] * len(s)))
else:
print(int(str(int(s[0]) + 1) * len(s)))
else:
A = list(str(n))
if min(A) == max(A):
pri... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC... |
It is a simplified version of problem F2. 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 leading... | for _ in range(int(input())):
n, k = map(int, input().split())
n = str(n)
stack = [["", 0]]
l = len(n)
store = ""
while stack:
num, loop = stack.pop()
if len(num) == l and len(set(num)) <= k:
store = num
break
flag = 0
for i in range(loop, ... | 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 LIST LIST STRING NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING WHILE VAR ASSIGN VAR VAR FUNC_CALL VAR IF FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR AS... |
It is a simplified version of problem F2. 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 leading... | t = int(input())
for _ in range(t):
n, k = map(int, input().split())
l = []
while n > 0:
l.insert(0, n % 10)
n = n // 10
digit = set()
ans = []
idx = 0
while len(digit) < k - 1:
digit.add(l[idx])
ans.append(l[idx])
idx += 1
while idx < len(l) and l... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST WHILE VAR NUMBER EXPR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR BIN_OP VA... |
It is a simplified version of problem F2. 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 leading... | for _ in range(int(input())):
n, k = map(int, input().split())
s = str(n)
m = int(len(s) * "1")
for i in range(1, 10):
if i * m >= n:
ans = i * m
break
if k == 2:
for i in range(9):
for j in range(i + 1, 10):
flag = 0
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR STRING FOR VAR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ... |
It is a simplified version of problem F2. 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 leading... | for _ in range(int(input())):
n, k = input().split()
k = int(k)
if len(n) == 1:
print(n)
continue
if k == 1:
f = True
ff = True
for u in n:
if n[0] < u and ff:
f = False
elif u < n[0]:
ff = False
if f... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR VAR ASSIGN VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR EXPR F... |
It is a simplified version of problem F2. 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 leading... | for s in [*open(0)][1:]:
prefix, k = map(int, s.split())
n = str(prefix)
while len(set(str(prefix))) > k:
prefix = prefix // 10 if not prefix % 10 else prefix + 1
prefix = str(prefix)
suffix = str(min(prefix) * (len(n) - len(prefix)))
print(prefix + suffix) | FOR VAR LIST FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR 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 ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR BIN... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | def rs():
return input().strip()
def ri():
return int(input())
def ria():
return list(map(int, input().split()))
def ia_to_s(a):
return " ".join([str(s) for s in a])
def how_many(m, a, pre, j):
return 2 ** (m - 1 - j) - sum([(1) for x in a if x.startswith(pre) and x[j] == "0"])
def solve(n... | FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP NUMBER BIN_OP BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR VAR FUNC_CALL ... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | def solve():
n, m = map(int, input().split())
a = [int(input(), 2) for _ in range(n)]
a = sorted(a)
Del = {}
def push(x):
Del[x] = 1
def process(cur, dx):
cur += dx
while cur in Del:
cur += dx
return cur
mean = (1 << m - 1) - 1
cur = 0
f... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FUNC_DEF ASSIGN VAR VAR NUMBER FUNC_DEF VAR VAR WHILE VAR VAR VAR VAR RETURN VAR ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER ASS... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | testcases = int(input())
for _ in range(testcases):
n, m = map(int, input().split())
d = dict()
mid = 2 ** (m - 1) - 1
for i in range(n):
s = int(input(), 2)
d[s] = 1
if i % 2 == 0:
if s <= mid:
mid += 1
while mid in d:
... | 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 BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER IF BIN_OP VAR NUMBER N... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | def read_int():
return int(input())
def read_string_array():
return input().split()
def read_int_array():
return [int(_) for _ in read_string_array()]
def read_line():
return input()
def solve(n, m, a):
a = [int(_, 2) for _ in a]
median = (2**m - 1) // 2
k = 2**m
removed = set()
... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | def count_smaller(value, banlist):
total = value
for v in banlist:
if v < value:
total -= 1
return total
cases = int(input())
for case in range(cases):
n, m = map(int, input().split())
banned = []
for i in range(n):
banned.append(int(input(), 2))
desindex = ((1 ... | FUNC_DEF ASSIGN VAR VAR FOR VAR VAR IF VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP B... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | from sys import stdin, stdout
def input():
return stdin.readline()
def ans(n, m, l, f, low, high):
for i in range(low, high + 1):
mi = 0
ma = 0
for j in l:
if j <= i:
mi += 1
if j > i:
ma += 1
rig = f - i - ma
le... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR IF BIN_OP VAR VAR NUMBER VAR VAR RETURN VAR FUNC_DEF FOR VAR FUNC_CA... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | def add(s):
b = []
carry = 1
for i in range(len(s) - 1, -1, -1):
if carry == 0:
cur = s[i]
elif s[i] == "0":
cur = "1"
carry = 0
else:
cur = "0"
b.append(cur)
res = "".join(b)[::-1]
return res
def sub(s):
b = []
... | FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR NUMBER ASSIGN VAR VAR VAR IF VAR VAR STRING ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR STRING EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL STRING VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR LIST IF VAR... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | def binary_number(line):
count = len(line)
number = 0
degree = 0
for x in range(count):
if line[x] == "1":
number += pow(2, count - 1 - degree)
degree += 1
return number
def binary_line(number, long):
line = ""
for x in range(long):
if number % 2 == 1:
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR BIN_O... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | T = int(input())
for _ in range(T):
N, M = map(int, input().split())
binary = {int(input(), 2) for _ in range(N)}
ALL = 1 << M
L = -1
R = ALL
K = (ALL - N) // 2
half_or_bigger = (
lambda x: ALL - x - sum(1 if bina > x else 0 for bina in binary) - 1
)
while R - L > 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 NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | t = int(input())
for _ in range(t):
n, m = map(int, input().split())
cnt = int(pow(2, m))
a = [0] * n
for i in range(n):
a[i] = int(input(), 2)
low = max(cnt // 2 - 105, 0)
high = min(cnt // 2 + 105, cnt - 1)
ans = 0
while low <= high:
mid = (low + high) // 2
less... | 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 NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | import sys
input = sys.stdin.readline
def print(val):
sys.stdout.write(val + "\n")
def prog():
for _ in range(int(input())):
n, m = map(int, input().split())
missing = [int(input().strip(), 2) for i in range(n)]
missing.sort()
median = (2**m - n - 1) // 2
for i in mi... | IMPORT ASSIGN VAR VAR FUNC_DEF EXPR FUNC_CALL VAR BIN_OP VAR STRING FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP ... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | def solve():
n, m = map(int, input().split())
a = []
for _ in range(n):
a.append(input())
a.sort()
ans = int((2**m - n - 1) // 2)
for i in a:
if f(i) > ans:
s = []
for j in range(m):
s.append(str(ans >> j & 1))
print("".join(s[:... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | def dd(i, nn):
s = bin(i).replace("0b", "")
l = len(s)
kk = ""
for i in range(nn - l):
kk = kk + "0"
print(kk + s)
t = int(input())
for i in range(t):
n, m = map(int, input().split())
aa = []
for pp in range(n):
pp = input()
aa.append(int(pp, 2))
y = 2 ** (m... | FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR STRING STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR STRING EXPR FUNC_CALL VAR BIN_OP 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 FUN... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | t = int(input())
for i in range(t):
n, m = map(int, input().split())
median = (2**m - 1 - n) // 2
a = [int(input(), 2) for i in range(n)]
for i in sorted(a):
if i <= median:
median += 1
y = bin(median)[2:]
print("0" * (m - len(y)) + y) | 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 BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR FUN... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | t = int(input())
for i in range(t):
n, m = map(int, input().split())
arr = []
for j in range(n):
x = input()
arr.append(int(x, 2))
current_median = 2 ** (m - 1) - 1
to_left = (2**m - n - 1) // 2 + 1
while True:
curr_to_left = current_median + 1
present = False
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_O... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | t = int(input())
for i in range(t):
n, m = map(int, input().split())
a = [int(input(), 2) for _ in range(n)]
ans = (2**m - n - 1) // 2
for s in sorted(a):
if s <= ans:
ans += 1
ans = bin(ans)
ans = ans[2:]
ans = "0" * (m - len(ans)) + ans
print(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 FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR FUN... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | t = int(input())
for y in range(t):
n, m = map(int, input().split())
mid = 2 ** (m - 1) - 1
d = dict()
for i in range(n):
x = int(input(), 2)
d[x] = 1
if i % 2 == 0:
if x <= mid:
mid += 1
while mid in d:
mid += 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 BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER IF BIN_OP VAR NUMBER N... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | def solve():
n, m = map(int, input().split())
a_s = [int(input(), 2) for _ in range(n)]
total = 2**m - n
med = (total + 1) // 2
l = -1
r = 2**m
while r - l > 1:
mid = (r + l) // 2
cnt = mid + 1
for a in a_s:
if a <= mid:
cnt -= 1
if... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | def solve():
n, m = [int(x) for x in input().split()]
a = []
for i in range(n):
a.append(input())
a = [int(x, 2) for x in a]
need = ((1 << m) - n - 1) // 2 + 1
cur = (1 << m - 1) - 1
while True:
left = cur + 1
flag = bool(cur in a)
for s in a:
if s... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | def binaryToDecimal(x):
return int(x) if len(x) <= 1 else binaryToDecimal(x[:-1]) * 2 + int(x[-1])
def decimalToBinary(m, x):
if x == 0:
return "0" * m
res = ""
while x > 0:
res = str(x % 2) + res
x //= 2
while len(res) < m:
res = "0" + res
return res
def uppe... | FUNC_DEF RETURN FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER FUNC_CALL VAR VAR NUMBER FUNC_DEF IF VAR NUMBER RETURN BIN_OP STRING VAR ASSIGN VAR STRING WHILE VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR NUMBER WHILE FUNC_CALL VAR VAR VAR ASSIGN VAR BIN... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | def solve(n, m, remove):
l, r = 0, 2**m - 1
k = 2**m - n
target = (k - 1) // 2
while l < r - 1:
mid = (l + r) // 2
c = mid + 1 - sum(x <= mid for x in remove)
if c - 1 >= target:
r = mid
else:
l = mid
c1 = l + 1 - sum(x <= l for x in remove)
... | FUNC_DEF ASSIGN VAR VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER WHILE VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR VAR VAR IF BIN_OP VAR NUMBER VAR ASSIGN VAR VAR ... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | import sys
input = sys.stdin.readline
def stringminus(s):
i = -1
n = len(s)
s2 = ["0"] * n
for j in range(n):
s2[j] = s[j]
while s[i] == "0":
s2[i] = "1"
i -= 1
s2[i] = "0"
sol = s2[0]
for i in range(1, n):
sol += s2[i]
return sol
def stringplus(s... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST STRING VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR WHILE VAR VAR STRING ASSIGN VAR VAR STRING VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR RETURN VAR FUNC_... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | def dec(b, m):
return "{:0{}b}".format(int(b, 2) - 1, m)
def inc(b, m):
return "{:0{}b}".format(int(b, 2) + 1, m)
def median(n, m, a):
md = "0" + "1" * (m - 1)
state = 1
seen = {}
for e in a:
if e > md:
state -= 1
if state == -1:
while True:
... | FUNC_DEF RETURN FUNC_CALL STRING BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR FUNC_DEF RETURN FUNC_CALL STRING BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER VAR FUNC_DEF ASSIGN VAR BIN_OP STRING BIN_OP STRING BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR DICT FOR VAR VAR IF VAR VAR VAR NUMBER IF VAR NUMBER WHILE NUMBER ASSIGN ... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | def check(x, nums, k):
small = x + 1
for i in nums:
if i <= x:
small -= 1
if small <= (k - 1) // 2:
return False
return True
def solve(nums, m, ans):
n = len(nums)
low = 0
high = pow(2, m) - 1
x = 0
k = pow(2, m) - n
while low <= high:
mid = ... | FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER IF VAR BIN_OP BIN_OP VAR NUMBER NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER VAR VAR WHILE VAR ... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep="\n")
def solve():
n, m = nm()
l = [int(ns(), 2)... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN 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 VAR STRING FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR ASSIG... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | def op_one_median(median, removed, op):
median += op
while median in removed:
median += op
return median
def add_one_median(median, removed):
res = op_one_median(median, removed, 1)
return res
def remove_one_median(median, removed):
res = op_one_median(median, removed, -1)
return... | FUNC_DEF VAR VAR WHILE VAR VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | T = int(input())
for t in range(T):
n, m = map(int, input().split())
nums = set()
even = True
curr_med = (2**m - 1) // 2
for i in range(n):
num = int(input(), 2)
nums.add(num)
if num > curr_med:
if not even:
curr_med -= 1
while curr... | 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 BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR IF ... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | def cast(now):
if now == 0:
return ""
return cast(now // 2) + str(now % 2)
def is_mediana(all_numbers, num, a):
if num in a:
return False
left = num
right = all_numbers - num - 1
for i in a:
if i < num:
left -= 1
else:
right -= 1
retu... | FUNC_DEF IF VAR NUMBER RETURN STRING RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER VAR NUMBER RETURN VAR VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR FUNC_CALL VA... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | from sys import stdin, stdout
def solve():
n, m = map(int, stdin.readline().split())
median = (1 << m - 1) - 1
left, right = median, (1 << m) - 1 - median
deleted = []
for _ in range(n):
x = int(input(), 2)
if left == right:
left -= 1
if x >= median:
... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER WHI... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | t = int(input())
for _ in range(t):
n, m = map(int, input().split())
arr = []
for i in range(n):
arr.append(input().strip())
arr1 = []
for i in arr:
arr1.append(int(i, 2))
a = (2**m - n - 1) // 2
arr1.sort()
for i in arr1:
if i <= a:
a += 1
ans = b... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP NU... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | def solve():
ans = 2 ** (m - 1) - 1
l = 0
removed = set()
for i in range(n):
removed.add(a[i])
if l == 0:
if a[i] <= ans:
ans = ansplus(ans, removed)
elif a[i] >= ans:
ans = ansminus(ans, removed)
l ^= 1
ans = format(ans, "0" + ... | FUNC_DEF ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR IF VAR NUMBER IF VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP B... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | def cvt(st):
st = st[::-1]
num = 0
for i, ix in enumerate(st):
num += int(int(ix) * int(2**i))
return num
for _ in range(int(input())):
n, m = [int(i) for i in input().split()]
maxx = 2**m - 1
ran = maxx + 1
med = maxx // 2
rem = set()
num = maxx + 1
for i in range(... | FUNC_DEF ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP NUMBER VAR RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER A... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | for _ in range(int(input())):
n, m = map(int, input().split())
a = [None] * n
for i in range(n):
a[i] = input()
a[i] = int(a[i], 2)
now = 2 ** (m - 1) - 1
lr = (2**m - n - 1) // 2 + 1
while True:
e, le = 0, now + 1
for i in range(n):
if a[i] <= now:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NONE VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP ... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | import sys
input = sys.stdin.readline
(T,) = map(int, input().split())
for _ in range(T):
N, M = map(int, input().split())
m = 2 ** (M - 1) - 1
vs = set()
for i in range(N):
x = int(input(), 2)
vs.add(x)
if i % 2:
if m <= x:
while True:
... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR 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 BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER EXPR FUN... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | for _ in range(int(input())):
n, m = map(int, input().split())
a = [int(input(), 2) for _ in range(n)]
a.sort()
k = (1 << m) - n
median = (k - 1) // 2
for elem in a:
if elem <= median:
median += 1
median = bin(median)[2:]
median = (m - len(median)) * "0" + median
... | 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 NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER FOR VAR VAR IF VAR VAR VAR NUMBER ASSIGN VA... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | import sys
def process():
n, m = [int(s) for s in sys.stdin.readline().split()]
med = (2**m - 1 - n) // 2
ss = set()
count = 0
for i in range(n):
r = int(sys.stdin.readline().strip(), 2)
if r < med:
count += 1
else:
ss.add(r)
while med in ss:
... | IMPORT FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR NUMBER IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR WHILE... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | def convert(z):
s = ""
while z > 0:
if z % 2:
s = "1" + s
else:
s = "0" + s
z = z // 2
return s
def num(s):
sumi = 0
for i in s:
sumi = 2 * sumi + int(i)
return sumi
def f(x):
global lfi
cnt1 = 0
cnt2 = 0
for i in lfi:
... | FUNC_DEF ASSIGN VAR STRING WHILE VAR NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR FUNC_CALL VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR ... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | def quick_gcd(a, b):
for i in range(min(a, b), 0, -1):
if a % i == 0 and b % i == 0:
return i
def go():
n, m = map(int, input().split())
s = [int(input(), 2) for _ in range(n)]
sets = set()
v = (2**m - 1 - n) // 2
for ss in s:
if ss <= v:
v += 1
... | FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER NUMBER IF BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | def read_int():
return int(input())
def read_ints():
return list(map(int, input().split(" ")))
t = read_int()
for case_num in range(t):
n, m = read_ints()
a = []
for i in range(n):
a.append(int(input(), 2))
a.sort()
k = 2**m - n
ans = (k - 1) // 2
for ai in a:
if ... | FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR AS... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | for i in range(int(input())):
n, m = map(int, input().split())
a = [int(input(), 2) for _ in range(n)]
x = (2**m - n - 1) // 2
for v in sorted(a):
if v <= x:
x += 1
print("{0:0={1}b}".format(x, 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 FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL ... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | INF = 10**18
t = int(input())
n = int()
m = int()
def bin(x):
global m
res = str()
while x > 0:
res += str(x % 2)
x //= 2
while len(res) < m:
res += "0"
return res[::-1]
def get(x):
res = 0
x = x[::-1]
for i in range(len(x)):
res += 2**i * int(x[i])
... | ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR WHILE VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER WHILE FUNC_CALL VAR VAR VAR VAR STRING RETURN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR NU... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | t = int(input())
for _ in range(t):
n, m = map(int, input().split())
binaryString = []
for _ in range(n):
binaryString.append(input())
if m <= 8:
isIncluded = [True] * 2**m
for val in binaryString:
isIncluded[int(val, 2)] = False
curIndex = 0
medianInd... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP NUMBER VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | from sys import stdin, stdout
int_in = lambda: int(stdin.readline())
arr_in = lambda: [int(x) for x in stdin.readline().split()]
mat_in = lambda rows: [arr_in() for y in range(rows)]
str_in = lambda: stdin.readline().strip()
out = lambda o: stdout.write("{}\n".format(o))
arr_out = lambda o: out(" ".join(map(str, o)))
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR STR... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | for _ in range(int(input())):
n, m = map(int, input().split())
x = (2**m - n - 1) // 2
arr = []
for i in range(n):
arr.append(int(input(), 2))
arr.sort()
for i in range(0, n):
if arr[i] <= x:
x += 1
if x in arr:
x += 1
y = bin(x)[2:]
print("0" * (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 BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER V... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | def toBinary(i, digit):
b = bin(i).replace("0b", "")
n = digit - len(b)
x = ""
for itr in range(n):
x = x + "0"
return x + b
def main():
t = int(input())
for _ in range(t):
n, m = map(int, input().split())
l = []
for i in range(n):
l.append(int(i... | FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR STRING STRING ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR STRING RETURN BIN_OP VAR VAR 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_C... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | for _ in range(int(input())):
n, m = map(int, input().split())
a = []
mp = {}
for i in range(n):
s = input()
s = int(s, 2)
a.append(s)
l = 1 << m
median = (l - 1) // 2
for elem in a:
l -= 1
mp[elem] = 1
if l % 2 == 1 and median >= elem:
... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | from sys import stdin, stdout
print = stdout.write
input = stdin.readline
def solve():
n, m = map(int, input().split())
x = pow(2, m - 1) - 1
cou = x * 2
se = set()
for _ in range(n):
y = int(input().strip(), 2)
se.add(y)
if y >= x and cou % 2 == 1:
x -= 1
... | ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR VAR I... |
Consider all binary strings of length $m$ ($1 \le m \le 60$). A binary string is a string that consists of the characters 0 and 1 only. For example, 0110 is a binary string, and 012aba is not. Obviously, there are exactly $2^m$ such strings in total.
The string $s$ is lexicographically smaller than the string $t$ (bot... | def prog():
for _ in range(int(input())):
n, m = map(int, input().split())
missing = [int(input().strip(), 2) for i in range(n)]
missing.sort()
missing2 = set(missing)
median = (2**m - n + 1) // 2
curr = median - 1
index = median
while curr in missing2... | FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER NUMBER ASSIGN VAR... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.