description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | a, e, x = map(int, input().split())
big = a - e
small = e - 1
l = 0
r = a
c = a - 1
ans = 1
while l < r:
m = (l + r) // 2
if m < x:
c -= 1
l = m + 1
ans *= small % (10**9 + 7)
small -= 1
elif m == x:
ans = ans
l = m + 1
else:
c -= 1
ans *= ... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP VAR BIN_... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | def bis(a, x):
left = 0
right = len(a)
cnt_1 = cnt_2 = 0
while left < right:
middle = (left + right) // 2
if a[middle] <= x:
left = middle + 1
cnt_1 += 1
else:
right = middle
cnt_2 += 1
return cnt_1, cnt_2
mod = 10**9 + 7
N, X... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR NUMBER RETURN VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | import sys
input = sys.stdin.readline
max_n = 1000
fact, inv_fact = [0] * (max_n + 1), [0] * (max_n + 1)
fact[0] = 1
mod = 10**9 + 7
def make_nCr_mod():
global fact
global inv_fact
for i in range(max_n):
fact[i + 1] = fact[i] * (i + 1) % mod
inv_fact[-1] = pow(fact[-1], mod - 2, mod)
for ... | IMPORT ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR N... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | n, x, pos = input().split()
n = int(n)
x = int(x)
pos = int(pos)
mod = 1000000000.0 + 7
big = n - x
small = x - 1
left = 0
right = n
ans = 1
while left < right:
middle = (left + right) // 2
n -= 1
if middle == pos:
left = middle + 1
continue
elif middle > pos:
ans = ans * big % m... | ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBE... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | f, t = -1, 0
INT = 10**9 + 7
def mult(a, b):
ans = 1
for i in range(b):
ans *= a - i
ans %= INT
return ans
def fact(a):
ans = 1
for i in range(a):
ans *= i + 1
ans %= INT
return ans
L = []
def BinarySearch(num, pos):
global f, t
a = [i for i in ran... | ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR VAR RETURN VAR ASSIGN VAR LIST FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VA... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | mod = 1000 * 1000 * 1000 + 7
fac = [1] * 10001
for i in range(2, 1001):
fac[i] = fac[i - 1] * i
def comb(a, b):
if a < b:
return 0
return fac[a] // fac[a - b]
def solve(n, x, pos):
smaller = 0
greater = 0
l = 0
r = n
while l < r:
mid = (l + r) // 2
if mid < po... | ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR FUNC_DEF IF VAR VAR RETURN NUMBER RETURN BIN_OP VAR VAR VAR BIN_OP VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER A... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | import sys
input = sys.stdin.buffer.readline
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
rs = lambda: input().decode().rstrip("\n\r")
wrt = sys.stdout.write
pr = lambda *args, end="\n": wrt(" ".join([str(x) for x in args]) + end)
enum = enumerate
inf = float("inf")
cdiv = lambda x, y: -(-x /... | IMPORT ASSIGN VAR VAR 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 FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR ASSIGN VAR STRING FUNC_CALL VAR BIN_OP FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | mod = 10**9 + 7
def modExp(a, n, m=10**9 + 7):
if n == 0:
return 1
elif n == 1:
return a
else:
while n >= 2:
if n % 2 == 0:
n = n // 2
return modExp(a % m * (a % m) % m, n, m)
else:
n = (n - 1) // 2
... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF BIN_OP BIN_OP NUMBER NUMBER NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN VAR WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP V... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | n, X, pos = [int(x) for x in input().split(" ")]
a = [i for i in range(n)]
x = pos
smaller = 0
larger = 0
positions_checked = set()
left = 0
right = len(a)
middle = None
while left < right:
if (left + right) % 2 == 0:
middle = round((left + right) / 2)
else:
middle = int((left + right) / 2)
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NONE WHILE VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CAL... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | mod = 1000000007
n, x, pos = map(int, input().split())
ans = 1
left = 0
right = n
toLeft = n - x
toRight = x - 1
failed = False
c = 0
while left < right:
middle = (left + right) // 2
if middle == pos:
left = middle + 1
c += 1
elif middle > pos:
if toLeft == 0:
failed = Tr... | ASSIGN VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR N... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | from sys import stdin
input = stdin.readline
def A():
t = int(input())
for __ in range(t):
n, m = map(int, input().split())
a = list(map(int, input().split()))
if sum(a) == m:
print("YES")
else:
print("NO")
def B():
t = int(input())
for __ in ... | ASSIGN 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_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR FUNC_CALL ... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | def A(k, n):
ans = 1
if k >= 1:
for i in range(n - k + 1, n + 1):
ans *= i
return ans
def f(n):
ans = 1
for i in range(n):
ans *= i + 1
return ans
def solve(n, x, pos):
cntBig = 0
cntLess = 0
left = 0
right = n
ans = 1
mod = 1000000007
... | FUNC_DEF ASSIGN VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VA... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | import sys
def Ints():
return map(int, sys.stdin.readline().strip().split())
def Strs():
return map(str, sys.stdin.readline().strip().split())
def Array():
return list(map(int, sys.stdin.readline().strip().split()))
def Str():
return sys.stdin.readline().strip()
def Int():
return int(sys.s... | IMPORT FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR F... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | mod = 1000000007
def power(n, x):
val = 1
while x != 0:
if x & 1:
val = val * n % mod
n = n * n % mod
x //= 2
return val
def fact(n):
val = 1
for i in range(1, n + 1):
val = val * i % mod
return val
def comb(n, x):
y1 = power(fact(x), mod - 2... | ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | MOD = 10**9 + 7
n, x, pos = map(int, input().split())
lt = 0
gt = 0
left = 0
right = n
while left < right:
middle = (left + right) // 2
if pos >= middle:
if pos > middle:
lt += 1
left = middle + 1
else:
gt += 1
right = middle
if x - 1 >= lt and n - x >= gt:
c ... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR IF... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | def C(n, k):
ans = 1
for i in range(n, n - k, -1):
ans *= i
ans %= 10**9 + 7
ans = max(1, ans)
return ans
n, m, k = map(int, input().split())
l = 0
r = int(n)
x1 = 0
x2 = 0
while l < r:
mid = (l + r) // 2
if mid < k:
l = mid + 1
x1 += 1
elif mid == k:
... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR NUMBER VAR VAR VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER VAR RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE V... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | mod = 1000000007
def facto(f, q):
facto = 1
for i in range(f, q + 1):
facto = facto * i % mod
return facto
n, x, p = map(int, input().split())
left = 0
right = n
r = 0
l = 0
while left < right:
middle = (left + right) // 2
if middle == p:
left = middle + 1
elif middle > p:
... | ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | [n, k, pos] = [int(i) for i in input().split()]
l = 0
r = n
c1 = 0
c2 = 0
while l < r:
m = (l + r) // 2
if m <= pos:
c1 += 1
l = m + 1
else:
c2 += 1
r = m
ans = 1
for i in range(n - (c1 + c2)):
ans = ans * (i + 1)
ans = ans % 1000000007
c1 -= 1
p1 = k - 1
p2 = n - k
f... | ASSIGN LIST VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | import sys
input = sys.stdin.readline
n, x, pos = list(map(int, input().split()))
mod = 10**9 + 7
ANS = [0] * n
left = 0
right = n
while left < right:
middle = (left + right) // 2
if pos >= middle:
ANS[middle] = -1
left = middle + 1
else:
ANS[middle] = 1
right = middle
ANS[p... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR N... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | n, x, pos = map(int, input().split())
Max_m = x - 1
Max_b = n - x
kol_m = 0
kol_b = 0
l = 0
r = n
while l < r:
m = (l + r) // 2
if m <= pos:
l = m + 1
if pos == m:
continue
if m < pos:
kol_m += 1
if m > pos:
kol_b += 1
else:
r = m
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR IF VAR VAR VAR NUMBER IF VAR V... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | def binary_search(start, number, find):
while start < number:
mid = (start + number) // 2
if mid <= find:
start = mid + 1
else:
number = mid
check.append(mid)
m = 1000000007
def factorial(number):
ans = 1
for i in range(2, number + 1):
ans ... | FUNC_DEF WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR RETURN BIN_OP VAR VAR ASSIGN... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | import sys
input = sys.stdin.readline
MOD = 10**9 + 7
N = 2000
fact = [(0) for _ in range(N)]
invfact = [(0) for _ in range(N)]
fact[0] = 1
for i in range(1, N):
fact[i] = fact[i - 1] * i % MOD
invfact[N - 1] = pow(fact[N - 1], MOD - 2, MOD)
for i in range(N - 2, -1, -1):
invfact[i] = invfact[i + 1] * (i + 1) ... | IMPORT ASSIGN VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR NUMBER FUNC_CAL... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | le, num, pos = list(map(int, input().split()))
needBigger = 0
needLower = 0
mod = 1000000000.0 + 7
l = 0
r = le
while l < r:
mid = (l + r) // 2
if mid <= pos:
if mid != pos:
needLower += 1
l = mid + 1
else:
r = mid
needBigger += 1
amountOfLess = num - 1
amountOfBi... | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR NUMBER AS... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | n, x, pos = map(int, input().split())
mod = 10**9 + 7
N = 10**5
mod = 10**9 + 7
fac = [1] * (N + 1)
finv = [1] * (N + 1)
for i in range(N):
fac[i + 1] = fac[i] * (i + 1) % mod
finv[-1] = pow(fac[-1], mod - 2, mod)
for i in reversed(range(N)):
finv[i] = finv[i + 1] * (i + 1) % mod
def cmb1(n, r, mod):
if r... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BI... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | prime = 10**9 + 7
def process(n, x, pos):
s = 0
e = n
smaller = []
larger = []
while s < e:
m = (s + e) // 2
if m <= pos:
if m < pos:
smaller.append(m)
s = m + 1
else:
larger.append(m)
e = m
if x - 1 < len(... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR IF BIN_OP VAR NUMBER FUNC_CALL VAR... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | n, x, p = map(int, input().split())
l = 0
r = n
MOD = 1000000000.0 + 7
gt, ls = 0, 0
while l < r:
m = (l + r) // 2
if p < m:
gt += 1
r = m
if p >= m:
if p > m:
ls += 1
l = m + 1
if n - x < gt or x - 1 < ls:
ans = 0
print(0)
exit()
ans = 1
c = n - x + 1... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR VAR IF VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VA... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | def binarySearch(a, x, status):
left = 0
right = len(a)
while left < right:
mid = (left + right) // 2
if a[mid] <= x:
left = mid + 1
status[mid] = -1
else:
right = mid
status[mid] = 1
def inv(n, p):
return pow(n, p - 2, p)
fact ... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR FUN... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | from sys import stdin, stdout
input = stdin.readline
print = lambda x: stdout.write(str(x) + "\n")
def bs(n, pos):
a = list(range(n))
l, r = 0, n
low, high = 0, 0
taken = set()
while l < r:
m = (l + r) // 2
if a[m] < pos:
l = m + 1
if m not in taken:
... | ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR STRING FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR NUM... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | M = 10**9 + 7
def mpow(x, y):
r = 1
while y > 0:
if y & 1:
r = r * x % M
x = x * x % M
y = y // 2
return r
def nCr(a, b):
if b > a or a < 0 or b < 0:
return 0
return fact[a] * mpow(fact[b], M - 2) % M * mpow(fact[a - b], M - 2) % M
n, x, pos = list(m... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF IF VAR VAR VAR NUMBER VAR NUMBER RETURN NUMBER RETURN BIN_OP BIN_OP BIN_OP BIN_OP VAR ... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | def solve(n, val, pos):
l = 0
r = n
small = val - 1
big = n - val
pos1, pos2 = 0, 0
while l < r:
mid = (l + r) // 2
if mid <= pos:
pos1 += 1
l = mid + 1
elif mid > pos:
pos2 += 1
r = mid
ans, mod = 1, 10**9 + 7
for i... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR NUMBER NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR NUMBER BIN_OP BIN_OP NUMBER NUMBER NU... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | import sys
input = sys.stdin.readline
def bs(r, x):
left = 0
right = r
while left < right:
m = (left + right) // 2
if m <= x:
left = m + 1
arr[m] = "S"
else:
right = m
arr[m] = "G"
mod = 10**9 + 7
fact = [1] * 1001
for i in range(1... | IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR STRING ASSIGN VAR VAR ASSIGN VAR VAR STRING ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VA... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | from sys import maxsize, stderr, stdin, stdout
mod = int(1000000000.0 + 7)
def tup():
return map(int, stdin.readline().split())
def I():
return int(stdin.readline())
def lint():
return [int(x) for x in stdin.readline().split()]
def S():
return input().strip()
def grid(r, c):
return [lint(... | ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF NUMBER EX... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | def modFact(n, p):
if n >= p:
return 0
result = 1
for i in range(1, n + 1):
result = result * i % p
return result
def ncr(n, r, p):
num, den = 1, 1
for i in range(r):
num = num * (n - i) % p
den = den * (i + 1) % p
return num * pow(den, p - 2, p) % p
l = l... | FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR RETURN BIN... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | def fact(n):
ans = 1
for i in range(2, n + 1):
ans *= i
return ans
n, m, k = [int(x) for x in input().split()]
l = m - 1
g = n - l - 1
ans = 1
start = 0
end = n
while start < end:
mid = (start + end) // 2
if mid == k:
start = mid + 1
elif mid < k:
ans *= l
l -= ... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | mod = 10**9 + 7
n, x, pos = map(int, input().split())
left, right = 0, n
r = 1
z = 0
p, q = x - 1, n - x
while left < right:
mid = (left + right) // 2
z += 1
if pos == mid:
left = mid + 1
elif pos < mid:
right = mid
r *= q
q -= 1
else:
left = mid + 1
r... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBE... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | n, a, b = map(int, input().split())
mod = 1000000000 + 7
ans = 1
cnt, cnt1 = 0, 0
i, j = 0, n
while i < j:
mid = (i + j) // 2
if mid < b:
ans *= a - 1 - cnt1
ans %= mod
cnt1 += 1
i = mid + 1
elif mid > b:
ans *= n - a - cnt
ans %= mod
cnt += 1
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR BIN_OP BIN_OP VAR NUMBER VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR V... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | mod = 1000000007
big = 0
small = 0
fact = []
def c(n: int, k: int):
if n < k:
return 0
return fact[n] // (fact[k] * fact[n - k]) % mod
def binary(n: int, pos: int):
l = 0
r = n
while l < r:
mid = (l + r) // 2
if mid <= pos:
if mid != pos:
globa... | ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FUNC_DEF VAR VAR IF VAR VAR RETURN NUMBER RETURN BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR FUNC_DEF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR IF VAR VAR VAR NUMBER ASSI... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | def solve(n):
ans_arr = [[(0) for _ in range(n)] for _ in range(n)]
for i in range(0, n, 2):
ans_arr[i][i] = 1
ans_arr[i][i + 1] = 1
ans_arr[i + 1][i] = 1
ans_arr[i + 1][i + 1] = 1
if n - i == 3:
for j in range(3):
ans_arr[i + 2][i + j] = 1
... | FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR NU... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | def search(a, x):
left = 0
right = len(a)
while left < right:
middle = (left + right) // 2
if a[middle] <= x:
left = middle + 1
else:
right = middle
if left > 0 and a[left - 1] == x:
return True
else:
return False
def perm(n, r):
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR IF VAR NUMBER VAR BIN_OP VAR NUMBER VAR RETURN NUMBER RETURN NUMBER FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR BIN_OP... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | n, x, pos = map(int, input().split())
smaller = 0
larger = 0
for i in range(1, n + 1):
if i > x:
larger += 1
elif i < x:
smaller += 1
l = 0
r = n
ans = 1
while l < r:
mid = (l + r) // 2
if mid < pos:
ans = ans * smaller
smaller -= 1
l = mid + 1
elif mid == pos... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR BIN_O... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | def solve():
n, x, p = map(int, input().split())
a = [i for i in range(n)]
left = 0
right = n
b = []
while left < right:
m = (left + right) // 2
b.append(m)
if a[m] <= p:
left = m + 1
else:
right = m
k = 0
m = 0
for i in b:
... | FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR LIST WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | import sys
n, x, pos = [int(a) for a in input().split()]
factorials = [1]
for i in range(1, 1033):
factorials.append(factorials[-1] * i)
def fac(n):
return factorials[n]
mod = int(1000000000.0 + 7)
count_left = 0
count_right = 0
def binary_search(a, x):
global count_left, count_right
left = 0
... | IMPORT ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_DEF RETURN VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | m = 1000000007
def P(a, b):
res = 1
i = a - b + 1
while i <= a:
res = res * i % m
i += 1
return res
n, x, pos = input().split()
n = int(n)
x = int(x)
pos = int(pos)
l, r = 0, n
gc, lec = 0, 0
while l < r:
mid = int((l + r) / 2)
if pos == mid:
l = mid + 1
elif pos ... | ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER VAR ASSIGN... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | n, x, pos = map(int, input().split())
mod = 10**9 + 7
left = 0
right = n
moves = []
middles = []
middle = (left + right) // 2
while left < right:
middle = (left + right) // 2
if middle <= pos:
left = middle + 1
moves.append(1)
else:
right = middle
moves.append(-1)
middles... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | mod = 10**9 + 7
class Combi:
def __init__(self, N, mod):
self.power = [(1) for _ in range(N + 1)]
self.rev = [(1) for _ in range(N + 1)]
self.mod = mod
for i in range(2, N + 1):
self.power[i] = self.power[i - 1] * i % self.mod
self.rev[N] = pow(self.power[N], s... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER CLASS_DEF FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR VAR FUNC_CALL V... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | n, x, pos = map(int, input().split())
def binarysearch(n, pos, x):
left = 0
right = n
ans = 1
l = 0
r = 0
while left < right:
middle = (left + right) // 2
if middle < pos:
r += 1
left = middle + 1
elif middle == pos:
left = middle + 1... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | MOD = int(1000000000.0 + 7)
n, x, pos = map(int, input().split())
under_cnt = x - 1
over_cnt = n - x
under = 0
over = 0
left = 0
right = n
while left < right:
middle = (left + right) // 2
if middle < pos:
left = middle + 1
under += 1
elif middle > pos:
right = middle
over += ... | ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR NU... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | M = int(1000000000.0) + 7
def fact(n):
res = 1
for i in range(2, n + 1):
res *= i
res %= M
return res
def modinv(a):
return int(pow(a, M - 2, M))
def moddiv(a, b):
bb = modinv(b)
a *= bb
a %= M
return a
def npr(n, r):
if n <= 0 or r <= 0:
return 1
... | ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR VAR VAR RETURN VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR RETURN VAR FUNC_DEF IF VAR NUMBER VAR NUMBER RETU... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | def ncr(n, r, p):
if r > n:
return 0
num = den = 1
for i in range(r):
num = num * (n - i) % p
den = den * (i + 1) % p
return num * pow(den, p - 2, p) % p
def fac(n, p):
if n >= p:
return 0
result = 1
for i in range(1, n + 1):
result = result * i % p
... | FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR RETURN BIN_OP BIN_OP VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL ... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | a, e, x = [int(i) for i in input().split()]
b, s = a - e, e - 1
l, r, c, res = 0, a, a - 1, 1
modulo = 10**9 + 7
while l < r:
m = (l + r) // 2
if m < x:
c -= 1
l = m + 1
res *= s % (10**9 + 7)
s -= 1
elif m == x:
res = res
l = m + 1
else:
c -= 1
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMB... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | n, val, pos = map(int, input().split())
less = val - 1
large = n - val
s = 0
e = n
ans = 1
while s < e:
mid = (s + e) // 2
if mid < pos:
s = mid + 1
ans *= less
less -= 1
elif mid > pos:
e = mid
ans *= large
large -= 1
else:
s = mid + 1
less += lar... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR VAR VAR NU... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | def fact(n):
ans = 1
while n > 1:
ans *= n % 1000000007
n -= 1
return ans
def solve(up, dw):
mi = up - dw
ans = 1
while up > mi:
ans *= up
up -= 1
return ans
arr = [int(x) for x in input().split()]
n, ele, x = arr[0], arr[1], arr[2]
l, r = 0, n
cb, cs = 0,... | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER VAR ... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | N, x, pos = map(int, input().split())
mod = 10**9 + 7
def nPr(n, r):
if n < r:
return 0
if n == 0 or r == 0:
return 1
fact = 1
for i in range(n, n - r, -1):
fact = fact * i % mod
return fact
gt = 0
lt = 0
left = 0
right = N
s = set()
while left < right:
mid = (right +... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR RETURN VAR ASSIGN VAR NUMBER ASSIGN V... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | def fast_factorial(mod=None):
res = [1, 1]
size = 2
def ff(k):
nonlocal size
while k >= size:
res.append(res[-1] * size)
size += 1
return res[k]
def ff_mod(k):
nonlocal size
while k >= size:
res.append(res[-1] * (size % mod) %... | FUNC_DEF NONE ASSIGN VAR LIST NUMBER NUMBER ASSIGN VAR NUMBER FUNC_DEF WHILE VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR NUMBER RETURN VAR VAR FUNC_DEF WHILE VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR VAR VAR VAR NUMBER RETURN VAR VAR IF VAR NONE RETURN VAR RETURN VAR ASSIGN VAR BIN_OP BIN_... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | n, x, pos = map(int, input().split())
MOD = 10**9 + 7
l, r, a, b = 0, n, 0, 0
while l < r:
m = (l + r) // 2
if pos == m:
l = m + 1
elif pos < m:
b += 1
r = m
else:
a += 1
l = m + 1
aa, bb = x - 1, n - x
if aa < a or bb < b:
print(0)
exit(0)
def A(n, k):
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR VAR NUMBER VAR NUMBER NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR N... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | from sys import exit, stdin
def BS(A, x):
left = 0
right = len(A)
mids = []
smal = []
while left < right:
middle = (left + right) // 2
mids.append(middle)
if A[middle] <= x:
left = middle + 1
smal.append(1)
else:
right = middle
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR NUMBER RETURN VAR VAR ASSIGN VAR NUMBER VAR NUMBER ... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | import sys
input = sys.stdin.readline
I = lambda: list(map(int, input().split()))
def ncr(n, r, p=10**9 + 7):
if n < r:
return 0
num = 1
r = min(r, n - r)
ct = 1
while ct <= r:
num = num * n % p
num = num * pow(ct, p - 2, p) % p
ct += 1
n -= 1
return nu... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF BIN_OP BIN_OP NUMBER NUMBER NUMBER IF VAR VAR RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR FU... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | def inv(x):
return pow(x, 1000000005, 1000000007)
def ncr(n, r):
if r > n:
return 0
z = fact[n] * inv(fact[r])
z %= 1000000007
z = z * inv(fact[n - r])
z %= 1000000007
return z
fact = [(0) for i in range(1005)]
fact[0] = 1
fact[1] = 1
for i in range(2, 1005):
fact[i] = fact[i... | FUNC_DEF RETURN FUNC_CALL VAR VAR NUMBER NUMBER FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR BIN_OP VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR F... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | def solve():
n, x, pos = map(int, input().split())
l = 0
r = n
smaller = 0
larger = 0
while l < r:
m = (l + r) // 2
if m < pos:
smaller += 1
l = m + 1
elif m > pos:
larger += 1
r = m
else:
l = m + 1
i... | FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | a, b, c = map(int, input().split())
l, h = 0, a
r = 1
z = 0
p, q = b - 1, a - b
while l < h:
m = (l + h) // 2
if m == c:
z += 1
l = m + 1
elif m > c:
z += 1
r *= q
q -= 1
h = m
else:
z += 1
r *= p
p -= 1
l = m + 1
for i in r... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR NUMBER VAR VAR VAR NUMBER ASS... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | def c(n, k):
if k > n:
return 0
s = 1
for i in range(max(n - k, k) + 1, n + 1):
s *= i
for i in range(2, min(k, n - k) + 1):
s //= i
return s % mod
def fa(k):
s = 1
for i in range(2, k + 1):
s *= i
s %= mod
return s
n, x, pos = map(int, input()... | FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR NUMBER BIN_OP VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR BIN_OP VAR VAR NUMBER VAR VAR RETURN BIN_OP VAR VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR ... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | MAXN = 1005
mod = 10**9 + 7
def nCr(n, r):
global fact
if r > n:
return 0
num = fact[n]
denom = fact[r] * fact[n - r] % mod
return num * pow(denom, mod - 2, mod) % mod
n, x, pos = map(int, input().split())
bits = len(bin(n)[2:])
if (1 << 30) % n == 0:
bits -= 1
fact = [1] * MAXN
for ... | ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR RETURN BIN_OP BIN_OP VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_C... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | n, x, pos = map(int, input().split())
u = [0] * n
u[pos] = x
for i in range(pos + 1, n):
u[i] = x + 1
L = 0
R = n
cnt1 = cnt2 = 0
a = []
b = []
while L < R:
M = (L + R) // 2
if u[M] <= x:
if M != pos:
cnt1 += 1
a.append(M)
L = M + 1
else:
cnt2 += 1
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | mod = 1000000007
n, x, pos = map(int, input().split())
top, bot, lo, hi = n, 0, 0, 0
while top > bot:
mid = top + bot >> 1
if mid > pos:
hi += 1
top = mid
else:
if mid < pos:
lo += 1
bot = mid + 1
F, I = [(1) for _ in range(n + 1)], [(1) for _ in range(n + 1)]
for... | ASSIGN VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR NUMBER NUMBER NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR ... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | import sys
def mul(val, times, M):
ans = 1
for i in range(0, times):
ans *= val
ans %= M
val -= 1
return ans
def input():
return sys.stdin.readline().rstrip()
[n, x, pos] = list(map(int, input().split()))
gt = 0
lt = 0
M = 10**9 + 7
l = 0
r = n
while l < r:
mid = int((l... | IMPORT FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR VAR VAR NUMBER RETURN VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR ASSIGN LIST VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NU... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | mod = int(1000000000.0 + 7)
n, x, pos = map(int, input().split())
def bs(pos):
l = 0
r = n
small = set()
large = set()
eq = 0
while l < r:
mid = l + r >> 1
if mid <= pos:
if mid != pos:
small.add(mid)
else:
eq += 1
... | ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR ... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | n, x, pos = list(map(int, input().split()))
mod = 10**9 + 7
a = 0
b = 0
left = 0
right = n
arr = range(1, n + 1)
while left < right:
middle = (left + right) // 2
if middle <= pos:
left = middle + 1
a += 1
else:
right = middle
b += 1
a -= 1
factorial = [1]
for i in range(1, n ... | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR BIN_... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | n, x, p = map(int, input().split())
mod = 10**9 + 7
ans = 1
left, right = 0, n
c1, c2 = 0, 0
while left < right:
mid = left + (right - left) // 2
if mid <= p:
c1 += 1
left = mid + 1
else:
c2 += 1
right = mid
ans = 1
for i in range(1, n - c1 - c2 + 1):
ans = ans * i % mod
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER VAR ASSIGN VAR VAR NUMBER NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VA... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | n, x, pos = map(int, input().split())
mo = int(1000000000.0 + 7)
A = [1]
for i in range(1, 1010):
A.append(A[-1] * i % mo)
def exgcd(a, b):
if not b:
return 1, 0
y, x = exgcd(b, a % b)
y -= a // b * x
return x, y
def getinv(a, m):
x, y = exgcd(a, m)
return --1 if x == 1 else x % ... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR VAR FUNC_DEF IF VAR RETURN NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | mod = 10**9 + 7
n, x, pos = list(map(int, input().split()))
m = n - x
l = x - 1
ans = 1
i = 0
j = n
while i < j:
mid = (i + j) // 2
if mid > pos:
ans = ans * m % mod
m = m - 1
j = mid
elif mid <= pos:
if mid == pos:
ans = ans * 1
else:
ans = an... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | mod = 10**9 + 7
def inverse(i):
return pow(i, mod - 2, mod)
fact = [1] * (10**5 + 1)
ifact = [1] * (10**5 + 1)
for i in range(2, 10**5 + 1):
fact[i] = fact[i - 1] * i
ifact[i] = ifact[i - 1] * inverse(i)
fact[i] %= mod
ifact[i] %= mod
def ncr(n, k):
ans = fact[n] * ifact[k] * ifact[n - k]
... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR VAR BIN_OP VA... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | n, x, p = map(int, input().split())
MOD = 1000000007
nums = [(i + 1) for i in range(n)]
left, right = 0, n
a, b = -1, 0
while left < right:
middle = (left + right) // 2
if nums[middle] <= nums[p]:
left = middle + 1
a += 1
else:
right = middle
b += 1
total = 1
for i in range(x... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER VAR ASSIGN VAR VAR NUMBER NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR NUM... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | n, x, pos = map(int, input().split())
l = 0
r = n
sub = n - x
pro = 1
small = x - 1
cnt = 0
while l < r:
mid = (l + r) // 2
if mid > pos:
pro = pro * sub
sub -= 1
r = mid
cnt += 1
elif mid < pos:
l = mid + 1
pro *= small
small -= 1
cnt += 1
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER IF VAR ... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | pr = []
def ok(n, t):
left = 0
right = n
while left < right:
m = int((left + right) / 2)
pr.append(m)
if m <= t:
left = m + 1
else:
right = m
return
mod = int(1000000000.0) + 7
n, m, idx = map(int, input().split())
ok(n, idx)
big, small, res = ... | ASSIGN VAR LIST FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR RETURN ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EX... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | n, x, pos = map(int, input().split())
x1, x2 = 0, n
ans = []
f = 2000000 * [0]
p = int(1000000000.0 + 7)
def call(a, b):
if a == 0 or b == 0 or a == b:
return 1
if b == 1:
return a
if f[a * 1001 + b]:
return f[a * 1001 + b]
f[a * 1001 + b] = (call(a - 1, b) % p + call(a - 1, b ... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP NUMBER LIST NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER FUNC_DEF IF VAR NUMBER VAR NUMBER VAR VAR RETURN NUMBER IF VAR NUMBER RETURN VAR IF VAR BIN_OP BIN_OP VAR NUMBER VAR RETURN VAR BIN_OP... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | import sys
input = sys.stdin.readline
n, x, pos = map(int, input().split())
pos += 1
mod = 1000000007
smaller = 0
bigger = 0
left = 0
right = n
while left < right:
middle = (left + right) // 2
if middle < pos:
left = middle + 1
if middle < pos - 1:
smaller += 1
else:
big... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBE... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | def power(a, b, mod):
res = 1
while b:
if b % 2:
res = res * a % mod
b //= 2
a = a * a % mod
return res % mod
def choose(n, k, fac, MOD):
res = fac[n] % MOD
res = res * power(fac[n - k], MOD - 2, MOD) % MOD
return res
n, x, pos = map(int, input().split())
... | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR IF BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR RETURN BIN_OP VAR VAR FUNC_DEF ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR VAR RETURN VAR ASSIGN VAR VAR VA... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | n, x, pos = map(int, input().split())
a = [i for i in range(n)]
mod = 10**9 + 7
lower = 0
higher = 0
left = 0
right = n
while left < right:
middle = (left + right) // 2
if a[middle] <= pos:
lower += 1
left = middle + 1
else:
higher += 1
right = middle
res = 1
num_l = x - 1
nu... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBE... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | def fact(n):
ans = 1
for i in range(1, n + 1):
ans *= i
ans %= mod
return ans
def binary_search(n, x, idx):
l = 0
r = n
ans = 1
bigger = 0
smaller = 0
while l < r:
mid = (l + r) // 2
if mid > idx:
ans *= n - x - bigger
ans %= ... | FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR VAR VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR NUMBER ASSIGN VA... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | bigmod = 10**9 + 7
def Bserach(n, pos, x):
left = 0
right = n
l = 0
r = -1
while left < right:
middle = (left + right) // 2
if middle <= pos:
r += 1
left = middle + 1
else:
l += 1
right = middle
answer = 1
for i in ran... | ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP VAR... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | from sys import stdin, stdout
def get():
return stdin.readline().strip()
def getf(sp=" "):
return [int(i) for i in get().split(sp)]
def put(a, end="\n"):
stdout.write(str(a) + end)
def putf(a, sep=" ", end="\n"):
stdout.write(sep.join([str(i) for i in a]) + end)
def fact_mod(n):
ans = 1
... | FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF STRING RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_DEF STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_DEF STRING STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_O... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | n, x, pos = list(map(int, input().split()))
middle = n // 2
left = 0
right = n
larger = []
smaller = []
def fact(p, y=1):
if p <= 1:
return y
else:
return fact(p - 1, y * p)
while left < right:
middle = (left + right) // 2
if middle <= pos:
if middle < pos:
smalle... | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FUNC_DEF NUMBER IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | n, x, pos = map(int, input().split())
def factoriel(n):
if n < 2:
return 1
b = n - 1
while b > 0:
n *= b
b -= 1
return n
def test():
low = 0
big = 0
left = 0
right = n
while left < right:
middle = (left + right) // 2
if middle > pos:
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASS... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | MOD = 1000000007
def f(n, cnt):
ans = 1
for _ in range(cnt):
ans = ans * n % MOD
n -= 1
return ans
def main():
n, x, pos = map(int, input().split())
chk1 = 0
chk_r = 0
left = 0
right = n
while left < right:
middle = (left + right) // 2
if middle <=... | ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMB... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | n, x, pos = map(int, input().split())
permutations = [0] * n
modulo = 10**9 + 7
def binary_search(copy_of_the_x):
left_numbers = x - 1
right_numbers = n - x
left = 0
right = n
while left < right:
middle = (left + right) // 2
if middle < pos:
permutations[middle] = left_... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR VA... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | def aranjamente(n, k) -> int:
modulo = 10**9 + 7
output = 1
if k > n:
return 0
for x in range(n - k + 1, n + 1):
output = output * x % modulo
return output
def reorder():
n, k, pos = [int(x) for x in input().split(" ")]
left = 0
right = n
modulo = 10**9 + 7
ans ... | FUNC_DEF ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER IF VAR VAR RETURN NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR RETURN VAR VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER AS... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | n, x, pos = map(int, input().split())
left = 0
right = n
larger_count = 0
smaller_count = 0
mod = 10**9 + 7
def fact(p, y=1):
if p <= 1:
return y
else:
return fact(p - 1, y * p)
while left < right:
middle = (left + right) // 2
if middle <= pos:
if middle < pos:
sm... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF NUMBER IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NU... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | def perm(N, R):
temp = 1
while R > 0:
temp *= N
R -= 1
N -= 1
return temp
def BinarySearch(n, x, pos):
left, right = 0, n
l, r = 0, 0
while left < right:
middle = (left + right) // 2
if middle <= pos:
if not middle == pos:
l +... | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR VAR VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR VAR NUMBER VAR ASSIGN VAR VAR NUMBER NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR IF VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR VAR IF VAR VAR VAR BIN_OP VAR VAR... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | n, x, pos = map(int, input().split())
low = 0
high = n
big = n - x
small = x - 1
cntbig = 0
cntsmall = 0
ans = 1
mod = 10**9 + 7
while low < high:
mid = (low + high) // 2
if mid < pos:
ans *= small - cntsmall
ans %= mod
cntsmall += 1
low = mid + 1
elif mid > pos:
ans ... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR BI... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | def binSrc(n, x):
left, right = 0, n
d = {(0): [], (1): [], (2): []}
while left < right:
mid = (left + right) // 2
if mid < x:
left = mid + 1
d[1].append(mid)
elif mid > x:
right = mid
d[2].append(mid)
else:
left = m... | FUNC_DEF ASSIGN VAR VAR NUMBER VAR ASSIGN VAR DICT NUMBER NUMBER NUMBER LIST LIST LIST WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR IF VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBE... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | n, x, pos = map(int, input().split())
gt = []
l, r = 0, n
while l < r:
mid = (l + r) // 2
if mid <= pos:
gt.append(False)
l = mid + 1
else:
gt.append(True)
r = mid
a, b = gt.count(True), gt.count(False)
aa, bb = n - x, x
bb -= 1
b -= 1
sol = 1
for i in range(a):
sol *= aa... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR NUMBER VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR NUMBER... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | import sys
input = sys.stdin.readline
mod = 1000000007
def gcd(a, b):
if a == 0:
return b
return gcd(b % a, a)
def lcm(a, b):
return a * b / gcd(a, b)
def binsimul(x, n):
give = {}
a = [i for i in range(n)]
left = 0
right = n
while left < right:
middle = (left + ri... | IMPORT ASSIGN VAR VAR ASSIGN VAR NUMBER FUNC_DEF IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR BIN_OP VAR VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN VAR DICT ASSIGN VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMB... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | import sys
input = sys.stdin.readline
def inp():
return int(input())
def inara():
return list(map(int, input().split()))
def insr():
s = input()
return list(s[: len(s) - 1])
def invr():
return map(int, input().split())
n, x, pos = invr()
boro = [0] * n
lo = 0
hi = n
while lo < hi:
mid... | 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 ASSIGN VAR VAR VAR FUNC_CALL VAR ... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | def binarysearch(pos, smaller, bigger):
ans = 1
left = 0
right = smaller + bigger + 1
while left < right:
mid = (left + right) // 2
if pos < mid:
right = mid
if mid != pos:
ans *= bigger
bigger -= 1
else:
left = ... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR IF VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER VAR VAR VAR VAR NUMBER RETURN VAR VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | n, x, pos = map(int, input().split())
mod = 10**9 + 7
A = [0] * pos + [x] + [x + 1] * (n - pos - 1)
left = 0
right = n
L = x - 1
R = n - x
a = [0] * n
a[pos] = 1
ans = 1
while left < right:
middle = (left + right) // 2
if A[middle] <= x:
if a[middle] == 0:
a[middle] = 1
ans *= L
... | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP LIST NUMBER VAR LIST VAR BIN_OP LIST BIN_OP VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VA... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | from sys import stdin
class Input:
def __init__(self):
self.it = iter(stdin.readlines())
def line(self):
return next(self.it).strip()
def array(self, sep=" ", cast=int):
return list(map(cast, self.line().split(sep=sep)))
def testcases(unknown=False):
inpt = Input()
de... | CLASS_DEF FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR VAR FUNC_DEF STRING VAR RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_DEF NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR LIST FUNC_CALL VAR STRING FUNC_CALL VAR WHILE VAR NUMBER EXPR FUNC... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | n, x, pos = list(map(int, input().split()))
lo = 0
hi = n
greater = n - x
smaller = x - 1
ans = 1
mod = 10**9 + 7
while lo < hi:
mid = (lo + hi) // 2
if mid < pos:
ans = ans * smaller % mod
smaller -= 1
lo = mid + 1
elif mid == pos:
lo = mid + 1
else:
ans = ans * ... | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | n, x, p = list(map(int, input().split()))
smallc = 0
largec = 0
left = 0
right = n
while left < right:
mid = (left + right) // 2
if mid < p:
smallc += 1
left = mid + 1
elif mid > p:
largec += 1
right = mid
else:
left = mid + 1
largeAv = n - x
smallAv = x - 1
mod =... | ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIG... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | st = input().split()
n = int(st[0])
x = int(st[1])
pos = int(st[2])
mniejsze = 0
wieksze = 0
left = 0
right = n
while left < right:
middle = (left + right) // 2
if middle > pos:
wieksze += 1
right = middle
else:
if middle < pos:
mniejsze += 1
left = middle + 1
l_w... | 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 VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR NUMBER ASSIGN VAR VAR IF VAR VAR VAR NU... |
Andrey thinks he is truly a successful developer, but in reality he didn't know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number $x$ in an array. For an array $a$ indexed from zero, and an integer $x$ the pseudo... | def perm(n, r):
if n < r:
return 0
ans = 1
k = n
while k > n - r:
ans *= k
k -= 1
return ans
def fact(x):
if x < 0:
return 0
ans = 1
while x:
ans *= x
x -= 1
return ans
n, x, p = map(int, input().split())
b = [0] * n
left = 0
right ... | FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR BIN_OP VAR VAR VAR VAR VAR NUMBER RETURN VAR FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN V... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.