description stringlengths 171 4k | code stringlengths 94 3.98k | normalized_code stringlengths 57 4.99k |
|---|---|---|
You have $n$ sticks of the given lengths.
Your task is to choose exactly four of them in such a way that they can form a rectangle. No sticks can be cut to pieces, each side of the rectangle must be formed by a single stick. No stick can be chosen multiple times. It is guaranteed that it is always possible to choose s... | import sys
f = sys.stdin
out = sys.stdout
def fun(l, b):
return (2 * (l + b)) ** 2 / (l * b)
t = int(f.readline().rstrip("\r\n"))
for _ in range(t):
n = int(f.readline().rstrip("\r\n"))
a = list(map(int, f.readline().rstrip("\r\n").split()))
d = {}
arr = []
for i in a:
if i in d:
... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP NUMBER BIN_OP VAR VAR NUMBER BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL F... |
You have $n$ sticks of the given lengths.
Your task is to choose exactly four of them in such a way that they can form a rectangle. No sticks can be cut to pieces, each side of the rectangle must be formed by a single stick. No stick can be chosen multiple times. It is guaranteed that it is always possible to choose s... | super_ans = []
for i in range(int(input())):
n = input()
if n == "4":
super_ans.append(input())
continue
elif n == "5":
a = sorted(map(int, input().split()))
if a[0] == a[1] and a[2] == a[3]:
super_ans.append(" ".join([str(a[0]), str(a[0]), str(a[2]), str(a[2])]))... | ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR IF VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL STRING LIST FUNC_CALL VAR... |
You have $n$ sticks of the given lengths.
Your task is to choose exactly four of them in such a way that they can form a rectangle. No sticks can be cut to pieces, each side of the rectangle must be formed by a single stick. No stick can be chosen multiple times. It is guaranteed that it is always possible to choose s... | import sys
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
t = int(input())
for case in range(t):
n = int(input())
a = list(map(int, input().split()))
a.sort()
tmp = 10**4
ans = 10**9
i = 0
rec = 0, 0
break_bit = 0
while i < n - ... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUM... |
You have $n$ sticks of the given lengths.
Your task is to choose exactly four of them in such a way that they can form a rectangle. No sticks can be cut to pieces, each side of the rectangle must be formed by a single stick. No stick can be chosen multiple times. It is guaranteed that it is always possible to choose s... | import sys
input = sys.stdin.readline
T = int(input())
for i in range(T):
n = int(input())
d = {}
lens = []
nums = list(map(int, input().strip().split()))
for num in nums:
d[num] = d.get(num, 0) + 1
if d[num] == 2:
lens.append(num)
d[num] = 0
lens = sorte... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FOR VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER IF VAR VAR NUMBER E... |
You have $n$ sticks of the given lengths.
Your task is to choose exactly four of them in such a way that they can form a rectangle. No sticks can be cut to pieces, each side of the rectangle must be formed by a single stick. No stick can be chosen multiple times. It is guaranteed that it is always possible to choose s... | from sys import stdin, stdout
def read():
return stdin.readline().rstrip("\n")
def read_array(sep=None, maxsplit=-1):
return read().split(sep, maxsplit)
def read_int():
return int(read())
def read_int_array(sep=None, maxsplit=-1):
return [int(a) for a in read_array(sep, maxsplit)]
def write(*a... | FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF NONE NUMBER RETURN FUNC_CALL FUNC_CALL VAR VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF NONE NUMBER RETURN FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR STRING STRING EXPR FUNC_... |
You have $n$ sticks of the given lengths.
Your task is to choose exactly four of them in such a way that they can form a rectangle. No sticks can be cut to pieces, each side of the rectangle must be formed by a single stick. No stick can be chosen multiple times. It is guaranteed that it is always possible to choose s... | import sys
read = lambda: sys.stdin.readline().strip()
prcs = lambda x, y: (x + y) ** 2 / (x * y)
n = int(read())
for i in range(0, n):
t = int(read())
a = list(map(int, read().split()))
a.sort()
dub = []
ind = 0
while ind < t - 1:
if a[ind] == a[ind + 1]:
dub.append(a[ind])... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST ASS... |
You have $n$ sticks of the given lengths.
Your task is to choose exactly four of them in such a way that they can form a rectangle. No sticks can be cut to pieces, each side of the rectangle must be formed by a single stick. No stick can be chosen multiple times. It is guaranteed that it is always possible to choose s... | from sys import stdin, stdout
T = int(stdin.readline())
ans = []
for cc in range(0, T):
n = int(stdin.readline())
a = [int(x) for x in stdin.readline().split()]
a.sort()
a.append(1061109567)
res = [0, 0, 1, 1]
pre = 0
cnt = 0
for i in a:
if i == pre:
cnt += 1
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR... |
You have $n$ sticks of the given lengths.
Your task is to choose exactly four of them in such a way that they can form a rectangle. No sticks can be cut to pieces, each side of the rectangle must be formed by a single stick. No stick can be chosen multiple times. It is guaranteed that it is always possible to choose s... | queries = int(input())
output = []
for i in range(queries):
numCount = input()
if numCount == "4":
output.append(input())
else:
if numCount == "5":
l = sorted(map(int, input().split()))
x, y = l[1], l[3]
else:
lastNum = b = x = y = 0
d ... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR IF VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR IF VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP N... |
You have $n$ sticks of the given lengths.
Your task is to choose exactly four of them in such a way that they can form a rectangle. No sticks can be cut to pieces, each side of the rectangle must be formed by a single stick. No stick can be chosen multiple times. It is guaranteed that it is always possible to choose s... | import sys
T = int(sys.stdin.readline().rstrip())
for i in range(T):
n = int(sys.stdin.readline().rstrip())
a = list(map(int, sys.stdin.readline().rstrip().split()))
rec = []
a = sorted(a)
k = 0
while k < n - 1:
if a[k] == a[k + 1]:
rec.append(a[k])
k += 1
... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP... |
You have $n$ sticks of the given lengths.
Your task is to choose exactly four of them in such a way that they can form a rectangle. No sticks can be cut to pieces, each side of the rectangle must be formed by a single stick. No stick can be chosen multiple times. It is guaranteed that it is always possible to choose s... | import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
n = int(input())
arr = list(map(int, input().split()))
freq = {}
for item in arr:
if item in freq:
freq[item] += 1
else:
freq[item] = 1
sticks = []
for item in arr:
if freq[... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR IF VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR VAR NUMBER EXPR ... |
You have $n$ sticks of the given lengths.
Your task is to choose exactly four of them in such a way that they can form a rectangle. No sticks can be cut to pieces, each side of the rectangle must be formed by a single stick. No stick can be chosen multiple times. It is guaranteed that it is always possible to choose s... | import sys
rd = lambda: sys.stdin.readline().rstrip()
t = int(rd())
for _ in range(t):
n = int(rd())
a = list(map(int, rd().split()))
b = []
res_a, res_b = 1, 1e18
a = sorted(a)
i = 0
while i < n - 1:
if a[i] == a[i + 1]:
b.append(a[i])
i += 1
i += 1
... | IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR BIN_O... |
You have $n$ sticks of the given lengths.
Your task is to choose exactly four of them in such a way that they can form a rectangle. No sticks can be cut to pieces, each side of the rectangle must be formed by a single stick. No stick can be chosen multiple times. It is guaranteed that it is always possible to choose s... | from sys import stdin, stdout
def read():
return stdin.readline().rstrip("\n")
def f(a, b):
return a / b + b / a
results = []
for _ in range(int(read())):
read()
arr = sorted(map(int, read().split()))
i = 0
len_arr_minus_one = len(arr) - 1
prev_el, next_el = None, None
min_sticks_e... | FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN ... |
You have $n$ sticks of the given lengths.
Your task is to choose exactly four of them in such a way that they can form a rectangle. No sticks can be cut to pieces, each side of the rectangle must be formed by a single stick. No stick can be chosen multiple times. It is guaranteed that it is always possible to choose s... | from sys import stdin
def main():
input()
l = stdin.read().splitlines()[1::2]
for i, s in enumerate(l):
cnt, x, n = [], 0.0, 0
for y in sorted(map(float, s.split())):
if x == y:
n += 1
else:
if n:
cnt.append((x, n)... | FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR NUMBER NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR IF VAR VAR VAR NUMBER IF VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR NUMBER IF VAR EXPR FUNC_CALL VAR VAR VAR ASSIG... |
You have $n$ sticks of the given lengths.
Your task is to choose exactly four of them in such a way that they can form a rectangle. No sticks can be cut to pieces, each side of the rectangle must be formed by a single stick. No stick can be chosen multiple times. It is guaranteed that it is always possible to choose s... | import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
n = int(input())
b = list(map(int, input().split()))
d = dict()
c = []
for j in range(n):
if b[j] in d.keys():
d[b[j]] += 1
if d[b[j]] % 2 == 0:
c.append(b[j])
else:
... | IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER IF BIN_OP VAR VA... |
You have $n$ sticks of the given lengths.
Your task is to choose exactly four of them in such a way that they can form a rectangle. No sticks can be cut to pieces, each side of the rectangle must be formed by a single stick. No stick can be chosen multiple times. It is guaranteed that it is always possible to choose s... | import sys
t = int(sys.stdin.readline())
arrz = []
for l in range(t):
n = int(sys.stdin.readline())
arr = list(map(int, sys.stdin.readline().split()))
arr.sort()
flag = 0
arr2 = []
dict1 = {}
for i in range(n):
try:
dict1[arr[i]] += 1
if dict1[arr[i]] == 2:
... | IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER IF VAR VAR V... |
You have $n$ sticks of the given lengths.
Your task is to choose exactly four of them in such a way that they can form a rectangle. No sticks can be cut to pieces, each side of the rectangle must be formed by a single stick. No stick can be chosen multiple times. It is guaranteed that it is always possible to choose s... | import sys
input = sys.stdin.readline
out = sys.stdout
t = int(input())
for i in range(t):
n = int(input())
a = list(map(int, input().split()))
if len(set(a)) == 1:
print(a[0], a[0], a[0], a[0])
else:
a.sort()
g1 = False
d = {}
mx = 10001
for i in a:
... | IMPORT ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FU... |
You have $n$ sticks of the given lengths.
Your task is to choose exactly four of them in such a way that they can form a rectangle. No sticks can be cut to pieces, each side of the rectangle must be formed by a single stick. No stick can be chosen multiple times. It is guaranteed that it is always possible to choose s... | ans = []
def main():
t = int(input())
for l in range(t):
n = int(input())
if n == 4:
ans.append(input())
else:
b = y = num = x = 0
d = 10**10
for i in sorted(map(int, input().split())):
if num == i:
c +... | ASSIGN VAR LIST FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR VAR NUM... |
Alice and Bob were playing a game yet again but this time, Bob already lost the game. Now he wants to take revenge.
Bob saw a jigsaw puzzle which was solved by Alice and decided to jumble the puzzle pieces again. There are N puzzle pieces in a line numbered from 1 to N in increasing order and he has K minutes before A... | for t in range(int(input())):
n, k = map(int, input().split())
no = n // 2
if no <= k:
print(n * (n - 1) // 2)
elif n == 1:
print(0)
else:
ans = n * (n - 1) // 2
r = n - 2 * k
se = r * (r - 1) // 2
ans = ans - se
print(ans) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP... |
Alice and Bob were playing a game yet again but this time, Bob already lost the game. Now he wants to take revenge.
Bob saw a jigsaw puzzle which was solved by Alice and decided to jumble the puzzle pieces again. There are N puzzle pieces in a line numbered from 1 to N in increasing order and he has K minutes before A... | def ans(n, k):
if k >= n // 2:
return n * (n - 1) // 2
else:
not_swapped = n - 2 * k
return n * (n - 1) // 2 - not_swapped * (not_swapped - 1) // 2
test_cases = int(input())
while test_cases != 0:
d = list(map(int, input().split()))
print(ans(d[0], d[1]))
test_cases -= 1 | FUNC_DEF IF VAR BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR RETURN BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR V... |
Alice and Bob were playing a game yet again but this time, Bob already lost the game. Now he wants to take revenge.
Bob saw a jigsaw puzzle which was solved by Alice and decided to jumble the puzzle pieces again. There are N puzzle pieces in a line numbered from 1 to N in increasing order and he has K minutes before A... | for t in range(int(input())):
n, k = map(int, input().split())
mid = n // 2
if n == 1:
print(0)
elif mid < k:
print(n * (n - 1) // 2)
else:
p = n - 2 * k
t = n * (n - 1) // 2 - p * (p - 1) // 2
print(t) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP... |
Alice and Bob were playing a game yet again but this time, Bob already lost the game. Now he wants to take revenge.
Bob saw a jigsaw puzzle which was solved by Alice and decided to jumble the puzzle pieces again. There are N puzzle pieces in a line numbered from 1 to N in increasing order and he has K minutes before A... | n = int(input())
for i in range(n):
N, K = map(int, input().split(" "))
if K >= N // 2:
print(N * (N - 1) // 2)
else:
print(K * N - K * (K + 1) // 2 + (N - K * 2) * K + (K - 1) * K // 2) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP... |
Alice and Bob were playing a game yet again but this time, Bob already lost the game. Now he wants to take revenge.
Bob saw a jigsaw puzzle which was solved by Alice and decided to jumble the puzzle pieces again. There are N puzzle pieces in a line numbered from 1 to N in increasing order and he has K minutes before A... | def sum_upto_n(n):
return n * (n + 1) // 2
for _ in range(int(input())):
n, k = map(int, input().strip().split())
k = min(k, n // 2)
q1 = sum_upto_n(n - 1) - sum_upto_n(n - k - 1)
q2 = (n - 2 * k) * k
q3 = sum_upto_n(k - 1)
print(q1 + q2 + q3) | FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSI... |
Alice and Bob were playing a game yet again but this time, Bob already lost the game. Now he wants to take revenge.
Bob saw a jigsaw puzzle which was solved by Alice and decided to jumble the puzzle pieces again. There are N puzzle pieces in a line numbered from 1 to N in increasing order and he has K minutes before A... | T = int(input())
for i in range(0, T):
temp = input().split()
N = int(temp[0])
K = int(temp[1])
var2 = 0
if K >= int(N // 2):
var2 = (N - 1) * N // 2
else:
var2 = -2 * K**2 + 2 * (K * N) - K
print(int(var2)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_O... |
Alice and Bob were playing a game yet again but this time, Bob already lost the game. Now he wants to take revenge.
Bob saw a jigsaw puzzle which was solved by Alice and decided to jumble the puzzle pieces again. There are N puzzle pieces in a line numbered from 1 to N in increasing order and he has K minutes before A... | T = int(input())
for x in range(T):
N, K = map(int, input().split())
if K >= N // 2:
print(int(N * (N - 1) // 2))
else:
print(K * (2 * (N - K) - 1)) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP NUMBER BIN_OP VAR VAR NUMBER |
Alice and Bob were playing a game yet again but this time, Bob already lost the game. Now he wants to take revenge.
Bob saw a jigsaw puzzle which was solved by Alice and decided to jumble the puzzle pieces again. There are N puzzle pieces in a line numbered from 1 to N in increasing order and he has K minutes before A... | for _ in range(int(input())):
n, b = map(int, input().split())
if n // 2 <= b:
s = (n - 1) * n // 2
print(s)
else:
s = (
(n - 1 - b * 2) * b
+ b * (b + 1) // 2
+ (n - 1) * n // 2
- (n - b - 1) * (n - b) // 2
)
print(s) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR BIN_OP BIN_OP VAR BIN_OP ... |
Alice and Bob were playing a game yet again but this time, Bob already lost the game. Now he wants to take revenge.
Bob saw a jigsaw puzzle which was solved by Alice and decided to jumble the puzzle pieces again. There are N puzzle pieces in a line numbered from 1 to N in increasing order and he has K minutes before A... | t = input()
for c in range(0, int(t)):
length, moves = map(int, input().split())
ans = length * (length - 1) // 2
if moves < length // 2:
noswap = length - 2 * moves
nopairs = noswap * (noswap - 1) // 2
ans = ans - nopairs
print(ans) | ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP ... |
Alice and Bob were playing a game yet again but this time, Bob already lost the game. Now he wants to take revenge.
Bob saw a jigsaw puzzle which was solved by Alice and decided to jumble the puzzle pieces again. There are N puzzle pieces in a line numbered from 1 to N in increasing order and he has K minutes before A... | for _ in range(int(input())):
n, k = map(int, input().split())
m = n // 2
if n == 1:
print(0)
elif m <= k:
a = n * (n - 1) // 2
print(a)
else:
b = n * (n - 1) // 2
c = n - 2 * k
c = c * (c - 1) // 2
print(b - c) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER AS... |
Alice and Bob were playing a game yet again but this time, Bob already lost the game. Now he wants to take revenge.
Bob saw a jigsaw puzzle which was solved by Alice and decided to jumble the puzzle pieces again. There are N puzzle pieces in a line numbered from 1 to N in increasing order and he has K minutes before A... | for i in range(int(input())):
a, b = map(int, input().split())
x = a * (a - 1) // 2
if b > a // 2:
print(x)
else:
c = a - b * 2
y = c * (c - 1) // 2
print(x - y) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VA... |
Alice and Bob were playing a game yet again but this time, Bob already lost the game. Now he wants to take revenge.
Bob saw a jigsaw puzzle which was solved by Alice and decided to jumble the puzzle pieces again. There are N puzzle pieces in a line numbered from 1 to N in increasing order and he has K minutes before A... | for _ in range(int(input())):
n, k = map(int, input().split())
if k >= n // 2:
print(n * (n - 1) // 2)
else:
val = k * (k - 1) // 2
val += (n - 2 * k) * k
req = n - k - 1
temp = n * (n - 1) // 2 - req * (req + 1) // 2
val += temp
print(val) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR... |
Alice and Bob were playing a game yet again but this time, Bob already lost the game. Now he wants to take revenge.
Bob saw a jigsaw puzzle which was solved by Alice and decided to jumble the puzzle pieces again. There are N puzzle pieces in a line numbered from 1 to N in increasing order and he has K minutes before A... | for _ in range(int(input())):
x, y = map(int, input().split())
f = x * (x - 1) // 2
h = 0
if y < x / 2:
h = x - 2 * y
f = f - h * (h - 1) // 2
print(f) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_C... |
Alice and Bob were playing a game yet again but this time, Bob already lost the game. Now he wants to take revenge.
Bob saw a jigsaw puzzle which was solved by Alice and decided to jumble the puzzle pieces again. There are N puzzle pieces in a line numbered from 1 to N in increasing order and he has K minutes before A... | T = int(input())
for t in range(T):
temp = input().split()
N = int(temp[0])
K = int(temp[1])
if N == 1:
print(0)
elif K >= N // 2:
print((N - 1) * N // 2)
else:
s = -2 * K * K + 2 * N * K - K
print(s) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN... |
Alice and Bob were playing a game yet again but this time, Bob already lost the game. Now he wants to take revenge.
Bob saw a jigsaw puzzle which was solved by Alice and decided to jumble the puzzle pieces again. There are N puzzle pieces in a line numbered from 1 to N in increasing order and he has K minutes before A... | T = int(input())
for t in range(T):
s = input().split()
n = int(s[0])
k = int(s[1])
if n == 1:
print(0)
elif n == 2 and k % 2 == 0:
print(0)
elif n == 2 and k % 2 != 0:
print(1)
elif k <= n // 2:
ans = n * k - k + (n - 2 * k) * k
print(ans)
else:
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER BIN_OP VAR NUMBER NUMBER EXPR... |
Alice and Bob were playing a game yet again but this time, Bob already lost the game. Now he wants to take revenge.
Bob saw a jigsaw puzzle which was solved by Alice and decided to jumble the puzzle pieces again. There are N puzzle pieces in a line numbered from 1 to N in increasing order and he has K minutes before A... | for tc in range(int(input())):
n, k = map(int, input().split())
if n == 1:
print(0)
elif n // 2 <= k:
print(n * (n - 1) // 2)
else:
tot = 0
x = n - k
tot += n * (n - 1) // 2 - x * (x - 1) // 2
con = n - 2 * k
tot += k * con
tot += k * (k - ... | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NU... |
Alice and Bob were playing a game yet again but this time, Bob already lost the game. Now he wants to take revenge.
Bob saw a jigsaw puzzle which was solved by Alice and decided to jumble the puzzle pieces again. There are N puzzle pieces in a line numbered from 1 to N in increasing order and he has K minutes before A... | t = int(input())
for _ in range(0, t):
n, k = map(int, input().split())
if n == 1:
print(0)
continue
if n < 2 * k:
k = n // 2
print((2 * (n - k) - 1) * k) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER BIN_OP VAR VAR NUMBER VAR |
Alice and Bob were playing a game yet again but this time, Bob already lost the game. Now he wants to take revenge.
Bob saw a jigsaw puzzle which was solved by Alice and decided to jumble the puzzle pieces again. There are N puzzle pieces in a line numbered from 1 to N in increasing order and he has K minutes before A... | def sigma(n):
s = n * (n + 1) // 2
return s
T = int(input())
for tc in range(T):
s = 0
n, k = map(int, input().split(" "))
if k >= n // 2:
print(sigma(n - 1))
else:
s += sigma(n - 1) - sigma(n - k - 1)
s += sigma(k - 1)
s += (n - 2 * k) * k
print(s) | FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_OP FUNC_CALL VA... |
Alice and Bob were playing a game yet again but this time, Bob already lost the game. Now he wants to take revenge.
Bob saw a jigsaw puzzle which was solved by Alice and decided to jumble the puzzle pieces again. There are N puzzle pieces in a line numbered from 1 to N in increasing order and he has K minutes before A... | for _ in range(int(input())):
n, k = map(int, input().split())
k = min(k, n // 2)
ans = (n - 1) * k + (n - 2 * k) * k
print(ans) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR VAR |
Alice and Bob were playing a game yet again but this time, Bob already lost the game. Now he wants to take revenge.
Bob saw a jigsaw puzzle which was solved by Alice and decided to jumble the puzzle pieces again. There are N puzzle pieces in a line numbered from 1 to N in increasing order and he has K minutes before A... | t = int(input())
for _ in range(t):
n, k = list(map(int, input().split()))
if n == 1:
print(0)
elif k >= n // 2:
print(n * (n - 1) // 2)
else:
print((2 * n - 2 * k - 1) * k) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR... |
Alice and Bob were playing a game yet again but this time, Bob already lost the game. Now he wants to take revenge.
Bob saw a jigsaw puzzle which was solved by Alice and decided to jumble the puzzle pieces again. There are N puzzle pieces in a line numbered from 1 to N in increasing order and he has K minutes before A... | for i in range(int(input())):
n, k = map(int, input().split())
sum1 = 0
if k < n // 2:
j = n - k
sum1 += n * (n - 1) // 2 - j * (j - 1) // 2
sum1 += (n - k - k) * k
sum1 += k * (k - 1) // 2
else:
sum1 = n * (n - 1) // 2
print(sum1) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR VAR BI... |
Alice and Bob were playing a game yet again but this time, Bob already lost the game. Now he wants to take revenge.
Bob saw a jigsaw puzzle which was solved by Alice and decided to jumble the puzzle pieces again. There are N puzzle pieces in a line numbered from 1 to N in increasing order and he has K minutes before A... | tc = int(input())
for i in range(tc):
arr = input().split(" ")
n = int(arr[0])
k = int(arr[1])
if 2 * k >= n:
print((n - 1) * n // 2)
else:
print(2 * n * k - 2 * k * k - k) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER ... |
Alice and Bob were playing a game yet again but this time, Bob already lost the game. Now he wants to take revenge.
Bob saw a jigsaw puzzle which was solved by Alice and decided to jumble the puzzle pieces again. There are N puzzle pieces in a line numbered from 1 to N in increasing order and he has K minutes before A... | for i in range(int(input())):
n, k = map(int, input().split())
k = min(k, n // 2)
print(
n * (n - 1) // 2
- (n - k) * (n - k - 1) // 2
+ (k - 1) * k // 2
+ (n - 2 * k) * k
) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER BIN_OP BIN_OP BIN_... |
Alice and Bob were playing a game yet again but this time, Bob already lost the game. Now he wants to take revenge.
Bob saw a jigsaw puzzle which was solved by Alice and decided to jumble the puzzle pieces again. There are N puzzle pieces in a line numbered from 1 to N in increasing order and he has K minutes before A... | def func(n):
return n * (n + 1) // 2
for _ in range(int(input())):
ans = 0
n, k = list(map(int, input().split()))
m = n // 2
if k >= m:
print(func(n - 1))
else:
ans = func(n) - func(n - k) - k
me = n - 2 * k
ans += me * k
ans += func(k - 1)
print... | FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_C... |
Alice and Bob were playing a game yet again but this time, Bob already lost the game. Now he wants to take revenge.
Bob saw a jigsaw puzzle which was solved by Alice and decided to jumble the puzzle pieces again. There are N puzzle pieces in a line numbered from 1 to N in increasing order and he has K minutes before A... | for i in range(int(input())):
n, k = map(int, input().split())
if k >= n // 2:
print(n * (n - 1) // 2)
else:
print(k * (2 * n - 3 - (k - 1) * 2)) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER |
Alice and Bob were playing a game yet again but this time, Bob already lost the game. Now he wants to take revenge.
Bob saw a jigsaw puzzle which was solved by Alice and decided to jumble the puzzle pieces again. There are N puzzle pieces in a line numbered from 1 to N in increasing order and he has K minutes before A... | for _ in range(int(input())):
sum1 = 0
n, k = map(int, input().split())
p = n
t = n - k
if k >= n // 2:
print(n * (n - 1) // 2)
else:
sum1 += p * (p - 1) // 2 - t * (t - 1) // 2
sum1 += k * (p - 2 * k) + k * (k - 1) // 2
print(sum1) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP... |
Alice and Bob were playing a game yet again but this time, Bob already lost the game. Now he wants to take revenge.
Bob saw a jigsaw puzzle which was solved by Alice and decided to jumble the puzzle pieces again. There are N puzzle pieces in a line numbered from 1 to N in increasing order and he has K minutes before A... | T = int(input())
for i in range(T):
N, K = map(int, input().split())
if N == 1:
print(0)
else:
p = N - min(K * 2, N - 1) - 1
x = 0
x = N - 1
print(x * (x + 1) // 2 - p * (p + 1) // 2) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP... |
Alice and Bob were playing a game yet again but this time, Bob already lost the game. Now he wants to take revenge.
Bob saw a jigsaw puzzle which was solved by Alice and decided to jumble the puzzle pieces again. There are N puzzle pieces in a line numbered from 1 to N in increasing order and he has K minutes before A... | T = int(input())
while T:
T -= 1
n, k = list(map(int, input().split()))
if n == 1 or k == 0:
print(0)
elif k >= n // 2:
print(n * (n - 1) // 2)
else:
j = k * (k * 2 - 1)
l = n - k * 2
print(j + l * k * 2) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR NUMBER NUMB... |
Alice and Bob were playing a game yet again but this time, Bob already lost the game. Now he wants to take revenge.
Bob saw a jigsaw puzzle which was solved by Alice and decided to jumble the puzzle pieces again. There are N puzzle pieces in a line numbered from 1 to N in increasing order and he has K minutes before A... | def solve():
n, k = map(int, input().split())
if k > n // 2:
k = n // 2
print(k * (2 * n - 2 * k - 1))
for _ in range(int(input())):
solve() | FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP BIN_OP BIN_OP NUMBER VAR BIN_OP NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR |
Alice and Bob were playing a game yet again but this time, Bob already lost the game. Now he wants to take revenge.
Bob saw a jigsaw puzzle which was solved by Alice and decided to jumble the puzzle pieces again. There are N puzzle pieces in a line numbered from 1 to N in increasing order and he has K minutes before A... | t = int(input())
for _ in range(t):
n, k = map(int, input().split())
xn = n // 2
if k >= xn:
print(n * (n - 1) // 2)
else:
a = n * (n - 1) // 2
x = n - 2 * k - 1
b = x * (x + 1) // 2
print(a - b) | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP NUMBER... |
Alice and Bob were playing a game yet again but this time, Bob already lost the game. Now he wants to take revenge.
Bob saw a jigsaw puzzle which was solved by Alice and decided to jumble the puzzle pieces again. There are N puzzle pieces in a line numbered from 1 to N in increasing order and he has K minutes before A... | def summ(n):
return n * (n + 1) // 2
for _ in range(int(input())):
n, k = map(int, input().split())
step = min(n // 2, k)
if n % 2 == 0:
rem = (n // 2 - step) * 2 - 1
else:
rem = (n // 2 - step) * 2
ang = summ(n - 1) - summ(rem)
print(ang) | FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER ASSIGN VAR ... |
Alice and Bob were playing a game yet again but this time, Bob already lost the game. Now he wants to take revenge.
Bob saw a jigsaw puzzle which was solved by Alice and decided to jumble the puzzle pieces again. There are N puzzle pieces in a line numbered from 1 to N in increasing order and he has K minutes before A... | numberofcases = int(input())
def sum(n):
return n * (n + 1) / 2
for case in range(numberofcases):
inputs = input().split(" ")
pieces = int(inputs[0])
swaps = int(inputs[1])
swapp = min(swaps, pieces // 2)
if pieces >= 2:
print(swapp * (pieces + pieces - 2 * swapp + 2) - 3 * swapp)
... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BI... |
Alice and Bob were playing a game yet again but this time, Bob already lost the game. Now he wants to take revenge.
Bob saw a jigsaw puzzle which was solved by Alice and decided to jumble the puzzle pieces again. There are N puzzle pieces in a line numbered from 1 to N in increasing order and he has K minutes before A... | def getSummation(n):
return (n - 1) * (n - 1 + 1) // 2
def getSummation1(n, k):
ans = n - 1
itr = ans - 1
for _ in range(k - 1):
ans += itr
itr -= 1
return ans
t = int(input())
while t:
n, k = map(int, input().split())
if k == 0:
print(0)
t -= 1
co... | FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC... |
Alice and Bob were playing a game yet again but this time, Bob already lost the game. Now he wants to take revenge.
Bob saw a jigsaw puzzle which was solved by Alice and decided to jumble the puzzle pieces again. There are N puzzle pieces in a line numbered from 1 to N in increasing order and he has K minutes before A... | for x in range(int(input())):
n, k = map(int, input().split())
if k > n // 2:
print(int(n * (n - 1) // 2))
else:
a = n * (n - 1) // 2 - (n - k - 1) * (n - k) // 2
print(a + (n - 2 * k) * k + k * (k - 1) // 2) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR NUMBER BIN_OP V... |
Alice and Bob were playing a game yet again but this time, Bob already lost the game. Now he wants to take revenge.
Bob saw a jigsaw puzzle which was solved by Alice and decided to jumble the puzzle pieces again. There are N puzzle pieces in a line numbered from 1 to N in increasing order and he has K minutes before A... | for i in range(int(input())):
a, b = map(int, input().split())
c = a // 2
s = 0
if b >= c:
c = a - 1
s = c * (c + 1) // 2
else:
s = -2 * b**2 + 2 * (b * a) - b
print(s) | FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER BIN_OP NUMBER B... |
Everything got unclear to us in a far away constellation Tau Ceti. Specifically, the Taucetians choose names to their children in a very peculiar manner.
Two young parents abac and bbad think what name to give to their first-born child. They decided that the name will be the permutation of letters of string s. To keep... | def findmin(lcopy, toexceed):
toex = ord(toexceed) - 97
for each in lcopy[toex + 1 :]:
if each > 0:
return True
return False
def arrange(lcopy, toexceed=None):
if toexceed is None:
ans = ""
for i in range(26):
ans += chr(i + 97) * lcopy[i]
return... | FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR VAR BIN_OP VAR NUMBER IF VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF NONE IF VAR NONE ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR RETURN VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CA... |
Everything got unclear to us in a far away constellation Tau Ceti. Specifically, the Taucetians choose names to their children in a very peculiar manner.
Two young parents abac and bbad think what name to give to their first-born child. They decided that the name will be the permutation of letters of string s. To keep... | from sys import stdin, stdout
words = [
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z",
]
s = stdin.readline().strip()
f = stdin.read... | ASSIGN VAR LIST STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR DICT FOR 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 = input().split()
a = int(n)
b = int(m)
count = 0
while b > a:
if b % 2 == 1:
count = count + 1
b = b + 1
else:
b = b // 2
count = count + 1
count = count + (a - b)
print(count) | 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 ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR EXPR 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 minimum_push(n, m):
if n >= m:
return n - m
if m % 2 == 0:
return 1 + minimum_push(n, m // 2)
else:
return 1 + minimum_push(n, m + 1)
n, m = map(int, input().split())
print(minimum_push(n, m)) | FUNC_DEF IF VAR VAR RETURN 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 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... | start, end = [int(x) for x in input().split()]
times = 0
while True:
if start == end:
break
elif start > end:
times += start - end
break
elif end % 2 == 0:
end = int(end / 2)
times += 1
else:
end += 1
times += 1
print(times) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE NUMBER IF VAR VAR IF VAR VAR VAR BIN_OP VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL 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... | from sys import stdin, stdout
a, b = map(int, stdin.readline().split())
if a > b:
print(a - b)
elif a < b:
c = 0
while a < b:
if b % 2 == 0:
b = b // 2
c += 1
else:
c += 1
b += 1
b = b // 2
c += 1
c += a - b
pri... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR IF 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 NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER VAR BIN_OP VAR VAR EXPR FUNC_CALL 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... | a, b = map(int, input().split())
c = 0
while True:
if b % 2 == 0 and b > a:
c += 1
b = b // 2
else:
c += 1
b += 1
if b == a:
break
print(c) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE NUMBER IF BIN_OP VAR NUMBER NUMBER VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF 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())
stepnums = [-1] * 20000
stepnums[n] = 0
queue = []
queue.append(n)
while len(queue) > 0:
current = queue.pop(0)
if current == m:
print(stepnums[current])
break
if current * 2 < 2 * 10**4 and stepnums[current * 2] == -1:
queue.append(current * 2)
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR 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 BIN_OP NUMBER BIN_OP NUMBER NUMBER 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... | def Cal_Num(a, b):
if b % 2 != 0:
aim = b + 1
steps = 1
else:
aim = b
steps = 0
avg = aim // 2
if a >= avg:
steps += a - avg
else:
steps += Cal_Num(a, avg)
return steps + 1
n, m = map(int, input().split())
if n >= m:
print(n - m)
exit()
p... | FUNC_DEF IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR VAR VAR FUNC_CALL VAR VAR VAR RETURN BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL 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
max_val = int(10000000000000.0)
min_val = int(-10000000000000.0)
def read_int():
return int(stdin.readline())
def read_ints():
return [int(x) for x in stdin.readline().split()]
def read_str():
return input()
def read_strs():
return [x for x in stdin.readline().split()]
h... | ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF RETURN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE 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... | n, m = [int(i) for i in input().split()]
if n >= m:
ans = n - m
else:
count = 0
while m != n:
if m % 2 != 0 and m > n:
m += 1
m /= 2
count += 1
elif m > n and m % 2 == 0:
m /= 2
else:
m += 1
count += 1
ans = coun... | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN 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())
maxn = 30000.0 + 1
lay = [(0) for _ in range(int(30000.0 + 1))]
vis = [(0) for _ in range(int(30000.0 + 1))]
def bfs(now):
cnt, head, tail = 0, 0, 0
que = [(0) for i in range(int(100000.0))]
que[tail], tail = now, tail + 1
while tail > head:
fa, head = que[head... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER FUNC_DEF ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL 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... | n, m = [int(x) for x in input().split()]
count = 0
while n != m:
if n > m:
n -= 1
count += 1
elif m > n:
if m % 2 == 0:
m = m // 2
count += 1
elif m % 2 == 1:
m = m + 1
count += 1
print(count) | ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER 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... | def twoBotton(n, m):
q = [(n, 0)]
visited = set()
while q:
cur, count = q.pop(0)
if cur == m:
return count
if cur * 2 < m * 2 and cur * 2 not in visited:
visited.add(cur * 2)
q.append((cur * 2, count + 1))
if cur - 1 >= 0 and cur - 1 not in... | FUNC_DEF ASSIGN VAR LIST VAR NUMBER ASSIGN VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR FUNC_CALL VAR NUMBER IF VAR VAR RETURN VAR IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER 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... | n, m = map(int, input().split())
q = [n]
b = 1
r = 0
i = 0
used = [False] * (2 * 10**4 + 10)
used[n] = True
while i < len(q):
if i == b:
b = len(q)
r += 1
if q[i] == m:
print(r)
break
if q[i] > 1:
if not used[q[i] - 1]:
q.append(q[i] - 1)
used[... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP NUMBER BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER IF 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())
print(
min(
i + ((n << i) - m >> i) + bin(((n << i) - m) % (1 << i)).count("1")
for i in range(50)
if n << i >= m
)
) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR FUNC_CALL FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR BIN_OP NUMBER VAR STRING VAR FUNC_CALL VAR NUMBER 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 = map(int, input().strip().split(" "))
if m <= n:
print(n - m)
else:
cont = 1
pas = 0
while m > n:
n *= 2
pas += 1
cont *= 2
tot = n - m
while tot > 0:
pas += tot // cont
tot = tot % cont
cont /= 2
print(int(pas)) | 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 NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR WHILE VAR NUMBER VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR 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... | a, b = map(int, input().split())
if a >= b:
print(a - b)
else:
op = 0
while b != a:
if b < a:
op += a - b
break
if b % 2 != 0:
b += 1
else:
b = b // 2
op += 1
print(op) | 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 VAR VAR VAR BIN_OP VAR VAR 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... | x = list(input().split())
n = int(x[0])
m = int(x[1])
total = 0
z = m
while True:
while n > z:
n -= 1
total += 1
red = 0
while m % 2 == 0 and m > n:
m = m / 2
red += 1
total += 1
azul2 = 0
while m % 2 == 1 and m > n:
m += 1
azul2 += 1
t... | ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE NUMBER WHILE VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER NUMBER VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER 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... | import sys
input = sys.stdin.readline
def solve(n, m):
if n >= m:
return n - m
graph = {}
for i in range(1, 2 * m + 1):
graph[i] = set()
for i in graph:
if i - 1 in graph:
graph[i].add(i - 1)
if i * 2 in graph:
graph[i].add(i * 2)
ans = 0
... | IMPORT ASSIGN VAR VAR FUNC_DEF IF VAR VAR RETURN BIN_OP VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FOR VAR VAR 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 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... | def process_node(arr, visited, o_visited, rev):
curr = arr.pop(0)
if curr[0] in visited:
return
visited[curr[0]] = curr[1]
if curr[0] in o_visited:
print(o_visited[curr[0]] + visited[curr[0]])
exit()
if not rev:
arr.append((curr[0] * 2, curr[1] + 1))
arr.appen... | FUNC_DEF ASSIGN VAR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR RETURN ASSIGN VAR VAR NUMBER VAR NUMBER IF VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR IF VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER 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... | input = input().split(" ")
n = int(input[0])
m = int(input[1])
result = 0
while n < m:
if m % 2 == 0:
m //= 2
else:
m += 1
result += 1
if n > m:
result += n - m
print(result) | ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR 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... | s = input()
s = s.split()
n = int(s[0])
m = int(s[1])
graph = [[] for i in range(0, 20001)]
count = 1
for i in graph[1:]:
if count <= 10000:
i.append(count * 2)
if count > 1:
i.append(count - 1)
count += 1
visited = [(False) for i in range(0, 40004)]
stk = [n]
dist = 0
while True:
dist +... | 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 LIST VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL 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, m = map(int, input().split())
res = 0
if n >= m:
res = n - m
elif n < m:
while m > n:
if m % 2 == 0:
m = m // 2
res += 1
elif m % 2 == 1:
m = m + 1
res += 1
if m < n:
res = res + (n - m)
break
print(res) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN 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... | n, m = [int(next) for next in input().split()]
if m <= n:
print(n - m)
else:
answer = 0
while n < m:
if m % 2 == 1:
m += 1
answer += 1
m //= 2
answer += 1
if n == m:
print(answer)
else:
print(answer + n - m) | 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 IF BIN_OP VAR NUMBER NUMBER VAR 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 |
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 = 0
while not m == n:
if m < n:
m = m + 1
k += 1
continue
if m % 2 == 0:
m = m // 2
else:
m = m + 1
k += 1
print(k) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP 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... | n, m = map(int, input().split())
if n >= m:
print(n - m)
exit(0)
q = [(n, 0)]
d = {}
while q:
x, y = q.pop(0)
if x in d:
continue
d[x] = True
if x == m:
print(y)
break
if 2 * x <= 2 * m:
q.append((2 * x, y + 1))
if x - 1 > 0:
q.append((x - 1, y + 1... | 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 LIST VAR NUMBER ASSIGN VAR DICT WHILE VAR ASSIGN VAR VAR FUNC_CALL VAR NUMBER IF VAR VAR ASSIGN VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR IF BIN_OP NUMBER VAR BIN_OP 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(" "))
b = 1
r = 2
i = 0
if n >= m:
while n > m:
n -= b
i += 1
elif n < m:
while n < m:
if m % 2 == 0:
m //= 2
else:
m += 1
i += 1
while n > m:
n -= b
i += 1
print(i) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR WHILE VAR VAR VAR VAR VAR NUMBER IF VAR VAR WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR NUMBER WHILE 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())
upar = [n]
niche = []
steps = 0
br = 0
dict = {n}
if n < m:
while True:
if br == 1:
break
for i in upar:
if i > 0 and i < m * 2:
if i - 1 not in dict:
niche.append(i - 1)
dict.add(i - 1)
... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR IF VAR VAR WHILE NUMBER IF VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL 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... | from sys import stdin
input = stdin.readline().rstrip()
n, m = int(input.split()[0]), int(input.split()[1])
q = [n]
visited = {}
count = {n: 0}
while q:
num = q.pop()
if num == m:
print(count[num])
break
if num - 1 > 0 and not visited.get(num - 1):
q.insert(0, num - 1)
visit... | ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST VAR ASSIGN VAR DICT ASSIGN VAR DICT VAR NUMBER WHILE VAR ASSIGN VAR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR IF BIN_OP VAR NUMBER NUMBER FUNC_CALL 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... | n, m = map(int, input().split())
if n > m:
print(n - m)
exit()
r = 0
while m != n:
if m % 2 or m < n:
r += 1
m += 1
else:
r += 1
m //= 2
print(r) | 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 ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR 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... | a, b = map(int, input().split())
if b > a:
ans = 0
while True:
if b % 2 == 0:
b /= 2
ans += 1
else:
b += 1
ans += 1
if b == a:
print(ans)
break
elif b < a:
print(int(ans + a - b))
brea... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR NUMBER WHILE NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR EXPR FUNC_CALL 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... | a = input().split()
n = int(a[0])
m = int(a[1])
k = 0
if m < n:
k = n - m
else:
while m != n:
if m < n:
m += 1
k += 1
elif m % 2 == 0:
m /= 2
k += 1
else:
m += 1
k += 1
print(k) | ASSIGN VAR FUNC_CALL 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 BIN_OP VAR VAR WHILE VAR VAR IF VAR VAR VAR NUMBER VAR NUMBER 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 two_buttons(n, m):
d = {n: 0}
keys = {n}
while True:
new_keys = set()
for k in keys:
if 2 * k <= 10000 and 2 * k not in d:
d[2 * k] = d[k] + 1
new_keys.add(2 * k)
if k >= 1 and k - 1 not in d:
d[k - 1] = d[k] + 1
... | FUNC_DEF ASSIGN VAR DICT VAR NUMBER ASSIGN VAR VAR WHILE NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF BIN_OP NUMBER VAR NUMBER BIN_OP NUMBER VAR VAR ASSIGN VAR BIN_OP NUMBER VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP NUMBER VAR IF VAR NUMBER BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR 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 findMin(n, m):
sum = 0
if n >= m:
return n - m
while n < m:
if m % 2 != 0:
m += 1
else:
m //= 2
sum += 1
return sum + (n - m)
n, m = [int(x) for x in input().split()]
print(findMin(n, m)) | 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 RETURN BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR VAR FUNC_CALL VAR 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())
d = {}
d[n] = 0
unvisited = [n]
finished = False
while m not in d and unvisited:
n = unvisited[0]
del unvisited[0]
if n > 1 and n - 1 not in d:
d[n - 1] = d[n] + 1
unvisited += [n - 1]
if n < m and n * 2 not in d:
d[n * 2] = d[n] + 1
unvis... | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR VAR NUMBER ASSIGN VAR LIST VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR ASSIGN VAR VAR NUMBER VAR NUMBER IF VAR NUMBER BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER VAR LIST BIN_OP VAR NUMBER IF 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... | import sys
n, m = map(int, sys.stdin.readline().split())
counter = 0
if n > m:
counter = n - m
else:
while m - n != 0:
if m % 2 == 0 and m > n:
m /= 2
counter += 1
else:
if n >= m:
counter += n - m
break
m = (m + 1)... | IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR VAR WHILE BIN_OP VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER VAR NUMBER 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... | p = input().split()
a = int(p[0])
b = int(p[1])
if b <= a:
print(a - b)
else:
i = 0
while a != b:
while b % 2 == 0 and b > a:
b = b // 2
i = i + 1
if b != a:
b = b + 1
i = i + 1
print(i) | 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 ASSIGN VAR NUMBER WHILE VAR VAR WHILE BIN_OP VAR NUMBER NUMBER VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR 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... | n, m = map(int, input().split())
cont = 0
while n < m:
if m & 1:
m += 1
else:
m = m // 2
cont += 1
resultado = cont + (n - m)
print(resultado) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR IF BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP 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 = [int(x) for x in input().split()]
if n >= m:
print(n - m)
else:
count = 0
while n != m:
if n < m:
if m % 2 == 0:
m = m / 2
else:
m = m + 1
count += 1
else:
count += n - m
n = m
print("{0:.0... | 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 IF VAR VAR IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER VAR BIN_OP VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING 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... | lists = []
list_count = [1]
visited = set()
count = 0
def find_short(end):
global count, lists, list_count, visited
while len(lists) != 0:
current = lists[0]
current_count = list_count[0]
lists = lists[1:]
list_count = list_count[1:]
if current == end:
if cu... | ASSIGN VAR LIST ASSIGN VAR LIST NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_DEF WHILE FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR IF VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER 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... | from sys import stdin
n, m = str(stdin.readline()).replace("\n", "").split(" ")
n = int(n)
m = int(m)
i = 0
if n >= m:
print(n - m)
else:
while m != n:
if m % 2 == 0 and n < m:
m = m / 2
i = i + 1
elif m % 2 == 1 and n < m:
m = m + 1
m = m / 2
... | ASSIGN VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR STRING STRING STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR WHILE VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR 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... | inp = [int(i) for i in str(input()).split(" ")]
start = inp[0]
ans = inp[1]
def BFS(start, ans):
if start == ans:
print(0)
else:
SAPairs = [(0, start)]
explored = {}
while SAPairs:
path = SAPairs.pop(0)
successors = []
if path[-1] > 0:
... | ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST NUMBER VAR ASSIGN VAR DICT WHILE VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST IF VAR NUMBER 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... | from sys import stdin, stdout
def get_value(steps, key, value):
if key in steps:
numbers = steps[key]
numbers.append(value)
return numbers
else:
return [value]
def is_valid(new_number, calculated_numbers):
max_number = 10000
if (
new_number >= 0
and ne... | FUNC_DEF IF VAR VAR ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR VAR RETURN VAR RETURN LIST VAR FUNC_DEF ASSIGN VAR NUMBER IF VAR NUMBER VAR VAR VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR NUMBER LIST VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR VAR FOR 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... | start, end = map(int, input().split())
def compute(start, end):
if start >= end:
return start - end
elif end % 2 != 0:
return 1 + compute(start, end + 1)
else:
return 1 + compute(start, end // 2)
print(compute(start, end)) | ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR VAR RETURN 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 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... | class Graph:
adj_list = {}
num_vertices = 0
visited = set()
def __init__(self, start, end, num_vertices):
self.start = start
self.end = end
self.adj_list = {}
self.num_vertices = num_vertices
self.visited = set()
self.path = [None] * (num_vertices * 4 + 1... | CLASS_DEF ASSIGN VAR DICT ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR DICT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NONE BIN_OP BIN_OP VAR NUMBER NUMBER FUNC_DEF ASSIGN VAR NUMBER LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP 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... | import sys
input = sys.stdin.readline
def inp():
return int(input())
def inlt():
return list(map(int, input().split()))
def insr():
s = input()
return list(s[: len(s) - 1])
def invr():
return map(int, input().split())
numbers = list(invr())
n = numbers[0]
m = numbers[1]
if m < n:
prin... | IMPORT ASSIGN VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR RETURN FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR 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 rec(n, m):
if m == n:
return 0
elif (m + 1) // 2 < n:
return n - m // 2 + 1
elif (m + 1) // 2 >= n:
if m % 2 == 0:
return 1 + rec(n, m // 2)
else:
return 1 + 1 + rec(n, (m + 1) // 2)
def main():
s = input().split()
n = int(s[0])
m = i... | FUNC_DEF IF VAR VAR RETURN NUMBER IF BIN_OP BIN_OP VAR NUMBER NUMBER VAR RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER IF BIN_OP BIN_OP VAR NUMBER NUMBER VAR IF BIN_OP VAR NUMBER NUMBER RETURN BIN_OP NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP NUMBER NUMBER FUNC_CALL VAR VAR BIN_OP BIN_OP VAR NU... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.