description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
for _ in range(int(input())): p, f = map(int, input().split()) sn, an = map(int, input().split()) s, a = map(int, input().split()) if a < s: s, a = a, s sn, an = an, sn i = 0 ans = 0 while i <= sn and i * s <= p: x = sn - i y = an t = p - i * s ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE ...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
t = int(input()) i = 0 while i < t: pf = list(map(int, input().split())) Q = list(map(int, input().split())) sw = list(map(int, input().split())) p = pf[0] f = pf[1] if sw[0] <= sw[1]: Qs = Q[0] Qw = Q[1] else: Qs = Q[1] Qw = Q[0] s = min(sw) w = max(s...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR 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 VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF V...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
for _ in range(int(input())): n, k = map(int, input().split()) cs, cw = map(int, input().split()) ps, pw = map(int, input().split()) if pw > ps: ps, pw = pw, ps cs, cw = cw, cs ans = 0 mx = 0 for i in range(cs + 1): if i * ps > n: break a = i + min...
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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VA...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
import sys input = sys.stdin.readline for _ in range(int(input())): p, f = map(int, input().split()) c1, c2 = map(int, input().split()) s, w = map(int, input().split()) xx = min(c1, p // s) ans = 0 for i in range(0, xx + 1): tem = 0 cc = p - s * i tem += i axe = ...
IMPORT ASSIGN VAR VAR 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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CA...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
def read_int(): return int(input().strip()) def read_ints(): return list(map(int, input().strip().split())) def read_floats(): return list(map(float, input().strip().split())) def read_str(): return input().strip() def solve_t(): p, f = read_ints() cnt_s, cnt_w = read_ints() s, w = r...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
t = int(input()) for _ in range(t): p, f = map(int, input().split()) cnts, cntw = map(int, input().split()) s, w = map(int, input().split()) ans = 0 if s >= w: pass else: s, w = w, s cnts, cntw = cntw, cnts for i in range(cntw + 1): curp, curf = p, f c...
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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR FOR VAR F...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
import sys sys.setrecursionlimit(10**5) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def MI(): return map(int, sys.stdin.readline().split()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [...
IMPORT EXPR FUNC_CALL VAR BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR STRING FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
gans = [] for _ in range(int(input())): p, f = map(int, input().split()) n, m = map(int, input().split()) s, w = map(int, input().split()) if s > w: s, w = w, s n, m = m, n ans = 0 for i in range(min(n, p // s) + 1): j = min(n - i, f // s) p1 = p - i * s f...
ASSIGN VAR LIST 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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR ...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
from sys import stdin, stdout for _ in range(int(input())): p, f = map(int, input().split()) s, x = map(int, input().split()) sw, xw = map(int, input().split()) if xw < sw: sw, xw = xw, sw s, x = x, s ans = 0 for i in range(s + 1): temp = 0 f1 = f p1 = p ...
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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BI...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
def main(): myCapacity, folCapacity = map(int, input().strip().split()) swords, axes = map(int, input().strip().split()) swordWeight, axeWeight = map(int, input().strip().split()) if swordWeight > axeWeight: swordWeight, axeWeight = axeWeight, swordWeight swords, axes = axes, swords ...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NU...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
t = int(input()) for _ in range(t): P, F = map(int, input().split()) cs, cw = map(int, input().split()) S, W = map(int, input().split()) p = max(P, F) f = min(P, F) s = min(S, W) w = max(S, W) if S > W: cs, cw = cw, cs ans = 0 for i in range(min(cw, p // w) + 1): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CA...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
for i in range(int(input())): p, f = map(int, input().split()) cnt1, cnt2 = map(int, input().split()) s, w = map(int, input().split()) if s > w: s, w = w, s cnt1, cnt2 = cnt2, cnt1 idd1 = min(cnt1, p // s) idd2 = 0 p -= s * idd1 cnt1 -= idd1 if p >= w: idd2 = ...
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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VA...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
import sys def rl(proc=None): if proc is not None: return proc(sys.stdin.readline()) else: return sys.stdin.readline().rstrip() def srl(proc=None): if proc is not None: return list(map(proc, rl().split())) else: return rl().split() def solve(p, f, cs, cw, s, w): ...
IMPORT FUNC_DEF NONE IF VAR NONE RETURN FUNC_CALL VAR FUNC_CALL VAR RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF NONE IF VAR NONE RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BI...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
t = int(input()) for _ in range(t): p, f = map(int, input().split()) cnts, cntw = map(int, input().split()) s, w = map(int, input().split()) p, f = max(p, f), min(p, f) if w < s: cnts, s, cntw, w = cntw, w, cnts, s sNo = p // s + f // s sNo = min(sNo, cnts) best = sNo for i i...
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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR ASSIGN VAR VAR...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
t = int(input()) for qwe in range(t): p, f1 = map(int, input().split()) cs, cw = map(int, input().split()) s, w = map(int, input().split()) ansold = 0 if s > w: s, w = w, s cs, cw = cw, cs pc = p f1c = f1 csc = cs cwc = cw sc = s wc = w for i in range(min(...
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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VA...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
import sys def minp(): return sys.stdin.readline().strip() def mint(): return int(minp()) def mints(): return list(map(int, minp().split())) def check(s, n, v): for i in range(n): if s[i : i + n].count(v) == 0: return False return True def solve(): p, f = mints() ...
IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR BIN_OP VAR VAR VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VA...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
tests = int(input()) answers = [] for _ in range(tests): cap1, cap2 = [int(i) for i in input().split()] n1, n2 = [int(i) for i in input().split()] light, heavy = [int(i) for i in input().split()] if light > heavy: n1, n2 = n2, n1 cap1, cap2 = cap2, cap1 light, heavy = heavy, ligh...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
t = int(input().split()[0]) for i in range(t): [p, f] = [int(x) for x in input().split()] [cs, ca] = [int(x) for x in input().split()] [s, a] = [int(x) for x in input().split()] if s > a: [s, a] = [a, s] [cs, ca] = [ca, cs] best = 0 for p_ns in range(0, min(cs, p // s) + 1): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN LIST VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN LIST VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN LIST VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN LIST VAR VAR LIST VAR ...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
for t in range(int(input())): p, f = list(map(int, input().split())) c_sw, c_ax = list(map(int, input().split())) w_sw, w_ax = list(map(int, input().split())) if w_sw > w_ax: c_sw, c_ax = c_ax, c_sw w_sw, w_ax = w_ax, w_sw ans = 0 for n_sw_p in range(c_sw + 1): n_sw_f = c...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
T = int(input()) for _ in range(0, T): p, f = map(int, input().split()) cs, cw = map(int, input().split()) s, w = map(int, input().split()) ans = 0 for i in range(cs + 1): ks = cs kw = cw P = p F = f ct = 0 if i * s <= P: P -= i * s ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSI...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
t = int(input()) for _ in range(t): p, f = map(int, input().split()) cs, cw = map(int, input().split()) s, w = map(int, input().split()) ans = 0 if w < s: s, w = w, s cs, cw = cw, cs for i in range(cs + 1): count = min(i, p // s) np = p - count * s ns = cs...
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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR FOR VAR F...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
TC = int(input()) while TC > 0: cap = list(map(int, input().split())) cnt = list(map(int, input().split())) wei = list(map(int, input().split())) cap = sorted(cap) if wei[0] > wei[1]: wei[0], wei[1] = wei[1], wei[0] cnt[0], cnt[1] = cnt[1], cnt[0] ans = 0 for x1 in range(cnt[...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR 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 VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR NUMBER ASSIGN VA...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
t = int(input()) for _ in range(t): p, f = map(int, input().split()) cnts, cntw = map(int, input().split()) s, w = map(int, input().split()) num = 0 if s > w: s, w = w, s cnts, cntw = cntw, cnts for i in range(min(p // s, cnts) + 1): t1 = max(p - s * i, 0) t2 = ma...
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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR FOR VAR F...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
mod = 10**9 + 7 def solve(): p, f = map(int, input().split()) cs, cw = map(int, input().split()) s, w = map(int, input().split()) if w < s: w, s = s, w cs, cw = cw, cs ans = 0 for i in range(cs + 1): pp = p ff = f tcs = cs tcw = cw ps = m...
ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL V...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
scan = lambda: map(int, input().split()) for _ in range(int(input())): f, p = scan() cnt_s, cnt_w = scan() s, w = scan() ans = -1 s, w, cnt_s, cnt_w = (w, s, cnt_w, cnt_s) if s > w else (s, w, cnt_s, cnt_w) for i in range(cnt_s + 1): if i * s > p: break swp = i ...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
def answer(p, f, cs, cw, s, w): if max(p, f) >= cs * s + cw * w: return cs + cw elif max(p, f) < min(s, w): return 0 elif s > w: if p // w + f // w > cw: maxi = 0 for i in range(0, cw + 1): count = 0 if p - i * w >= 0: ...
FUNC_DEF IF FUNC_CALL VAR VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR RETURN BIN_OP VAR VAR IF FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR RETURN NUMBER IF VAR VAR IF BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR BIN_OP VAR VAR...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
from sys import stdin, stdout def input(): return stdin.readline().strip() def ans(p, f, cs, cw, s, w): assert s <= w def ok(n): ns = 0 nw = 0 if n <= cs: ns = n nw = 0 else: ns = cs nw = n - cs if not 0 <= ns <= cs...
FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR IF NUMBER VAR VAR RETURN NUMBER IF NUMBER VAR VAR RETURN NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR ...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
for _ in range(int(input())): p, f = map(int, input().split()) sw, ax = map(int, input().split()) s, w = map(int, input().split()) ans = 0 if s > w: s, w = w, s sw, ax = ax, sw for i in range(sw + 1): nf, ns = p, f nf -= i * s if nf < 0: contin...
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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR FOR VAR FUNC_CALL VAR BI...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
t = int(input()) for _ in range(t): p, f = map(int, input().split()) cnt = list(map(int, input().split())) weights = list(map(int, input().split())) if weights[0] > weights[1]: low = 1 else: low = 0 ass = 0 if f > p: p, f = f, p for i in range(min(cnt[low], p // w...
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 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 IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASS...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
def can_do_one_more(p, f, ns, nw, s, w): for fw in range(nw + 1): if fw * w > f: continue fs = (f - fw * w) // s ps = ns - fs pw = nw - fw if ps < 0 or pw < 0 or fs < 0 or fw < 0: continue if ps * s + pw * w <= p and fs * s + fw * w <= f: ...
FUNC_DEF FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR RETURN NUMBER RET...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
def main(): t = int(input()) for i in range(t): max_weights = _read_ints() items_amounts = _read_ints() items_weights = _read_ints() result = compute_max_ingots_n(max_weights, items_amounts, items_weights) print(result) def _read_ints(): return tuple(map(int, input(...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR VAR ASSIGN VAR ...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
for _ in range(int(input())): p, f = map(int, input().split()) cs, cw = map(int, input().split()) s, w = map(int, input().split()) def solve(ps, pw, x, y, p2): if ps > pw: return solve(pw, ps, y, x, p2) if ps * x >= p2: return p2 // ps return x + min((p2 ...
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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR VAR RETURN FUNC_CALL VAR VAR VAR VAR VAR VAR IF BIN_OP VAR VAR VAR RETURN BIN_OP VA...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
import sys T = int(sys.stdin.readline().strip()) for t in range(0, T): p, f = list(map(int, sys.stdin.readline().strip().split())) ns, nw = list(map(int, sys.stdin.readline().strip().split())) s, w = list(map(int, sys.stdin.readline().strip().split())) if s > w: s, w = w, s ns, nw = nw,...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FU...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
def byServant(f, s, sw, a, aw): ans = 0 sICan = f // sw sICan = min(s, sICan) ans += sICan f -= sICan * sw aICan = f // aw aICan = min(aICan, a) ans += aICan return ans t = int(input()) while t: t -= 1 p, f = input().split() p, f = int(p), int(f) s, a = input().spli...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR V...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
for _ in range(int(input())): p, f = [int(j) for j in input().split()] counts, countw = [int(j) for j in input().split()] s, w = [int(j) for j in input().split()] if s > w: g = w w = s s = g g = countw countw = counts counts = g ans = 0 g = p // s ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR A...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
import sys input = sys.stdin.readline def solution(): p, f = map(int, input().split()) cnt_s, cnt_w = map(int, input().split()) s, w = map(int, input().split()) if s > w: s, w = w, s cnt_s, cnt_w = cnt_w, cnt_s ans = 0 for i in range(cnt_s + 1): j = cnt_s - i i...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASS...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
for t in range(int(input())): p, f = map(int, input().split()) cnts, cntw = map(int, input().split()) s, w = map(int, input().split()) if s > w: s, w = w, s cnts, cntw = cntw, cnts ans = 0 for i in range(cnts + 1): ms, fs = i, cnts - i ms = min(ms, p // s) ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BI...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
for _ in range(int(input())): p, f = map(int, input().split()) cnts, cntw = map(int, input().split()) s, w = map(int, input().split()) if s > w: s, w = w, s cnts, cntw = cntw, cnts ans = 0 for i in range(cnts + 1): if i * s > p: break ans_sub = 0 ...
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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BI...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
def maxItem(p, f, cnts, cntw, s, w): if s > w: return maxItem(p, f, cntw, cnts, w, s) if p < f: return maxItem(f, p, cntw, cnts, w, s) ans = 0 for s1 in range(min(cnts, p // s) + 1): w1 = min(cntw, (p - s1 * s) // w) s2 = min(cnts - s1, f // s) w2 = min(cntw - w1,...
FUNC_DEF IF VAR VAR RETURN FUNC_CALL VAR VAR VAR VAR VAR VAR VAR IF VAR VAR RETURN FUNC_CALL VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
t = int(input()) for _ in range(t): p, f = map(int, input().split()) cnt_s, cnt_w = map(int, input().split()) s, w = map(int, input().split()) if s > w: s, w = w, s cnt_s, cnt_w = cnt_w, cnt_s max_s = min(p // s, cnt_s) ans = 0 for x in range(max_s, -1, -1): rest_p = ...
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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BI...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
t = int(input()) for tt in range(t): ss = input().split(" ") p = int(ss[0]) f = int(ss[1]) if p > f: p, f = f, p ss = input().split(" ") cs = int(ss[0]) cw = int(ss[1]) ss = input().split(" ") s = int(ss[0]) w = int(ss[1]) if s > w: s, w = w, s cs, cw ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
for _ in range(int(input())): p, f = map(int, input().split()) cnts, cntw = map(int, input().split()) s, w = map(int, input().split()) scount = min(p // s, cnts) ans = 0 for i in range(scount + 1): tempP = p - i * s temp = i + min(tempP // w, cntw) tempcntS = cnts - i ...
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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMB...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
import sys input = sys.stdin.readline def answer(x, y, f, s, w): total = 0 g1 = min(f // s, x) total += g1 q = f - g1 * s g1 = min(q // w, y) total += g1 return total a = int(input()) for i in range(a): p, f = map(int, input().split()) c1, c2 = map(int, input().split()) s, w...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR 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 V...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
def maximize_items_count(p, f, cnt_s, cnt_w, s, w): if s > w or s == w and cnt_s < cnt_w: cnt_s, cnt_w = cnt_w, cnt_s s, w = w, s max_sum = 0 max_cnt_s = min(cnt_s, p // s + f // s) p_cnt_s = 0 while p_cnt_s <= max_cnt_s: p_cnt_w = (p - s * p_cnt_s) // w f_cnt_w = (f ...
FUNC_DEF IF VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR BIN_OP VAR VAR VAR IF VAR NUMBER V...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
n = int(input()) for i in range(n): play1, play2 = map(int, input().split()) count1, count2 = map(int, input().split()) x, y = map(int, input().split()) l = 0 x1, y1, x2, y2 = 0, 0, 0, 0 ans = 0 if x > y: x, y = y, x count1, count2 = count2, count1 n1 = play1 // x for...
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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMB...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
for _ in range(int(input())): p, f = map(int, input().split()) cs, cw = map(int, input().split()) s, w = map(int, input().split()) if s > w: s, w = w, s cs, cw = cw, cs ans = 0 for i in range(cs + 1): if i <= p // s: pp, ff = p, f pp -= s * i ...
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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BI...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
for t in range(int(input())): p, f = map(int, input().split()) cs, cw = map(int, input().split()) s, w = map(int, input().split()) if s < w: bw = [s, cs] ww = [w, cw] else: bw = [w, cw] ww = [s, cs] tot = p + f hmb = min(tot // bw[0], bw[1]) tot -= hmb * b...
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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR LIST VAR VAR ASSIGN VAR LIST VAR VAR ASSIGN VAR LIST VAR VAR ASSIGN VAR LIST ...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
import sys input = sys.stdin.readline t = int(input()) for _ in range(t): p, f = map(int, input().split()) cs, cw = map(int, input().split()) s, w = map(int, input().split()) if s > w: s, w = w, s cs, cw = cw, cs best = 0 for i in range(cs + 1): if i * s <= p: ...
IMPORT ASSIGN VAR 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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIG...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
for _ in range(int(input())): p, q = map(int, input().split()) aa, bb = map(int, input().split()) a, b = map(int, input().split()) if a > b: a, b = b, a aa, bb = bb, aa count = p // a + q // a if count <= aa: ans = count else: MAX = 0 for i in range(aa...
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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VA...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
T = int(input()) for t in range(T): p, f = map(int, input().split()) cs, cw = map(int, input().split()) s, w = map(int, input().split()) ans = 0 if w < s: cs, cw = cw, cs s, w = w, s ans = 0 for i in range(cs + 1): pp, ff, ccs, ccw = p, f, cs, cw iuses = min(p...
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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VA...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
def solve(a, b, c, d, e, f) -> int: ans = 0 for j in range(0, min(c, a // e) + 1): ans1 = j ans2 = min((a - ans1 * e) // f, d) ans3 = min(c - ans1, b // e) ans4 = min((b - ans3 * e) // f, d - ans2) ans = max(ans, ans1 + ans2 + ans3 + ans4) return ans t = int(input()...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR ASSI...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
tests = int(input()) for t in range(tests): p, f = list(map(int, input().split())) cnt_1, cnt_2 = list(map(int, input().split())) cost_1, cost_2 = list(map(int, input().split())) if cost_1 > cost_2: cnt_1, cnt_2 = cnt_2, cnt_1 cost_1, cost_2 = cost_2, cost_1 max_cap_1 = min(p // cost...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN V...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
def solve(p, f, cnt_s, cnt_w, s, w): if s > w: cnt_s, cnt_w = cnt_w, cnt_s s, w = w, s r = 0 for a in range(cnt_s + 1): if a * s > p: continue b = (p - a * s) // w b = min(b, cnt_w) c = min(f // s, cnt_s - a) d = (f - c * s) // w d ...
FUNC_DEF IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VA...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
num = int(input()) output = [] for i in range(num): p, f = map(int, input().split()) n, m = map(int, input().split()) s, w = map(int, input().split()) max_num = 0 r_all = n, p // s, m, p // w r_min = r_all.index(min(r_all)) t = 1 if r_min < 2 else 0 for i in range(r_all[r_min] + 1): ...
ASSIGN VAR FUNC_CALL VAR 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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR A...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
import sys input = sys.stdin.buffer.readline inin = lambda: int(input()) inar = lambda: list(map(int, input().split())) inst = lambda: input().decode().rstrip("\n\r") _T_ = inin() for _t_ in range(_T_): p, f = inar() cs, cw = inar() s, w = inar() if w < s: s, w = w, s cs, cw = cw, cs ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR IF...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
import sys input = sys.stdin.readline t = int(input()) for _ in range(t): p, f = list(map(int, input().split())) cw, ca = list(map(int, input().split())) ww, wa = list(map(int, input().split())) if ww > wa: ww, wa = wa, ww cw, ca = ca, cw if p // ww + f // ww < cw: ans = p /...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VA...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
tests = int(input()) for t in range(tests): p, f = list(map(int, input().split())) cnt_1, cnt_2 = list(map(int, input().split())) cost_1, cost_2 = list(map(int, input().split())) if cost_1 > cost_2: cnt_1, cnt_2 = cnt_2, cnt_1 cost_1, cost_2 = cost_2, cost_1 max_cap_1 = p // cost_1 +...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN V...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
for tt in range(int(input())): p, f = map(int, input().split()) cnts, cntw = map(int, input().split()) s, w = map(int, input().split()) if s > w: w, s = s, w cnts, cntw = cntw, cnts ans = 0 for i in range(0, cnts + 1): pp, ff, cntss, cntww, ss, ww = p, f, cnts, cntw, s, w...
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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NU...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
for _ in range(int(input())): p, f = map(int, input().split()) cs, cw = map(int, input().split()) s, w = map(int, input().split()) if s > w: s, w = w, s cs, cw = cw, cs P = p // s F = f // s if P + F < cs: print(P + F) else: ans = cs for i in range...
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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_O...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
import sys input = sys.stdin.readline T = int(input()) for t in range(T): P, F = [int(_) for _ in input().split()] cs, cw = [int(_) for _ in input().split()] ws, ww = [int(_) for _ in input().split()] if ww < ws: ws, ww = ww, ws cs, cw = cw, cs capacity = P + F if cs * ws >= cap...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR V...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
for _ in range(int(input())): p, f = map(int, input().split()) cs, cw = map(int, input().split()) s, w = map(int, input().split()) p, f = max(p, f), min(p, f) if w < s: w, s = s, w cw, cs = cs, cw ns = min(p // s, cs) ans = 0 for i in range(0, ns + 1): s1 = i ...
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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
def func(cnts, cntw, s, w, p, f): if s < w: pass else: cnts, cntw = cntw, cnts s, w = w, s ans = 0 for s1 in range(min(cnts, p // s) + 1): s2 = min(cntw, (p - s1 * s) // w) w1 = min(cnts - s1, f // s) w2 = min(cntw - s2, (f - w1 * s) // w) ans = ma...
FUNC_DEF IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
def solve(p, f, ns, na, ws, wa): if ws > wa: ws, wa = wa, ws ns, na = na, ns best = 0 for i in range(ns + 1): mySwordCount = i mySwordCost = i * ws if mySwordCost <= p: rem_p = p - mySwordCost myWarAxeCount = min(rem_p // wa, na) re...
FUNC_DEF IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL V...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
import sys reader = (s.rstrip() for s in sys.stdin) input = reader.__next__ def gift(): for _ in range(t): p, f = list(map(int, input().split())) c1, c2 = list(map(int, input().split())) w1, w2 = list(map(int, input().split())) if w1 > w2: w1, w2 = w2, w1 c...
IMPORT ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FUNC_DEF FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
t = int(input()) for you in range(t): l = input().split() p = int(l[0]) f = int(l[1]) l = input().split() cnts = int(l[0]) cntw = int(l[1]) l = input().split() s = int(l[0]) w = int(l[1]) maxa = [] if s > w: w, s = s, w cnts, cntw = cntw, cnts for i in ran...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
t = int(input()) for i in range(t): p, f = map(int, input().split()) cs, cw = map(int, input().split()) s, w = map(int, input().split()) if w < s: s, w = w, s cs, cw = cw, cs num = 0 ms = p // s for i in range(min(ms, cs) + 1): cnt = i rem = p - i * s ...
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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VA...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
def read(): return list(map(int, input().split())) for _ in range(int(input())): p, f = read() cnts, cntw = read() s, w = read() if s > w: s, w = w, s cnts, cntw = cntw, cnts res = 0 for i in range(min(p // s, cnts) + 1): j = min((p - i * s) // w, cntw) k = ...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CA...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
import sys input = sys.stdin.buffer.readline T = int(input()) for testcase in range(T): p, f = map(int, input().split()) Cs, Cw = map(int, input().split()) s, w = map(int, input().split()) if s > w: s, w = w, s Cs, Cw = Cw, Cs res = 0 for i in range(Cs + 1): if i * s > p...
IMPORT ASSIGN VAR 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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIG...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
def fun2(p, f, s, w, cs, cw): xs = min(cs, f // s) f -= s * xs xw = min(cw, p // w + f // w) return xs + xw def fun(): p, f = map(int, input().split(" ")) cs, cw = map(int, input().split(" ")) s, w = map(int, input().split(" ")) if s > w: s, w = w, s cs, cw = cw, cs ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR RETURN BIN_OP VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR FUNC_CAL...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
t = int(input()) for _ in range(t): p, f = [int(x) for x in input().split()] cs, cw = [int(x) for x in input().split()] s, w = [int(x) for x in input().split()] maxWpCnt = -float("inf") for pcs in range(cs + 1): if pcs * s > p: break pcw = min(cw, (p - pcs * s) // w) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
z = lambda: map(int, input().split()) k = lambda *x: (min(*x), max(*x)) for _ in range(int(input())): p, f = z() x, y = z() s, w = z() a, b = k((s, x), (w, y)) c, d = a[0], b[0] e = p // c + f // c if e <= a[1]: print(e) else: m = 0 for i in range(a[1] + 1): ...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER VAR NUMBER A...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
cases = int(input()) def can_take(s, w, cs, cw, p): if s > w: return can_take(w, s, cw, cs, p) if s * cs >= p: return p // s return cs + min((p - s * cs) // w, cw) while cases: p, f = [int(x) for x in input().split()] cnts, cntw = [int(x) for x in input().split()] s, w = [int...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF IF VAR VAR RETURN FUNC_CALL VAR VAR VAR VAR VAR VAR IF BIN_OP VAR VAR VAR RETURN BIN_OP VAR VAR RETURN BIN_OP VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR VAR VAR VAR WHILE VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
t = int(input()) for case in range(t): p, f = list(map(int, input().split())) cnts, cntw = list(map(int, input().split())) s, w = list(map(int, input().split())) _max = 0 for i in range(min(cnts, p // s) + 1): result = i current_cnts = cnts - i usedw = min((p - i * s) // w, c...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BI...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
t = int(input()) for _ in range(t): p, f = map(int, input().split()) cs, cw = map(int, input().split()) s, w = map(int, input().split()) if s > w: cs, cw = cw, cs s, w = w, s if p // s + f // s <= cs: print(p // s + f // s) else: ans = 0 for i in range(cs ...
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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR IF BIN_OP BIN_OP VAR VAR BI...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
import sys lines = sys.stdin.read().splitlines() lincnt = -1 def input(): global lincnt lincnt += 1 return lines[lincnt] for _ in range(int(input())): p, f = map(int, input().split()) cs, ca = map(int, input().split()) s, a = map(int, input().split()) if s < a: s, a = a, s ...
IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_DEF VAR NUMBER RETURN VAR VAR 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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF V...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
def max_count(cns, s, cnw, w, weight): cs = min(cns, weight // s) weight -= s * cs cw = min(cnw, weight // w) return cs, cw for _ in range(int(input())): p, f = map(int, input().split()) cns, cnw = map(int, input().split()) s, w = map(int, input().split()) if p >= f: if s > w: ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR RETURN VAR VAR 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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL ...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
R = lambda: map(int, input().split()) (t,) = R() for _ in [0] * t: p, f = R() a = R() b = R() (x, a), (y, b) = sorted(zip(b, a)) a = min(a, p // x + f // x) * x print( a // x + min( b, max( (p - u) // y + (f - a + u) // y fo...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR BIN_OP LIST NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
def ints(): return map(int, input().split()) for _ in range(int(input())): p, f = ints() cs, cw = ints() s, w = ints() ans = 0 for i in range(cs + 1): rem = p - i * s if rem < 0: break j = min(cw, rem // w) t1 = i + j ccs = cs - i ccw...
FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
for _ in range(int(input())): p, f = list(map(int, input().split())) cs, cw = list(map(int, input().split())) s, w = list(map(int, input().split())) x = p + f c = 0 fi = 0 la = 0 if s > w: s, w = w, s cs, cw = cw, cs if cs * s < x: fi = cs x -= cs * s ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NU...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
for _ in range(int(input())): player1_capacity, player2_capacity = map(int, input().split()) cnt_s, cnt_w = map(int, input().split()) s, w = map(int, input().split()) objects = [(s, cnt_s), (w, cnt_w)] objects.sort() lighter_weight, lighter_quantity = objects[0] heavier_weight, heavier_quant...
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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR VAR NUM...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
import sys _ord, inp, num, neg, _Index = lambda x: x, [], 0, False, 0 i, s = 0, sys.stdin.buffer.read() try: while True: if s[i] >= b"0"[0]: num = 10 * num + _ord(s[i]) - 48 elif s[i] == b"-"[0]: neg = True elif s[i] != b"\r"[0]: inp.append(-num if neg el...
IMPORT ASSIGN VAR VAR VAR VAR VAR VAR LIST NUMBER NUMBER NUMBER ASSIGN VAR VAR NUMBER FUNC_CALL VAR WHILE NUMBER IF VAR VAR UNKNOWN NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER VAR FUNC_CALL VAR VAR VAR NUMBER IF VAR VAR UNKNOWN NUMBER ASSIGN VAR NUMBER IF VAR VAR UNKNOWN NUMBER EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN V...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
t = int(input()) ans = [] for i in range(t): p, f = map(int, input().split()) cnts, cntw = map(int, input().split()) s, w = map(int, input().split()) max1 = 0 if s < w: for x in range(min(p // w, cntw) + 1): max1 = max( max1, x + mi...
ASSIGN VAR FUNC_CALL VAR 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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL ...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
for _ in range(int(input())): p, f = (int(i) for i in input().split()) cnt_s, cnt_w = (int(i) for i in input().split()) s, w = (int(i) for i in input().split()) if w < s: s, w = w, s cnt_s, cnt_w = cnt_w, cnt_s cap_lowest = p // s + f // s if cap_lowest <= cnt_s: print(ca...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR V...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
for _ in range(int(input())): p, f = map(int, input().split()) cs, cw = map(int, input().split()) s, w = map(int, input().split()) if w < s: cs, cw = cw, cs s, w = w, s maxa = 0 for c in range(min(cs, p // s) + 1): d = min((p - c * s) // w, cw) a = min(cs - c, f /...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BI...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
import sys input = lambda: sys.stdin.readline().strip() t = int(input()) while t: t -= 1 p, f = map(int, input().split()) cnt_s, cnt_w = map(int, input().split()) s, w = map(int, input().split()) ans = 0 if p < f: p, f = f, p if s > w: s, w = w, s cnt_s, cnt_w = cnt_...
IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
tc = int(input()) for _ in range(tc): l1, l2 = [int(x) for x in input().strip().split()] cnt1, cnt2 = [int(x) for x in input().strip().split()] w1, w2 = [int(x) for x in input().strip().split()] diff = abs(w1 - w2) if w1 < w2: smallw = w1 smallc = cnt1 bigw = w2 bigc ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR IF...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
LIGHT = 0 HEAVY = 1 def calc_deep(p, s): res = 0 d_weight = s[HEAVY]["weight"] - s[LIGHT]["weight"] first = True power = p[0] light = min(power // s[LIGHT]["weight"], s[LIGHT]["count"]) power -= light * s[LIGHT]["weight"] heavy = min(power // s[HEAVY]["weight"], s[HEAVY]["count"]) powe...
ASSIGN VAR NUMBER ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR VAR STRING VAR VAR STRING ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR STRING VAR VAR STRING VAR BIN_OP VAR VAR VAR STRING ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR STRING VAR VAR STRING VAR BIN...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
t = int(input()) for _ in range(t): yy, ff = map(int, input().split()) nns, nnw = map(int, input().split()) ws, ww = map(int, input().split()) answers = [] ns = nns nw = nnw y = yy f = ff for i in range(min(ns, y // ws) + 1): ns = nns nw = nnw y = yy f...
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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR FOR VAR ...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
from sys import stdin T = int(stdin.readline().strip()) for caso in range(T): n, m = map(int, stdin.readline().strip().split()) a, b = map(int, stdin.readline().strip().split()) w1, w2 = map(int, stdin.readline().strip().split()) if w2 < w1: x = b b = a a = x x = w2 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASS...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
t = int(input()) for _ in range(t): p, f = [int(i) for i in input().split()] cnt_s, cnt_w = [int(i) for i in input().split()] s, w = [int(i) for i in input().split()] if s < w: s, w = w, s cnt_s, cnt_w = cnt_w, cnt_s max_w = p // w + f // w if max_w <= cnt_w: print(max_w)...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
TC = int(input()) for tc in range(TC): P, F = map(int, input().split()) CS, CW = map(int, input().split()) S, W = map(int, input().split()) if W < S: S, W = W, S CS, CW = CW, CS maxp = P // S maxf = F // S if maxp + maxf <= CS: print(maxp + maxf) continue ...
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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR A...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
t = int(input()) for i in range(t): ca, cb = map(int, input().split()) na, nb = map(int, input().split()) wa, wb = map(int, input().split()) if wa > wb: wa, wb = wb, wa na, nb = nb, na limit = ca // wa def cal(x): res = x cur_a = ca - x * wa y = min(cb //...
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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR F...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
def main(): t = int(input()) for i in range(t): max_weights = _read_ints() items_amounts = _read_ints() items_weights = _read_ints() result = compute_max_ingots_n(max_weights, items_amounts, items_weights) print(result) def _read_ints(): return tuple(map(int, input(...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR VAR ASSIGN VAR ...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
def solve(mid): cs = min(mid, cnt_s) cw = mid - cs for i in range(cs + 1): nokori_p = p - i * s nokori_f = f - (cs - i) * s if nokori_p < 0 or nokori_f < 0: continue if nokori_p // w + nokori_f // w < cw: continue return True return False ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR VAR IF VAR NUMBER VAR NUMBER IF BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
from sys import stdin input = stdin.readline q = int(input()) for _ in range(q): p, f = map(int, input().split()) ns, na = map(int, input().split()) s, a = map(int, input().split()) wynik = 0 for ps in range(ns + 1): if ps * s > p: continue pa = (p - ps * s) // a ...
ASSIGN VAR 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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP V...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
for _ in range(int(input())): p, f = map(int, input().split()) cs, cw = map(int, input().split()) s, w = map(int, input().split()) if s > w: w, s = s, w cs, cw = cw, cs ans = min(p // w + f // w, cw) for i in range(cs): a = min(i + 1, p // s) b = min(cs - a, f // ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
for nt in range(int(input())): p, f = map(int, input().split()) c1, c2 = map(int, input().split()) s, w = map(int, input().split()) p, f = max(p, f), min(p, f) if s > w: w, s = s, w c1, c2 = c2, c1 ans = 0 for i in range(c1 + 1): if i * s <= p: ans = max( ...
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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
T = int(input()) for i in range(T): p, f = map(int, input().split()) cs, cw = map(int, input().split()) s, w = map(int, input().split()) if w < s: cs, cw = cw, cs s, w = w, s P, F, CS, CW, S, W = p, f, cs, cw, s, w PERFECT = False total = 0 taken = min(p // s, cs) cs ...
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 VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR ...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
from sys import stdin for _ in " " * int(stdin.readline()): c1, c2 = map(int, stdin.readline().split()) cnt1, cnt2 = map(int, stdin.readline().split()) w1, w2 = map(int, stdin.readline().split()) ans = 0 for i in range(cnt1 + 1): a1, b1, s = c1, c2, 0 k = min(a1 // w1, i) s ...
FOR VAR BIN_OP STRING FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR VAR NUMBER ASSIGN ...
You are playing one RPG from the 2010s. You are planning to raise your smithing skill, so you need as many resources as possible. So how to get resources? By stealing, of course. You decided to rob a town's blacksmith and you take a follower with you. You can carry at most $p$ units and your follower — at most $f$ uni...
for _ in range(int(input())): n, m = list(map(int, input().split())) a, b = list(map(int, input().split())) s, w = list(map(int, input().split())) if s > w: s, w = w, s a, b = b, a if n < m: n, m = m, n ans = -(10**18) for i in range(a + 1): cnt = 0 nx...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ...