description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
def OK(mid): x = max(countb * mid - b, 0) y = max(counts * mid - s, 0) z = max(countc * mid - c, 0) if m >= x * mb + y * ms + z * mc: return True else: return False n = input() b, s, c = list(map(int, input().split())) mb, ms, mc = list(map(int, input().split())) m = int(input()) c...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR NUMBER IF VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
def f(x): cb = max(0, (tb * x - nb) * pb) cs = max(0, (ts * x - ns) * ps) cc = max(0, (tc * x - nc) * pc) return cc + cs + cb <= rs s = list(input()) tb, ts, tc = s.count("B"), s.count("S"), s.count("C") nb, ns, nc = list(map(int, input().split())) pb, ps, pc = list(map(int, input().split())) rs = int...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR RETURN BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
S = input() x, y, z = map(int, input().split()) px, py, pz = map(int, input().split()) r = int(input()) b, s, c = 0, 0, 0 for i in S: if i == "B": b -= -1 elif i == "S": s -= -1 else: c -= -1 lo = 0 hi = 10**20 while 1: mid = (lo + hi) // 2 money = ( max(0, mid * b - ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASS...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
w = input() nb, ns, nc = map(int, input().split()) pb, ps, pc = map(int, input().split()) m = int(input()) b = w.count("B") s = w.count("S") c = w.count("C") def fun(x): return max(0, b * x - nb) * pb + max(0, c * x - nc) * pc + max(0, s * x - ns) * ps if s == 0: j = 0 else: j = int((ns + m / ps) / s) i...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP F...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
def ans(x): sum = 0 if n1 * x - nb > 0: sum = sum + (n1 * x - nb) * pb if n2 * x - ns > 0: sum = sum + (n2 * x - ns) * ps if n3 * x - nc > 0: sum = sum + (n3 * x - nc) * pc if r >= sum: return 1 else: return 0 s = input() a = list(input().split()) nb = i...
FUNC_DEF ASSIGN VAR NUMBER IF BIN_OP BIN_OP VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR IF BIN_OP BIN_OP VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR IF BIN_OP BIN_OP VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR IF VAR V...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
R = lambda: map(int, input().split()) str = input() bs, ss, cs = str.count("B"), str.count("S"), str.count("C") nb, ns, nc = R() pb, ps, pc = R() money = int(input()) l, r = 0, money + max(nb, ns, nc) while l < r: m = (l + r + 1) // 2 mb, ms, mc = ( max(0, bs * m - nb) * pb, max(0, ss * m - ns) ...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER BIN_OP VAR FUNC_CALL VAR VAR VAR ...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
recipe = input() cb, cs, cc = [recipe.count(x) for x in "BSC"] nb, ns, nc = map(int, input().split()) pb, ps, pc = map(int, input().split()) r = int(input()) n_ready = min( nb // cb if cb != 0 else 100, ns // cs if cs != 0 else 100, nc // cc if cc != 0 else 100, ) nnb, nns, nnc = nb - n_ready * cb, ns - n_r...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER BIN_OP VAR VAR NUMBER VAR NUMBER BIN_OP VAR VAR NU...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
s = input() n = [int(i) for i in input().split()] p = [int(i) for i in input().split()] item = ["B", "S", "C"] r = int(input()) freq = {"B": 0, "S": 0, "C": 0} for i in s: try: freq[i] += 1 except: freq[i] = 1 count = 0 frac = 101 for i in range(3): if freq[item[i]]: frac = min(frac,...
ASSIGN VAR FUNC_CALL VAR ASSIGN 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 STRING STRING STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBE...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
def process(key, a, b, p, k, n): nc = [(b[i] - a[i] * key) for i in range(n)] c = 0 for i in range(n): if nc[i] < 0: c += p[i] * nc[i] * -1 k -= c if k >= 0: return True else: return False def bin_src(a, b, p, n, k, lo, hi): while hi - lo > 1: mi...
FUNC_DEF ASSIGN VAR BIN_OP VAR VAR BIN_OP VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR BIN_OP BIN_OP VAR VAR VAR VAR NUMBER VAR VAR IF VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUN...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
def boleh(mid, recipe_B, recipe_C, recipe_S): need_B = max(recipe_B * mid - have_B, 0) need_S = max(recipe_S * mid - have_S, 0) need_C = max(recipe_C * mid - have_C, 0) total = need_B * price_B + need_S * price_S + need_C * price_C if rubles >= total: return True return False recipe = ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR IF VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR ASS...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
s = input() m = list(map(int, input().split())) c = list(map(int, input().split())) cur = int(input()) p = [0] * 3 p[0] = s.count("B") p[1] = s.count("S") p[2] = s.count("C") def posb(t): x = 0 x += max(0, c[0] * (p[0] * t - m[0])) x += max(0, c[1] * (p[1] * t - m[1])) x += max(0, c[2] * (p[2] * t - m...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FUNC_CALL VAR STRING ASSIGN VAR NUMBER FUNC_CALL VAR STRING ASSIGN ...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
strs = input() rb = 0 rs = 0 rc = 0 for i in strs: if i == "B": rb += 1 if i == "S": rs += 1 if i == "C": rc += 1 temparr = input() temparr = temparr.split() kb = int(temparr[0]) ks = int(temparr[1]) kc = int(temparr[2]) temparr = input() temparr = temparr.split() cb = int(temparr[0]...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUM...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
s = input() nb, ns, nc = map(int, input().split()) pb, ps, pc = map(int, input().split()) cost = int(input()) s = list(s) cb = s.count("B") cs = s.count("S") cc = s.count("C") def pos(m): br = max(0, cb * m - nb) sa = max(0, cs * m - ns) ch = max(0, cc * m - nc) ct = br * pb + sa * ps + ch * pc if...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING FUNC_DEF ...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
recipe = input() k_lst = [int(x) for x in input().split(" ")] p_lst = [int(x) for x in input().split(" ")] r = int(input()) recipe_lst = [recipe.count("B"), recipe.count("S"), recipe.count("C")] number, cost, test2 = 0, 0, 0 test = True for i in range(3): if recipe_lst[i] > 0: test2 += 1 cost += recipe_...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VA...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
s = list(input()) nb, ns, nc = map(int, input().split()) pb, ps, pc = map(int, input().split()) m = int(input()) l, r = 0, 10**14 + 1 while l < r: mid = (l + r) // 2 cost1 = max(0, (mid * s.count("B") - nb) * pb) cost2 = max(0, (mid * s.count("S") - ns) * ps) cost3 = max(0, (mid * s.count("C") - nc) * p...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER BIN_OP BIN_OP NUMBER NUMBER NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VA...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
s1 = input() b = 0 s = 0 c = 0 for i in range(0, len(s1)): if s1[i] == "B": b += 1 elif s1[i] == "S": s += 1 else: c += 1 n1, n2, n3 = map(int, input().split()) p1, p2, p3 = map(int, input().split()) r = int(input()) l1 = [b, s, c] l2 = [n1, n2, n3] l3 = [p1, p2, p3] i = 0 while i < ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASS...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
st = input() B = st.count("B") S = st.count("S") C = st.count("C") b, s, c = map(int, input().split()) bp, sp, cp = map(int, input().split()) r = int(input()) lm = 0 rm = int(1000000000000000.0) + 1 while rm - lm > 1: m = (rm + lm) // 2 bb = max(m * B - b, 0) ss = max(m * S - s, 0) cc = max(m * C - c, 0...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FU...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
def main(): s = input() x, y, z = map(int, input().split()) p1, p2, p3 = map(int, input().split()) a = s.count("B") b = s.count("S") c = s.count("C") r = int(input()) low = 1 high = 10**18 while low < high: mid = (low + high) // 2 cost = ( max(0, (mid ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR ...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
lecept = input() n = list(map(int, input().split())) p = list(map(int, input().split())) money = int(input()) b = lecept.count("B") s = lecept.count("S") c = lecept.count("C") def need(m): need_b = m * b need_s = m * s need_c = m * c need_buy_b = need_b - n[0] need_buy_s = need_s - n[1] need_b...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING FUNC_DEF ASSIGN VAR BIN_OP...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
st = input() a = [int(i) for i in input().split()] d = [int(i) for i in input().split()] p = int(input()) def f(x): dop = 0 if a[0] < b * x: dop += (b * x - a[0]) * d[0] if a[1] < s * x: dop += (s * x - a[1]) * d[1] if a[2] < c * x: dop += (c * x - a[2]) * d[2] return dop ...
ASSIGN VAR FUNC_CALL VAR ASSIGN 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 FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER IF VAR NUMBER BIN_OP VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER VAR NUMBER IF VAR NUMBER BIN_OP VAR VAR VA...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
import sys lines = sys.stdin.readlines() burger = lines[0].strip() count = [0, 0, 0] for l in burger: if l == "B": count[0] += 1 elif l == "S": count[1] += 1 else: count[2] += 1 have = list(map(int, lines[1].strip().split(" "))) price = list(map(int, lines[2].strip().split(" "))) mo...
IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR LIST NUMBER NUMBER NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER NUMBER IF VAR STRING VAR NUMBER NUMBER VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR F...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
def check(m): need = [h[0] * m, h[1] * m, h[2] * m] need[0], need[1], need[2] = need[0] - N[0], need[1] - N[1], need[2] - N[2] calc = 0 if need[0] > 0: calc += need[0] * P[0] if need[1] > 0: calc += need[1] * P[1] if need[2] > 0: calc += need[2] * P[2] if calc <= r: ...
FUNC_DEF ASSIGN VAR LIST BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER NUMBER VAR BIN_O...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
def check(x): b = max(0, x * cb - nb) * pb c = max(0, x * cc - nc) * pc s = max(0, x * cs - ns) * ps temp = b + c + s if temp <= money: return True else: return False recipe = input() nb, ns, nc = map(int, input().split()) pb, ps, pc = map(int, input().split()) money = int(inpu...
FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR IF VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR ASS...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
3 def readln(): return tuple(map(int, input().split())) cb = cs = cc = 0 for c in list(input()): if c == "B": cb += 1 if c == "S": cs += 1 if c == "C": cc += 1 nb, ns, nc = readln() pb, ps, pc = readln() (p,) = readln() a = 0 b = 10**15 while b - a > 1: m = a + b >> 1 ...
EXPR NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN V...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
S = input() n1, n2, n3 = map(int, input().split()) p1, p2, p3 = map(int, input().split()) r = int(input()) m1, m2, m3 = S.count("B"), S.count("S"), S.count("C") L = 0 R = 10000000000000 while L < R: mid = (L + R + 1) // 2 fee = ( max(0, mid * m1 - n1) * p1 + max(0, mid * m2 - n2) * p2 + ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR AS...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
s = input() n = list(map(int, input().split())) r = list(map(int, input().split())) mon = int(input()) di = {} di["B"] = 0 di["S"] = 0 di["C"] = 0 for i in s: di[i] = di[i] + 1 db = di["B"] ds = di["S"] dc = di["C"] nb = n[0] ns = n[1] nc = n[2] sub = di["B"] * r[0] sus = di["S"] * r[1] suc = di["C"] * r[2] su = su...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR STRING NUMBER ASSIGN VAR STRING NUMBER ASSIGN VAR STRING NUMBER FOR VAR VAR ASSIGN VAR VAR BIN_...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
h = input() c = h.count("B"), h.count("S"), h.count("C") n = list(map(int, input().split())) p = list(map(int, input().split())) r = int(input()) a, b = 0, 10**15 while a + 1 < b: x = (a + b) // 2 y = sum(max(0, x * c[i] - n[i]) * p[i] for i in range(3)) if y <= r: a = x else: b = x prin...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER BIN_OP NUMBER NUMBER WHILE...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
def Divide(a, b): if b == 0: return 10**100 return a // b def main(): s = input() Nb, Ns, Nc = map(int, input().split()) Pb, Ps, Pc = map(int, input().split()) r = int(input()) B = s.count("B") S = s.count("S") C = s.count("C") needed = B * Pb + C * Pc + S * Ps ans ...
FUNC_DEF IF VAR NUMBER RETURN BIN_OP NUMBER NUMBER RETURN BIN_OP VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
s = input() nb, ns, nc = map(int, input().split()) pb, ps, pc = map(int, input().split()) r = int(input()) d = {"B": 0, "S": 0, "C": 0} for c in s: d[c] += 1 db, ds, dc = d["B"], d["S"], d["C"] f = ( lambda x: max(0, x * db - nb) * pb + max(0, x * ds - ns) * ps + max(0, x * dc - nc) * pc ) a, b = 0, 100...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR VAR STRING VAR STRING VAR STRI...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
from sys import exit recipe = list(input()) enoughFridge = True breadNum, sausageNum, cheeseNum = map(int, input().split()) fridgeNum = [breadNum, sausageNum, cheeseNum] breadCost, sausageCost, cheeseCost = map(int, input().split()) costs = [breadCost, sausageCost, cheeseCost] cheapest = min(costs) money = int(input()...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
b, s, c = 0, 0, 0 for i in input(): if i == "B": b += 1 elif i == "S": s += 1 else: c += 1 nb, ns, nc = list(map(int, input().split())) pb, ps, pc = list(map(int, input().split())) money = int(input()) num = nb if not b == 0: num = min(num, nb // b) if not c == 0: num = min(n...
ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN V...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
st = input() nb, ns, nc = map(int, input().split()) pb, ps, pc = map(int, input().split()) r = int(input()) b = 0 s = 0 c = 0 for char in st: if char == "B": b += 1 elif char == "S": s += 1 else: c += 1 def bin_search(mid): reqb = b * mid - nb reqc = c * mid - nc reqs =...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER VAR NUMBER FUNC_DE...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
s = input().rstrip() nBread, nSausage, nCheese = map(int, input().split()) priceBread, priceSausage, priceCheese = map(int, input().split()) money = int(input()) def canBuy(n): cost = ( max(needBread * n - nBread, 0) * priceBread + max(needSausage * n - nSausage, 0) * priceSausage + max(ne...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP BIN_OP BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR NUMBER VAR BIN_OP FUNC_CALL VAR BIN_OP BIN_...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
s = list(input()) a = [s.count(c) for c in "BSC"] n = list(map(int, input().split())) p = list(map(int, input().split())) t = int(input()) l = 0 r = 10**13 while l + 1 < r: mid = (l + r) // 2 c = 0 for i in range(3): c += p[i] * max(a[i] * mid - n[i], 0) if c > t: r = mid else: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER WHILE BIN_OP VAR N...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
res = input() nb, ns, nc = map(int, input().split(" ")) pb, ps, pc = map(int, input().split(" ")) ru = int(input()) cb, cs, cc = 0, 0, 0 for i in res: if i == "B": cb += 1 elif i == "S": cs += 1 elif i == "C": cc += 1 l = 0 r = 10**16 - 1 while r - l > 1: z = (r + l) // 2 a =...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER IF VAR STRING VAR ...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
def result(): input1 = input() list1 = [0] * 3 for i in input1: if i == "B": list1[0] += 1 elif i == "S": list1[1] += 1 elif i == "C": list1[2] += 1 for i in range(3): if list1[i] == 0: list1[i] = 1e-19 list2 = list(map(...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER NUMBER IF VAR STRING VAR NUMBER NUMBER IF VAR STRING VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIG...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
s = input() a, b, c = map(int, input().split()) ca, cb, cc = map(int, input().split()) r = int(input()) apu = s.count("B") bpu = s.count("S") cpu = s.count("C") def calc(n): return ( max((n * apu - a) * ca, 0) + max((n * bpu - b) * cb, 0) + max((n * cpu - c) * cc, 0) ) mx = r mn = 0 ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING FUNC_DEF RETURN BIN_OP BIN_OP FUNC_CAL...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
g = input() b, s, c = list(map(int, input().split())) m_b, m_s, m_c = list(map(int, input().split())) money = int(input()) b1 = g.count("B") s1 = g.count("S") c1 = g.count("C") total = 0 if max(b, s, c) > max(b1, s1, c1): while True: v1 = b - b1 v2 = s - s1 v3 = c - c1 if min(v1, v2,...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
recipe = input() nb, ns, nc = map(int, input().split()) pb, ps, pc = map(int, input().split()) r = int(input()) c = {} c["B"] = c["S"] = c["C"] = 0 for x in recipe: c[x] += 1 bb = 1000000000000 if not c["B"] else nb // c["B"] bs = 1000000000000 if not c["S"] else ns // c["S"] bc = 1000000000000 if not c["C"] else n...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR STRING VAR STRING VAR STRING NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR STRING NUMBER BIN_OP VAR VAR ...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
s = input() b, s, c = s.count("B"), s.count("S"), s.count("C") n1, n2, n3 = map(int, input().split()) p1, p2, p3 = map(int, input().split()) m = int(input()) u1, u2, u3 = 0, 0, 0 if b: u1 = n1 // b else: p1 = 0 if s: u2 = n2 // s else: p2 = 0 if c: u3 = n3 // c else: p3 = 0 maxx = max(u1, u2, u3...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER IF VAR ASSIG...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
strng = input() nb, ns, nc = map(int, input().split()) pb, ps, pc = map(int, input().split()) r = int(input()) b, s, c = 0, 0, 0 for i in strng: if i == "B": b += 1 elif i == "S": s += 1 elif i == "C": c += 1 else: 1 // 0 ans = 0 while nb > 0 or ns > 0 or nc > 0: cost...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER EXPR BI...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
st = input() b = 0 s = 0 c = 0 count = 0 for i in range(len(st)): if st[i] == "B": b += 1 elif st[i] == "S": s += 1 elif st[i] == "C": c += 1 aval = list(map(int, input().split())) prices = list(map(int, input().split())) rubies = int(input()) if b == 0: aval[0] = 0 prices[0]...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
def scan(type): return list(map(type, input().split())) (string,) = scan(str) nb, ns, nc = scan(int) pb, ps, pc = scan(int) (r,) = scan(int) b = s = c = 0 for char in string: if char == "B": b += 1 if char == "S": s += 1 if char == "C": c += 1 ans = 0 if b == 0: nb = 0 if s...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER ASS...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
inf = 100000000000000 ch = input() B = sum(x == "B" for x in ch) S = sum(x == "S" for x in ch) C = sum(x == "C" for x in ch) a = [int(x) for x in input().split()] nb = a[0] ns = a[1] nc = a[2] a = [int(x) for x in input().split()] pb = a[0] ps = a[1] pc = a[2] if B == 0: pb = 0 B = 1 nb = inf if S == 0: ...
ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR STRING VAR VAR ASSIGN VAR FUNC_CALL VAR VAR STRING VAR VAR ASSIGN VAR FUNC_CALL VAR VAR STRING VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL V...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
recipe = input() needs = [0, 0, 0] has = list(map(int, input().split())) prices = list(map(int, input().split())) r = int(input()) res = 10**100 for ch in recipe: if ch == "B": needs[0] += 1 elif ch == "S": needs[1] += 1 else: needs[2] += 1 low = 0 high = 10**20 while low < high: ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER NUMBER IF VAR ST...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
h = input() h_c = [h.count("B"), h.count("S"), h.count("C")] al = [*map(int, input().split())] pr = [*map(int, input().split())] su = int(input()) l = 0 r = 10**16 while l < r: v = 0 m = (l + r) // 2 v += max(0, (m * h_c[0] - al[0]) * pr[0]) v += max(0, (m * h_c[1] - al[1]) * pr[1]) v += max(0, (m *...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER WHILE VAR V...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
st = input() b, s, c = map(int, input().split()) pb, ps, pc = map(int, input().split()) r = int(input()) rb = rs = rc = 0 lo = 0 hi = int(10000000000000.0) for i in range(len(st)): if st[i] is "B": rb = rb + 1 if st[i] is "S": rs = rs + 1 if st[i] is "C": rc = rc + 1 for i in range(7...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
def check(x): bread_cost = max(0, recipe[0] * x - has_b) * price_b sausage_cost = max(0, recipe[1] * x - has_s) * price_s cheese_cost = max(0, recipe[2] * x - has_c) * price_c cost = bread_cost + sausage_cost + cheese_cost return cost <= money s_recipe = input() has_b, has_s, has_c = map(int, inpu...
FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR RETURN VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
ingrs = list(input()) able = list(map(int, input().split())) prices = list(map(int, input().split())) money = int(input()) B = ingrs.count("B") S = ingrs.count("S") C = ingrs.count("C") def check(k): p = money p -= max(k * B - able[0], 0) * prices[0] p -= max(k * S - able[1], 0) * prices[1] p -= max(k...
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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING FUNC_DEF ASS...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
D = {"B": 0, "S": 0, "C": 0} str = input() D["B"] = str.count("B") D["S"] = str.count("S") D["C"] = str.count("C") P = {"B": 0, "S": 0, "C": 0} nb, ns, nc = map(int, input().split()) N = {"B": nb, "S": ns, "C": nc} P["B"], P["S"], P["C"] = map(int, input().split()) r = int(input()) start = [] if D["B"] != 0: start....
ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR STRING FUNC_CALL VAR STRING ASSIGN VAR STRING FUNC_CALL VAR STRING ASSIGN VAR STRING FUNC_CALL VAR STRING ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR A...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
def price(x): return ( max(0, x * req[0] - a[0]) * cost[0] + max(0, x * req[1] - a[1]) * cost[1] + max(0, x * req[2] - a[2]) * cost[2] ) def main(): low = 0 high = r + 1000 ans = 0 while low <= high: mid = (low + high) // 2 c = price(mid) if c ==...
FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER VAR NUMBER BIN_OP FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER VAR NUMBER BIN_OP FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMB...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
def checker(h): cost_b = max(0, (tb * h - n[0]) * p[0]) cost_s = max(0, (ts * h - n[1]) * p[1]) cost_c = max(0, (tc * h - n[2]) * p[2]) return cost_b + cost_s + cost_c <= r recipe = input() n = [int(i) for i in input().split()] p = [int(i) for i in input().split()] r = int(input()) tb, ts, tc = recipe...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER VAR NUMBER RETURN BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
t = input() n = list(map(int, input().split())) p = list(map(int, input().split())) q = [t.count("B"), t.count("S")] q.append(len(t) - q[0] - q[1]) n = [n[i] for i in range(3) if q[i]] p = [p[i] for i in range(3) if q[i]] q = [q[i] for i in range(3) if q[i]] m = len(q) r = int(input()) k = [(n[i] // q[i]) for i in rang...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR STRING FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR FUNC_CA...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
def burger(recipe, quantity, price, coins): cb = recipe.count("B") cs = recipe.count("S") cc = recipe.count("C") if cb == 0: quantity[0] = 0 if cs == 0: quantity[1] = 0 if cc == 0: quantity[2] = 0 ans = 0 while True: if quantity[0] >= cb and quantity[1] >=...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF VAR NUMBER ASSIGN VAR NUMBER NUMBER IF VAR NUMBER ASSIGN VAR NUMBER NUMBER IF VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR VAR ...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
import sys input = lambda: sys.stdin.readline().strip() s = input() rb = s.count("B") rs = s.count("S") rc = s.count("C") nb, ns, nc = [int(x) for x in input().split()] pb, ps, pc = [int(x) for x in input().split()] r = int(input()) def bsearch(L, R, can, left_feasible=True): while R - L > 1: M = L + (R ...
IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FU...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
s = input() B, S, C = 0, 0, 0 for i in s: if i == "B": B += 1 if i == "S": S += 1 if i == "C": C += 1 a, b, c = list(map(int, input().split())) pa, pb, pc = list(map(int, input().split())) money = int(input()) k = 0 lbound = -1 hbound = 10**20 for i in range(1000): mid = (hbound ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CA...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
s = input() lis = [0] * 3 for i in s: if i == "B": lis[0] += 1 elif i == "S": lis[1] += 1 else: lis[2] += 1 nb, ns, nc = map(int, input().split()) pb, ps, pc = map(int, input().split()) rup = int(input()) l = 0 r = 2000000000000 while l <= r: mid = l + (r - l) // 2 cost = ( ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER NUMBER IF VAR STRING VAR NUMBER NUMBER VAR NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASS...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
ham = input() n = list(map(int, input().split())) p = list(map(int, input().split())) r = int(input()) hm = {"B": 0, "S": 0, "C": 0} for i in ham: hm[i] += 1 hm = list(hm.values()) def func(x): money_left = r for i in range(len(n)): temp = (hm[i] * x - n[i]) * p[i] if temp > 0: ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VA...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
burger = input() b = burger.count("B") s = burger.count("S") c = burger.count("C") nb, ns, nc = map(int, input().split()) pb, ps, pc = map(int, input().split()) money = int(input()) def ok(target): costB = max(0, (target * b - nb) * pb) costS = max(0, (target * s - ns) * ps) costC = max(0, (target * c - n...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR NUMB...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
def cost(burgers, receipt, n, p): return sum([(max(burgers * receipt[i] - n[i], 0) * p[i]) for i in range(3)]) s = input() receipt = s.count("B"), s.count("S"), s.count("C") n = tuple(map(int, input().split())) p = tuple(map(int, input().split())) r = int(input()) left = -1 right = 10**15 while left < right - 1: ...
FUNC_DEF RETURN FUNC_CALL VAR BIN_OP FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR NUMBER VAR VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
import sys inf = float("inf") def get_array(): return list(map(int, sys.stdin.readline().strip().split())) def get_ints(): return map(int, sys.stdin.readline().strip().split()) def input(): return sys.stdin.readline().strip() def check(n): required = ( max(0, mydict["B"] * n - nb) * pb ...
IMPORT ASSIGN VAR FUNC_CALL VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP BIN_OP BIN_OP FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR STRING VAR ...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
s1 = input() nb = 0 ns = 0 nc = 0 for i in s1: if i == "B": nb += 1 elif i == "C": nc += 1 else: ns += 1 b, s, c = map(int, input().split()) pb, ps, pc = map(int, input().split()) tr = int(input()) tc = nb * pb + nc * pc + ns * ps l = 0 r = int(1000000000000.0) + 1 l = -1 r = int(100...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN ...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
def main(): s = input() recipe = {c: s.count(c) for c in "BSC"} count = dict(zip("BSC", map(int, input().split()))) price = dict(zip("BSC", map(int, input().split()))) for c in recipe: if not recipe[c]: recipe[c], count[c], price[c] = 1, 10**13, 0 r = int(input()) x, y, z...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR NUMBER BIN_O...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
def solution(): s = input() nb, ns, nc = map(int, input().split()) pb, ps, pc = map(int, input().split()) p = int(input()) l = 0 r = 10**14 B = 0 S = 0 C = 0 for i in range(len(s)): if s[i] == "B": B += 1 elif s[i] == "C": C += 1 el...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
s = input() fb = 0 fs = 0 fc = 0 for c in s: if c == "B": fb += 1 elif c == "S": fs += 1 else: fc += 1 nb, ns, nc = [int(i) for i in input().split()] pb, ps, pc = [int(i) for i in input().split()] fp = int(input()) INT_MX = 10**12 + 101 rb = INT_MX rs = INT_MX rc = INT_MX lb = INT_MX...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
recipe = input() nb, ns, nc = map(int, input().split()) pb, ps, pc = map(int, input().split()) all_money = int(input()) have = {} for c in recipe: if not c in have: have[c] = 1 else: have[c] += 1 def can(x): b, s, c = 0, 0, 0 cur_money = 0 if "B" in have: b = have["B"] * x ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER FUNC_DEF ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER ASSIGN VA...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
a = input() s = [a.count("B"), a.count("S"), a.count("C")] b = list(map(int, input().split())) c = list(map(int, input().split())) d = int(input()) l = 0 r = d + max(b) + 1 while r - l > 1: v = (r + l) // 2 if ( max(0, v * s[0] - b[0]) * c[0] + max(0, v * s[1] - b[1]) * c[1] + max(0, v *...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP ...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
recipe = input() b = recipe.count("B") s = recipe.count("S") c = recipe.count("C") n_b, n_s, n_c = map(int, input().split()) p_b, p_s, p_c = map(int, input().split()) price = int(input()) l = 0 r = 100000000000000 while r - l > 1: ans = (r + l) // 2 if ( max(0, ans * b - n_b) * p_b + max(0, ans ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WH...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
rec = input() b, s, c = 0, 0, 0 for i in rec: if i == "B": b += 1 elif i == "S": s += 1 else: c += 1 nb, ns, nc = [int(i) for i in input().split()] pb, ps, pc = [int(i) for i in input().split()] r = int(input()) one = b * pb + s * ps + c * pc ans = 999999999999999999999 if b != 0: ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BI...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
k = [(0) for x in range(3)] for i in input(): if i == "B": k[0] += 1 elif i == "S": k[1] += 1 else: k[2] += 1 n = [int(i) for i in input().split()] p = [int(i) for i in input().split()] N = int(input()) left = 0 right = 0 for i in range(3): if k[i] != 0: if (n[i] + N // p...
ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR IF VAR STRING VAR NUMBER NUMBER IF VAR STRING VAR NUMBER NUMBER VAR NUMBER NUMBER ASSIGN 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 FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER AS...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
def price(x): return ( max(0, r_b * x - n_b) * p_b + max(0, r_s * x - n_s) * p_s + max(0, r_c * x - n_c) * p_c ) recipe = input().strip() r_b, r_s, r_c = recipe.count("B"), recipe.count("S"), recipe.count("C") n_b, n_s, n_c = map(int, input().split()) p_b, p_s, p_c = map(int, input().s...
FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
rec = input() n = [int(x) for x in input().split()] p = [int(x) for x in input().split()] rb = rec.count("B") rs = rec.count("S") rc = rec.count("C") nb, ns, nc = n[0], n[1], n[2] pb, ps, pc = p[0], p[1], p[2] rub = int(input()) l = 0 r = 10**14 while l < r: mid = (l + r) // 2 costb = max(0, (mid * rb - nb) * p...
ASSIGN VAR FUNC_CALL VAR ASSIGN 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 FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER VAR...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
def main(): s = input() a = b = c = 0 for elem in s: if elem == "B": a += 1 elif elem == "S": b += 1 else: c += 1 na, nb, nc = map(int, input().split()) pa, pb, pc = map(int, input().split()) k = int(input()) l = 0 r = 10**13 ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER IF VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN V...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
f = {"B": 0, "S": 0, "C": 0} for c in input(): f[c] = f.get(c, 0) + 1 b, s, c = map(int, input().split()) pb, ps, pc = map(int, input().split()) tot = int(input()) def can(x): nb = f["B"] * x - b ns = f["S"] * x - s nc = f["C"] * x - c nb = max(nb, 0) ns = max(ns, 0) nc = max(nc, 0) co...
ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_O...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
import sys t = 1 def func(x, lst, a): cb = max(0, lst[0] * x - lst[3]) * lst[6] cc = max(0, lst[2] * x - lst[5]) * lst[8] cs = max(0, lst[1] * x - lst[4]) * lst[7] if a >= cb + cc + cs: return True else: return False for ___ in range(t): st = input() nb, ns, nc = map(int...
IMPORT ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR VAR NUMBER VAR NUMBER IF VAR BIN_OP BI...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
def solution1(recipe, storage, price, r): for i in range(3): if recipe[i] == 0: recipe[i] = 1 price[i] = 0 burgers = min(storage[i] // recipe[i] for i in range(3)) storage = [(storage[i] - burgers * recipe[i]) for i in range(3)] while any(storage): quantity = [max...
FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR VAR BIN_OP VAR VAR VAR VAR FUNC_CALL VAR NUMBER WHILE FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR VAR VA...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
def f(tar, l, p, r): req = 0 for i in range(len(l)): if p[i][1] == 0: pass elif l[i] // p[i][1] < tar: req += p[i][1] * p[i][0] * tar - p[i][0] * l[i] if req <= r: return True else: return False s = input() a, b, c = map(int, input().split()) x, ...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER NUMBER IF BIN_OP VAR VAR VAR VAR NUMBER VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR VAR NUMBER VAR BIN_OP VAR VAR NUMBER VAR VAR IF VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR F...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
dic = {"B": 0, "S": 0, "C": 0} s = input() for i in range(len(s)): dic[s[i]] += 1 a, b, c = map(int, input().split()) pa, pb, pc = map(int, input().split()) money = int(input()) def cost(x): return ( pa * max(dic["B"] * x - a, 0) + pb * max(dic["S"] * x - b, 0) + pc * max(dic["C"] * x ...
ASSIGN VAR DICT STRING STRING STRING NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN B...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
t = input() n = list(map(int, input().split())) p = list(map(int, input().split())) r = int(input()) q = [t.count("B"), t.count("S")] q.append(len(t) - q[0] - q[1]) n = [n[i] for i in range(3) if q[i]] p = [p[i] for i in range(3) if q[i]] q = [q[i] for i in range(3) if q[i]] m = len(q) a = min(n[i] // q[i] for i in ran...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR STRING FUNC_CALL VAR STRING EXPR FUNC_CALL VAR BIN_OP BIN_OP FUNC_CALL VAR VAR VAR NUMBER VA...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
_receipt = input() _receipt = { "B": _receipt.count("B"), "S": _receipt.count("S"), "C": _receipt.count("C"), } _at_kitchen = list(map(int, input().split())) _at_kitchen = {"B": _at_kitchen[0], "S": _at_kitchen[1], "C": _at_kitchen[2]} _prices = list(map(int, input().split())) _prices = {"B": _prices[0], "S...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT STRING STRING STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT STRING STRING STRING VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
s = input() nb, ns, nc = map(int, input().split()) pb, ps, pc = map(int, input().split()) n = int(input()) b = 0 ss = 0 c = 0 for i in range(len(s)): if s[i] == "B": b += 1 if s[i] == "C": c += 1 if s[i] == "S": ss += 1 def check(m): B = m * b S = m * ss C = m * c n...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR NUMBER IF VAR VAR ...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
import sys def hamburguers2(ing, kit, prices, munny): ham_ing = {} pieces = {"B": kit[0], "S": kit[1], "C": kit[2]} prices = {"B": prices[0], "S": prices[1], "C": prices[2]} for char in ing: if char not in ham_ing: ham_ing[char] = 1 else: ham_ing[char] += 1 ...
IMPORT FUNC_DEF ASSIGN VAR DICT ASSIGN VAR DICT STRING STRING STRING VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR DICT STRING STRING STRING VAR NUMBER VAR NUMBER VAR NUMBER FOR VAR VAR IF VAR VAR ASSIGN VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR LIST FOR VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
def check(x, N, P, r, s): cb = s.count("B") cs = s.count("S") cc = s.count("C") b_need = max(0, cb * x - N[0]) s_need = max(0, cs * x - N[1]) c_need = max(0, cc * x - N[2]) cost = b_need * P[0] + c_need * P[2] + s_need * P[1] r -= cost if r < 0: return False return True ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BI...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
def possible(n, money): if n * B > nB: money = money - pB * (n * B - nB) if n * C > nC: money = money - pC * (n * C - nC) if n * S > nS: money = money - pS * (n * S - nS) if money < 0: return False else: return True hb = str(input()) B = hb.count("B") C = hb...
FUNC_DEF IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR VAR IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR VAR IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR VAR IF VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR F...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
def bin(a, b, c, n, m, k, pn, pm, pk, r): [L, R] = [0, (r + n + m + k) * 100] while R - L > 1: M = (R + L) // 2 a2 = max(M * a - n, 0) b2 = max(M * b - m, 0) c2 = max(M * c - k, 0) if a2 * pn + b2 * pm + c2 * pk <= r: L = M else: R = M ...
FUNC_DEF ASSIGN LIST VAR VAR LIST NUMBER BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR V...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
inStr = None nList = None pList = None r = None pptList = None def calPrice(count, pt, n): price = pt * count - n return price if price > 0 else 0 def isEnough(count): needList = [calPrice(count, pt, n) for pt, n in zip(pptList, nList)] needMoney = sum([(nl * pr) for nl, pr in zip(needList, pList)])...
ASSIGN VAR NONE ASSIGN VAR NONE ASSIGN VAR NONE ASSIGN VAR NONE ASSIGN VAR NONE FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR RETURN VAR NUMBER VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR FUNC_CALL VAR VAR VAR RETURN VAR VAR FUNC...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
receipt = input() rec = [0, 0, 0] for ing in receipt: if ing == "B": rec[0] += 1 elif ing == "S": rec[1] += 1 else: rec[2] += 1 nb, ns, nc = map(int, input().split()) pb, ps, pc = map(int, input().split()) r = int(input()) k = min( nb // rec[0] if rec[0] else 1000000000.0, ns...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER FOR VAR VAR IF VAR STRING VAR NUMBER NUMBER IF VAR STRING VAR NUMBER NUMBER VAR NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASS...
Polycarpus loves hamburgers very much. He especially adores the hamburgers he makes with his own hands. Polycarpus thinks that there are only three decent ingredients to make hamburgers from: a bread, sausage and cheese. He writes down the recipe of his favorite "Le Hamburger de Polycarpus" as a string of letters 'B' (...
recipe = input() nb, ns, nc = map(int, input().split(" ")) pb, ps, pc = map(int, input().split(" ")) rubles = int(input()) BREAD, SAUSAGE, CHEESE = recipe.count("B"), recipe.count("S"), recipe.count("C") left, right = 0, 10000000000000 while left < right: mid = (left + right + 1) // 2 bread = max(mid * BREAD - ...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER NUMBER WHILE VAR...
Read problems statements [Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. Chef is a cook and he has recently opened a restaurant. The restaurant is open during $N$ time intervals $[L_{1}, R_{1}), [L_{2}, R_{2}), \dots, [L_{N}, R_{N})$. No two of these intervals overlap — formally, for each valid $...
class point: def __init__(self, a, b): self.st = a self.en = b def f(p): return p.st t = int(input()) for _ in range(t): n, m = map(int, input().split()) points = [] for i in range(n): a, b = map(int, input().split()) temp = point(a, b) points.append(temp...
CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF RETURN VAR 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 LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR V...
Read problems statements [Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. Chef is a cook and he has recently opened a restaurant. The restaurant is open during $N$ time intervals $[L_{1}, R_{1}), [L_{2}, R_{2}), \dots, [L_{N}, R_{N})$. No two of these intervals overlap — formally, for each valid $...
def binary_search(a, m): start = 0 end = len(a) - 1 mid = 0 while start <= end: mid = (start + end) // 2 if m >= a[mid][0] and m < a[mid][1]: return 0 elif m == a[mid][1]: if mid == len(a) - 1: return -1 else: re...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR NUMBER VAR VAR VAR NUMBER RETURN NUMBER IF VAR VAR VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER RETURN NUMBER RETURN BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR I...
Read problems statements [Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. Chef is a cook and he has recently opened a restaurant. The restaurant is open during $N$ time intervals $[L_{1}, R_{1}), [L_{2}, R_{2}), \dots, [L_{N}, R_{N})$. No two of these intervals overlap — formally, for each valid $...
from sys import stdin, stdout input = stdin.readline def binarySearch(arr, p): n = len(arr) low = 0 high = n - 1 ans = -1 while high >= low: mid = (low + high) // 2 l, r = arr[mid] if p >= l and p < r: return 0 elif p < l: high = mid - 1 ...
ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR VAR IF VAR VAR VAR VAR RETURN NUMBER IF VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR BIN_...
Read problems statements [Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. Chef is a cook and he has recently opened a restaurant. The restaurant is open during $N$ time intervals $[L_{1}, R_{1}), [L_{2}, R_{2}), \dots, [L_{N}, R_{N})$. No two of these intervals overlap — formally, for each valid $...
def binsearch(x): l = 0 r = len(times) while l < r: i = (l + r) // 2 ele = times[i] if x >= ele[1]: l = i + 1 elif x < ele[0]: r = i elif x in range(ele[0], ele[1]): return 0 if ele[0] - x > 0: return ele[0] - x elif...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR IF VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR IF VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER RETURN NUMBER IF BIN_OP VAR NUMBER VAR NUMBER RETURN BIN_OP VAR NUMB...
Read problems statements [Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. Chef is a cook and he has recently opened a restaurant. The restaurant is open during $N$ time intervals $[L_{1}, R_{1}), [L_{2}, R_{2}), \dots, [L_{N}, R_{N})$. No two of these intervals overlap — formally, for each valid $...
t = int(input()) for k in range(t): n, m = input().split() n, m = int(n), int(m) inv = [] for i in range(n): l, r = input().split() inv.append([int(l), int(r)]) def f(x): return x[0] inv = sorted(inv, key=f) for i in range(m): q = int(input()) if q >...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR LIST FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_DEF RETURN VAR NUMB...
Read problems statements [Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. Chef is a cook and he has recently opened a restaurant. The restaurant is open during $N$ time intervals $[L_{1}, R_{1}), [L_{2}, R_{2}), \dots, [L_{N}, R_{N})$. No two of these intervals overlap — formally, for each valid $...
def ChefRes(TimeIntervals, n, m): for i in range(m): x = int(input()) start = 0 end = 2 * n - 1 if x <= TimeIntervals[start]: print(TimeIntervals[start] - x) continue elif x >= TimeIntervals[end]: print(-1) continue else...
FUNC_DEF FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VA...
Read problems statements [Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. Chef is a cook and he has recently opened a restaurant. The restaurant is open during $N$ time intervals $[L_{1}, R_{1}), [L_{2}, R_{2}), \dots, [L_{N}, R_{N})$. No two of these intervals overlap — formally, for each valid $...
def bSearch(i, j, arr, x): ans = -1 while i <= j: mid = (i + j) // 2 if x < arr[mid][1]: if arr[mid][0] <= x: ans = 0 return ans else: ans = arr[mid][0] - x j = mid - 1 else: i = mid + 1 ...
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR NUMBER IF VAR VAR NUMBER VAR ASSIGN VAR NUMBER RETURN VAR ASSIGN VAR BIN_OP VAR VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC...
Read problems statements [Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. Chef is a cook and he has recently opened a restaurant. The restaurant is open during $N$ time intervals $[L_{1}, R_{1}), [L_{2}, R_{2}), \dots, [L_{N}, R_{N})$. No two of these intervals overlap — formally, for each valid $...
t = int(input()) def lowerbound(intervals, ass): s = 0 e = len(intervals) - 1 lower_bound = -1 while s <= e: mid = (s + e) // 2 if intervals[mid][0] <= ass: s = mid + 1 else: lower_bound = mid e = mid - 1 return lower_bound if lower_bound...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR NUMBER VAR FUNC_CALL VAR VAR FOR ...
Read problems statements [Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. Chef is a cook and he has recently opened a restaurant. The restaurant is open during $N$ time intervals $[L_{1}, R_{1}), [L_{2}, R_{2}), \dots, [L_{N}, R_{N})$. No two of these intervals overlap — formally, for each valid $...
def check(l, val): if l[0][0] > val: print(l[0][0] - val) return elif l[-1][1] <= val: print(-1) return else: start = 0 end = len(l) - 1 while start <= end: mid = (start + end) // 2 if l[mid][0] <= val and l[mid][1] > val: ...
FUNC_DEF IF VAR NUMBER NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER VAR RETURN IF VAR NUMBER NUMBER VAR EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR NUMBER VAR VAR VAR NUMBER VAR EXPR FUNC_CALL VA...
Read problems statements [Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. Chef is a cook and he has recently opened a restaurant. The restaurant is open during $N$ time intervals $[L_{1}, R_{1}), [L_{2}, R_{2}), \dots, [L_{N}, R_{N})$. No two of these intervals overlap — formally, for each valid $...
def waitTime(timeIV, N, P): low, high = 0, N - 1 ans = -1 while low <= high: mid = low + (high - low) // 2 if timeIV[mid][1] > P: ans = mid high = mid - 1 else: low = mid + 1 if ans == -1: return ans return max(0, timeIV[ans][0] - P...
FUNC_DEF ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR NUMBER VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR NUMBER BIN_OP VAR VAR NUMBER VAR FUNC_DEF EXPR ...
Read problems statements [Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. Chef is a cook and he has recently opened a restaurant. The restaurant is open during $N$ time intervals $[L_{1}, R_{1}), [L_{2}, R_{2}), \dots, [L_{N}, R_{N})$. No two of these intervals overlap — formally, for each valid $...
for _ in range(int(input())): N, M = map(int, input().split()) l = [] for j in range(N): L, R = list(map(int, input().split())) l.append(L) l.append(R) l.sort() for i in range(0, M): p = int(input()) if p < l[0]: print(l[0] - p) continu...
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 LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR AS...
Read problems statements [Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. Chef is a cook and he has recently opened a restaurant. The restaurant is open during $N$ time intervals $[L_{1}, R_{1}), [L_{2}, R_{2}), \dots, [L_{N}, R_{N})$. No two of these intervals overlap — formally, for each valid $...
def chefRest(timings, personTime, n): high = n - 1 low = 0 while low <= high: mid = low + (high - low) // 2 if timings[mid][0] <= personTime <= timings[mid][1]: if timings[mid][0] <= personTime < timings[mid][1]: return 0 elif mid == n - 1: ...
FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR NUMBER VAR VAR VAR NUMBER IF VAR VAR NUMBER VAR VAR VAR NUMBER RETURN NUMBER IF VAR BIN_OP VAR NUMBER RETURN NUMBER RETURN BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR IF VAR VAR VAR NUMBER ASS...