description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bi...
l, r = map(int, input().split()) i = 61 mx = 0 while i >= 0: if l & 1 << i ^ r & 1 << i: break i -= 1 while i >= 0: mx ^= 1 << i i -= 1 print(mx)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP BIN_OP VAR BIN_OP NUMBER VAR BIN_OP VAR BIN_OP NUMBER VAR VAR NUMBER WHILE VAR NUMBER VAR BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bi...
def main(): a, b = map(int, input().split()) K = 60 if a == b: ans = 0 else: curr = K while b & 1 << curr == a & 1 << curr: curr -= 1 ans = 1 << curr curr -= 1 lb = False ga = False for i in range(curr, -1, -1): if b...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE BIN_OP VAR BIN_OP NUMBER VAR BIN_OP VAR BIN_OP NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER I...
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bi...
a, b = map(int, input().split()) if a == b: print(0) exit() aa = "" bb = "" while a or b: aa += str(a % 2) bb += str(b % 2) a //= 2 b //= 2 aa = aa[::-1] bb = bb[::-1] idx = 0 while aa[idx] == bb[idx]: idx += 1 ln = len(aa) r = 2 ** (ln - idx) - 1 print(r)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR STRING ASSIGN VAR STRING WHILE VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER W...
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bi...
l, r = map(int, input().split()) ans = l ^ r x = bin(ans)[1:] if ans == 0: print(0) else: ptr = -1 po = 0 while True: if x[ptr] == "0": ans += 2**po po += 1 ptr -= 1 if ptr == -len(x) - 1: break print(ans)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF VAR VAR STRING VAR BIN_OP NUMBER VAR VAR NUMBER VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_C...
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bi...
n, m = map(int, input().split()) n = str(bin(n))[2:] m = str(bin(m))[2:] n = "0" * (len(m) - len(n)) + n f = 0 for i in range(len(n)): if n[i] == "0" and m[i] == "1": print(2 ** (len(n) - i) - 1) f = 1 break if not f: print(f)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR ...
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bi...
def f(a, b): r = list(bin(b).lstrip("0b")) l = list((len(bin(b)) - len(bin(a))) * "0" + bin(a).lstrip("0b")) for i in range(len(r)): if r[i] == "1" and l[i] == "1": r[i] = "0" if int("".join(r), 2) >= a: pass else: r[i] = "1" ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR STRING FUNC_CALL FUNC_CALL VAR VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING ASSIGN VAR VAR STRING IF F...
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bi...
l, r = list(map(int, input().strip().split())) if l == r: print(0) exit() l, r = bin(l)[2:].zfill(64), bin(r)[2:].zfill(64) i = 0 while i < len(r): if l[i] == r[i]: i += 1 else: break rslt = len(r[:i]) * "0" + len(r[i:]) * "1" print(int(rslt, 2))
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER NUMBER FUNC_CALL FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER ASSIGN V...
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bi...
l = input().split() a = int(l[0]) b = int(l[1]) e = max(a, b) r = min(a, b) d = format(e, "b") c = 0 t = 0 j = 0 x = 0 if a != b: for i in range(len(d), 0 + j, -1): c += 2 ** (i - 1) k = c while c ^ r < r or c ^ e > e: c = 0 for i in range(len(d) - j, 0, -1): c += 2 ** (i...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR FOR VAR FUNC_CALL VAR FUNC_C...
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bi...
[l, r] = map(int, input().split()) if l == r: print(0) else: found = False bin1 = bin(l)[2:] bin2 = bin(r)[2:] bit = 0 while len(bin1) < len(bin2): bin1 = "0" + bin1 while len(bin2) < len(bin1): bin2 = "0" + bin2 while found == False: if bin1[bit] == bin2[bit]: ...
ASSIGN LIST VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP STRING VAR WHILE FUNC_CALL VAR VAR FUNC_CALL VAR VAR ...
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bi...
R = lambda: map(int, input().split()) l, r = R() cnt = 0 while l != r: l >>= 1 r >>= 1 cnt += 1 print(2**cnt - 1)
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bi...
l, r = map(int, input().split()) ls = str(bin(l))[2:] rs = str(bin(r))[2:] llog = len(ls) rlog = len(rs) ans = 0 if llog < rlog: z = rlog - 1 while z > -1: ans += 2**z z -= 1 else: ct = 0 stringa = "" for i in range(len(ls)): if ls[i] == rs[i] and ct == 0: stringa...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR NUMBER VAR BIN_OP NUMBER VAR VAR NUMB...
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bi...
a, b = list(map(int, input().split())) s1 = list(map(int, reversed(list(bin(a)[2:])))) s2 = list(map(int, reversed(list(bin(b)[2:])))) s1 += [0] * (len(s2) - len(s1)) out = 0 for i in range(len(s1)): if s1[i] ^ s2[i]: out = i + 1 print(2**out - 1)
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR VAR FUNC_CALL...
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bi...
lr = input().split() l, r = [int(x) for x in lr] if l == r: print(0) else: a, b = list(bin(l)[2:]), list(bin(r)[2:]) if len(a) == len(b): i = 0 while a[i] == b[i]: i += 1 left = "1" * (len(a) - i) print(int(left, 2)) elif len(a) > len(b): left = "1" * ...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP STRING...
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bi...
l, r = map(int, input().split()) s = bin(l)[2:] t = bin(r)[2:] z = max(len(s), len(t)) s = "0" * (z - len(s)) + s t = "0" * (z - len(t)) + t i = 0 while i < z and s[i] == t[i]: i = i + 1 print(pow(2, z - i) - 1)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP VAR FUNC_CALL VAR VAR VAR ...
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bi...
a, b = map(int, input().split()) c = a ^ b if c == 0: print(0) else: l = len("{:b}".format(c)) print((1 << l) - 1)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bi...
n = input().split() m = int(n[1]) n = int(n[0]) if m < n: c = m m = n n = c c = "" a = bin(m)[2:] b = bin(n)[2:] b = "0" * (len(a) - len(b)) + b while a[0] == b[0] and len(a) != 0: c1 = str(int(a[0]) ^ int(b[0])) c += c1 a = a[1:] b = b[1:] if len(a) == 0 or len(b) == 0: break aa...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP FUNC_CALL VAR VAR FUNC_CALL ...
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bi...
l, r = map(int, input().split()) ans = 0 a, b, c = [], [], [] if l == r: print(0) exit() for i in range(63, -1, -1): if (r ^ l) & 1 << i: for j in range(i, -1, -1): ans |= 1 << j break print(ans)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR LIST LIST LIST IF VAR VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP BIN_OP VAR VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR VAR NUMBER NUMBER VAR BIN_OP NUMBER VAR EXPR FU...
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bi...
l, r = [int(x) for x in input().split()] r = bin(r)[2:] l = bin(l)[2:] r = r[::-1] l = l[::-1] if l == r: print(0) else: l += "0" * (len(r) - len(l)) p = -1 for i in range(len(r)): if r[i] != l[i]: p = i a = "1" * p + "0" b = "0" * p + "1" print(int(a, 2) ^ int(b, 2))
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR NUMBER VAR BIN_OP STRING BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_...
A little girl loves problems on bitwise operations very much. Here's one of them. You are given two integers l and r. Let's consider the values of $a \oplus b$ for all pairs of integers a and b (l ≤ a ≤ b ≤ r). Your task is to find the maximum value among all considered ones. Expression $x \oplus y$ means applying bi...
def main(): l, r = map(int, input().split()) l1 = bin(l)[2:] r1 = bin(r)[2:] if len(l1) < 64: l1 = "0" * (64 - len(l1)) + l1 if len(r1) < 64: r1 = "0" * (64 - len(r1)) + r1 ans = 0 for i in range(64): if l1[i] != r1[i]: ans = pow(2, 64 - i) - 1 ...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP NUMBER FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP NUMBER FUNC_CALL VA...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, L = map(int, input().split()) c = input().split() for i in range(n): c[i] = int(c[i]) if i > 0 and c[i - 1] * 2 < c[i]: c[i] = c[i - 1] * 2 ans = c[0] * L cur = 0 for i in range(n - 1, -1, -1): ans = min(ans, cur + (L + 2**i - 1) // 2**i * c[i]) cur += c[i] * (L // 2**i) L -= 2**i * (L //...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR VAR ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER FOR V...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, L = map(int, input().split()) c = list(map(int, input().split())) while len(c) < 32: c.append(c[-1] * 2) n = 32 for i in range(n): for j in range(i + 1, n): k = 2 ** (j - i) if k * c[i] < c[j]: c[j] = k * c[i] ans = 0 for i in range(n): if L & 1 << i: ans = min(ans + c...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR WHILE FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP NUMBER BIN_OP V...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, L = map(int, input().split()) a = [int(x) for x in input().split()] for i in range(0, n - 1): a[i + 1] = min(a[i + 1], 2 * a[i]) s = 0 ans = 1000**1000 for i in range(n - 1, -1, -1): d = L // (1 << i) s += d * a[i] L -= d << i ans = min(ans, s + (L > 0) * a[i]) print(ans)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR ...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, l = map(int, input().split()) c, s = 0, 10**18 a = list(map(int, input().split())) for i in range(len(a) - 1): a[i + 1] = min(a[i + 1], a[i] * 2) for i in range(n - 1, -1, -1): d = 1 << i c += a[i] * (l // d) l %= d s = min(s, c + (l != 0) * a[i]) print(s)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER FOR VAR FUNC...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, L = map(int, input().split()) P = L def log(n): a = 1 while a * 2 <= n: a *= 2 return a c = list(map(int, input().split())) for i in range(1, n): c[i] = min(c[i - 1] * 2, c[i]) for i in range(n - 2, -1, -1): c[i] = min(c[i], c[i + 1]) Mark = list(map(int, ("0 " * n).split())) d = len(...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_DEF ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER VAR VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR VA...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, L = map(int, input().split()) c = list(map(int, input().split())) for i in range(1, n): c[i] = min(c[i], c[i - 1] * 2) for i in range(30): c.append(c[-1] * 2) r = 0 for i in range(31): if L >> i & 1: r += c[i] else: r = min(r, c[i]) print(r)
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
import sys n, l = map(int, input().split()) cs = list(map(int, input().split())) cbs = [(c / 2**i, c, 2**i) for i, c in enumerate(cs)] cbs.sort() def solve(i, r): _, c, q = cbs[i] rem = r % q if rem == 0: return r // q * c a = (r // q + 1) * c if i + 1 == len(cbs): return a b ...
IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR VAR BIN_OP NUMBER VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER RETURN...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, l = map(int, input().split()) c = list(map(int, input().split())) dp = [0] * 31 dp[0] = c[0] for i in range(1, 31): if i >= n: dp[i] = 2 * dp[i - 1] else: dp[i] = min(2 * dp[i - 1], c[i]) for i in range(29, -1, -1): dp[i] = min(dp[i], dp[i + 1]) b = bin(l)[2:] k = len(b) m = dp[k] x = 0 f...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR ASSIGN VAR VAR BIN_OP NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
from sys import stdin, stdout sze = 100 INF = float("inf") n, l = map(int, stdin.readline().split()) c = list(map(int, stdin.readline().split())) may = [(1) for i in range(sze)] for i in range(n - 1, -1, -1): for j in range(i): if c[i] > c[j] * 2 ** (i - j): may[i] = 0 ans = INF cnt = 0 value =...
ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR BIN_OP VAR VAR ...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, m = map(int, input().split()) l = [int(x) for x in input().split()] for i in range(1, n): l[i] = min(l[i], 2 * l[i - 1]) c = l + [(l[-1] * 2**i) for i in range(1, 32)] def cost(x): ans = 0 for i in range(32): if x & 1 << i: ans += c[i] return ans ans = cost(m) for i in range(3...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR VAR FUNC_CALL VAR NUMBER NUMBER FUNC_DEF A...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
def min_cost(l, a): if l <= 0: return 0 bl = bin(l)[2:] lb = len(bl) temp_cost = a[lb - 1] + min_cost(l - pow(2, lb - 1), a) if min(a[lb:]) <= temp_cost: return min(a[lb:]) return temp_cost n, l = input().split() n = int(n) l = int(l) a = [int(x) for x in input().split()] for i...
FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR IF FUNC_CALL VAR VAR VAR VAR RETURN FUNC_CALL VAR VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR AS...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
def validator(chunk: int) -> int: pass n: int L: int bottle_L: int total: int = 0 answer: int = float("inf") n, L = list(map(int, input().split())) costs: list = list(map(int, input().split())) for i in range(len(costs) - 1): costs[i + 1] = min(costs[i + 1], 2 * costs[i]) for i in range(len(costs) - 1, -1, -1...
FUNC_DEF VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR NUMBER VAR VAR FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, l = map(int, input().split()) c = list(map(int, input().split())) res = 0 for i in range(1, n): c[i] = min(c[i - 1] * 2, c[i]) p = 1 << n - 1 y = l // p l -= y * p res += c[n - 1] * y RES = [] if l > 0: RES.append(res + c[n - 1]) for i in range(n - 2, -1, -1): p //= 2 y = l // p if y == 1: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR VAR ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, l = map(int, input().split()) ci = list(map(int, input().split())) mini = ci[-1] for i in range(n - 2, -1, -1): if ci[i] < mini: mini = ci[i] else: ci[i] = mini for i in range(1, n): ci[i] = min(ci[i], ci[i - 1] * 2) for i in range(n, 34): ci += [ci[-1] * 2] s = bin(l)[2:] ans = 0 d...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR V...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
listin = lambda: list(map(int, input().split())) mapin = lambda: map(int, input().split()) n, l = mapin() c = listin() lc = [c[0]] for i in range(1, n): lc.append(min(lc[-1] * 2, c[i])) ans = 10**20 s = 0 for i in range(n - 1, -1, -1): num = l // 2**i s += num * lc[i] l -= num * 2**i ans = min(ans, ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER VAR VAR ASSIGN VAR BIN_OP NU...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, L = map(int, input().split()) a = [int(x) for x in input().split()] for i in range(1, n): a[i] = min(a[i], a[i - 1] * 2) ans = float("inf") cos = 0 for i in range(n - 1, -1, -1): tem = L // (1 << i) cos += tem * a[i] L -= tem << i if L > 0: ans = min(ans, cos + a[i]) else: ans...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUM...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, L = map(int, input().split()) c = [*map(int, input().split())] rational = [True] * n for i in range(n): for j in range(n): if i < j and c[i] >= c[j]: rational[i] = False if i < j and c[i] * 2 ** (j - i) <= c[j]: rational[j] = False def dfs(i, L): if i == 0: r...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR NUMBER IF VAR VAR BIN_OP VAR VAR BIN_OP NUMBER BIN_OP VAR VAR VAR VAR ASSIGN ...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, l = map(int, input().split()) c = list(map(int, input().split())) for i in range(1, n): c[i] = min(c[i], c[i - 1] * 2) d = [(2**i) for i in range(n)] i = n - 1 while i >= 1: if c[i] < c[i - 1]: c[i - 1] = c[i] d[i - 1] = d[i] i -= 1 i = n - 1 cost = 0 mini = 999999999999999999999999999999...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR ...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, liters = (int(x) for x in input().split()) prices = list(map(int, input().split())) answer = 10**18 cache = 0 for i in range(n - 1): prices[i + 1] = min(prices[i + 1], prices[i] * 2) for i in range(n - 1, -1, -1): div = 1 << i cache += prices[i] * (liters // div) liters %= div mult = liters != 0 ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER FOR VAR FUNC_CA...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
def main(): n, needed = map(int, input().split()) costs = list(map(int, input().split())) done = False while not done: done = True cur = costs[0] for i, x in enumerate(costs[1:], 1): cur <<= 1 if cur < x: costs[i] = cur done...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR NUMBER NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR F...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, L = map(int, input().split()) c = list(map(int, input().split())) v = [(2**i) for i in range(n)] for i in range(n): for j in range(i + 1, n): if v[i] * c[j] < v[j] * c[i]: c[i], c[j] = c[j], c[i] v[i], v[j] = v[j], v[i] lo, hi = 1, int(1e18) while lo < hi: md = (lo + hi) // 2 ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
from itertools import permutations MOD = 10**9 + 7 def find_best(c): n = 2 ** len(c) best_c = c[0] * n best_i = 0 for i, ci in enumerate(c): if n // 2**i * c[i] < best_c: best_c = n // 2**i * c[i] best_i = i return best_i def main(): n, l = [int(c) for c in i...
ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR BIN_OP NUMBER VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR VAR VAR ASSIGN VAR VAR RETURN VAR FUNC_DEF ...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, li = map(int, input().split()) c = list(map(int, input().split())) for i in range(n - 1): if c[i] * 2 < c[i + 1]: c[i + 1] = c[i] * 2 for i in range(n - 2, -1, -1): if c[i] > c[i + 1]: c[i] = c[i + 1] i = n - 1 ans = 0 a = [] while li > 0: ans += c[i] * (li >> i) li %= 2**i if li ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF V...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, l = map(int, input().split()) a = [int(i) for i in input().split()] for i in range(1, n): a[i] = min(a[i], 2 * a[i - 1]) for i in range(32 - n): a.append(a[-1] * 2) ans = 0 lastset = 0 for i in range(32): if 1 << i & l == 1 << i: lastset = i for j in range(0, 32): if 1 << j & l == 1 << j: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP NUMBER VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBE...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, L = map(int, input().split(" ")) c = list(map(int, input().split(" "))) min_cost = [c[0]] for i in range(n - 1): min_cost.append(min([min_cost[i] * 2, c[i + 1]])) sumval = 0 ans = float("inf") for i in range(n - 1, -1, -1): times = L // (1 << i) sumval += times * min_cost[i] L %= 1 << i if L == 0...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR LIST BIN_OP VAR VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, L = [int(i) for i in input().split()] c = [int(i) for i in input().split()] costPerLemon = [] ans = 12345678901234567890 for i in range(n): costPerLemon.append(c[i] / 2**i) size = n money = 0 while size > 1: target = min(costPerLemon) i = costPerLemon.index(target) times = int(L / 2**i) money += ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP NUMBER VAR ASSIGN VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR ...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, L = map(int, input().split()) c = list(map(int, input().split())) c += [float("inf")] * (35 - len(c)) for i in range(len(c) - 1): if c[i] * 2 < c[i + 1]: c[i + 1] = 2 * c[i] def main(): l = bin(L)[2:][::-1] ans = 0 for i in range(len(c)): if ans > c[i]: ans = c[i] ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR BIN_OP LIST FUNC_CALL VAR STRING BIN_OP NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMB...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, l = map(int, input().split()) c = list(map(int, input().split())) for i in range(1, n): c[i] = min(c[i], c[i - 1] * 2) x = 0 d = l for sht in range(n - 1): if l >> sht & 1: x += c[sht] d -= 2**sht x += c[-1] * (d // 2 ** (n - 1)) ans = x u = "0" * (n - len(str(bin(l)[2:]))) + str(bin(l)[2:]) ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP BIN_OP ...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, l = map(int, input().split()) d = 32 * [10737418240000000000] m = [10737418240000000000] c = list(map(int, input().split())) d[0] = c[0] if n <= 30: for t in range(n, 32): c.append(1073741824000000000) for t in range(32): if t != 0: if c[t] <= 2 * d[t - 1]: d[t] = c[t] els...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER LIST NUMBER ASSIGN VAR LIST NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR NUMBER IF VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VA...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
def solve(a, l): if l == 0: return 0 if l == 1: return a[0] k = 0 while 2**k < l: k += 1 return min(a[k], a[k - 1] + solve(a, l - 2 ** (k - 1))) def main(): n, l = map(int, input().split()) a = list(map(int, input().split())) for i in range(n - 2, -1, -1): ...
FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP NUMBER VAR VAR VAR NUMBER RETURN FUNC_CALL VAR VAR VAR BIN_OP VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VA...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, L = list(map(int, input().split())) c = list(map(int, input().split())) total_max = pow(2, n - 1) cost_dp = [i for i in c] for i in range(1, n): if 2 * cost_dp[i - 1] < cost_dp[i]: cost_dp[i] = 2 * cost_dp[i - 1] def solve(L, ind): if L == 0: return 0 if ind < 0: return 10000000...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP NUMBER VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR VAR BIN_OP NUMBER ...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, L = map(int, input().split()) bottles = (int(x) for x in input().split()) bottles = [(2**i, p) for i, p in enumerate(bottles)] perliter = lambda x: x[1] / x[0] bottles = sorted(bottles, key=perliter) temp = 0 paid = float("inf") for liters, price in bottles: got, L = divmod(L, liters) temp += got * price ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING FOR VAR VAR VAR ASSIGN V...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, L = [int(i) for i in input().split()] c = [int(i) for i in input().split()] for i in range(1, n): if c[i] > c[i - 1] * 2: c[i] = c[i - 1] * 2 ans1 = 0 ans2 = 0 ans = 10**20 for i in range(n - 1, -1, -1): r1 = L // 2**i r2 = (L + 2**i - 1) // 2**i L -= r1 * 2**i ans1 = ans2 + r2 * c[i] ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FOR...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
def solve(l, costs): ans = 0 for i in range(31, -1, -1): if l >> i & 1 == 1: ans += min(costs[i + 1], costs[i] + solve(l - ex(2, i), costs)) break return ans def ex(base, exp): ans = 1 for i in range(exp): ans = ans * base return ans n, l = str(input()...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR NUMBER VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR RETURN VAR A...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, L = [int(x) for x in input().split()] c = [int(x) for x in input().split()] size = [(2**p) for p in range(n)] for index in range(n): if index > 0: c[index] = min(c[index], c[index - 1] * 2) for index in range(n): if index > 0: temp = n - 1 - index c[temp] = min(c[temp], c[temp + 1]) p...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBE...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, L = map(int, input().split()) c = list(map(int, input().split())) C = [[(0) for i in range(30)] for i in range(n)] for i in range(n): for j in range(30): if j <= i: C[i][j] = c[i] else: C[i][j] = c[i] << j - i ans = 0 for i in range(30): tmp = 1e18 pos = 0 for ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR BIN_...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
def solve(a1, b1, cur_sum, cur_L, idx): if cur_L == 0: return cur_sum if idx == len(a1) - 1: if cur_L > 0: ost = cur_L % b1[-1] > 0 if ost: cur_sum += a1[-1] cur_sum += a1[-1] * (cur_L // b1[-1]) return cur_sum else: ...
FUNC_DEF IF VAR NUMBER RETURN VAR IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR VAR NUMBER NUMBER IF VAR VAR VAR NUMBER VAR BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER RETURN VAR RETURN VAR ASSIGN VAR BIN_OP VAR VAR VAR NUMBER IF VAR ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP VAR BIN_OP VAR VAR BI...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
import sys MAXN = 31 INF = 2**62 - 1 + 2**62 def get_ints(): return list(map(int, sys.stdin.readline().strip().split())) def read(): ints = get_ints() n = ints[0] L = ints[1] cost = get_ints() assert len(cost) == n, "MUST have the same number of elements" return n, L, cost def tobinar...
IMPORT ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER NUMBER NUMBER BIN_OP NUMBER NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR STRING RETURN ...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, lit = map(int, input().split()) cost = list(map(int, input().split())) + [1 << 100] * 33 n = len(cost) rlit = lit for i in range(n): for j in range(i - 1, -1, -1): cost[i] = min(cost[i], cost[j] * (1 << i - j)) res = 0 for i in range(n): if 1 << i & lit: res += cost[i] b = [] while lit: b...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR BIN_OP LIST BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL ...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, L = map(int, input().split(" ")) a = [int(x) for x in input().split()] for i in range(1, n): a[i] = min(a[i], 2 * a[i - 1]) minans = 2 * 10**18 ans = 0 for i in range(n - 1, -1, -1): h = L // (1 << i) ans += h * a[i] L -= h * (1 << i) minans = min(minans, ans + a[i]) print(min(ans, minans))
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP ...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, lt = (int(x) for x in input().split()) costs = [int(x) for x in input().split()] c1 = costs[0] costs = costs[1:] maincost = lt * c1 mainlen = lt remcost = 0 currv = 1 for c in costs: currv *= 2 nmainl = lt - lt % currv prevc = maincost / mainlen if maincost != 0 else 0 if prevc > c / currv: n...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR VAR NUMBER...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
s = 0 ans = 100**1000 n, l = map(int, input().split()) a = list(map(int, input().split())) for i in range(0, n - 1): a[i + 1] = min(a[i + 1], 2 * a[i]) for i in range(n - 1, -1, -1): d = l // (1 << i) s += d * a[i] l -= d << i ans = min(ans, s + (l > 0) * a[i]) print(ans)
ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR VAR FOR VAR FUNC...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
ii = lambda: int(input()) kk = lambda: map(int, input().split()) ll = lambda: list(kk()) n, l = kk() cs = ll() cpl = [(cs[i] / 2**i, 2**i, cs[i]) for i in range(n)] cpl.sort() cnt = 0 best = l * 10**9 for i in range(n): curr = cpl[i] units = l // curr[1] l -= units * curr[1] cnt += units * curr[2] b...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR BIN_OP NUMBER VAR BIN_OP NUMBER VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
read = lambda: map(int, input().split()) n, L = read() c = list(read()) for _ in range(5): for i in range(n - 2, -1, -1): c[i] = min(c[i], c[i + 1]) for i in range(1, n): c[i] = min(c[i], c[i - 1] * 2) cur = 0 ans = 10**30 L1 = L for i in range(n - 1, -1, -1): cnt = L1 // 2**i cur += cnt...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, l = map(int, input().split()) c = list(map(int, input().split())) eff = [0] best = 0 for i in range(1, n): if c[i] < 2 ** (i - best) * c[best]: eff.append(i) best = i cost = 0 fcost = 10**1000 for curr in range(len(eff) - 1, -1, -1): num = l // 2 ** eff[curr] l -= 2 ** eff[curr] * num ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR BIN_OP BIN_OP NUMBER BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR ...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
def dec(costs, V): r = 0 price, typ = costs[len(costs) - 1] fills = int((V - V % int(2 ** (typ - 1))) / int(2 ** (typ - 1))) r = r + price * fills V = V - int(2 ** (typ - 1)) * fills if V <= 0: return r elif len(costs) > 1: smallerCosts = dec(costs[: len(costs) - 1], V) ...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR FUNC_CALL VAR BIN_OP NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP FUNC_CALL VAR BIN_OP NUMBER BI...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
import sys input = sys.stdin.readline n, L = map(int, input().split()) c = list(map(int, input().split())) a = [c[0]] for i in range(1, 31): cand = [a[-1] * 2] if i < n: cand.append(c[i]) a.append(min(cand)) ans = [] sum = 0 for i in reversed(range(31)): if L <= 1 << i: ans.append(sum +...
IMPORT ASSIGN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR LIST BIN_OP VAR NUMBER NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, L = [int(a) for a in input().strip().split()] costs_n = [int(a) for a in input().strip().split()] costs = [(0) for i in range(31)] for i in range(n): costs[i] = costs_n[i] for i in range(1, n): costs[i] = min(costs[i], costs[i - 1] * 2) for i in range(n - 2, -1, -1): costs[i] = min(costs[i], costs[i + 1]...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR BIN_OP VA...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, l = map(int, input().split()) b = list(map(int, input().split())) c = [float("inf")] * 31 for i in range(n): c[i] = b[i] i = 0 while i < n: p = 2**i r = i while r < 30: j = 2**r c[r] = min(c[r], b[i] * (j // p)) r += 1 i += 1 c[30] = min(c[30], 2 * c[29]) s = bin(l)[2:] s ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST FUNC_CALL VAR STRING NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR VAR WHILE VAR NUMBER ASS...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
entrada = input().split() n = int(entrada[0]) L = int(entrada[1]) arr_c = [int(c) for c in input().split()] for i in range(0, n - 1): arr_c[i + 1] = min(arr_c[i + 1], 2 * arr_c[i]) result = 4 * 10**18 soma = 0 i = n - 1 while i >= 0: temp = L // (1 << i) soma += temp * arr_c[i] L -= temp << i result...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR VAR ASSIGN VAR BIN_OP NUMB...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
s = input().split() n, L = int(s[0]), int(s[1]) c = list(map(int, input().split())) for i in range(n - 1, 0, -1): if c[i] < c[i - 1]: c[i - 1] = c[i] for i in range(1, n): if c[i] > c[i - 1] * 2: c[i] = c[i - 1] * 2 while len(c) < 31: c.append(c[-1] * 2) s = set() ans = 0 for i in range(30, ...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR VAR FOR VAR FUNC_CALL VAR NUMBER ...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
def merge(a, b): c = [] while len(a) != 0 and len(b) != 0: if a[0][0] < b[0][0]: c.append(a[0]) a.remove(a[0]) else: c.append(b[0]) b.remove(b[0]) if len(a) == 0: c += b else: c += a return c def mergesort(x): if l...
FUNC_DEF ASSIGN VAR LIST WHILE FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER IF VAR NUMBER NUMBER VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR NUMBER VAR VAR VAR VAR RETURN VAR FUNC_DEF IF FUNC_CALL VAR...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, L = [int(k) for k in input().split(" ") if k] dp = [int(k) for k in input().split(" ") if k] for i in range(1, n): dp[i] = min(2 * dp[i - 1], dp[i]) binary = [] while L != 0: binary.append(L % 2) L //= 2 while len(dp) < len(binary): dp.append(2 * dp[-1]) def minify(p): result = 9999999999999999...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR BIN_OP NUMBER VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR LIST WHILE VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
def one_case(): n, ll = map(int, input().split()) a = [int(x) for x in input().split()] if n == 1: print(a[0] * ll) return d = [(2**i) for i in range(n)] for i in range(1, n): if a[i] > a[i - 1] * 2: a[i] = a[i - 1] * 2 for i in range(n - 2, -1, -1): i...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR RETURN ASSIGN VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSI...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
R = lambda: map(int, input().split()) def get_cost(num): res = 0 for i in range(32): if num & 1 << i: res += cs[i] return res n, l = R() cs = list(R()) for i in range(1, 32): if i >= len(cs): cs.append(2 * cs[i - 1]) elif cs[i] > 2 * cs[i - 1]: cs[i] = 2 * cs[...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR VAR VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP N...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, L = map(int, input().split()) c = list(map(int, input().split())) L = format(L, "b")[::-1] dp = [0] * (len(L) + 1) l = [] for i in range(len(L)): if i < n: l.append(c[i]) m = min(l) if m < dp[i]: dp[i + 1] = m else: dp[i + 1] = dp[i] if L[i] == "1": dp[i + 1] += m ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR STRING NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR V...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, L = list(map(int, input().split())) arr = [int(x) for x in input().split()] def pos(x): ans = 0 while x: x //= 2 ans += 1 return ans - 1 def solve(ltr): if ltr == 0: return 0 val = pos(ltr) if val + 1 < n: Bmin = min(arr[val + 1 :]) else: val = ...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR NUMBER VAR NUMBER RETURN BIN_OP VAR NUMBER FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_C...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
inf = 10**20 dp = [inf] * 31 n, m = map(int, input().split()) a = [int(x) for x in input().split()] for i in range(n): dp[i] = a[i] for i in range(1, 31): c = 1 for j in range(i, -1, -1): dp[i] = min(dp[i], dp[j] * c) c *= 2 m = bin(m)[2:] an = inf for i in range(len(m), n + 1): an = min...
ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP LIST VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER NUMB...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, L = map(int, input().split()) c = [int(i) for i in input().split()] for i in range(n): if i > 0: c[i] = min(c[i], c[i - 1] * 2) s = 0 ret = -1 for i in range(n - 1, -1, -1): if L > 0: cnt = L // 2**i s += c[i] * cnt L %= 2**i if L == 0: continue if ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF ...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, l = tuple(map(int, input().split())) cost = list(map(int, input().split())) for i in range(1, n): cost[i] = min(cost[i], 2 * cost[i - 1]) ans, s = float("inf"), 0 for i in range(n - 1, -1, -1): litre = 1 << i need = l // litre s += cost[i] * need l = l % litre ans = min(ans, s + (l != 0) * co...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR STRING NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR ...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
def ev(l, costs): s = 0 for i in range(0, len(costs) - 1): s += costs[i] * (l % 2) l = l // 2 s += l * costs[-1] return s n, l = map(int, input().split()) cs = list(map(int, input().split())) for i in range(1, n): if cs[i - 1] * 2 < cs[i]: cs[i] = 2 * cs[i - 1] res = ev(l, ...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER VAR BIN_OP VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR BIN_OP VAR VAR NUMBER RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR V...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
cin = input().split() n = int(cin[0]) m = int(cin[1]) data = list(map(int, input().split())) for x in range(1, max(len(data), len(bin(m)) - 2) + 10): if x < len(data): if data[x] > data[x - 1] * 2: data[x] = data[x - 1] * 2 else: data.append(data[x - 1] * 2) for x in reversed(range(0...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER NUMBER IF VAR FUNC_CALL VAR VAR ...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
INF = int(1e18) def read_int(): return list(map(int, input().split())) n, l = read_int() costs = read_int() bottles = [(1 << i, c) for i, c in enumerate(costs)] bottles.sort(key=lambda b: (b[1] / b[0], 1 / b[1])) min_cost = dict() def find_min_cost(l): if l == 0: return 0 if l in min_cost: ...
ASSIGN VAR FUNC_CALL VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER BIN_OP NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
import sys n, L = map(int, sys.stdin.readline().split()) c = list(map(int, sys.stdin.readline().split())) for i in range(1, n): c[i] = min(c[i], 2 * c[i - 1]) for i in range(n - 2, -1, -1): c[i] = min(c[i], c[i + 1]) res = L // 2 ** (n - 1) * c[n - 1] L %= 2 ** (n - 1) tres = 0 for sh in range(n): if L & 2...
IMPORT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP NUMBER VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR ...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
val = input() n, L = val.split() n = int(n) L = int(L) ans = 0 string = input() string = string.split() for i in range(1, len(string)): if 2 * int(string[i - 1]) < int(string[i]): string[i] = 2 * int(string[i - 1]) for i in range(len(string)): if ans > int(string[i]): ans = int(string[i]) if...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR ASSIGN VAR VAR BIN...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
read = lambda: map(int, input().split()) n, L = read() c = list(read()) for i in range(n): for j in range(i + 1, n): p = c[i] * (1 << j - i) c[j] = min(c[j], p) while len(c) <= 30: c.append(c[-1] * 2) ans = c[-1] s = 0 for i in range(30, -1, -1): if L & 1 << i > 0: s += c[i] else...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR BIN_OP NUMBER BIN_OP VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR WHILE FUNC_CALL VAR VAR NUMBER EX...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
variants, volume = map(int, input().split()) cost = [int(x) for x in input().split()] for i in range(1, variants): cost[i] = min(cost[i], 2 * cost[i - 1]) while len(cost) < 32: cost.append(cost[-1] * 2) ans = 0 binaryRepresentation = list(bin(volume)[2:]) while len(binaryRepresentation) < 32: binaryRepresen...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP NUMBER VAR BIN_OP VAR NUMBER WHILE FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN ...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
def process(n, c): for i in range(n, 30 + 1): c.append(0) for i in range(1, 30 + 1): if c[i] == 0: c[i] = c[i - 1] * 2 else: c[i] = min(c[i], c[i - 1] * 2) mn = c[30] for i in range(30, 0 - 1, -1): c[i] = min(c[i], mn) mn = min(c[i], mn) ...
FUNC_DEF FOR VAR FUNC_CALL VAR VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NU...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, L = [int(i) for i in input().split()] L = list(bin(L).replace("0b", "")) L.reverse() c = [int(i) for i in input().split()] l = 0 C = [] for i in range(len(L)): c_l = {} for j in range(n): if j > i: c_l[c[j] / 2**i] = j elif j <= i: c_l[c[j] / 2**j] = j c_ls = list(...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR VAR STRING STRING EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
from sys import maxsize n, l = map(int, input().split()) cost = list(map(int, input().split())) min_rubles = 0 prev = maxsize for i in range(31): if i < n: prev = min(2 * prev, cost[i]) else: prev *= 2 if l & 2**i: min_rubles += prev else: min_rubles = min(min_rubles, pr...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER VAR VAR VAR VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR VAR VAR ASSIGN VAR FUNC_CALL ...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
def tt(l, r): h = len(l) o = l[h - r :] c = h - r for i in range(h - r - 1, -1, -1): if l[i] == "1": o = "0" + o break else: o = "1" + o c -= 1 else: return "0" return l[: c - 1] + o n, l = map(int, input().split()) a = list(m...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER NUMBER IF VAR VAR STRING ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR BIN_OP STRING VAR VAR NUMBER RETURN STRING RETURN BIN_OP VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR FUNC_...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
R = lambda: map(int, input().split()) n, L = R() L2 = "{0:b}".format(L) t = len(L2) c = list(R()) b = [0] * max(n, t) l = [0] * max(n, t) b[0] = float("inf") temp = 0 for i in range(n - 1, -1, -1): if c[i] < b[0]: b[0] = c[i] temp = i l[0] = 2**temp for i in range(1, n): if l[i - 1] >= 2**i:...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP LIST NUMBER FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FUNC_CALL VAR ST...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, L = map(int, input().split()) A = list(map(int, input().split())) + [1 << 64] * 30 n += 30 for i in range(1, n): A[i] = min(A[i], A[i - 1] * 2) cur = 0 now_cost = 0 ans = 1 << 64 for i in range(n - 1, -1, -1): if cur | 1 << i >= L: ans = min(ans, now_cost + A[i]) else: cur |= 1 << i ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR BIN_OP LIST BIN_OP NUMBER NUMBER NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUM...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n = input().split() l = int(n[1]) n = int(n[0]) c = input().split() cperl = [] for i in range(n): c[i] = int(c[i]) cperl.append([c[i] / 2**i, 2**i, i]) cperl.sort() f = False nl = [0] nc = [0] i = 0 while not f: p = nl[i] nl[i] += cperl[i][1] * ((l - p) // cperl[i][1]) nc[i] += c[cperl[i][2]] * ((l ...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR LIST BIN_OP VAR VAR BIN_OP NUMBER VAR BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR A...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, L = map(int, input().split()) c = list(map(int, input().split())) ad = [ ( len([(1) for j in range(i + 1, n) if c[j] <= c[i]]) == 0 and len([(1) for j in range(0, i) if c[j] * 2 ** (i - j) < c[i]]) == 0 ) for i in range(n) ] order = [i for i in range(n) if ad[i]] def solve(L, max_i): ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR NUMBER FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR BIN_OP VAR VAR BIN_OP NUMBER BIN_OP VAR VAR VAR VAR...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, l = map(int, input().split()) a = list(map(int, input().split())) b = [0] * n b[0] = a[0] if n == 1 and l == 1: print(a[0]) else: for i in range(1, n): b[i] = min(a[i], b[i - 1] * 2) if b[i] < b[i - 1]: for j in range(i): b[j] = min(b[i], b[j]) c = [0] * n ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR BIN_OP V...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, m = map(int, input().split()) l = list(map(int, input().split())) L = [] L1 = [] for i in range(n): L.append([l[i] / 2**i, i]) L.sort() f = 123123123 s = 0 for i in range(n): if f > L[i][1]: if m % 2 ** L[i][1] == 0: L1.append(s + m // 2 ** L[i][1] * l[L[i][1]]) else: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST BIN_OP VAR VAR BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR ...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, L = [int(x) for x in input().split()] T = [int(x) for x in input().split()] for i in range(0, n): T[i] = 2**i, T[i] def f(n, L, T): if L == 0: return 0 if n == 1: return ((L - 1) // T[0][0] + 1) * T[0][1] else: best = T[0][0], T[0][1] for j in T: if best[...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR BIN_OP NUMBER VAR VAR VAR FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER NUMBER VAR NU...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, L = map(int, input().split()) powers = [] fir = 1 for i in range(n): powers.append(fir) fir *= 2 c = list(map(int, input().split())) for i in range(1, n): c[i] = min(2 * c[i - 1], c[i]) cost = 0 fincost = [] for i in range(n - 1, -1, -1): cost += L // powers[i] * c[i] L = L % powers[i] if L =...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR BIN_OP NUMBER VAR BIN_OP VAR NUMBER VAR ...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, L = map(int, input().split()) c = list(map(int, input().split())) best = [(c[i] / (1 << i), i) for i in range(0, n)] best.sort() cost = 0 costs = [0] * n for i in range(0, n): a, b = best[i] q = L // (1 << b) L -= q * (1 << b) cost += q * c[b] if L > 0: costs[i] = cost + c[b] else: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR BIN_OP NUMBER VAR VAR VAR FUNC_CALL VAR NUMBER VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR ...
A New Year party is not a New Year party without lemonade! As usual, you are expecting a lot of guests, and buying lemonade has already become a pleasant necessity. Your favorite store sells lemonade in bottles of n different volumes at different costs. A single bottle of type i has volume 2^{i} - 1 liters and costs c...
n, l = [int(k) for k in input().split()] w = [int(k) for k in input().split()] w = [[2**k, w[k]] for k in range(n)] w.sort(key=lambda x: x[1] * 2**30 // x[0]) res = 0 c = 0 new = [] while l > 0: if l >= w[c][0]: res += l // w[c][0] * w[c][1] l = l % w[c][0] if l != 0: new.append(...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST BIN_OP NUMBER VAR VAR VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER BIN_OP NUMBER NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR ...