description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | n, m = list(map(int, input().split()))
cnt = 0
l = n
while l < m:
cnt += 1
l *= 2
dif = l - m
val = 2**cnt
while dif > 0:
cnt += dif // val
dif %= val
val //= 2
print(cnt) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP NUMBER VAR WHILE VAR NUMBER VAR BIN_OP VAR VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | N, M = map(int, input().split())
queue = [N]
d = [(-1) for i in range(100010)]
d[N] = 0
while queue:
p = queue.pop(0)
if p < 0:
continue
if d[p - 1] == -1:
if p - 1 == M:
print(d[p] + 1)
exit()
d[p - 1] = d[p] + 1
queue.append(p - 1)
if p * 2 > max... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER WHILE VAR ASSIGN VAR FUNC_CALL VAR NUMBER IF VAR NUMBER IF VAR BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIG... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | def eh_par(x):
return numero_m % 2 == 0
numero_n, numero_m = map(int, input().split())
aux = 0
while numero_m > numero_n:
if eh_par(numero_m):
numero_m = numero_m // 2
else:
numero_m += 1
aux += 1
diferenca = numero_n - numero_m
min_apertos = aux + diferenca
print(min_apertos) | FUNC_DEF RETURN BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR IF FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | target, value = map(int, input().split())
count = 0
while True:
if value == target:
break
if value < target:
value += 1
elif value % 2 == 1:
value += 1
else:
value = value // 2
count += 1
print(count) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE NUMBER IF VAR VAR IF VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | import sys
sys.setrecursionlimit(100000)
def _(lista, m, counter=1, visitado={}):
temporal = []
for i in lista:
l = i - 1
r = i * 2
if r < 2 * m:
if r not in visitado:
temporal += [r]
visitado[r] = 0
if l > 0:
if l not in... | IMPORT EXPR FUNC_CALL VAR NUMBER FUNC_DEF NUMBER DICT ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR BIN_OP NUMBER VAR IF VAR VAR VAR LIST VAR ASSIGN VAR VAR NUMBER IF VAR NUMBER IF VAR VAR VAR LIST VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR IF VAR VAR RETURN VAR RETURN FUNC_... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | rin = lambda: map(int, input().split())
def solve(n, m):
if m < n:
return n - m
counter = 0
while True:
next_m = m // 2 if m % 2 == 0 else (m + 1) // 2
if next_m <= n:
return min(n - next_m + 1 + m % 2 + counter, counter + (2 * n - m) + 1)
else:
coun... | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR VAR RETURN BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR VAR RETURN FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER VAR BIN_OP BIN_... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | a, b = map(int, input().split())
s = 0
while b > a:
if b % 2 == 0:
b //= 2
else:
b += 1
s += 1
print(a - b + s) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | n, m = [int(x) for x in input().split()]
flag = True
c = 0
while flag:
if m < n:
print(n - m + c)
break
elif m % 2 == 0:
m //= 2
c += 1
else:
m += 1
c += 1
if m == n:
flag = False
print(c) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | n, m = input().strip().split()
n = int(n)
m = int(m)
time = 0
if n > m:
time += n - m
else:
while m - n != 0:
if divmod(m, 2)[1] == 0 and m > n:
m = int(m / 2)
time += 1
elif n >= m:
time += n - m
break
else:
m = int((m + 1) / 2... | ASSIGN VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR VAR VAR BIN_OP VAR VAR WHILE BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER NUMBER NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR VAR BIN_OP VAR VAR ASS... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | n, m = map(int, input().split())
k = max(n, m)
a = [-1] * (k * 3)
b = [0] * (k * 4)
d = [0] * (k * 4)
l = 1
b[0] = n
i = 0
a[n] = 0
while i < l:
cur = b[i]
j = cur * 2
if j < m * 2:
if a[j] == -1:
b[l] = j
d[l] = d[i] + 1
a[j] = d[l]
l += 1
j = cur... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER WHILE ... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | def bfs(d, s, e):
que = []
que.append(s)
dist = {s: 0}
flag = 0
while que:
f = que[0]
que.pop(0)
for i in d[f]:
if i not in dist:
que.append(i)
dist[i] = dist[f] + 1
if i == e:
flag = 1
br... | FUNC_DEF ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR ASSIGN VAR DICT VAR NUMBER ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER RETURN VAR VAR ASSIGN VAR VAR FUNC_CALL... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | x = input()
x = x.split(" ")
y = int(x[1])
x = int(x[0])
save_set = set()
second_set = set()
dict_set = set()
save_set.add(x)
count = 0
while True:
if y in save_set:
print(count)
break
for num in save_set:
if num - 1 not in dict_set:
second_set.add(num - 1)
dict_s... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR VAR IF BIN_OP VAR NU... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | n, aim = map(int, input().split())
step = 0
while 1:
if aim < n:
step += n - aim
print(step)
break
elif aim > n:
if aim % 2 == 0:
aim = aim // 2
step += 1
else:
aim += 1
step += 1
else:
print(step)
break | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE NUMBER IF VAR VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR IF VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | f = lambda: input()
n, m = list(map(int, f().split()))
dp = [99999] * 10001
dp[n] = 0
def click():
for i in range(0, n + 1):
dp[i] = n - i
if i * 2 <= 10000:
if dp[i * 2] > dp[i] + 1:
dp[i * 2] = dp[i] + 1
for i in range(n + 1, 10001):
if dp[i] == 99999:
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR VAR NUMBER FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER ASSI... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | def bfs():
n, m = map(int, input().split())
count = 0
queue = [[n, count]]
seen = []
if n >= m:
return n - m
else:
while queue:
k = queue.pop()
xx = k[0]
t = k[1]
seen.append(xx)
if xx == m:
return t
... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST LIST VAR VAR ASSIGN VAR LIST IF VAR VAR RETURN BIN_OP VAR VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR VAR RETURN VAR IF BIN_OP VAR NUMBER VAR BIN_OP VA... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | n, m = map(int, input().split())
if n < m:
x = m
c = 0
while x != n:
if x % 2 == 1:
x += 1
c += 1
if x == n:
break
if x > n:
x = x / 2
else:
x += 1
c += 1
print(c)
elif n > m:
print(n - m)
else:
p... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER IF VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | def buttons(n, m):
moves = 0
while n != m:
if m % 2 != 0 or m < n:
m += 1
else:
m = m / 2
moves += 1
return moves
n, m = map(int, input().split())
print(buttons(n, m)) | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | n, m = map(int, input().split())
result = 0
while n < m:
result += 1 + m % 2
m = (m + m % 2) / 2
result += n - m
print(int(result)) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | import sys
n, m = map(int, input().split())
a = set([n])
i = 0
while True:
i += 1
b = set()
for cur in a:
b1 = cur * 2
b2 = cur - 1
if b1 == m or b2 == m:
print(i)
sys.exit()
if cur < m:
b.add(b1)
if b2 > 0:
b.add(b2)
... | IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR LIST VAR ASSIGN VAR NUMBER WHILE NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CAL... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | n, m = [int(i) for i in input().strip().split(" ")]
targets = list()
targets.append(m)
while targets[-1] > n:
next_target = targets[-1]
if next_target % 2 == 1:
targets.append(next_target + 1)
else:
targets.append(next_target / 2)
targets.reverse()
print(n - int(targets[0]) + len(targets) - ... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR WHILE VAR NUMBER VAR ASSIGN VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP BIN_... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | def main():
entrada = list(map(int, input().split()))
n = entrada[0]
m = entrada[1]
if n == m:
print(0)
elif n >= m:
print(n - m)
else:
contador = 0
while m > n:
if m % 2 == 0:
m = m / 2
contador += 1
else:
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP ... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | ori, fin = input().split(" ")
ori = int(ori)
fin = int(fin)
myset = set()
myset.add(ori)
ret = -1
finished = False
visited = set()
while not finished and myset:
ret += 1
newset = set()
for num in myset:
if num == fin:
finished = True
if num < fin and 2 * num not in visited:
... | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR WHILE VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR VAR ASSIGN VAR NUMBER IF VAR VAR BIN_O... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | n, m = map(int, input().split())
a = 0
def soma(n, m, a):
while n < m:
if m & 1:
m += 1
else:
m = m // 2
a += 1
return a + (n - m)
a = soma(n, m, a)
if n < m:
if a == 0:
print(n - m)
else:
print(a)
else:
print(n - m) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_DEF WHILE VAR VAR IF BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER RETURN BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VA... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | n, m = map(int, input().split())
t = 0
if m > n:
while n < m:
if m % 2 == 1:
m = m + 1
elif m % 2 == 0:
m = m / 2
t = t + 1
if m < n:
while n != m:
m = m + 1
t = t + 1
print(t) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR VAR WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR N... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | queue = []
first, second = list(map(int, input().split(" ")))
queue.append([first, 0])
pos_mem = [False] * 100005
while queue:
e = queue.pop(0)
if pos_mem[e[0]] or e[0] > 10000 or e[0] < 1:
continue
else:
pos_mem[e[0]] = True
if e[0] - 1 == second:
print(e[1] + 1)
break
... | ASSIGN VAR LIST ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR LIST VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER WHILE VAR ASSIGN VAR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER V... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | n, m = map(int, input().split())
res = 0
while n != m:
res += 1
if n < m and m % 2 == 0:
half = m / 2
m -= half
else:
m += 1
print(res) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | a, b = map(int, input().split(" "))
for i in range(15):
if a * 2**i >= b:
x = 2**i
y = a * 2**i - b
break
tot = 0
while x != 1:
if y % 2 == 0:
y //= 2
x //= 2
tot += 1
elif y % 2 == 1:
y -= 1
y //= 2
x //= 2
tot += 2
print(tot +... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF BIN_OP VAR N... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | n, m = [int(x) for x in input().split()]
moves = 0
if n > m:
print(abs(n - m))
exit()
while n != m:
if m % 2 == 0 and m > n:
m /= 2
moves += 1
else:
m += 1
moves += 1
print(moves) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | n, t = map(int, input().split(" "))
if t <= n:
print(abs(t - n))
else:
count = 0
if t % 2 != 0:
count += 1
t += 1
while t > n:
t = t / 2
count += 1
if t % 2 != 0 and t != n:
count += 1
t += 1
count += n - t
print(int(count)) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR VAR VAR NUMBER VAR NUMBER VAR BIN_OP VAR VA... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | n, m = input().split()
n = int(n)
m = int(m)
bfs = []
tmp = [m]
bfs.append(tmp)
res = -1
i = 0
while True:
tmp = []
maior = 0
for j in bfs[i]:
if j == n:
res = i
break
if j > maior:
maior = j
if j % 2 == 0:
tmp.append(j / 2)
els... | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR IF VAR VAR ASSIGN VAR VAR IF BIN_OP VAR... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | import sys
input = lambda: sys.stdin.readline()
int_arr = lambda: list(map(int, input().split()))
str_arr = lambda: list(map(str, input().split()))
get_str = lambda: map(str, input().split())
get_int = lambda: map(int, input().split())
get_flo = lambda: map(float, input().split())
mod = 1000000007
def solve(n, m):
... | IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | n, m = map(int, input().split())
a = 0
while n != m:
if m > n:
if m % 2 == 0:
m /= 2
a += 1
else:
m += 1
a += 1
elif n > m:
m += 1
a += 1
print(abs(a)) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | n, m = map(int, input().strip().split(" "))
Step = 0
while n != m:
if m < n or m % 2 != 0:
m += 1
elif m > n:
m = int(m / 2)
Step += 1
print(Step) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | def get_step(n, m):
step = 0
while m > n:
if m % 2 == 0:
m //= 2
else:
m += 1
step += 1
if m == n:
return step
else:
return step + n - m
n, m = input().split(" ")
n = int(n)
m = int(m)
print(get_step(n, m)) | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR RETURN VAR RETURN BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | q = input().split()
x = int(q[0])
p = int(q[1])
count = 0
while x < p:
if p % 2 == 0:
p = int(p / 2)
count += 1
else:
p = p + 1
p = int(p / 2)
count += 2
if p == x:
count = count + 0
else:
count = count + x - p
print(count) | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR ASSIG... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | def calculate(x, y):
if x == y:
return 0
elif x > y:
return abs(y - x)
elif y % 2 == 0:
return 1 + calculate(x, y // 2)
else:
return 1 + calculate(x, y + 1)
def main():
show, target = map(int, input().split())
print(calculate(show, target))
main() | FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR VAR RETURN FUNC_CALL VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER RETURN BIN_OP NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER RETURN BIN_OP NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VA... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | inp = input()
chars = inp.split()
n = int(chars[0])
m = int(chars[1])
ans = 0
while n < m:
if m % 2 == 1:
m = m + 1
else:
m = m / 2
ans = ans + 1
print(int(ans + n - m)) | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR ... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | import sys
sys.setrecursionlimit(100000000)
s = input()
s = s.split()
n = int(s[0])
m = int(s[1])
c = 0
def solve(n, m, c):
if m < n:
return n - m + c
if m == n:
return c
elif m % 2 == 0:
return solve(n, int(m / 2), c + 1)
else:
return solve(n, m + 1, c + 1)
print(so... | IMPORT EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF IF VAR VAR RETURN BIN_OP BIN_OP VAR VAR VAR IF VAR VAR RETURN VAR IF BIN_OP VAR NUMBER NUMBER RETURN FUNC_CALL VAR VAR FUNC_CALL VAR BIN_O... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | def bfs(n, m):
stack = [n]
counter = 0
if n == m:
print(0)
else:
while stack:
counter += 1
n_i = stack.pop(0)
if m in apuntadores[n_i]:
print(contadores[n_i])
break
else:
for a in apuntadores[... | FUNC_DEF ASSIGN VAR LIST VAR ASSIGN VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER WHILE VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR FOR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CA... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | def solve(n, m):
if n >= m:
return n - m
elif m % 2 == 0:
if m / 2 < n:
return n - m // 2 + 1
elif m / 2 > n:
return 1 + solve(n, m // 2)
else:
return 1
else:
return 1 + solve(n, m + 1)
a, b = map(int, input().split())
print(solve... | FUNC_DEF IF VAR VAR RETURN BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR NUMBER VAR RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR NUMBER VAR RETURN BIN_OP NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER RETURN NUMBER RETURN BIN_OP NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CA... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | n, m = map(int, input().split())
t = 0
if n > m:
print(n - m)
else:
while n < m:
if m % 2 == 0:
m = m / 2
t += 1
else:
m = (m + 1) / 2
t += 2
print(int(abs(n - m) + t)) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR BIN_OP VAR... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | start, end = list(map(int, input().split()))
if start > end:
print(start - end)
else:
count = 0
while start != end:
if not end % 2 and end > start:
end = end // 2
else:
end += 1
count += 1
print(count) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | import sys
range = sys.stdin.readline()
range_list = range.split()
range1 = int(range_list[0])
range2 = int(range_list[1])
count = 0
if range2 > range1:
while range2 > range1:
if range2 % 2 == 0:
range2 /= 2
else:
range2 += 1
count += 1
count += range1 - range2
e... | IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | n, m = [int(x) for x in input().strip().split()]
if m <= n:
print(n - m)
else:
end = m + 1 if m % 2 else m
dp = [(n - i if i <= n else 0) for i in range(end + 1)]
if n % 2:
dp[n + 1] = dp[int((n + 1) / 2)] + 1
start = n + 3
else:
start = n + 2
for i in range(start, end + ... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR FUNC_CALL VAR B... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | n, m = list(map(int, input().strip().split()))
c = m - n
for i in range(1000):
if m <= n:
break
if m % 2 != 0:
m = m + 1
continue
else:
m = m / 2
continue
print([int(i + n - m), -c][c <= 0]) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR LIST FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR NUMBER |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | x, y = map(int, input().split())
q = []
q.append([x, 0])
vis = set()
while q:
t = q.pop(0)
if t[0] == y:
print(t[1])
break
if t[0] * 2 == y or t[0] - 1 == y:
print(t[1] + 1)
break
if t[0] * 2 not in vis and t[0] * 2 <= y * 4:
q.append([t[0] * 2, t[1] + 1])
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR LIST VAR NUMBER ASSIGN VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR EXPR FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | n, m = map(int, input().split())
vis = [-1] * 20000
q = [0] * 20000
tail = 1
q[0] = n
vis[n] = 0
on = 0
while on < tail:
cur = q[on]
on += 1
if cur + cur < 20000 and vis[cur + cur] == -1:
vis[cur + cur] = 1 + vis[cur]
q[tail] = cur + cur
tail += 1
if cur - 1 > 0 and vis[cur - 1] ... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR NUMBER ASSIGN VAR BIN... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | import sys
sys.setrecursionlimit(100000)
n, m = map(int, input().split())
def find(stack, m, count=1, visited={}):
tmp = []
for e in stack:
l = e * 2
r = e - 1
if l < 2 * m:
if l not in visited:
tmp += [l]
visited[l] = 0
if r > 0:
... | IMPORT EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF NUMBER DICT ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR BIN_OP NUMBER VAR IF VAR VAR VAR LIST VAR ASSIGN VAR VAR NUMBER IF VAR NUMBER IF VAR VAR VAR LIST VAR ASSIGN VAR VAR... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | source, target = [int(x) for x in input().split(" ")]
rev_buf = target
steps = 0
while rev_buf != source:
if rev_buf < source:
rev_buf += 1
elif rev_buf % 2 == 0:
rev_buf /= 2
else:
rev_buf += 1
steps += 1
print(steps) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | from sys import stdin
n, m = map(int, stdin.readline().rstrip().split(" "))
c = 0
while m != n:
c += 1
if m % 2 == 1 or m < n:
m += 1
elif m > n and not m % 2:
m = m // 2
print(c) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | a, b = list(map(int, input().split()))
if a >= b:
print(a - b)
else:
p = 0
while True:
if b % 2 == 0:
p += 1
b = b // 2
else:
p += 2
b = b // 2 + 1
if a >= b:
p += a - b
break
print(p) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VA... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | import sys
n, m = map(int, sys.stdin.readline().split())
s = set()
s.add(n)
s_total = set()
ans = 0
while s:
ans += 1
s_total |= s
s = {(2 * i) for i in s} | {(i - 1) for i in s if i > 1}
s = s - s_total
s1 = {i for i in s if i <= m}
s2 = s - s1
s = s1
if s2:
s.add(min(s2))
... | IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR VAR VAR VA... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | a, b = map(int, input().split())
if b <= a:
print(a - b)
else:
k = int(0)
while b != a:
if b > a and b % 2 == 0:
b = b / 2
else:
b = b + 1
k = k + 1
print(k) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER WHILE VAR VAR IF VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | import sys
def search(n, m, res):
if n == m:
return res
if n > m:
return res + (n - m)
if m % 2 == 0:
return search(n, m // 2, res + 1)
return search(n, m + 1, res + 1)
def main():
f = sys.stdin
n, m = map(int, f.readline().rstrip().split())
print(search(n, m, 0))... | IMPORT FUNC_DEF IF VAR VAR RETURN VAR IF VAR VAR RETURN BIN_OP VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER RETURN FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER RETURN FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL V... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | R = lambda: map(int, input().split())
n, m = R()
if n >= m:
print(n - m)
exit()
cnt = 0
while n != m:
if n > m:
m += 1
elif not m % 2:
m //= 2
else:
m += 1
cnt += 1
print(cnt) | ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | q = list(map(int, input().split()))
n, m = q[0], q[1]
if n > m:
print(n - m)
else:
L = [n]
q = 0
a = m
while n < a:
if a % 2 == 0:
a = a // 2
else:
a = a + 1
q += 1
print(n - a + q) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR LIST VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FU... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | nz, mz = input().split()
n = int(nz)
m = int(mz)
c = 0
while m > n:
if m % 2 == 0:
m = m // 2
else:
m += 1
c += 1
c += n - m
print(c) | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | n, mi = map(int, input().split())
ras = 0
for i in range(100000):
if n == mi:
break
if n > mi:
ras = ras + 1
mi = mi + 1
continue
elif mi % 2:
mi = mi + 1
ras = ras + 1
continue
elif mi % 2 == 0:
mi = mi // 2
ras += 1
contin... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | arr = list(map(int, input().split()))
n = arr[0]
m = arr[1]
if m <= n:
print(n - m)
else:
c = 0
t = n
while not (t <= m and m <= 2 * t):
t *= 2
c += 1
l = [0] * (2 * t + 1)
for i in range(1, n):
l[i] = n - i
h = n
stk = [n]
c = 0
while h <= t:
h *=... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR VAR BIN_OP NUMBER VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER FOR VAR FUN... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | n, m = str(input()).split()
n = int(n)
m = int(m)
num = 0
while n != m:
if n > m:
num += n - m
n = m
else:
if m % 2 == 1:
m += 1
num += 1
m //= 2
num += 1
print(num) | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | n, m = list(map(lambda x: int(x), input().split()))
if n > m:
print(n - m)
elif n == m:
print(0)
elif m // n == 2:
print(1)
else:
count = 0
while m > n:
if m % 2 == 0:
m = m // 2
else:
m = m + 1
count += 1
if m == n:
print(count)
else:
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BI... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | n, p = map(int, input().split())
def dp(n, p, steps=0):
if n >= p:
return steps + n - p
steps += 1
x = p // 2
if p % 2:
steps += 2 * (p // 2 + 1) - p
x += 1
return dp(n, x, steps)
print(dp(n, p)) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF NUMBER IF VAR VAR RETURN BIN_OP BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER VAR BIN_OP BIN_OP NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER VAR VAR NUMBER RETURN FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | takeInput = input()
N, M = [int(x) for x in takeInput.split(" ")]
short = 0
def func(n, m):
global short
if n == m:
return short
if n > m:
short = short + n - m
return short
short += 1
if m % 2 == 0:
return func(n, m / 2)
else:
return func(n, m + 1)
pr... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FUNC_DEF IF VAR VAR RETURN VAR IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR RETURN VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER RETURN FUNC_CALL VAR VAR BIN_OP VAR NUMBER RETURN FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | def fun(n, m):
ans = 0
ans = n * (m // n)
print(n, m, "---")
if m % 2 == 0:
ans += n - m // 2 + 1
else:
ans += n - m // 2 + 2
return ans
def bfs(n, m):
temp = [(n, 0)]
ans = 0
visited = set()
count = 0
while temp:
node, count = temp.pop(0)
if... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR VAR STRING IF BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER RETURN VAR FUNC_DEF ASSIGN VAR LIST VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | n, k = map(int, input().split())
ans = 0
while k != n:
while k < n:
ans += 1
k += 1
while k > n:
if k % 2 == 0:
k //= 2
ans += 1
else:
ans += 1
k += 1
print(ans) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR WHILE VAR VAR VAR NUMBER VAR NUMBER WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | nums = [int(x) for x in input().split(" ")]
n = nums[0]
m = nums[1]
if n > m:
print(n - m)
else:
count = 0
while m != n:
if m > n:
if m % 2 == 0:
m /= 2
else:
m += 1
else:
m += 1
count += 1
print(count) | ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | def min_count(a, b):
if a == b:
return 0
if a > b:
return a - b
count = 0
while b > a:
if b % 2 == 1:
b += 1
count += 1
b /= 2
count += 1
count += a - b
return count
def main():
a, b = map(int, input().split())
print(int(m... | FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR VAR RETURN BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR BIN_OP VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VA... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | n, m = map(int, input().strip().split(" "))
if n > m:
print(n - m)
else:
verge = {}
path = [-1] * 2 * m
pick = []
for i in range(1, 2 * m + 1):
temp = []
if i > 1:
temp.append(i - 1)
if i <= m:
temp.append(2 * i)
verge[i] = temp
path[n] = 0... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR DICT ASSIGN VAR BIN_OP BIN_OP LIST NUMBER NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR LIST IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR ... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | import sys
numbers = sys.stdin.readline().split(" ")
numbers = list(map(int, numbers))
p = numbers[0]
q = numbers[1]
count2 = 0
count1 = 0
while q > p:
if q % 2 != 0:
q = (q + 1) / 2
count2 = count2 + 1
count1 = count1 + 1
elif q % 2 == 0:
q = q / 2
count2 = count2 + 1
d... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER I... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | n, m = map(int, input().split())
if n >= m:
print(n - m)
else:
k = 0
while m > n:
k += 1 + m % 2
m = round((m + m % 2) / 2)
k += n - m
print(k) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | n, m = map(int, input().split())
cnt = 0
while True:
if n == m:
print(int(cnt))
break
if m < n:
print(int(cnt + n - m))
break
elif m % 2 == 0:
m = m / 2
cnt += 1
else:
m += 1
cnt += 1 | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE NUMBER IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | def buttons(m, n, Steps):
if m == n:
return Steps
elif m % 2 == 0 and m > n:
return buttons(m // 2, n, Steps + 1)
elif m % 2 == 1 and m > n:
return buttons((m + 1) // 2, n, Steps + 2)
else:
return Steps + (n - m)
[n, m] = input().split(" ")
print(buttons(int(m), int(n),... | FUNC_DEF IF VAR VAR RETURN VAR IF BIN_OP VAR NUMBER NUMBER VAR VAR RETURN FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR VAR RETURN FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER RETURN BIN_OP VAR BIN_OP VAR VAR ASSIGN LIST VAR VAR FUNC_CALL FUNC_CALL VAR STRI... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | def nrstDouble(n, m):
i = 0
while n < m:
n *= 2
i += 1
return i
n, m = map(int, input().split())
ans = 0
while 1:
if m <= n:
ans += n - m
break
i = nrstDouble(n, m)
val = (n * 2**i - m) // 2**i
if val == 0:
n *= 2
ans += 1
else:
n... | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE NUMBER IF VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP NUMBER VAR VAR BIN_OP NUMBER VAR IF VAR NUMBER VAR N... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | n, m = map(int, input().split())
if n >= m:
print(n - m)
else:
count = 0
while m > n:
if m % 2 == 0:
m //= 2
count += 1
else:
count += 1
m += 1
if m == n:
print(count)
else:
c1 = count + (n - m)
while m != n:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER V... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | n, m = map(int, input().split(" "))
class Fila(list):
def __init__(self):
super(Fila, self).__init__()
self.max_N = 10010
self.queue = []
self.memo = [(False) for _ in range(self.max_N)]
def is_empty(self):
return len(self.queue) == 0
def push(self, element):
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING CLASS_DEF VAR FUNC_DEF EXPR FUNC_CALL FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR NUMBER FUNC_DEF IF VAR NUMBER NUMBER VAR NUMBER VAR RETURN IF VAR VAR NUMBER RETURN ASSI... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | n, m = [int(x) for x in input().split()]
t = 0
def wh(m):
global t
if m % 2 == 0:
m = m / 2
t = t + 1
else:
m = (m + 1) / 2
t = t + 2
if m > n:
wh(m)
else:
t = t + n - m
print(int(t))
if n >= m:
print(n - m)
else:
wh(m) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_DEF IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR EXP... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | def main():
n, m = [int(x) for x in input().split()]
used = [(0) for x in range(1, 100001)]
q = [n]
count = 1
if m == n:
print(0)
return
elif m < n:
print(n - m)
return
while True:
newQ = []
for x in q:
if x - 1 == m or 2 * x == m:
... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR LIST VAR ASSIGN VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER RETURN IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR RETURN WHILE NUMBER ASSIGN VAR LIST FOR VAR VAR IF BIN_OP VAR NUMBER VAR ... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | def two_buttons(start, end):
cache = get_cache(start)
temp = start
while end not in cache:
cache[temp * 2] = 1 + cache[temp]
for i in range(temp * 2 - 1, temp, -1):
if i % 2 == 0:
cache[i] = 1 + min(cache[i // 2], cache[i + 1])
else:
ca... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP ... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | def findit(n, m):
if n == m:
print(0)
return
if n > m:
print(n - m)
return
a = [-1] * (2 * m)
q = [n]
a[n] = 0
while True:
nextone = q.pop(0)
if nextone == m:
print(a[nextone])
return
howmany = a[n]
subone = ... | FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR NUMBER RETURN IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR RETURN ASSIGN VAR BIN_OP LIST NUMBER BIN_OP NUMBER VAR ASSIGN VAR LIST VAR ASSIGN VAR VAR NUMBER WHILE NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR VAR RETURN ASSIGN VAR VAR VAR ASSIGN VAR BIN_O... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | x, y = list(map(int, input().split()))
a = 0
while x != y:
a = a + 1
if y < x or y & 1:
y = y + 1
else:
y = y // 2
print(a) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | def Solve(n, m):
moves = 0
stack = [(n, 0)]
count = 0
vals = set()
while stack:
curr = stack.pop(0)
k = curr[0]
moves = curr[1]
if k not in vals:
vals.add(k)
if k == m:
optimal = moves
if 2 * k - m <= n:
... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR IF BIN_OP BIN_OP NUMBER VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | def min_Push(n, m):
if m > n:
if m % 2 == 0:
return 1 + min_Push(n, m / 2)
else:
return 1 + min_Push(n, m + 1)
else:
return n - m
nums = input().split()
n = int(nums[0])
m = int(nums[1])
print(int(min_Push(n, m))) | FUNC_DEF IF VAR VAR IF BIN_OP VAR NUMBER NUMBER RETURN BIN_OP NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER RETURN BIN_OP NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER RETURN BIN_OP VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL ... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | def count_presses(n, m):
if n == m:
return 0
if n > m:
return n - m
if m % 2:
return count_presses(n, m + 1) + 1
return count_presses(n, m // 2) + 1
print(count_presses(*map(int, input().split()))) | FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR VAR RETURN BIN_OP VAR VAR IF BIN_OP VAR NUMBER RETURN BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER RETURN BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | start, end = map(int, input().split())
step_list = [0] * (10000 * 3)
queue = [start]
for i in queue:
if i == end:
break
else:
if i > 1:
if step_list[i - 1] == 0:
step_list[i - 1] = step_list[i] + 1
queue.append(i - 1)
if i < 10000:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR LIST VAR FOR VAR VAR IF VAR VAR IF VAR NUMBER IF VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER IF VAR BIN_OP VAR NUM... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | n, m = map(int, input().split())
dp = [None] * 10030
todo = [m]
cur = 0
while dp[n] is None:
newtodo = []
for x in todo:
if x < 10030 and dp[x] is None:
dp[x] = cur
newtodo.append(x + 1)
if x % 2 == 0:
newtodo.append(x // 2)
cur += 1
todo = new... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NONE NUMBER ASSIGN VAR LIST VAR ASSIGN VAR NUMBER WHILE VAR VAR NONE ASSIGN VAR LIST FOR VAR VAR IF VAR NUMBER VAR VAR NONE ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NU... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | def solve():
n, m = map(int, input().split())
count = 0
while n != m:
count += 1
if m < n:
m += 1
elif m % 2 == 0:
m /= 2
else:
m += 1
print(count)
solve() | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER IF VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | def pops():
global head
head = head + 1
return q[head - 1]
head = 0
n, m = map(int, input().split())
q = [n]
d = {n: 0}
while q:
n = q.pop(0)
j = n * 2
k = n - 1
if d.get(j, -1) == -1 and j > -1 and j <= 20001:
d[j] = d[n] + 1
q.append(j)
if d.get(k, -1) == -1 and k > -... | FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR ASSIGN VAR DICT VAR NUMBER WHILE VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR NUMBER NUM... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | a, b = input().split()
a = int(a)
b = int(b)
count = 0
def get_min(a, b):
global count
if b >= a:
if b == a:
return count
if b % 2 == 0:
count += 1
get_min(a, b / 2)
else:
count += 2
get_min(a, (b + 1) / 2)
else:
c... | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FUNC_DEF IF VAR VAR IF VAR VAR RETURN VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR FUNC_CALL VAR... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | class Node:
def __init__(self, value, level):
self.value = value
self.level = level
def run():
nums = [eval(n) for n in input().split()]
start = Node(nums[0], 0)
end = nums[1]
count = 0
queue = [start]
visited = {}
while len(queue) != 0:
node = queue.pop(0)
... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST VAR ASSIGN VAR DICT WHILE FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER IF VAR VAR ASSIGN VAR V... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | import sys
a, b = map(int, input().split())
depth = 0
while True:
red = b / 2
blue = b + 1
depth += 1
if red == a or blue == a:
print(depth)
exit()
elif not red == int(red):
b = blue
elif blue < a:
b = blue
else:
b = red | IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR IF VAR FUNC_CALL VAR VAR ASSIGN VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | def count(x, y, res):
if x >= y:
return x - y + res
elif y % 2:
return count(x, (y + 1) // 2, res + 2)
else:
return count(x, y // 2, res + 1)
s = input().split()
x, y = s
print(count(int(x), int(y), 0)) | FUNC_DEF IF VAR VAR RETURN BIN_OP BIN_OP VAR VAR VAR IF BIN_OP VAR NUMBER RETURN FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER RETURN FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | def findShortest(n, m):
count = 0
if n > m:
count += n - m
n = m
while n < m:
count += 1
if m % 2 == 0:
m //= 2
else:
m += 1
return count + n - m
n, m = (int(x) for x in input().split(" "))
print(findShortest(n, m)) | FUNC_DEF ASSIGN VAR NUMBER IF VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR WHILE VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER RETURN BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | n, m = list(map(int, input().split()))
d = [-1] * 30000
d[n] = 0
head = 0
tail = 1
q = []
q.append(n)
while head < tail:
v = q[head]
head += 1
if v > 1 and d[v - 1] == -1:
d[v - 1] = d[v] + 1
q.append(v - 1)
tail += 1
if v <= m and d[2 * v] == -1:
d[2 * v] = d[v] + 1
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR WHILE VAR VAR ASSIGN VAR VAR VAR VAR NUMBER IF VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | a = list(map(int, input().split()))
if a[1] <= a[0]:
print(a[0] - a[1])
else:
count = 0
while True:
if a[1] <= a[0]:
count += a[0] - a[1]
break
elif a[1] % 2 == 0:
a[1] //= 2
count += 1
else:
a[1] += 1
count += 1... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF VAR NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER VAR NUMBER NUMBER VAR NUMBE... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | start, goal = [int(x) for x in input().split()]
if start >= goal:
print(start - goal)
else:
temp = goal
steps = 0
while temp != start:
if temp > start:
if temp % 2 == 0:
temp = temp // 2
else:
temp += 1
else:
temp += 1
... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | n, m = map(int, input().split())
t, q = n, 0
while t < m:
t *= 2
q += 1
q += t - m
stack = [[n, 0]]
mn = q
visited = [False] * 20000
while stack:
cur = stack.pop(0)
if cur[1] < q:
if cur[0] * 2 == m or cur[0] - 1 == m:
if cur[1] + 1 < mn:
mn = cur[1] + 1
c... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER WHILE VAR VAR VAR NUMBER VAR NUMBER VAR BIN_OP VAR VAR ASSIGN VAR LIST LIST VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER WHILE VAR ASSIGN VAR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR IF BIN_OP VAR NUMBER NUMBER VAR BIN_OP... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | from sys import stdin
def get_int_list():
from sys import stdin
return [int(x) for x in stdin.readline().replace("\n", "").split(" ")]
n, m = get_int_list()
count = 0
while n != m:
if m > n:
if m % 2 == 0:
m = m / 2
count += 1
else:
m += 1
... | FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING STRING STRING ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | g = {}
for i in range(-100, 20001):
g[i] = []
for i in range(1, 10001):
if 2 * i <= 10000:
g[i] = [i - 1, 2 * i]
else:
g[i] = [i - 1]
a, b = list(map(int, input().split(" ")))
visited = [False] * 20005
dist = [100000] * 20005
x = [a]
dist[a] = 0
while x:
a = x.pop()
if not visited[a]... | ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER IF BIN_OP NUMBER VAR NUMBER ASSIGN VAR VAR LIST BIN_OP VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR VAR LIST BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR B... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | s = input().split()
a = int(s[1])
b = int(s[0])
otv = 0
while a != b:
otv += 1
if a % 2 == 0 and a > b:
a = a / 2
elif a % 2 == 1 and a > b:
a = a + 1
else:
a = a + 1
print(otv) | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_C... |
Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at so... | import sys
def read():
return sys.stdin.readline().strip()
def printf(a, sep=" ", end="\n"):
sys.stdout.write(sep.join(map(str, a)) + end)
def readf():
return [int(i) for i in read().split()]
def main():
n, m = readf()
if n > m:
printf([n - m])
else:
k = m // n + 1
... | IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF STRING STRING EXPR FUNC_CALL VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR LIST BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR N... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.