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... | arr = list(map(int, input().rstrip().split()))
n = arr[0]
m = arr[1]
ans = 0
while m > n:
if m % 2 == 0:
m //= 2
else:
m += 1
ans += 1
print(ans + n - m) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER 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... | 3
n, m = list(map(int, input().split()))
mem = [2**30] * 4 * max(n, m)
mem[n] = 0
q = [n]
while q:
c = q.pop(0)
if 2 * c < len(mem) and mem[2 * c] > mem[c] + 1:
q.append(2 * c)
mem[2 * c] = mem[c] + 1
if c > 1 and mem[c - 1] > mem[c] + 1:
q.append(c - 1)
mem[c - 1] = mem[c] +... | EXPR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP LIST BIN_OP NUMBER NUMBER NUMBER FUNC_CALL VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR NUMBER IF BIN_OP NUMBER VAR FUNC_CALL VAR VAR VAR BIN_OP NUMBER VAR BIN_OP 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... | nums = str(input()).split()
fr = int(nums[0])
t = int(nums[1])
def diff(a, b):
if b <= a:
return a - b
elif b % 2 == 0:
return diff(a, b / 2) + 1
else:
return diff(a, (b + 1) / 2) + 2
print(int(diff(fr, t))) | ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER FUNC_DEF IF VAR VAR RETURN BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER RETURN BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER RETURN BIN_OP FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER E... |
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())
g = []
for _ in range(1, 20001):
g.append([])
for i in range(1, 20000):
g[i].append(i - 1)
for i in range(1, 10001):
g[i - 1].append(i * 2 - 1)
used = [None] * 20000
used[n - 1] = 0
queue = [n - 1]
def bfs():
while queue != []:
for v in g[queue[0]]:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR LIST FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER 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... | inputArray = input().split(" ")
n = int(inputArray[0])
m = int(inputArray[1])
count = 0
if n == m:
print(int(0))
elif m < n:
print(int(n - m))
else:
while m > n:
if m % 2 == 0:
m = m / 2
else:
m = m + 1
count += 1
count += n - m
print(int(count)) | ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN ... |
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... | p = input()
p = p.split()
n = int(p[0])
m = int(p[1])
c = 0
if m > n:
a = 0
b = n
c = m
while c > b:
b = b * 2
a += 1
while b > c:
b -= 1
a += 1
d = 0
e = n
f = m
while f > e:
if f % 2 != 0:
f = f + 1
d += 1
f = ... | 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 ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER WHILE VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN 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... | def solve(a, b):
big = float("inf")
small = float("-inf")
if a == b:
return 0
elif a > b:
steps = a - b
return steps
else:
ab, bb = a, b
steps = 0
while a < b:
last = a
a *= 2
steps += 1
steps += a - b
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR VAR RETURN NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR VAR RETURN VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR VAR NUMBER 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... | n, m = map(int, input().split())
r = [0] * 10**5
r[n] = 1
t = [n]
i = 0
while t[i] != m:
a = t[i]
if a * 2 < 10**5 and r[a * 2] == 0:
r[a * 2] = r[a] + 1
t.append(a * 2)
if a and r[a - 1] == 0:
r[a - 1] = r[a] + 1
t.append(a - 1)
i += 1
print(r[m] - 1) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR ASSIGN VAR VAR VAR IF BIN_OP VAR NUMBER BIN_OP NUMBER NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER BIN_OP 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
rs = [int(i) for i in input().split()]
m = rs[0]
n = rs[1]
if m > n:
print(m - n)
sys.exit(0)
if m == n:
print(0)
sys.exit(0)
q = 0
while m < n:
if n % 2 == 0:
n = n // 2
else:
n += 1
q += 1
if n >= m:
print(q + (n - m))
else:
print(q + (m - n)) | IMPORT ASSIGN VAR FUNC_CALL VAR 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 EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR NUMBER 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... | n, m = map(int, input().split())
ans = [(-1) for i in range(10**5)]
q = [(0) for i in range(10**5)]
le = rg = 0
q[le] = n
ans[n] = 0
def add(x, t):
global le, rg, q, ans
if ans[x] != -1:
return
ans[x] = ans[t] + 1
rg += 1
q[rg] = x
while le <= rg:
top = q[le]
le += 1
if top <... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR VAR NUMBER FUNC_DEF IF VAR VAR NUMBER RETURN ASSIGN VAR VAR BIN_OP VAR VAR NUMBER 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... | a, b = input().split()
a = int(a)
b = int(b)
if b < a:
print(a - b)
else:
x = a
y = b
i = 0
while x < y:
x = 2 * x
i = i + 1
i = i + x - y
j = 0
while b > a:
if b % 2 != 0:
b = b + 1
j = j + 1
b = b / 2
j = j + 1
j = j +... | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR NUMBER WHI... |
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 main(n, m):
count = 0
if m < n:
return n - m
while m > n:
if m % 2 == 0:
m /= 2
count += 1
else:
m += 1
count += 1
return count + n - m
lines = sys.stdin.readlines()
nums = lines[0].strip().split(" ")
n = int(nums... | IMPORT FUNC_DEF ASSIGN VAR NUMBER IF VAR VAR RETURN BIN_OP VAR VAR WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER RETURN BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN 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... | n, m = input().split()
n = int(n)
m = int(m)
if n >= m:
print(n - m)
else:
count = 0
while n < m:
count += 1
n *= 2
num = n - m
num = bin(num)[2:]
count2 = 0
for i in range(count):
if num[-1] == "1":
count2 += 1
num = num[:-1]
if num == "":... | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER 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... | n, m = [int(x) for x in input().split()]
t = 0
while n != m:
if n >= m:
t += n - m
break
elif n < m and m % 2 == 0:
m /= 2
t += 1
else:
m += 1
t += 1
print(int(t)) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR BIN_OP VAR VAR IF VAR VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER 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... | from sys import stdin
def solution(n, m):
if n == m:
print(0)
return
if n > m:
print(n - m)
return
counter = 0
while n != m:
if m > n and m % 2 == 0:
m /= 2
else:
m += 1
counter += 1
print(counter)
for line in stdin:... | 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 NUMBER WHILE VAR VAR IF VAR VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL 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... | def isPair(x):
return not x % 2
start, target = map(int, input().split())
ans = 0
while start != target:
ans += 1
if start < target and isPair(target):
target /= 2
else:
target += 1
print(ans) | FUNC_DEF RETURN BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER IF VAR VAR FUNC_CALL 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... | numbers = input().split()
numbers[0] = int(numbers[0])
numbers[1] = int(numbers[1])
def NumPress(numbers):
if numbers[0] >= numbers[1]:
return numbers[0] - numbers[1]
length = 0
visited = []
OldQueue = [numbers[0]]
NewQueue = []
while 1 == 1:
length = length + 1
add = T... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST VAR NUMBER ASSIGN VAR LIST WHILE NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER 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), b = map(int, input().split()), 0
def m_is_even(m):
return m % 2 == 0
if n == m:
print(b)
else:
while m > n:
b += 1
if m_is_even(m) and m > n:
m -= m // 2
continue
m += 1
while n > m:
b += 1
m += 1
print(b) | ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER FUNC_DEF RETURN BIN_OP VAR NUMBER NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR WHILE VAR VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER WHILE 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... | n, m = map(int, input().split())
answer = 0
while True:
red = m / 2
blue = m + 1
answer += 1
if red == n or blue == n:
break
elif not red == int(red):
m = blue
else:
tryred = abs(1 - red / n)
tryblue = abs(1 - blue / n)
if tryred < tryblue:
m =... | 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 IF VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER 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... | def fun(n, m):
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
return moves
n, t = map(int, str(input()).split(" "))
print(fun(n, t)) | FUNC_DEF 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 RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR STRING EXPR FUNC_CALL 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... | n, m = map(int, input().split())
lis = [[m, 0]]
length = 1
dp = [(0) for i in range(100000)]
while True:
if length == 0 or length == 200:
break
li = lis.pop()
length -= 1
a = li[0]
b = li[1]
if dp[a] == 1:
continue
dp[a] = 1
if a == n:
print(b)
break
i... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST LIST VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER WHILE NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR E... |
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:
c = 0
d = m
while True:
if d <= n:
break
if d % 2 == 0:
d = d // 2
c = c + 1
elif d % 2 != 0:
d = d + 1
d = d // 2
c = c + 2
c = c + (n - d)
... | 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 ASSIGN VAR VAR WHILE NUMBER IF VAR VAR IF BIN_OP VAR NUMBER 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 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... | def bfs(n, m):
parent = [-1] * (10 * m)
q = list()
q.append(n)
parent[n] = n
while len(q) != 0:
child = q.pop()
if child == m:
break
if child > 2 * m:
continue
if child * 2 < len(parent) and parent[child * 2] == -1:
q.append(child *... | FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR WHILE FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR IF VAR VAR IF VAR BIN_OP NUMBER VAR IF BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER NUMBER 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... | x, y = map(int, input().split())
if x > y:
print(x - y)
else:
c = 0
while y > x:
if y % 2 == 0:
y = y // 2
c += 1
else:
y = y + 1
c += 1
print(c + (x - y)) | 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 ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP 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 bfs(start, goal):
moves = 0
q = [start]
seen = set()
while q:
for _ in range(len(q)):
num = q.pop(0)
if num < 1 or num > 10**4:
continue
if num == goal:
return moves
seen.add(num)
if num * 2 not in se... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST VAR ASSIGN VAR FUNC_CALL VAR WHILE VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR BIN_OP NUMBER NUMBER IF VAR VAR RETURN VAR EXPR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF 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... | class Solution:
def __init__(self):
self.n, self.m = map(int, input().split())
self.cnt = 0
def solution(self):
if self.n >= self.m:
print(self.n - self.m)
else:
while self.m > self.n:
if self.m % 2 == 0:
self.m //= 2
... | CLASS_DEF FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR FUNC_DEF ASSIGN 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... | def Main(n, m):
cnt = 0
lft = n
rgt = m
while True:
if lft == rgt:
break
if lft < rgt:
if rgt % 2 == 1:
rgt += 1
rgt //= 2
cnt += 2
else:
rgt //= 2
cnt += 1
elif lf... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR WHILE NUMBER IF VAR VAR IF VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR 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... | n, m = map(int, input().split())
v = set()
s = [n]
g = {}
while s:
x = s.pop()
if x not in v:
v.add(x)
if x <= 1:
s.append(2 * x)
g[x] = [2 * x]
elif x > m:
s.append(x - 1)
g[x] = [x - 1]
else:
s.append(x - 1)
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST VAR ASSIGN VAR DICT WHILE VAR ASSIGN VAR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR VAR LIST BIN_OP NUMBER VAR IF VAR VAR EXPR FUNC_CALL 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... | import sys
def calculate(n, m):
if n >= m:
return n - m
elif m % 2 == 0:
return calculate(n, m // 2) + 1
else:
return calculate(n, m + 1) + 1
line = list(map(int, sys.stdin.readline().split()))
n = line[0]
m = line[1]
print(calculate(n, m)) | IMPORT FUNC_DEF IF VAR VAR RETURN BIN_OP VAR VAR IF BIN_OP VAR NUMBER 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 ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER 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 bfs(graph, begin):
d = [None] * len(graph)
d[begin] = 0
vertices = [begin]
cur_d = 1
while len(vertices) > 0:
s_ver = []
for v in vertices:
for u in graph[v]:
if d[u] is None:
d[u] = cur_d
s_ver.append(u)
... | FUNC_DEF ASSIGN VAR BIN_OP LIST NONE FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST VAR ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR VAR FOR VAR VAR VAR IF VAR VAR NONE ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR 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... | n, m = map(int, input().split())
done = {n}
frontier = {n}
i = 0
while True:
i += 1
new_f = set()
for e in frontier:
for v in (e * 2, e - 1):
if v < 0 or v in done or v > 20000:
continue
if v == m:
print(i)
exit()
do... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VAR FOR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF VAR NUMBER VAR VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR E... |
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_min_operations(n, m):
if m == n:
return 0
if m < n:
return n - m
cnt = 0
while m >= n:
if m == n:
return cnt
if m % 2 != 0:
cnt += 1
m += 1
else:
if m / 2 < n:
return cnt + 1 + n - int(m / 2)
... | FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR VAR RETURN BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR RETURN VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER VAR RETURN BIN_OP BIN_OP BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR VAR F... |
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().split()]
c = 0
while True:
if m == n:
print(c)
break
if m % 2 == 1 or m < n:
c += 1
m += 1
else:
m = m // 2
c += 1 | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP 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... | n, ex = list(map(int, input().split()))
count = 0
if ex < n:
print(n - ex)
else:
ex, n = n, ex
while True:
if n < ex or n == ex:
count += ex - n
print(count)
break
elif n % 2 == 0:
n //= 2
count += 1
elif n % 2 != 0:
... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR VAR WHILE NUMBER IF VAR VAR VAR VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER 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... | inp = input().split()
num1 = int(inp[0])
num2 = int(inp[1])
def least_presses(start, goal):
curr = list()
curr.append(start)
visited = list()
visited.append(start)
steps = 0
while True:
next = list()
for num in curr:
if num * 2 not in visited and num <= -(-goal // 2... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF BIN_OP VAR NUMBER VAR 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... | def main() -> object:
n, m = [int(i) for i in input().split()]
count = 0
while n < m:
if m % 2 == 0:
m >>= 1
else:
m += 1
count += 1
count += n - m
return count
print(main()) | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR 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 VAR BIN_OP VAR VAR RETURN VAR VAR EXPR FUNC_CALL 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... | n, m = [int(x) for x in input().split(" ")]
d = 0
def main(n, m):
global d
if m == n:
print(d)
exit()
if n >= m:
d += n - m
print(d)
exit()
elif m % 2 == 0:
d += 1
m //= 2
else:
d += 1
m += 1
return main(n, m)
main(n, m) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR IF VAR VAR VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER RETURN 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... | def two_degree(n, m):
deg = 0
res = n
while res < m:
res *= 2
deg += 1
print(res)
return deg, res - m
my_str = input()
n, m = int(my_str.split()[0]), int(my_str.split()[1])
if m < n:
print(n - m)
else:
res = n
oper = 0
while res != m:
if m % 2 == 1 and m > r... | FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN 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... | l = list(map(int, input().split()))
n = l[0]
m = l[1]
if m < n:
print(n - m)
else:
r = 0
while m != n:
if m < n:
r += n - m
break
if m % 2 == 0:
r += 1
m = int(m / 2)
else:
r += 1
m += 1
print(r) | 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 WHILE VAR VAR IF VAR VAR VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR 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... | def get_num_of_steps(start_num, target_num):
upper_bound = start_num
while upper_bound < target_num:
upper_bound *= 2
visited = [False] * (upper_bound + 1)
visited[start_num] = True
queue = [(start_num, 0)]
min_steps = None
while len(queue) != 0:
head, steps = queue[0]
... | FUNC_DEF ASSIGN VAR VAR WHILE VAR VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST VAR NUMBER ASSIGN VAR NONE WHILE FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR IF BIN_OP NUMBER VAR VAR VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP 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... | def main():
n, m = map(int, input().split())
res, delta = 0, 1
while n < m:
res += 1
n *= 2
delta *= 2
while n > m:
while n - delta >= m:
res += 1
n -= delta
delta //= 2
print(res)
def __starting_point():
main()
__starting_point... | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER WHILE VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER WHILE VAR VAR WHILE BIN_OP VAR VAR VAR VAR NUMBER VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR FUNC_DEF EXPR FUNC_CALL 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... | from sys import *
inp = lambda: stdin.readline()
def main():
n, m = map(int, inp().split())
ans = 0
if n < m:
while m > n:
if m % 2 == 0:
m //= 2
ans += 1
else:
m += 1
ans += 1
ans += n - m
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_DEF 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 VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR 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 solution(n, m):
operations = 0
while n != m:
operations += 1
m += 1 if m < n or m % 2 == 1 else -m // 2
return operations
n, m = map(int, input().split())
print(solution(n, m)) | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER VAR VAR VAR BIN_OP VAR NUMBER NUMBER NUMBER BIN_OP 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... | def fun(n, m):
if n >= m:
return n - m
Q = [n]
mySet = set()
cnt = 1
while True:
new_Q = []
for num in Q:
x = 2 * num
y = num - 1
if x == m or y == m:
return cnt
if not x in mySet and x < 20000 and x > 0:
... | FUNC_DEF IF VAR VAR RETURN BIN_OP VAR VAR ASSIGN VAR LIST VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE NUMBER ASSIGN VAR LIST FOR VAR VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR VAR RETURN VAR IF VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF 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())
count = 0
while m > n:
if m % 2 == 0:
m = m // 2
else:
m += 1
count += 1
while m < n:
m += 1
count += 1
print(count) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER WHILE 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... | input = input().split()
start = int(input[0])
goal = int(input[1])
if goal == start:
print(0)
list = []
list.append(start)
found = False
i = 0
done = [False] * 20000
iter = 0
while not found:
end = len(list)
if goal in list[i:end]:
print(iter)
found = True
for j in range(i, end):
... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR FUNC_CALL VAR VAR IF 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()))
graph = {}
for i in range(2, 10**4 + 1):
graph[i] = []
graph[1] = [2]
distances = {}
max_value = 10**4
for i in range(2, max_value + 1):
graph[i] = [i - 1]
if i * 2 <= max_value:
graph[i].append(i * 2)
path_length = 0
q = [n]
distances[n] = 0
used_... | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR VAR LIST ASSIGN VAR NUMBER LIST NUMBER ASSIGN VAR DICT ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER 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... | def bfs(u, m):
N = 10**5
vis = [False] * N
d = [10**10] * N
d[u] = 0
q = []
q.append(u)
while q:
v = q.pop(0)
if v == m:
return d[v]
if v < 0:
continue
if vis[v] == False:
vis[v] = True
q.append(v - 1)
... | FUNC_DEF ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST BIN_OP NUMBER NUMBER VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR NUMBER IF VAR VAR RETURN VAR VAR IF VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR NUMBER 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 botoes(n, m):
op = 0
while True:
if m == n:
return op
if m < n:
return op + int(n - m)
if m % 2 == 0:
m /= 2
op += 1
else:
m += 1
op += 1
NM = [int(i) for i in input().split()]
n = NM[0]
m = NM[1]
print... | FUNC_DEF ASSIGN VAR NUMBER WHILE NUMBER IF VAR VAR RETURN VAR IF VAR VAR RETURN BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR 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... | def tb(x, y):
presses = 0
if x > y:
print(x - y)
return 0
while y != x:
if y < x or y % 2 == 1:
y += 1
presses += 1
else:
y = y / 2
presses += 1
print(presses)
return 0
values = input().split()
n = int(values[0])
m = i... | FUNC_DEF ASSIGN VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR RETURN NUMBER WHILE VAR VAR IF VAR VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN 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... | start, end = input().split()
start = int(start)
end = int(end)
counter = 0
if end < start:
print(int(min(start - 1, start - end)))
else:
end_new = end
while end_new > start:
if end_new % 2 != 0:
end_new = end_new + 1
counter += 1
else:
end_new = end_new / ... | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR ASSIGN VAR VAR 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... | n, m = map(int, input().split())
q = [n]
visit = {}
dist = {n: 0}
while len(q) != 0:
nod = q.pop(0)
if nod == m:
print(dist[m])
break
if nod - 1 not in visit and nod - 1 > 0:
visit[nod - 1] = 1
dist[nod - 1] = dist[nod] + 1
q.append(nod - 1)
if nod * 2 not in visi... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR ASSIGN VAR DICT ASSIGN VAR DICT VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER 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... | import sys
b, e = list(map(int, input().split()))
if b >= e:
print(b - e)
sys.exit()
count = 0
while b is not e:
if e > b:
if e % 2 is 0:
e = e // 2
else:
e = e + 1
else:
count = count + b - e
break
count = count + 1
print(count) | IMPORT 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 EXPR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR 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 VAR VAR 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... | import sys
ri = lambda: map(int, input().split(" "))
n, m = ri()
seen = set()
q = [(n, 0)]
seen.add(n)
while q:
x, t = q[0]
q.pop(0)
if x == m:
import sys
print(t)
sys.exit(0)
if x > 1 and x - 1 not in seen:
seen.add(x - 1)
q.append((x - 1, t + 1))
if x < m ... | IMPORT ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER EXPR FUNC_CALL VAR VAR WHILE VAR ASSIGN VAR VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR IMPORT EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER 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... | n, m = input().split()
n, m = int(n), int(m)
x = m
Sum = 0
if n >= m:
print(n - m)
else:
v = 0
for i in range(0, 15):
m = m / 2
v = v + 1
if m <= n:
break
if m == n:
print(v)
elif m == int(m):
a = n - m
print(int(a + v))
else:
m... | ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR IF 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... | n, m = [int(x) for x in input().split()]
nb_steps = 0
copy_m = m
double = {1}
while copy_m != 1:
copy_m = int((copy_m + 1) / 2)
double.add(copy_m)
while n != m:
nb_steps += 1
if n in double:
n = 2 * n
else:
n -= 1
print(nb_steps) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR WHILE VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP NUMBER 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 = [int(i) for i in input().split(" ")]
times_ = 0
minus_ = 0
while n < m:
if m % 2 == 0:
m = int(m / 2)
else:
m = m + 1
times_ += 1
print(times_ + (n - m)) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP 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 bfs(n, m):
queue = [n]
level = {}
level[n] = 0
if n > m:
return n - m
while queue:
s = queue.pop(0)
for a in [s * 2, s - 1]:
if level.get(a) == None and a > 0 and a < 2 * m:
level[a] = level[s] + 1
queue.append(a)
return lev... | FUNC_DEF ASSIGN VAR LIST VAR ASSIGN VAR DICT ASSIGN VAR VAR NUMBER IF VAR VAR RETURN BIN_OP VAR VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR NUMBER FOR VAR LIST BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR NONE VAR NUMBER VAR BIN_OP NUMBER VAR ASSIGN VAR VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN 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 = map(int, input().split())
h = 1
q = [n]
k = 2 * 10**4 + 1
popa = [(0) for i in range(2 * 10**4 + 1)]
if n > m:
print(n - m)
else:
visited = []
while q:
n = []
for i in q:
if i * 2 not in visited and i < 2 * m:
if 2 * i == m:
print(h)
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST VAR ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP NUMBER NUMBER NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR LIST WHILE VAR ASSIGN 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:
print(n - m)
else:
q = [n]
i = 0
steps = {n: 0}
run = True
while i < len(q) and run:
v = q[i]
i += 1
nxt = []
if v > 1:
nxt.append(v - 1)
if v < m:
nxt.append(v * 2)
for u in nxt:
... | 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 LIST VAR ASSIGN VAR NUMBER ASSIGN VAR DICT VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR LIST IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF 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
class Linear_Graph:
def __init__(self, lis):
self._vertices = lis
self._connections = dict()
def construct_links(self):
for vert in self._vertices:
if vert not in self._connections:
self._connections[vert] = []
if vert - 1 in sel... | IMPORT CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_DEF FOR VAR VAR IF VAR VAR ASSIGN VAR VAR LIST IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_DEF EXPR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR LIST VAR ASSIGN 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 = list(map(int, input().split()))
def bouton(n, m):
if n == m:
return 0
if n > m:
return n - m
if n <= 0 and m > 0:
return n
if m % 2 == 1:
return 1 + bouton(n, m + 1)
else:
return 1 + bouton(n, m / 2)
print(int(bouton(n, m))) | ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR VAR RETURN BIN_OP VAR VAR IF VAR NUMBER VAR NUMBER RETURN 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 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... | x = input()
n, m = x.strip().split(" ")
n, m = int(n), int(m)
LIM = 10**4 + 100
st = [None] * (LIM + 1)
st[n] = 0
delam = [n]
while len(delam) > 0:
nov = set()
for x in delam:
for k in (2 * x, x - 1):
if 0 <= k < LIM:
if st[k] is None:
nov.add(k)
... | ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NONE BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST VAR WHILE FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR 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 extend(l):
global n, door
for i in l[:]:
if done[i] == 0:
if i < n and i > 0:
if i * 2 not in l:
l.append(i * 2)
if i - 1 not in l:
l.append(i - 1)
elif i > 0:
door = min(step + i - n, doo... | FUNC_DEF FOR VAR VAR IF VAR VAR NUMBER IF VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER RETURN 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... | a, b = [int(x) for x in input().split()]
if a > b:
print(a - b)
else:
tot = 0
while a < b:
a *= 2
tot += 1
greatestPower = 2**tot
remainder = (a - b) % greatestPower
tot += (a - b) // greatestPower
for i in bin(remainder)[2:]:
if i == "1":
tot += 1
pri... | 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 NUMBER WHILE VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR FOR VAR FUNC_CALL VAR VAR NUMBER IF VAR STRING VAR NUMBER EXPR F... |
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... | ans = [-1] * 20004
def go(cur):
ans[cur] = 0
q = [[cur, 0]]
while q:
u, d = q.pop(0)
if u - 1 >= 0:
if ans[u - 1] == -1:
ans[u - 1] = d + 1
q.append([u - 1, d + 1])
if u * 2 <= 20000:
if ans[2 * u] == -1:
ans[2... | ASSIGN VAR BIN_OP LIST NUMBER NUMBER FUNC_DEF ASSIGN VAR VAR NUMBER ASSIGN VAR LIST LIST VAR NUMBER WHILE VAR ASSIGN VAR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR LIST BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF 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... | n, m = map(int, input().split())
d = []
a = []
count = 0
a.append(n)
if m < n:
print(n - m)
else:
while 1:
b = []
count = count + 1
for i in a:
if i not in d:
d.append(i)
if i <= m:
if 2 * i - m <= 100:
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR WHILE NUMBER ASSIGN VAR LIST ASSIGN VAR BIN_OP VAR NUMBER FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR IF VAR VAR IF BIN_OP BIN_OP NUMBER 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... | currentsteps = 9999999999999
def step(current, goal, steps, stepes):
global currentsteps
if stepes > 500:
return 99999999999999
if steps > currentsteps:
return steps
valores = []
for n in current:
if n >= goal:
val = steps + abs(n - goal)
if val < cu... | ASSIGN VAR NUMBER FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR VAR RETURN VAR ASSIGN VAR LIST FOR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR ASSIGN 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... | def count_minor_ops(a, b):
ops = 0
while True:
if a == b:
break
elif b < a:
ops += a - b
break
elif b % 2 == 0:
b = b // 2
else:
b += 1
ops += 1
return ops
a, b = list(map(int, input().split()))
print(count... | FUNC_DEF ASSIGN VAR NUMBER WHILE NUMBER IF VAR VAR IF VAR VAR VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL 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... | numbers = input().split()
numbers = [int(x) for x in numbers]
steps = 0
while numbers[0] != numbers[1]:
if numbers[0] == numbers[1]:
print(steps)
break
if numbers[1] % 2 == 1:
numbers[1] += 1
steps += 1
while numbers[0] < numbers[1] and numbers:
if numbers[1] % 2 == 1... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER WHILE VAR NUMBER VAR NUMBER VAR IF BIN_OP VAR NUMBER NUMBER NUMBER VAR NUMBER 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... | def fun(x, y, c):
if x == y:
print(c)
elif y > x:
if y % 2 == 0:
c += 1
fun(x, y / 2, c)
else:
c += 1
fun(x, y + 1, c)
else:
print(int(x - y + c))
n, m = input().split()
n = int(n)
m = int(m)
fun(n, m, 0) | FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR VAR IF VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN 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... | a, b = map(int, input().split())
z = 0
while a < b:
if b % 2 == True:
z += 1
b += 1
else:
b = b // 2
z += 1
print(str(int(abs(z + a - b)))) | 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 ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR 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... | a, b = [int(x) for x in input().split()]
count = 0
big = b
small = a
while big > small:
count += 1
if big % 2 == 0:
big /= 2
else:
big += 1
ans = count + (small - big)
print(int(ans)) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR WHILE VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP 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 = map(int, input().split())
if n > m:
print(n - m)
exit(0)
c = 0
while n < m:
if m % 2 == 0:
m = m / 2
else:
m += 1
c += 1
print(int(c + n - m)) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR 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... | def main():
n, m = input().split()
n, m = int(n), int(m)
a = 0
while m > n:
if m % 2:
m += 1
else:
m //= 2
a += 1
print(a + n - m)
main() | FUNC_DEF ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR 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... | n, m = [int(i) for i in input().split(" ")]
def tow_buttons(m: int) -> int:
return (
0
if n == m
else (
n - m
if n > m
else tow_buttons(m // 2) + 1 if not m % 2 else tow_buttons((m + 1) // 2) + 2
)
)
print(tow_buttons(m)) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF VAR RETURN VAR VAR NUMBER VAR VAR BIN_OP VAR VAR BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER 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
def twoButton():
import sys
data = sys.stdin.read()
data = data.split(" ")
n = int(data[0])
m = int(data[1])
if n == m:
return 0
elif m < n:
return n - m
else:
count = 0
while n < m:
if m % 2 == 0:
m = m / 2
... | IMPORT FUNC_DEF IMPORT 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 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 ASSIGN VAR BIN_OP 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... | import sys
input_list = input().split()
beg = int(input_list[0])
end = int(input_list[1])
steps = 0
while end > beg:
if end % 2 == 1:
end = end + 1
else:
end = end / 2
steps = steps + 1
diff = abs(beg - end)
steps = steps + diff
print(int(steps)) | IMPORT 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 BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP 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... | def solve(n, m):
count = 0
while m != n:
count += 1
if m > n and m % 2 == 0:
m /= 2
else:
m += 1
print(count)
x = tuple(map(int, input().rstrip().split()))
solve(x[0], x[1]) | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR 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 getPushes(n, m):
pushes = 0
while m != n:
if m < n:
m += 1
elif m % 2 == 0:
m /= 2
else:
m += 1
pushes += 1
return pushes
s = input().split()
n = int(s[0])
m = int(s[1])
if m <= n:
print(n - m)
else:
print(int(getPushes(n, m))... | FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR EXPR FUNC_CALL 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... | n, m = map(int, input().split())
if n >= m:
print(n - m), exit()
v = [-1] * (2 * m)
v[m] = 0
q = [m]
while q:
cur = q.pop(0)
d = v[cur]
if cur < 2 * m - 1 and v[cur + 1] == -1:
v[cur + 1] = d + 1
q.append(cur + 1)
if cur % 2 == 0 and v[cur // 2] == -1:
v[cur // 2] = d + 1
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP NUMBER VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR IF VAR BIN_OP BIN_OP NUMBER VAR NUMBER 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... | def main():
a = list(map(int, input().split(" ")))
n, m = a[0], a[1]
if n >= m:
print(n - m)
else:
d = [1000000000000.0] * (2 * m)
d[n] = 0
Q = [n]
while Q:
e = Q[0]
del Q[0]
if e < m and d[2 * e] >= 1000000000000.0:
... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP NUMBER VAR ASSIGN VAR VAR NUMBER ASSIGN VAR LIST VAR WHILE VAR ASSIGN VAR VAR NUMBER VAR NUMBER IF VAR 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... | n, m = (int(x) for x in input().split())
q = [(n, 0)]
visited = {n}
while q:
now = q[0]
del q[0]
if now[0] == m:
print(now[1])
break
else:
if now[0] * 2 <= 2 * m and not now[0] * 2 in visited:
q.append((now[0] * 2, now[1] + 1))
visited.add(now[0] * 2)
... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER ASSIGN VAR VAR WHILE VAR ASSIGN VAR VAR NUMBER VAR NUMBER IF VAR NUMBER VAR EXPR FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER BIN_OP NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER 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... | m, n = [int(i) for i in input().split()]
def d(begin, end):
if begin == end:
return 0
if begin == end + 1:
return 1
if end % 2 == 0 and end // 2 == begin:
return 1
if begin > end:
return begin - end
if end % 2 == 0:
return d(begin, end // 2) + 1
return d... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR BIN_OP VAR NUMBER RETURN NUMBER IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER VAR RETURN NUMBER IF VAR VAR RETURN BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER RETURN BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER RETU... |
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())
INF = 100000000
dp = [INF] * max(n + 2, m + 2)
for i in range(n, 0, -1):
dp[i] = n - i
for i in range(1, m):
if 2 * i <= m + 1:
dp[2 * i] = min(dp[2 * i], dp[i] + 1)
dp[2 * i - 1] = min(dp[2 * i - 1], dp[i] + 2)
print(dp[m]) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP NUMBER V... |
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf.
To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ... | n = int(input())
s = input()
idx = (n + 1) // 2 - 1
if n % 2 == 1:
x = idx + 1
ans = int(s)
while x < n and s[x] == "0":
x += 1
if x < n:
t1 = int(s[0:x])
t2 = int(s[x:n])
ans = min(t1 + t2, ans)
x = idx
while x >= 0 and s[x] == "0":
x -= 1
if x > 0:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR VAR VAR STRING VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR FUNC_CALL V... |
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf.
To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ... | n = int(input())
m = input()
x, y, z = -1, -1, -1
for i in range(n // 2 - 1, -1, -1):
if m[i] != "0":
x = i
break
for i in range(n - n // 2, n):
if m[i] != "0":
y = i
break
if n % 2 == 1 and m[n // 2] != "0":
z = n // 2
ans = int(m)
for xx in [x, y, z]:
if xx == -1:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER NUMBER IF VAR VAR STRING ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR IF VAR VAR STRING ASSIGN VAR VAR IF BIN_OP VAR NUMBER NUMBER... |
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf.
To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ... | l = int(input())
s = input()
x = l // 2
y = (l + 1) // 2
while x > -1 and s[x] == "0":
x -= 1
while y < l and s[y] == "0":
y += 1
a = 0
b = 0
for i in range(x):
a = 10 * a + int(s[i])
for i in range(x, l):
b = 10 * b + int(s[i])
ans = a + b
a = 0
b = 0
if y != l:
for i in range(y):
a = 10 * ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER WHILE VAR NUMBER VAR VAR STRING VAR NUMBER WHILE VAR VAR VAR VAR STRING VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER VAR FUN... |
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf.
To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ... | a = int(input())
b = input()
ans = int(b)
mid1 = a // 2
mid2 = a // 2 + 1
while mid1 >= 1:
if b[mid1] != "0":
ans = min(ans, int(b[0:mid1]) + int(b[mid1:]))
break
mid1 = mid1 - 1
while mid2 < a:
if b[mid2] != "0":
ans = min(ans, int(b[0:mid2]) + int(b[mid2:]))
break
mid2 ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER WHILE VAR NUMBER IF VAR VAR STRING ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHIL... |
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf.
To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ... | n = int(input())
s = input().strip()
mid = n // 2
ans = int(s)
if s[mid] != "0":
num = int(s[:mid]) + int(s[mid:])
ans = min(ans, num)
for i in range(mid + 1, n):
if s[i] != "0":
num = int(s[:i]) + int(s[i:])
ans = min(ans, num)
break
for i in range(mid - 1, 0, -1):
if s[i] != "0... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR STRING ASSIGN VAR BI... |
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf.
To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ... | n = int(input())
s = input()
mid1 = n // 2
if n % 2 == 0:
mid1 -= 1
mid2 = mid1
else:
mid2 = mid1
mid1 -= 1
while mid1 >= 0 and s[mid1 + 1] == "0":
mid1 -= 1
while mid2 + 1 < n and s[mid2 + 1] == "0":
mid2 += 1
ans = -1
if 0 <= mid1 < n - 1:
a = s[: mid1 + 1]
b = s[mid1 + 1 :]
if ans... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER STRING VAR NUMBER WHILE BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER STRING VAR NUMBER ASSIGN VAR NUMBER IF N... |
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf.
To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ... | import sys
def f(s, k):
return int(s[:k]) + int(s[k:])
def solve(s, k):
if s[k] != "0":
return f(s, k)
ans = []
i = k
while s[i] == "0":
i -= 1
if i != 0:
ans.append(f(s, i))
j = k
while j < len(s) and s[j] == "0":
j += 1
if j != len(s):
an... | IMPORT FUNC_DEF RETURN BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_DEF IF VAR VAR STRING RETURN FUNC_CALL VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR VAR WHILE VAR VAR STRING VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR WHILE VAR FUNC_CALL VAR VAR VAR VAR STRING VAR NUMBER IF ... |
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf.
To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ... | nn = int(input())
n = input()
d = list(n)
if nn % 2 == 0:
p = nn // 2
if n[p] == "0":
q = p - 1
while n[p] == "0" and n[q] == "0":
p = p + 1
q = q - 1
if n[p] == "0":
print(int(n[:q]) + int(n[q:]))
else:
print(int(n[:p]) + int(n[p:]... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR STRING VAR VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR STRING EXPR FUNC_C... |
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf.
To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ... | def getnumber(A, a):
return int(int(A[a + 1 :]) + int(A[: a + 1]))
n = int(input())
A = input()
k = n // 2 - 1
if n % 2 == 0:
a = k
if A[k + 1] == "0":
while A[k + 1] == "0" and k < n - 2:
k += 1
while A[a + 1] == "0" and a >= 0:
a -= 1
if A[k + 1] != "0" an... | FUNC_DEF RETURN FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR IF VAR BIN_OP VAR NUMBER STRING WHILE VAR BIN_OP VAR NUMBER S... |
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf.
To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ... | n = int(input())
v = input()
c = n // 2
while c > 0 and v[c] == "0":
c -= 1
d = n // 2 + 1
while d < n - 1 and v[d] == "0":
d += 1
a = int(v[:d]) + int(v[d:])
if v[d] == "0":
a = 10**100100
if c == 0:
c = d
b = int(v[:c]) + int(v[c:])
print(min(a, b)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR VAR STRING VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER WHILE VAR BIN_OP VAR NUMBER VAR VAR STRING VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR STRING ASSIGN ... |
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf.
To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ... | n = int(input())
s = input()
if n % 2:
for i in range(int(n / 2 + 1)):
a = None
b = None
ind1 = int(n / 2 - i)
ind2 = int(n / 2 + 1 + i)
if s[ind1] != "0" and s[ind2] == "0":
print(int(s[0:ind1]) + int(s[ind1:]))
break
elif s[ind2] != "0" and s... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NONE ASSIGN VAR NONE ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER VAR IF VAR VAR ST... |
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf.
To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ... | n = int(input())
s = input()
ans = int(s)
for k, i in ((1, n // 2), (-1, (n + 1) // 2)):
while i < n and "1" > s[i]:
i += k
if 0 < i < n:
ans = min(ans, int(s[:i]) + int(s[i:]))
print(ans) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR NUMBER BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER WHILE VAR VAR STRING VAR VAR VAR VAR IF NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL V... |
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf.
To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ... | l = int(input())
n = input()
if l % 2 == 0:
res1, res2 = n[: l // 2], n[l // 2 :]
i, j = l // 2 - 1, 0
else:
a, b = n[: l // 2 + 1], n[l // 2 :]
if int(a) < int(b):
res1, res2 = a, n[l // 2 + 1 :]
i, j = l // 2, 0
else:
res1, res2 = n[: l // 2], b
i, j = l // 2 - 1, 0... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASS... |
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf.
To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ... | length = int(input())
n = input()
if length == 2:
Bestans = int(n[0]) + int(n[1])
print(Bestans)
else:
bestAns = int(n)
p = length // 2
for i in range(p, -1, -1):
if n[i + 1] == "0":
continue
bestAns = min(bestAns, int(n[0 : i + 1]) + int(n[i + 1 :]))
break
p ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER STRING ASSIGN VAR FUNC_CALL ... |
Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf.
To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive ... | n = int(input())
s = input()
p = [i for i in range(n) if s[i] != "0"][1:]
p = sorted(p, key=lambda x: abs(x - n / 2))
minn = int(s)
for i in range(min(4, len(p))):
minn = min(minn, int(s[: p[i]]) + int(s[p[i] :]))
print(minn) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR VAR STRING NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.