description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis! The computers bought for the room were different. Some of them had only USB ...
def r(): return list(map(int, input().split())) n, ans = 0, 0 a, b, c = r() m = int(input()) tt = [] for i in range(m): val, port = input().split() val = int(val) if port[0] is "U": tt.append([val, 1]) else: tt.append([val, 0]) tt.sort(key=lambda x: x[0]) tt2 = [] for x, y in tt: ...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER STRING EXPR FUNC_CALL V...
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis! The computers bought for the room were different. Some of them had only USB ...
a, b, c = map(int, input().split()) m = int(input()) u = [] p = [] x = 0 y = 0 for i in range(m): s = input().split() if s[1] == "USB": u.append(int(s[0])) else: p.append(int(s[0])) u.sort() p.sort() u.reverse() p.reverse() while u and a: a -= 1 y += u[-1] u.pop() x += 1 whil...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CA...
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis! The computers bought for the room were different. Some of them had only USB ...
USB = [] PS2 = [] u, p, b = map(int, input().split()) m = int(input()) for _ in range(m): a, s = input().split() if s[0] == "U": USB += [int(a)] else: PS2 += [int(a)] USB.sort() PS2.sort() ans = 0 n1 = min(u, len(USB)) n2 = min(p, len(PS2)) both = sorted(USB[n1:] + PS2[n2:]) print(n1 + n2 + ...
ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER STRING VAR LIST FUNC_CALL VAR VAR VAR LIST FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR...
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis! The computers bought for the room were different. Some of them had only USB ...
a, b, c = map(int, input().split()) n = int(input()) u, p = [], [] for i in range(n): v, t = input().split() v = int(v) if t[0] == "U": u.append(v) else: p.append(v) u = sorted(u) p = sorted(p) s = 0 mod = [] k = 0 if len(u) < a: s += sum(u) k += len(u) else: s += sum(u[:a]) ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIG...
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis! The computers bought for the room were different. Some of them had only USB ...
import sys a, b, c = map(int, next(sys.stdin).split()) mouses = {"USB": [], "PS/2": []} for _ in range(int(input())): value, key = next(sys.stdin).strip().split() mouses[key].append(int(value)) for key in mouses.keys(): mouses[key].sort() usb, ps = min(a, len(mouses["USB"])), min(b, len(mouses["PS/2"])) re...
IMPORT ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR ASSIGN VAR DICT STRING STRING LIST LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC...
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis! The computers bought for the room were different. Some of them had only USB ...
u, p, b = map(int, input().split()) t = int(input()) usb = [] ps2 = [] for i in range(t): val = input().split() if val[1] == "USB": usb.append(int(val[0])) else: ps2.append(int(val[0])) c = 0 s = 0 usb.sort(reverse=True) ps2.sort(reverse=True) leu = len(usb) lep = len(ps2) j = 0 for i in ran...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ...
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis! The computers bought for the room were different. Some of them had only USB ...
from sys import stdin __author__ = "zihaozhu" USBOnly, UpsOnly, either = map(int, stdin.readline().split()) options = int(stdin.readline().rstrip()) usb = [] ups = [] for i in range(options): ip = stdin.readline().split() if ip[1] == "USB": usb.append(int(ip[0])) else: ups.append(int(ip[0])...
ASSIGN VAR STRING ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR V...
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis! The computers bought for the room were different. Some of them had only USB ...
a, b, c = list(map(int, input().split())) M = int(input()) usb = [] ps = [] for i in range(0, M): t, m = input().split() t = int(t) if m[0] == "U": usb.append(t) else: ps.append(t) usb.sort() ps.sort() num = 0 cost = 0 hu = 0 hp = 0 tu = len(usb) tp = len(ps) def chku(): return hu ...
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 LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR F...
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis! The computers bought for the room were different. Some of them had only USB ...
a, b, c = map(int, input().split()) m = int(input()) d = {"USB": [], "PS/2": []} for _ in range(m): v, t = input().split() d[t].append(int(v)) d["PS/2"].sort() d["USB"].sort() eq = cst = f1 = f2 = 0 nusb = len(d["USB"]) nps2 = len(d["PS/2"]) while a > 0 and f1 < nusb: a -= 1 eq += 1 cst += d["USB"][...
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 LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR STRING ASSIGN VAR VAR VAR VAR...
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis! The computers bought for the room were different. Some of them had only USB ...
u, p, b = tuple(map(int, input().split())) n = int(input()) equiped = 0 fullPrice = 0 arrusb = [] arrpc2 = [] for k in range(n): price, mtype = tuple(input().split()) if mtype == "USB": arrusb.append(int(price)) else: arrpc2.append(int(price)) arrusb.sort() arrpc2.sort() bcounter = 0 pcounte...
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 NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR IF VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUN...
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis! The computers bought for the room were different. Some of them had only USB ...
MAXINT = 10**10 a, b, c = map(int, input().split()) (m,) = map(int, input().split()) usb, ps2 = [], [] for _ in range(m): v, tp = input().split() if tp == "USB": usb.append(int(v)) else: ps2.append(int(v)) usb.sort() ps2.sort() ui, pi = 0, 0 un, pn = len(usb), len(ps2) usb.append(MAXINT) ps2...
ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR ...
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis! The computers bought for the room were different. Some of them had only USB ...
a, b, c = list(map(int, input().split())) m = int(input()) usb = [] ps = [] cost = 0 for i in range(m): ca, t = list(input().split()) ca = int(ca) if t == "USB": usb.append(ca) else: ps.append(ca) usb.sort() ps.sort() usb_c = len(usb) ps_c = len(ps) j = 0 i = 0 ec = 0 while i < usb_c and...
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 LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_C...
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis! The computers bought for the room were different. Some of them had only USB ...
comp = [] ind = input().split() for i in range(3): comp.append(int(ind[i])) USB = [] PS2 = [] for i in range(int(input())): a = input().split() if a[1] == "PS/2": PS2.append(int(a[0])) else: USB.append(int(a[0])) USB.sort() PS2.sort() usb = min(comp[0], len(USB)) ps2 = min(comp[1], len(P...
ASSIGN VAR LIST ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VA...
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis! The computers bought for the room were different. Some of them had only USB ...
a, b, c = map(int, input().split()) m = int(input()) usb = [] ps2 = [] cost = 0 for _ in range(m): s = input().split() if s[1] == "USB": usb.append(int(s[0])) else: ps2.append(int(s[0])) usb.sort() ps2.sort() u = len(usb) p = len(ps2) x = min(a, u) y = min(b, p) t = x + y cost = sum(usb[:x])...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ...
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis! The computers bought for the room were different. Some of them had only USB ...
a, b, c = map(int, input().split()) m = int(input()) dct = {} if m == 0: print(0, 0) exit() for _ in range(m): i, j = input().split() if j in dct.keys(): dct[j].append(int(i)) else: dct[j] = [int(i)] lst1 = ["USB", "PS/2"] for i in lst1: if i not in dct.keys(): dct[i] = [...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR ...
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis! The computers bought for the room were different. Some of them had only USB ...
import sys a, b, c = map(int, sys.stdin.readline().split()) m = int(sys.stdin.readline()) num_item = 0 cost = 0 usb_l = [] ps2_l = [] for i in range(m): val, type_p = sys.stdin.readline().split() val = int(val) if type_p[0] == "U": usb_l.append(val) else: ps2_l.append(val) usb_l.sort() ...
IMPORT 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 LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER STRING EXPR FUNC_CALL VAR VAR EXPR FU...
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis! The computers bought for the room were different. Some of them had only USB ...
from sys import stdin, stdout usb, ps2, both = map(int, stdin.readline().split()) challengersu = [] challengersp = [] ind1 = 0 ind2 = 0 n = int(stdin.readline()) for i in range(n): price, s = stdin.readline().split() if s == "USB": challengersu.append(int(price)) else: challengersp.append(i...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR...
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis! The computers bought for the room were different. Some of them had only USB ...
a, b, c = list(map(int, input().split())) m = int(input()) USB = [] PS = [] i2 = 0 i1 = 0 ans1 = 0 ans2 = 0 for i in range(m): n, k = input().split() if k == "USB": USB.append(int(n)) else: PS.append(int(n)) USB.sort() PS.sort() for i in range(a): if i >= len(USB): break ans1...
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 LIST ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR STRING EXPR FUNC_CALL VAR FUNC...
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis! The computers bought for the room were different. Some of them had only USB ...
z, b, c = map(int, input().split()) m = int(input()) a = [] for _ in range(m): x, y = input().split() if y == "USB": a.append([int(x), 1]) else: a.append([int(x), 2]) cost = ans = 0 a.sort() for i in a: if i[1] == 1: if z: z -= 1 ans += 1 cost ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR STRING EXPR FUNC_CALL VAR LIST FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR LIST FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER EXPR ...
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis! The computers bought for the room were different. Some of them had only USB ...
a, b, c = input().split() a, b, c = int(a), int(b), int(c) usb = "USB" ps2 = "PS/2" u = [] ps = [] n = int(input()) while n > 0: cost, s = input().split() if s == usb: u.append(int(cost)) elif s == ps2: ps.append(int(cost)) n -= 1 u.sort() ps.sort() cost, count = 0, 0 a_curr, ps_curr = 0...
ASSIGN VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR STRING ASSIGN VAR STRING ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL V...
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis! The computers bought for the room were different. Some of them had only USB ...
from sys import stdin A, B, C = list(map(int, stdin.readline().split())) M = int(stdin.readline()) usb_mouses = [] ps2_mouses = [] for m in range(M): p, t = stdin.readline().split() if t == "USB": usb_mouses.append(int(p)) elif t == "PS/2": ps2_mouses.append(int(p)) usb_mouses.sort() ps2_mo...
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 LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FU...
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis! The computers bought for the room were different. Some of them had only USB ...
a, b, c = map(int, input().split()) m = int(input()) usb = [] ps = [] count = 0 for _ in range(m): x, y = input().split() if y == "USB": usb.append(int(x)) else: ps.append(int(x)) usb.sort() ps.sort() ans = 0 usbc = 0 psc = 0 if a > len(usb): ans += sum(usb) usbc = len(usb) count...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VA...
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis! The computers bought for the room were different. Some of them had only USB ...
c = list(map(int, input().split())) m = int(input()) a = [] for i in range(m): n, t = input().split() a.append((int(n), int(t == "PS/2"))) a.sort() res = 0 b = [0] * 3 for n, t in a: if c[t] - b[t] > 0: b[t] += 1 res += n elif c[2] - b[2] > 0: b[2] += 1 res += n print(sum...
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 FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMB...
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis! The computers bought for the room were different. Some of them had only USB ...
a, b, c = (int(i) for i in input().split()) m = int(input()) l1 = [] l2 = [] c1, c2 = 0, 0 c3 = 0 s = 0 for i in range(m): x, y = (i for i in input().split()) if y == "USB": l1.append(int(x)) c1 += 1 else: l2.append(int(x)) c2 += 1 l1.sort() l2.sort() i1, i2 = 0, 0 while m > ...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR...
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis! The computers bought for the room were different. Some of them had only USB ...
a, b, c = map(int, input().split()) n = int(input()) mice_usb = [] mice_ps = [] for i in range(n): price, mice_type = input().split() if mice_type[0] == "U": mice_usb.append(int(price)) else: mice_ps.append(int(price)) usb = min(len(mice_usb), a) ps2 = min(len(mice_ps), b) mice_usb.sort() mi...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUN...
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis! The computers bought for the room were different. Some of them had only USB ...
a, b, c = map(int, input().split()) m = int(input()) s1 = [list(map(str, input().split())) for i in range(m)] for x in s1: x[0] = int(x[0]) s1 = sorted(s1) k = 0 s = 0 for x in s1: flag = True if x[1] == "USB": if a > 0: flag = False k += 1 a -= 1 s +=...
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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR FUNC_CALL VAR VAR FOR VAR VAR ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR...
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis! The computers bought for the room were different. Some of them had only USB ...
def list_from_input(): return list(map(int, input().split())) class Mouse: def __init__(self, price, type): self.type = type self.price = price @classmethod def from_input(cls): mouse_data = input().split() price = int(mouse_data[0]) type = mouse_data[1][0] ...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER RETURN FUNC_CALL VAR VAR VAR VAR FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC...
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis! The computers bought for the room were different. Some of them had only USB ...
inputLine = input().split() pcU = int(inputLine[0]) pcP = int(inputLine[1]) pcUP = int(inputLine[2]) priceList1 = [] priceList2 = [] readSize = int(input()) for i in range(readSize): tmpList = input().split() if tmpList[1] == "USB": priceList1.append(int(tmpList[0])) else: priceList2.append(...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER STRING EXPR FUNC_CALL VAR FUNC_...
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis! The computers bought for the room were different. Some of them had only USB ...
def calc(a, b, c, p): s = 0 comp = 0 for k, v in p: if a > 0 or b > 0 or c > 0: if "USB" == v and (a > 0 or c > 0): if a > 0: comp += 1 a -= 1 elif c > 0: comp += 1 c -= 1 ...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR IF VAR NUMBER VAR NUMBER VAR NUMBER IF STRING VAR VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR IF STRING VAR VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUM...
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis! The computers bought for the room were different. Some of them had only USB ...
from sys import stdin as fin a, b, c = [int(i) for i in input().split()] n = int(input()) usb = [] ps2 = [] for i in range(n): a1, a2 = fin.readline().strip().split() if a2 == "USB": usb.append(int(a1)) else: ps2.append(int(a1)) usb = sorted(usb) ps2 = sorted(ps2) n1 = len(usb) n2 = len(ps2...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR IF VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL ...
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis! The computers bought for the room were different. Some of them had only USB ...
a, b, c = [int(i) for i in input().split()] m = int(input()) u_list = [] p_list = [] for i in range(m): price, port = input().split() price = int(price) if port[0] == "U": u_list.append(price) else: p_list.append(price) u_list_len = len(u_list) p_list_len = len(p_list) u_list = sorted(u_...
ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER STRING EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VA...
Due to the increase in the number of students of Berland State University it was decided to equip a new computer room. You were given the task of buying mouses, and you have to spend as little as possible. After all, the country is in crisis! The computers bought for the room were different. Some of them had only USB ...
a, b, c = list(map(int, input().split())) n, u0, u1 = int(input()), [], [] for i in range(n): e0, e1 = input().split() if e1 == "USB": u0.append(int(e0)) else: u1.append(int(e0)) u0.sort() u1.sort() n = 0 x = 0 if len(u0) > a: x = x + sum(u0[:a]) u0 = u0[a:] n = n + a else: x...
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 LIST LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL V...
This is the easier version of the problem. In this version, $1 \le n \le 10^5$ and $0 \le a_i \le 1$. You can hack this problem only if you solve and lock both problems. Christmas is coming, and our protagonist, Bob, is preparing a spectacular present for his long-time best friend Alice. This year, he decides to prepa...
N = int(input()) A = [int(a) for a in input().split()] X = [-1] * (N + 1) k = 2 while k <= N: X[k] = 1 for i in range(k * 2, N + 1, k): X[i] = 0 while k <= N and X[k] >= 0: k += 1 P = [i for i in range(N + 1) if X[i] == 1] s = sum(A) L = [] for p in P: if s % p == 0: L.append(p) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER WHILE VAR VAR VAR VAR NUMBER VAR NUMBE...
This is the easier version of the problem. In this version, $1 \le n \le 10^5$ and $0 \le a_i \le 1$. You can hack this problem only if you solve and lock both problems. Christmas is coming, and our protagonist, Bob, is preparing a spectacular present for his long-time best friend Alice. This year, he decides to prepa...
PI = 3.141592653589793 INF = float("inf") MOD = 1000000007 def bin32(num): return "{0:032b}".format(num) def add(x, y): return (x + y) % MOD def sub(x, y): return (x - y + MOD) % MOD def mul(x, y): return x * y % MOD def gcd(x, y): if y == 0: return x return gcd(y, x % y) def...
ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FUNC_DEF RETURN FUNC_CALL STRING VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR VAR FUNC_DEF IF VAR NUMBER RETURN VAR RETURN FUNC_CALL VAR VAR BIN_OP VAR VAR FUNC...
This is the easier version of the problem. In this version, $1 \le n \le 10^5$ and $0 \le a_i \le 1$. You can hack this problem only if you solve and lock both problems. Christmas is coming, and our protagonist, Bob, is preparing a spectacular present for his long-time best friend Alice. This year, he decides to prepa...
import sys def getAllFactors(x): factors = [] for i in range(1, int(x**0.5) + 1): if x % i == 0: factors.append(i) if x // i != i: factors.append(x // i) return sorted(factors) def getPrimeFactors(x): primeFacs = [] for f in getAllFactors(x): ...
IMPORT FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR RETURN FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR FUNC_CALL VAR VA...
This is the easier version of the problem. In this version, $1 \le n \le 10^5$ and $0 \le a_i \le 1$. You can hack this problem only if you solve and lock both problems. Christmas is coming, and our protagonist, Bob, is preparing a spectacular present for his long-time best friend Alice. This year, he decides to prepa...
def count(x): ans = 0 for i in range(0, m, x): st = (2 * i + x - 1) // 2 for j in range(i, x + i): ans += abs(a[j] - a[st]) return ans n = int(input()) data = list(map(int, input().split())) a = [] m = 0 for i in range(n): if data[i] == 1: a.append(i) m += 1...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUN...
This is the easier version of the problem. In this version, $1 \le n \le 10^5$ and $0 \le a_i \le 1$. You can hack this problem only if you solve and lock both problems. Christmas is coming, and our protagonist, Bob, is preparing a spectacular present for his long-time best friend Alice. This year, he decides to prepa...
def f(n): minus = n // 2 if n % 2 == 0 else 0 n //= 2 return n * (n + 1) - minus def cal(a, k): ans = 0 cur = 0 for i, x in enumerate(a): if x == 0: ans += min(cur, k - cur) else: cur += 1 return ans + f(k) def uoc(x): i = 1 arr = [] wh...
FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER VAR NUMBER RETURN BIN_OP BIN_OP VAR BIN_OP VAR NUMBER VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR NUMBER RETURN BIN_OP VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR...
This is the easier version of the problem. In this version, $1 \le n \le 10^5$ and $0 \le a_i \le 1$. You can hack this problem only if you solve and lock both problems. Christmas is coming, and our protagonist, Bob, is preparing a spectacular present for his long-time best friend Alice. This year, he decides to prepa...
ret = 0 p = [True] * 100500 for i in range(2, 100300): for j in range(i * i, 100300, i): p[j] = False a = [i for i in range(2, 100001) if p[i]] n = int(input()) b = list(map(int, input().split())) def f(x): sm = 0 ths = 0 chk = [] for i in range(n): if b[i]: sm += 1 ...
ASSIGN VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER NUMBER VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VA...
This is the easier version of the problem. In this version, $1 \le n \le 10^5$ and $0 \le a_i \le 1$. You can hack this problem only if you solve and lock both problems. Christmas is coming, and our protagonist, Bob, is preparing a spectacular present for his long-time best friend Alice. This year, he decides to prepa...
import sys input = sys.stdin.readline n = int(input()) a = list(map(int, input().split())) x = [] c = 0 for i in range(n): if a[i]: x.append(i) c += 1 l = set() for i in range(1, int(c**0.5) + 1): if c % i == 0: l.add(i) l.add(c // i) ans = 10**18 for ll in l: if ll == 1: ...
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 LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR N...
This is the easier version of the problem. In this version, $1 \le n \le 10^5$ and $0 \le a_i \le 1$. You can hack this problem only if you solve and lock both problems. Christmas is coming, and our protagonist, Bob, is preparing a spectacular present for his long-time best friend Alice. This year, he decides to prepa...
from itertools import accumulate def divisors(n): tab = [] for i in range(2, int(n**0.5) + 2): if n % i == 0: while n % i == 0: n //= i tab.append(i) if n > 1: tab.append(n) return tab n = int(input()) a = list(map(int, input().split())) s = su...
FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR VAR NUMBER WHILE BIN_OP VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_C...
This is the easier version of the problem. In this version, $1 \le n \le 10^5$ and $0 \le a_i \le 1$. You can hack this problem only if you solve and lock both problems. Christmas is coming, and our protagonist, Bob, is preparing a spectacular present for his long-time best friend Alice. This year, he decides to prepa...
n = int(input()) a = list(map(int, input().split())) ids = [] for i in range(n): if a[i] == 1: ids.append(i) m = len(ids) sum = m if sum == 1: print(-1) exit() def calculate(inc): ret = 0 for i in range(0, m, inc): mid = (i + (i + inc - 1)) // 2 for j in range(i, i + inc): ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER F...
This is the easier version of the problem. In this version, $1 \le n \le 10^5$ and $0 \le a_i \le 1$. You can hack this problem only if you solve and lock both problems. Christmas is coming, and our protagonist, Bob, is preparing a spectacular present for his long-time best friend Alice. This year, he decides to prepa...
def simple_div(x): if not x & 1: yield 2 while not x & 1: x >>= 1 i = 3 while i * i <= x: if x % i == 0: yield i while x % i == 0: x //= i i += 2 if x != 1: yield x def __main__(): n = int(input()) a = ...
FUNC_DEF IF BIN_OP VAR NUMBER EXPR NUMBER WHILE BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF BIN_OP VAR VAR NUMBER EXPR VAR WHILE BIN_OP VAR VAR NUMBER VAR VAR VAR NUMBER IF VAR NUMBER EXPR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_...
This is the easier version of the problem. In this version, $1 \le n \le 10^5$ and $0 \le a_i \le 1$. You can hack this problem only if you solve and lock both problems. Christmas is coming, and our protagonist, Bob, is preparing a spectacular present for his long-time best friend Alice. This year, he decides to prepa...
def prime(x): if count % x == 0: return True return False n = int(input()) a = list(map(int, input().split())) count = 0 b = [0] for i in range(n): if a[i] == 1: b.append(i + 1) count += 1 jump = 0 i, j, k, add, inc, dj, tera = 0, 0, 0, 0, 0, 0, 0 mini = 999999999999 s = 1 if count...
FUNC_DEF IF BIN_OP VAR VAR NUMBER RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER A...
This is the easier version of the problem. In this version, $1 \le n \le 10^5$ and $0 \le a_i \le 1$. You can hack this problem only if you solve and lock both problems. Christmas is coming, and our protagonist, Bob, is preparing a spectacular present for his long-time best friend Alice. This year, he decides to prepa...
n = int(input()) l = list(map(int, input().split())) s, pref = 0, [] for i in range(n): s += l[i] if l[i]: pref.append(i) if s == 1: print(-1) exit() divs = [s] for i in range(2, int(s**0.5) + 1): if s % i == 0: divs.extend([i, s // i]) ans, value = 10**18, -3 for i in divs: cnt ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER LIST FOR VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR LIST VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP ...
This is the easier version of the problem. In this version, $1 \le n \le 10^5$ and $0 \le a_i \le 1$. You can hack this problem only if you solve and lock both problems. Christmas is coming, and our protagonist, Bob, is preparing a spectacular present for his long-time best friend Alice. This year, he decides to prepa...
n = int(input()) a = list(map(int, input().split())) if sum(a) == 1: print(-1) return sm = sum(a) nmax = 10**5 + 10 eratos = [(0) for i in range(nmax + 1)] prime = [] cnt = 2 while True: while cnt <= nmax and eratos[cnt]: cnt += 1 if cnt > nmax: break eratos[cnt] = 1 prime.append...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR LIST ASSIGN V...
This is the easier version of the problem. In this version, $1 \le n \le 10^5$ and $0 \le a_i \le 1$. You can hack this problem only if you solve and lock both problems. Christmas is coming, and our protagonist, Bob, is preparing a spectacular present for his long-time best friend Alice. This year, he decides to prepa...
n = int(input()) a = [int(x) for x in input().split()] m = 0 b = [] for i in range(n): m += a[i] if a[i] == 1: b.append(i) ans = n * m for i in range(2, m + 1): preans = 0 if m % i != 0: continue c = 0 for j in range(m): wg = j // i * i + i // 2 if j != wg: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR VAR VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR VAR NU...
This is the easier version of the problem. In this version, $1 \le n \le 10^5$ and $0 \le a_i \le 1$. You can hack this problem only if you solve and lock both problems. Christmas is coming, and our protagonist, Bob, is preparing a spectacular present for his long-time best friend Alice. This year, he decides to prepa...
import sys mod = 1000000007 eps = 10**-9 def main(): import sys input = sys.stdin.readline N = int(input()) A = list(map(int, input().split())) S = sum(A) if S == 1: print(-1) exit() div_list = [S] for d in range(2, int(S**0.5) + 1): if S % d == 0: ...
IMPORT ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FUNC_DEF 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 VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR LIST VAR FOR VAR FUNC_CALL ...
This is the easier version of the problem. In this version, $1 \le n \le 10^5$ and $0 \le a_i \le 1$. You can hack this problem only if you solve and lock both problems. Christmas is coming, and our protagonist, Bob, is preparing a spectacular present for his long-time best friend Alice. This year, he decides to prepa...
import sys def prime_decomposition(n): i = 2 table = [] while i * i <= n: while n % i == 0: n //= i table.append(i) i += 1 if n > 1: table.append(n) return table input = sys.stdin.readline N = int(input()) A = list(map(int, input().split())) su = s...
IMPORT FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE BIN_OP VAR VAR VAR WHILE BIN_OP VAR VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN VAR 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...
Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes. The exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the exam at any integer tim...
ssss = int(input()) for _ in range(ssss): n, t, a, b = map(int, input().split()) o = list(map(int, input().split())) s = list(map(int, input().split())) la = sum([(1) for i in o if i == 0]) lb = sum([(1) for i in o if i == 1]) ps = [(o[i], s[i]) for i in range(n)] d = {} cd = {} dla ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR 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 ASSIGN VAR FUNC_CALL VAR NUMBER VAR VAR VAR NUMBER ASSIG...
Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes. The exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the exam at any integer tim...
num_tests = int(input()) for test in range(num_tests): inp = input().rstrip().split(" ") n = int(inp[0]) T = int(inp[1]) a = int(inp[2]) b = int(inp[3]) inp = input().rstrip().split(" ") difficulty = [int(inp[i]) for i in range(len(inp))] inp = input().rstrip().split(" ") mandatory_a...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN ...
Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes. The exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the exam at any integer tim...
res = [] for nt in range(int(input())): n, t, a, b = map(int, input().split()) diff = list(map(int, input().split())) time = list(map(int, input().split())) count = diff.count(0) new = [(time[i], diff[i]) for i in range(n)] new.sort() ans = 0 curr = 0 k = 0 c = 0 while k < le...
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR 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 ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR VAR ...
Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes. The exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the exam at any integer tim...
for _ in range(int(input())): n, t, a, b = map(int, input().split()) pt = [int(o) for o in input().split()] times = [int(o) for o in input().split()] d = dict() for i in range(n): try: d[times[i]].append(pt[i]) except: d[times[i]] = [pt[i]] times = sorted(...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR ASSIG...
Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes. The exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the exam at any integer tim...
import sys t = int(input()) ans = [0] * t for pi in range(t): n, T, a, b = map(int, sys.stdin.readline().split()) a1 = list(map(int, sys.stdin.readline().split())) a2 = list(map(int, sys.stdin.readline().split())) easy_count = a1.count(0) hard_count = n - easy_count tasks = sorted((t, x) for x,...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR 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 ASSIGN VAR FUNC...
Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes. The exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the exam at any integer tim...
import sys input = sys.stdin.readline Q = int(input()) Query = [] for _ in range(Q): N, T, a, b = map(int, input().split()) Es = list(map(int, input().split())) Ts = list(map(int, input().split())) Query.append((N, T, a, b, Es, Ts)) for N, T, a, b, Es, Ts in Query: P = [] remain_a = 0 remai...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR 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 EXPR FUNC_CALL VAR...
Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes. The exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the exam at any integer tim...
m = int(input()) for _ in range(m): n, T, a, b = map(int, input().split()) diff = list(map(int, input().split())) t = list(map(int, input().split())) problem = [] for i in range(n): problem.append((diff[i], t[i])) problem.sort(key=lambda x: x[1]) possible = [0] * (n + 1) easy_cou...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR 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 ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL...
Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes. The exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the exam at any integer tim...
deadline = int(input()) for _ in range(deadline): n, T, a, b = map(int, input().split()) hard = list(map(int, input().split())) time = [(b if h else a) for h in hard] easies = n - sum(hard) deadlines = list(map(int, input().split())) tasks = [(deadlines[i], i) for i in range(n)] tasks.sort()...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL...
Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes. The exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the exam at any integer tim...
import sys def minp(): return sys.stdin.readline().strip() def mint(): return int(minp()) def mints(): return map(int, minp().split()) def solve(): n, T, a, b = mints() h = list(mints()) c = [0, 0] for i in h: c[i] += 1 i = 0 t = [None] * n for j in 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 VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER FOR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR ...
Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes. The exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the exam at any integer tim...
def Input(): tem = input().split() ans = [] for it in tem: ans.append(int(it)) return ans TT = Input()[0] for tt in range(TT): n, T, a, b = Input() pro = Input() t = Input() ma = {} last = [0, 0] for i in range(n): if t[i] not in ma.keys(): ma[t[i]] ...
FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR LIST NUMBER NUMBER FOR VAR F...
Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes. The exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the exam at any integer tim...
for _ in range(int(input())): n, T, A, B = list(map(int, input().split(" "))) level = list(map(int, input().split(" "))) time = list(map(int, input().split(" "))) ques = [[i, j] for i, j in zip(level, time)] tota, totb = 0, 0 for i in ques: if i[0]: totb += 1 else: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST VAR VAR VAR VAR FUNC...
Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes. The exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the exam at any integer tim...
import sys t = int(sys.stdin.readline()) for _ in range(t): n, time, a, b = map(int, sys.stdin.readline().split()) nums = list(map(int, sys.stdin.readline().split())) l = list(map(int, sys.stdin.readline().split())) easy, hard, ans = 0, 0, 0 for i in range(n): if nums[i] == 0: l...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR 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 ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR F...
Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes. The exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the exam at any integer tim...
def case(): n, t, a, b = map(int, input().split()) qtype = list(map(int, input().split())) qtime = list(map(int, input().split())) z = [] easy, hard = 0, 0 for i in range(n): easy += qtype[i] == 0 hard += qtype[i] == 1 z.append([qtime[i], qtype[i]]) z.sort() ans =...
FUNC_DEF ASSIGN VAR VAR 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 ASSIGN VAR LIST ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER VAR VAR VAR NUMBER EXP...
Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes. The exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the exam at any integer tim...
import sys input = sys.stdin.readline for _ in range(int(input())): n, T, a, b = map(int, input().split()) ar = list(map(int, input().split())) tr = list(map(int, input().split())) br = [] easy = 0 hard = 0 for i in range(n): if ar[i] == 0: easy += 1 br.appen...
IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR 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 ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMB...
Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes. The exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the exam at any integer tim...
from sys import stderr m = int(input()) for _ in range(m): n, T, a, b = list(map(int, input().split())) c = [a, b] ty = list(map(int, input().split())) ca = n - sum(ty) cb = n - ca time = list(map(int, input().split())) items = list(zip(time, ty)) items.sort() ans = 0 t = 0 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CAL...
Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes. The exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the exam at any integer tim...
from sys import stdin, stdout m = int(stdin.readline().strip()) for _ in range(m): n, T, a, b = map(int, stdin.readline().split()) diff = list(map(int, stdin.readline().split())) mand = list(map(int, stdin.readline().split())) easy, hard = [], [] for i in range(n): if diff[i]: h...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR 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 ASSIGN VAR VAR LIST LIST FOR VAR FUNC_CALL VAR...
Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes. The exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the exam at any integer tim...
for _ in range(int(input())): n, t, a, b = map(int, input().split()) qi = list(map(int, input().split())) ti = list(map(int, input().split())) e = [] ea = qi.count(0) ha = qi.count(1) for i in range(n): e.append([ti[i], qi[i]]) e.sort() ans = 0 te = 0 s = [0, 0] f...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR 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 ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VA...
Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes. The exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the exam at any integer tim...
case = int(input()) number = [] for i in range(case): c = input() c = c.split() n = int(c[0]) T = int(c[1]) a = int(c[2]) b = int(c[3]) problem = input() problem = list(map(int, problem.split())) time = input() time = list(map(int, time.split())) time_order = sorted(range(len...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR 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 NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL...
Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes. The exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the exam at any integer tim...
m = int(input()) for case_num in range(m): n, T, a, b = map(int, input().split(" ")) d = list(map(int, input().split(" "))) t = list(map(int, input().split(" "))) critical = set() for ti in t: critical.add(ti) if ti >= 1: critical.add(ti - 1) critical.add(T) criti...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FOR VAR VA...
Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes. The exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the exam at any integer tim...
import sys def main(): def calcTotalTime(easyCnts, hardCnts): return a * easyCnts + b * hardCnts m = int(input()) allans = [] for _ in range(m): n, T, a, b = readIntArr() ease = readIntArr() t = readIntArr() et = [] easyCnts = 0 hardCnts = 0 ...
IMPORT FUNC_DEF FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR EXPR ...
Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes. The exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the exam at any integer tim...
m = int(input()) for ii in range(m): n, T, a, b = list(map(int, input().split())) score = [a, b] d = list(map(int, input().split())) t = list(map(int, input().split())) easy = 0 for d1 in d: if d1 == 0: easy += 1 diff = zip(t, d) diff = sorted(diff) cnt = 0 cu...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST 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 NUMBER ...
Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes. The exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the exam at any integer tim...
M = int(input()) def foo(A, B, T, free_easy, free_hard, req_easy, req_hard): ans = 0 T -= req_easy * A + req_hard * B if T < 0: return 0 ans += req_easy + req_hard can_easy = min(free_easy, T // A) ans += can_easy T -= A * can_easy can_hard = min(free_hard, T // B) ans += c...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR IF VAR NUMBER RETURN NUMBER VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR VAR VAR BIN_OP VAR VAR RETURN VAR FUNC_DEF ASSI...
Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes. The exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the exam at any integer tim...
for _ in range(int(input())): n, T, a, b = map(int, input().split()) diff = list(map(int, input().split())) time = list(map(int, input().split())) alla = diff.count(0) allb = n - alla prob = list(zip(time, diff)) prob.sort() cnt = 0 sm = 0 hard_x = 0 easy_x = 0 def calc(...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR 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 ASSIGN VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FU...
Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes. The exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the exam at any integer tim...
import sys input = sys.stdin.readline t = int(input()) for i in range(t): n, T, a, b = map(int, input().split()) level = [int(i) for i in input().split()] time = [int(i) for i in input().split()] diff = zip(time, level) diff = sorted(diff) easy = level.count(0) hard = n - easy if easy *...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL ...
Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes. The exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the exam at any integer tim...
import sys input = sys.stdin.readline def solve(time, measy, mhard, teasy, thard): if measy * a + mhard * b > time: return 0 ret = measy + mhard time -= measy * a + mhard * b x = min(time // a, teasy - measy) ret += x time -= a * x y = min(time // b, thard - mhard) ret += y ...
IMPORT ASSIGN VAR VAR FUNC_DEF IF BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR VAR RETURN NUMBER ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR VAR VAR RETURN VAR ASSIGN V...
Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes. The exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the exam at any integer tim...
M = int(input()) for _ in range(M): n, T, a, b = map(int, input().split()) ns = [(a if x == "0" else b) for x in input().split()] ts = [int(x) for x in input().split()] sort = sorted(list(zip(ns, ts)), key=lambda x: x[1]) ns = [x[0] for x in sort] ts = [x[1] for x in sort] + [T + 1] best = 0...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR STRING 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_CALL VAR VAR VAR VAR NUMBER ASS...
Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes. The exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the exam at any integer tim...
def solve(): nproblems, tottime, a, b = map(int, input().split()) diffls = list(map(int, input().split())) mandls = list(map(int, input().split())) ls = [] for i in range(nproblems): ls.append((mandls[i], diffls[i])) ls.sort() nez = diffls.count(0) mandtime = 0 ptr = 0 ez...
FUNC_DEF ASSIGN VAR VAR 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 ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_...
Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes. The exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the exam at any integer tim...
for t in range(int(input())): n, ti, a, b = map(int, input().split()) aa = list(map(int, input().split())) bb = list(map(int, input().split())) c = [] count_eb = 0 count_hb = 0 count_ef = 0 count_hf = 0 for i in range(n): c.append([bb[i], aa[i]]) if aa[i] == 1: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR 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 ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER A...
Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes. The exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the exam at any integer tim...
t = int(input()) for _ in range(t): n, T, a, b = map(int, input().split()) h1 = [int(x) for x in input().split()] h2 = [int(x) for x in input().split()] h1.append(0) h2.append(T + 1) h = sorted(zip(h2, h1)) c0 = h1.count(0) - 1 c1 = h1.count(1) ans = 0 ptr = 0 man = 0 c =...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FU...
Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes. The exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the exam at any integer tim...
for _ in range(int(input())): n, t, a, b = map(int, input().split()) r = list(map(int, input().split())) s = list(map(int, input().split())) d = dict() hd = 0 es = 0 for i in range(n): if s[i] in d.keys(): d[s[i]][r[i]] += 1 else: d[s[i]] = [0, 0] ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR 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 ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FU...
Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes. The exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the exam at any integer tim...
class questions: def __init__(self, level, req_time): self.level = level self.Ti = req_time for _ in range(int(input())): n, N, a, b = map(int, input().split()) level = list(map(int, input().split())) Ti = list(map(int, input().split())) easy_q = level.count(0) hard_q = level....
CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR 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 ASSIGN VAR FUNC_CALL V...
Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes. The exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the exam at any integer tim...
m = int(input()) for i in range(m): n, T, a, b = list(map(int, input().split())) is_hard = list(map(int, input().split())) total_hard = sum(is_hard) total_easy = n - total_hard time_mandatory = list(map(int, input().split())) mandatory_times = sorted( [(time_mandatory[i], i) for i in ran...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL F...
Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes. The exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the exam at any integer tim...
import sys def input(): return sys.stdin.readline().rstrip() def slv(): n, T, a, b = map(int, input().split()) problem_type = list(map(int, input().split())) reqtime = list(map(int, input().split())) problems = [] all_a, all_b = 0, 0 for i in range(n): if problem_type[i] == 0: ...
IMPORT FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR VAR 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 ASSIGN VAR LIST ASSIGN VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VA...
Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes. The exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the exam at any integer tim...
t = int(input()) for _ in range(t): n, T, a, b = list(map(int, input().split(" "))) task_t = list(map(int, input().split(" "))) ness = list(map(int, input().split(" "))) perm = sorted(list(range(n)), key=lambda i: ness[i]) score = 0 tot_hard = sum(task_t) tot_easy = n - tot_hard must_eas...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL ...
Petya has come to the math exam and wants to solve as many problems as possible. He prepared and carefully studied the rules by which the exam passes. The exam consists of $n$ problems that can be solved in $T$ minutes. Thus, the exam begins at time $0$ and ends at time $T$. Petya can leave the exam at any integer tim...
import sys input = sys.stdin.readline t = int(input()) for testcases in range(t): n, T, a, b = list(map(int, input().split())) A = list(map(int, input().split())) L = list(map(int, input().split())) LCAN = [T] EASY = [] HARD = [] for i in range(n): if A[i] == 0: EASY.app...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR ...
In the game of Mastermind, there are two players — Alice and Bob. Alice has a secret code, which Bob tries to guess. Here, a code is defined as a sequence of n colors. There are exactly n+1 colors in the entire universe, numbered from 1 to n+1 inclusive. When Bob guesses a code, Alice tells him some information about ...
t = int(input()) for q in range(t): n, x, y = map(int, input().split()) Bob = list(map(int, input().split())) Cnt = [[0, i] for i in range(n + 1)] Ans = [-1] * n Occ = [[] for i in range(n + 1)] for i in range(n): Bob[i] -= 1 Cnt[Bob[i]][0] += 1 Occ[Bob[i]].append(i) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR LIST VAR FUNC_CALL ...
You are given an array $a_1, a_2, \dots, a_n$, which is sorted in non-descending order. You decided to perform the following steps to create array $b_1, b_2, \dots, b_n$: Create an array $d$ consisting of $n$ arbitrary non-negative integers. Set $b_i = a_i + d_i$ for each $b_i$. Sort the array $b$ in non-descending ...
t = int(input()) while t: n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) d1 = [0] * n d2 = [0] * n j = n - 1 res = [] for i in range(n - 1, -1, -1): while j >= 0 and b[j] >= a[i]: res.append(b[j]) j -= 1 d1...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER A...
You are given an array $a_1, a_2, \dots, a_n$, which is sorted in non-descending order. You decided to perform the following steps to create array $b_1, b_2, \dots, b_n$: Create an array $d$ consisting of $n$ arbitrary non-negative integers. Set $b_i = a_i + d_i$ for each $b_i$. Sort the array $b$ in non-descending ...
def solve(): n = int(input()) a = list(map(int, input().split())) + [10**10] b = list(map(int, input().split())) + [10**10] min_ = n * [0] max_ = n * [0] r = -1 for i in range(n): while r < n and a[i] > b[r + 1]: r += 1 min_[i] = r + 1 ind = 0 cur = n ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR LIST BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR LIST BIN_OP NUMBER NUMBER ASSIGN VAR BIN_OP VAR LIST NUMBER ASSIGN VAR BIN_OP VAR LIST NUMBER ASSI...
You are given an array $a_1, a_2, \dots, a_n$, which is sorted in non-descending order. You decided to perform the following steps to create array $b_1, b_2, \dots, b_n$: Create an array $d$ consisting of $n$ arbitrary non-negative integers. Set $b_i = a_i + d_i$ for each $b_i$. Sort the array $b$ in non-descending ...
testcases = int(input()) for t in range(testcases): n = int(input()) a = [int(i) for i in input().split()] b = [int(i) for i in input().split()] mini = [] i = 0 for x in a: while x > b[i]: i += 1 mini.append(b[i] - x) maxi = [] j = 0 for k in range(n - 1):...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR VAR WHILE VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP V...
You are given an array $a_1, a_2, \dots, a_n$, which is sorted in non-descending order. You decided to perform the following steps to create array $b_1, b_2, \dots, b_n$: Create an array $d$ consisting of $n$ arbitrary non-negative integers. Set $b_i = a_i + d_i$ for each $b_i$. Sort the array $b$ in non-descending ...
T = int(input()) for _ in range(T): n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) start = end = n - 1 m = [] M = [] for i in range(n - 1, -1, -1): while b[start] >= a[i] and start >= 0: start -= 1 start += 1 m.app...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL...
You are given an array $a_1, a_2, \dots, a_n$, which is sorted in non-descending order. You decided to perform the following steps to create array $b_1, b_2, \dots, b_n$: Create an array $d$ consisting of $n$ arbitrary non-negative integers. Set $b_i = a_i + d_i$ for each $b_i$. Sort the array $b$ in non-descending ...
for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) mini = [0] * n maxi = [0] * n up = 0 down = 0 while up < n and down < n: if b[down] < a[up]: down += 1 else: maxi[up] = b[down] -...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR ...
You are given an array $a_1, a_2, \dots, a_n$, which is sorted in non-descending order. You decided to perform the following steps to create array $b_1, b_2, \dots, b_n$: Create an array $d$ consisting of $n$ arbitrary non-negative integers. Set $b_i = a_i + d_i$ for each $b_i$. Sort the array $b$ in non-descending ...
for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) dp1, dp2 = [0] * n, [0] * n j = 0 for i in range(n): while b[j] < a[i]: j += 1 dp1[i] = b[j] - a[i] j = n - 1 for i in reversed(range(n)): ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP LIST NUMBER VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL ...
You are given an array $a_1, a_2, \dots, a_n$, which is sorted in non-descending order. You decided to perform the following steps to create array $b_1, b_2, \dots, b_n$: Create an array $d$ consisting of $n$ arbitrary non-negative integers. Set $b_i = a_i + d_i$ for each $b_i$. Sort the array $b$ in non-descending ...
def main(): for t in range(int(input())): n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) d1, d2 = [], [] j = 0 for i in range(n): while b[j] < a[i]: j += 1 print(b[j] - a[i], end=" ") ...
FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR LIST LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR WHILE VAR VAR VAR V...
You are given an array $a_1, a_2, \dots, a_n$, which is sorted in non-descending order. You decided to perform the following steps to create array $b_1, b_2, \dots, b_n$: Create an array $d$ consisting of $n$ arbitrary non-negative integers. Set $b_i = a_i + d_i$ for each $b_i$. Sort the array $b$ in non-descending ...
for i in range(int(input())): n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) j = 0 d = [] g = [0] * n for i in range(n): while a[i] > b[j]: j += 1 d.append(b[j] - a[i]) g[n - 1] = b[n - 1] - a[n - 1] j = n - 1 ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR WHI...
You are given an array $a_1, a_2, \dots, a_n$, which is sorted in non-descending order. You decided to perform the following steps to create array $b_1, b_2, \dots, b_n$: Create an array $d$ consisting of $n$ arbitrary non-negative integers. Set $b_i = a_i + d_i$ for each $b_i$. Sort the array $b$ in non-descending ...
import sys input = sys.stdin.readline def solve(): n = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) mi, ma = [], [] f = 0 for i in range(n - 1): if A[i + 1] > B[i]: val = B[i] for j in range(f, i + 1): ma....
IMPORT ASSIGN VAR VAR FUNC_DEF 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 VAR LIST LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR VAR ...
You are given an array $a_1, a_2, \dots, a_n$, which is sorted in non-descending order. You decided to perform the following steps to create array $b_1, b_2, \dots, b_n$: Create an array $d$ consisting of $n$ arbitrary non-negative integers. Set $b_i = a_i + d_i$ for each $b_i$. Sort the array $b$ in non-descending ...
def ss_min(l, a): n = len(l) def ceiling_of_element(x): start = 0 end = n - 1 res = -1 while start <= end: mid = (start + end) // 2 if a[mid] == x: return a[mid] elif x > a[mid]: start = mid + 1 else...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR RETURN VAR VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR VAR ASSIGN VAR LIST FOR V...
You are given an array $a_1, a_2, \dots, a_n$, which is sorted in non-descending order. You decided to perform the following steps to create array $b_1, b_2, \dots, b_n$: Create an array $d$ consisting of $n$ arbitrary non-negative integers. Set $b_i = a_i + d_i$ for each $b_i$. Sort the array $b$ in non-descending ...
def solve(): num = int(input()) l1 = list(map(int, input().split())) l2 = list(map(int, input().split())) ans1 = [] ans2 = [0] * num pointer = 0 for i in l1: while l2[pointer] < i: pointer += 1 ans1.append(l2[pointer] - i) maxx = [] for i in range(num - 1,...
FUNC_DEF 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 LIST ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER FOR VAR VAR WHILE VAR VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR...
You are given an array $a_1, a_2, \dots, a_n$, which is sorted in non-descending order. You decided to perform the following steps to create array $b_1, b_2, \dots, b_n$: Create an array $d$ consisting of $n$ arbitrary non-negative integers. Set $b_i = a_i + d_i$ for each $b_i$. Sort the array $b$ in non-descending ...
import sys def findleastgreater(lst, end, num): l, r = 1, end if lst[0] >= num: return 0 while l < r: mid = l + r >> 1 if lst[mid] >= num and lst[mid - 1] < num: return mid elif lst[mid] >= num: r = mid - 1 else: l = mid + 1 r...
IMPORT FUNC_DEF ASSIGN VAR VAR NUMBER VAR IF VAR NUMBER VAR RETURN NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR VAR BIN_OP VAR NUMBER VAR RETURN VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL...
You are given an array $a_1, a_2, \dots, a_n$, which is sorted in non-descending order. You decided to perform the following steps to create array $b_1, b_2, \dots, b_n$: Create an array $d$ consisting of $n$ arbitrary non-negative integers. Set $b_i = a_i + d_i$ for each $b_i$. Sort the array $b$ in non-descending ...
t = int(input()) while t > 0: n = int(input()) a = [int(x) for x in input().split()] b = [int(x) for x in input().split()] dmin = [] dmax = [] check = [] j = 0 for i in range(n): while a[i] > b[j]: j += 1 check.append(n - j) dmin.append(b[j] - a[i]) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL 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 ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR WHILE VAR VAR VAR V...
You are given an array $a_1, a_2, \dots, a_n$, which is sorted in non-descending order. You decided to perform the following steps to create array $b_1, b_2, \dots, b_n$: Create an array $d$ consisting of $n$ arbitrary non-negative integers. Set $b_i = a_i + d_i$ for each $b_i$. Sort the array $b$ in non-descending ...
t = int(input()) while t > 0: n = int(input()) a = list(map(int, input().split(" "))) b = list(map(int, input().split(" "))) bptr = n - 1 aptr = n - 1 store = [] dmin = [0] * n dmax = [0] * n a_used = 0 while aptr >= 0: while bptr >= 0 and b[bptr] >= a[aptr]: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR LIST ASS...
You are given an array $a_1, a_2, \dots, a_n$, which is sorted in non-descending order. You decided to perform the following steps to create array $b_1, b_2, \dots, b_n$: Create an array $d$ consisting of $n$ arbitrary non-negative integers. Set $b_i = a_i + d_i$ for each $b_i$. Sort the array $b$ in non-descending ...
standard_input = """4 3 2 3 5 7 11 13 1 1000 5000 4 1 2 3 4 1 2 3 4 4 10 20 30 40 22 33 33 55 """ for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) greaterThan = [(0) for _ in range(n)] k = n - 1 for i in range(n - 1, -1, -1): ...
ASSIGN VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FU...
You are given an array $a_1, a_2, \dots, a_n$, which is sorted in non-descending order. You decided to perform the following steps to create array $b_1, b_2, \dots, b_n$: Create an array $d$ consisting of $n$ arbitrary non-negative integers. Set $b_i = a_i + d_i$ for each $b_i$. Sort the array $b$ in non-descending ...
t = int(input()) for i in range(t): n = int(input()) a = list(map(int, input().strip().split())) b = list(map(int, input().strip().split())) i = 0 first = 0 last = n - 1 dmin = [] dmax = [] while i < n: if a[i] <= b[first]: dmin.append(b[first] - a[i]) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMB...