description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Read problems statements [Hindi] ,[Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. Appy loves balloons! She wants you to give her balloons on each of $N$ consecutive days (numbered $1$ through $N$); let's denote the number of balloons Appy wants on day $i$ by $A_{i}$. The problem is that you only h...
I = lambda: map(int, input().split()) def C(a, b): return [a // b + 1, a // b][a % b == 0] def f(d, k): return sum( (d[i][0] > k) * min(C(d[i][0] - k, d[i][1]), d[i][2]) for i in range(len(d)) ) n, m = I() a = list(I()) b = list(I()) d = [] l = 0 for i in range(n): d.append([a[i] * b[i], b...
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN LIST BIN_OP BIN_OP VAR VAR NUMBER BIN_OP VAR VAR BIN_OP VAR VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR VAR VAR NUMBER VAR VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSI...
Read problems statements [Hindi] ,[Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. Appy loves balloons! She wants you to give her balloons on each of $N$ consecutive days (numbered $1$ through $N$); let's denote the number of balloons Appy wants on day $i$ by $A_{i}$. The problem is that you only h...
def poss(k, inp, h): b = 0 for i in range(0, len(inp)): el = inp[i] if el[1] == 0: continue elif k >= 0: v1 = el[0] - k v2 = el[1] chkval = int((v1 + v2 - 1) // v2) if chkval > 0: b += chkval if b <= h: ...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR NUMBER NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR IF VAR NUMBER VAR VAR IF VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF AS...
Read problems statements [Hindi] ,[Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. Appy loves balloons! She wants you to give her balloons on each of $N$ consecutive days (numbered $1$ through $N$); let's denote the number of balloons Appy wants on day $i$ by $A_{i}$. The problem is that you only h...
def bs(l, h): while l < h: m = (l + h) // 2 if gf(m): h = m else: l = m + 1 return l def gf(x): d = c for i in range(n): d -= min(a[i], x // b[i]) return d <= 0 n, m = map(int, input().split()) a = tuple(map(int, input().split())) b = tuple...
FUNC_DEF WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR VAR FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR VAR VAR RETURN VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR ...
Read problems statements [Hindi] ,[Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. Appy loves balloons! She wants you to give her balloons on each of $N$ consecutive days (numbered $1$ through $N$); let's denote the number of balloons Appy wants on day $i$ by $A_{i}$. The problem is that you only h...
def check(A, B, maxCi, n, m): count = 0 for day in range(n): wants = A[day] f = maxCi // B[day] if f > 0: atleast = max(0, wants - f) count += atleast else: count += wants return count <= m def solve(A, B, m, n): l, h = 0, 10**18 ...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR VAR VAR VAR VAR RETURN VAR VAR FUNC_DEF ASSIGN VAR VAR NUMBER BIN_OP NUMBER NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR...
Read problems statements [Hindi] ,[Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. Appy loves balloons! She wants you to give her balloons on each of $N$ consecutive days (numbered $1$ through $N$); let's denote the number of balloons Appy wants on day $i$ by $A_{i}$. The problem is that you only h...
def binary(l, r, baloons, B, P): if l <= r: mid = (l + r) // 2 val = 0 for i in range(len(P)): if P[i] > mid: if (P[i] - mid) % B[i] == 0: val = val + (P[i] - mid) // B[i] else: val = val + (P[i] - mid) // B[...
FUNC_DEF IF VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR IF BIN_OP BIN_OP VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR NUMBER IF VAR VAR ASSIGN...
Read problems statements [Hindi] ,[Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. Appy loves balloons! She wants you to give her balloons on each of $N$ consecutive days (numbered $1$ through $N$); let's denote the number of balloons Appy wants on day $i$ by $A_{i}$. The problem is that you only h...
n, m = map(int, input().split()) l1 = list(map(int, input().split())) l2 = list(map(int, input().split())) lo = 0 hi = 10000000000000000000 while lo < hi: mid = (lo + hi) // 2 now = 0 for i in range(n): curr = max(0, l1[i] - mid // l2[i]) now += curr if now <= m: hi = mid els...
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 ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR...
Read problems statements [Hindi] ,[Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. Appy loves balloons! She wants you to give her balloons on each of $N$ consecutive days (numbered $1$ through $N$); let's denote the number of balloons Appy wants on day $i$ by $A_{i}$. The problem is that you only h...
def b_search(N, M, a, b): low = 1 high = max(a) * max(b) while low < high: mid = low + (high - low) // 2 bn = 0 for x in range(N): bn += max(0, a[x] - mid // b[x]) if bn <= M: high = mid else: low = mid + 1 return low [N, M] =...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR BIN_OP VAR VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR ASSIG...
Read problems statements [Hindi] ,[Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. Appy loves balloons! She wants you to give her balloons on each of $N$ consecutive days (numbered $1$ through $N$); let's denote the number of balloons Appy wants on day $i$ by $A_{i}$. The problem is that you only h...
def satisfy(a, b, m, value): for i in range(n): candies = a[i] * b[i] if candies > value: if a[i] < value // b[i]: continue m -= a[i] - value // b[i] if m < 0: return False return True def bsearch(a, b, m, value): lo = 0 ...
FUNC_DEF FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR IF VAR VAR IF VAR VAR BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR VAR IF VAR NUMBER RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR VA...
Read problems statements [Hindi] ,[Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. Appy loves balloons! She wants you to give her balloons on each of $N$ consecutive days (numbered $1$ through $N$); let's denote the number of balloons Appy wants on day $i$ by $A_{i}$. The problem is that you only h...
def check_least(n, m, a, b, c, least): required_m = 0 for index, ci in enumerate(c): ai = a[index] bi = b[index] if ci > least: diff = ci - least required_m += diff // bi if diff % bi != 0: required_m += 1 if required_m > m: ...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR IF BIN_OP VAR VAR NUMBER VAR NUMBER IF VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR VAR ...
Read problems statements [Hindi] ,[Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. Appy loves balloons! She wants you to give her balloons on each of $N$ consecutive days (numbered $1$ through $N$); let's denote the number of balloons Appy wants on day $i$ by $A_{i}$. The problem is that you only h...
def isvalid(a, b, m, mid): t = 0 for i in range(len(a)): g = a[i] - mid // b[i] t += max(0, g) if t > m: return False return True n, m = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) s = 0 e = 10**18 ans = -1 while s <...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR BIN_OP VAR VAR VAR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_...
Read problems statements [Hindi] ,[Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. Appy loves balloons! She wants you to give her balloons on each of $N$ consecutive days (numbered $1$ through $N$); let's denote the number of balloons Appy wants on day $i$ by $A_{i}$. The problem is that you only h...
n, m = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) C = [] for i in range(0, len(A)): C.append(A[i] * B[i]) D = [] for i, x in sorted(zip(C, B)): D.append(x) C.sort() l = 0 h = max(C) while l < h: b = 0 mid = (h + l) // 2 for i in range(len(C)): ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR LIST FOR VAR ...
Read problems statements [Hindi] ,[Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. Appy loves balloons! She wants you to give her balloons on each of $N$ consecutive days (numbered $1$ through $N$); let's denote the number of balloons Appy wants on day $i$ by $A_{i}$. The problem is that you only h...
def main(): N, BALLOONS = list(map(int, input().split())) A = list(map(int, input().split())) B = list(map(int, input().split())) UPPER_BOUND = max([(x * y) for x, y in zip(A, B)]) + 1 def predicate(MAX_TOFFEES_PER_DAY): required = 0 for ballons_req, toffees_per_ballon in zip(A, B):...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER FUNC_DEF ASSIGN VAR NU...
Read problems statements [Hindi] ,[Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. Appy loves balloons! She wants you to give her balloons on each of $N$ consecutive days (numbered $1$ through $N$); let's denote the number of balloons Appy wants on day $i$ by $A_{i}$. The problem is that you only h...
def solve(l1, l2, k, ans, n): w = 0 i = 0 while i < n: if c[i] > ans: m = ans // b[i] w += a[i] - m if w > k: return 0 i += 1 return 1 n, k = (int(s) for s in input().split()) a = [int(s) for s in input().split()] b = [int(s) for s in input()...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR VAR IF VAR VAR RETURN NUMBER VAR NUMBER RETURN NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ...
Read problems statements [Hindi] ,[Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. Appy loves balloons! She wants you to give her balloons on each of $N$ consecutive days (numbered $1$ through $N$); let's denote the number of balloons Appy wants on day $i$ by $A_{i}$. The problem is that you only h...
def needm(c, k): need = 0 for a, b in cs: buy = k // b if buy < a: need += a - buy return need n, m = map(int, input().split()) ays = list(map(int, input().split())) bs = list(map(int, input().split())) if sum(ays) <= m: print(0) else: cs = list(zip(ays, bs)) hi = m...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR VAR BIN_OP VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VA...
Read problems statements [Hindi] ,[Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. Appy loves balloons! She wants you to give her balloons on each of $N$ consecutive days (numbered $1$ through $N$); let's denote the number of balloons Appy wants on day $i$ by $A_{i}$. The problem is that you only h...
n, b = map(int, input().split()) bal = list(map(int, input().split())) can = list(map(int, input().split())) def is_valid_total_candies(mid, bal, can, b): rem_bal = 0 for i in range(len(bal)): if bal[i] * can[i] > mid: bal_mid = mid // can[i] rem_bal += bal[i] - bal_mid ...
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 FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR VA...
Read problems statements [Hindi] ,[Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. Appy loves balloons! She wants you to give her balloons on each of $N$ consecutive days (numbered $1$ through $N$); let's denote the number of balloons Appy wants on day $i$ by $A_{i}$. The problem is that you only h...
def balloons_needed(a, b, candies): need = 0 for i in range(len(a)): if b[i] == 0: continue need += max(0, a[i] - candies // b[i]) return need n, m = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) r = 0 for i in range(n): r...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR BIN_OP VAR VAR VAR RETURN VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VA...
Read problems statements [Hindi] ,[Bengali] , [Mandarin chinese] , [Russian] and [Vietnamese] as well. Appy loves balloons! She wants you to give her balloons on each of $N$ consecutive days (numbered $1$ through $N$); let's denote the number of balloons Appy wants on day $i$ by $A_{i}$. The problem is that you only h...
def calc(mid, m, C): maxc = 0 ballons = m for c, a, b in C: if c < mid: break ballons = ballons - (a - mid // b) maxc = max(mid // b * b, maxc) return ballons, maxc n, m = map(int, input().split()) A, B = list(map(int, input().split())), list(map(int, input().split(...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR VAR VAR VAR IF VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR VAR RETURN VAR VAR ASSIGN VAR 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 F...
Sarthak has a set S of N distinct prime numbers. He grew very fond of that set, and now he only likes a positive integer X if all of its prime factors belong to S. Given the set and a positive integer M, can you find out how many integers he likes which are not more than M? Note: Sarthak always like the number 1. ---...
def calculate(primeset, m): valueset = [1] for x in primeset: i = 0 while i < len(valueset): if valueset[i] * x <= m: valueset.append(valueset[i] * x) i += 1 return valueset def solve(primes, n, m): primes.sort() primeset1 = [primes[i] for i ...
FUNC_DEF ASSIGN VAR LIST NUMBER FOR VAR VAR ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER RETURN VAR FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR NUMBER VAR NUMBER ASSIGN...
Sarthak has a set S of N distinct prime numbers. He grew very fond of that set, and now he only likes a positive integer X if all of its prime factors belong to S. Given the set and a positive integer M, can you find out how many integers he likes which are not more than M? Note: Sarthak always like the number 1. ---...
def getAns(s): v = [1] for x in s: i = 0 while i < len(v): if v[i] * x <= m: v.append(v[i] * x) i += 1 return v t = int(input()) for _ in range(t): n, m = [int(v) for v in input().split()] s = sorted([int(v) for v in input().split()]) s1 ...
FUNC_DEF ASSIGN VAR LIST NUMBER FOR VAR VAR ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER RETURN 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 FUNC_CA...
Sarthak has a set S of N distinct prime numbers. He grew very fond of that set, and now he only likes a positive integer X if all of its prime factors belong to S. Given the set and a positive integer M, can you find out how many integers he likes which are not more than M? Note: Sarthak always like the number 1. ---...
import sys input = sys.stdin.readline def calculate(lst, m): d = [1] for x in lst: i = 0 while i < len(d): if x * d[i] <= m: d.append(x * d[i]) i += 1 return d for t in range(int(input())): n, m = map(int, input().split()) arr = list(map(i...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR LIST NUMBER FOR VAR VAR ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR NUMBER RETURN 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 FUNC...
One important contest will take place on the most famous programming platform (Topforces) very soon! The authors have a pool of $n$ problems and should choose at most three of them into this contest. The prettiness of the $i$-th problem is $a_i$. The authors have to compose the most pretty contest (in other words, the...
q = int(input()) for w in range(q): n = int(input()) arr = list(map(int, input().split())) arr = list(set(arr)) arr.sort(reverse=True) n = len(arr) ansarr = [(-1) for i in range(n)] maxans = 0 for i in range(n): currans = arr[i] for j in range(i + 1, min(i + 171, n)): ...
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 EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR ...
One important contest will take place on the most famous programming platform (Topforces) very soon! The authors have a pool of $n$ problems and should choose at most three of them into this contest. The prettiness of the $i$-th problem is $a_i$. The authors have to compose the most pretty contest (in other words, the...
import sys input = sys.stdin.readline q = int(input()) for testcase in range(q): n = int(input()) A = sorted(set(map(int, input().split())), reverse=True) L = len(A) ANS = A[0] for i in range(L): NOW0 = A[i] NOW1 = 0 flag = 0 for j in range(i + 1, L): if ...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR...
One important contest will take place on the most famous programming platform (Topforces) very soon! The authors have a pool of $n$ problems and should choose at most three of them into this contest. The prettiness of the $i$-th problem is $a_i$. The authors have to compose the most pretty contest (in other words, the...
import sys input = sys.stdin.readline for _ in range(int(input())): n = int(input()) a = [0, 0] + sorted(set(map(int, input().split()))) ans = a[-1] for z in range(len(a) - 1, 1, -1): y = z - 1 while a[y] > 0 and a[z] % a[y] == 0: y -= 1 x = y - 1 while a[x] ...
IMPORT ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER ASSIGN VAR B...
One important contest will take place on the most famous programming platform (Topforces) very soon! The authors have a pool of $n$ problems and should choose at most three of them into this contest. The prettiness of the $i$-th problem is $a_i$. The authors have to compose the most pretty contest (in other words, the...
for i in range(int(input())): n = int(input()) w = set() [w.add(int(j)) for j in input().split()] data = list(w) data.sort() nums = [data[-1]] ind = len(data) - 2 cnt = 1 while ind >= 0: if cnt == 1: if nums[0] % data[ind] != 0: nums.append(data[in...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE...
One important contest will take place on the most famous programming platform (Topforces) very soon! The authors have a pool of $n$ problems and should choose at most three of them into this contest. The prettiness of the $i$-th problem is $a_i$. The authors have to compose the most pretty contest (in other words, the...
M = lambda: list(map(int, input().split())) q = int(input()) for qer in range(q): n = int(input()) a = M() D = {} for i in a: D[i] = 1 a.sort(reverse=True) def get_max(): for i in a: if D[i]: return i return 0 def fix(x): for i in...
ASSIGN VAR FUNC_CALL 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 FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER FUNC_DEF FOR VAR VAR IF VAR VAR RETURN VAR RETUR...
One important contest will take place on the most famous programming platform (Topforces) very soon! The authors have a pool of $n$ problems and should choose at most three of them into this contest. The prettiness of the $i$-th problem is $a_i$. The authors have to compose the most pretty contest (in other words, the...
import sys input = sys.stdin.readline t = int(input().strip()) for _ in range(t): n = int(input().strip()) ls = list(map(int, input().strip().split())) ls = list(set(ls)) ls.sort() n = len(ls) if n == 1: print(ls[0]) elif n == 2: if ls[1] % ls[0] == 0: print(ls[1...
IMPORT ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR...
One important contest will take place on the most famous programming platform (Topforces) very soon! The authors have a pool of $n$ problems and should choose at most three of them into this contest. The prettiness of the $i$-th problem is $a_i$. The authors have to compose the most pretty contest (in other words, the...
def solve(a_s): a_s = set(a_s) n = max(a_s) largest = n if n // 2 in a_s and n // 3 in a_s and n // 5 in a_s: largest = n // 2 + n // 3 + n // 5 m = [] for _ in range(3): if not a_s: break n = max(a_s) a_s = set([j for j in a_s if n % j != 0]) ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR IF BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER IF VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VA...
One important contest will take place on the most famous programming platform (Topforces) very soon! The authors have a pool of $n$ problems and should choose at most three of them into this contest. The prettiness of the $i$-th problem is $a_i$. The authors have to compose the most pretty contest (in other words, the...
def cal(sorted_list, size): max_sum = 0 for k in range(len(sorted_list)): max_sum = max(sorted_list[k], max_sum) for i in range(k + 1, size): temp_1 = sorted_list[i] if sorted_list[k] % temp_1 != 0: if ( i + 1 < size ...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR VAR IF BIN_OP VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR ASSIGN VAR FU...
One important contest will take place on the most famous programming platform (Topforces) very soon! The authors have a pool of $n$ problems and should choose at most three of them into this contest. The prettiness of the $i$-th problem is $a_i$. The authors have to compose the most pretty contest (in other words, the...
import sys def calcSum(first): nonlocal m s = m[first] k = 1 for i in range(first + 1, len(m)): yes = True for j in range(first, i): if m[j] % m[i] == 0: yes = False break if yes: s += m[i] k += 1 i...
IMPORT FUNC_DEF ASSIGN VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR IF BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER IF VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CAL...
One important contest will take place on the most famous programming platform (Topforces) very soon! The authors have a pool of $n$ problems and should choose at most three of them into this contest. The prettiness of the $i$-th problem is $a_i$. The authors have to compose the most pretty contest (in other words, the...
answer = [] for _ in range(int(input())): input() l = sorted(map(int, input().split())) other = 0 if l[-1] % 30 == 0 and len(set(l) & {l[-1] // 2, l[-1] // 3, l[-1] // 5}) == 3: other = 31 * l[-1] // 30 while len(l) >= 2 and l[-1] % l[-2] == 0: del l[-2] while len(l) >= 3 and 0 i...
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER NUMBER FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER N...
One important contest will take place on the most famous programming platform (Topforces) very soon! The authors have a pool of $n$ problems and should choose at most three of them into this contest. The prettiness of the $i$-th problem is $a_i$. The authors have to compose the most pretty contest (in other words, the...
def calc(X, Y): if len(Y) == 3: return sum(Y) for x in X: for y in Y: if y % x == 0: break else: return calc([i for i in X if i != x], sorted(Y + [x])[::-1]) return sum(Y) for _ in range(int(input())): N = int(input()) A = sorted(set(...
FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN FUNC_CALL VAR VAR FOR VAR VAR FOR VAR VAR IF BIN_OP VAR VAR NUMBER RETURN FUNC_CALL VAR VAR VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR LIST VAR NUMBER RETURN FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FU...
One important contest will take place on the most famous programming platform (Topforces) very soon! The authors have a pool of $n$ problems and should choose at most three of them into this contest. The prettiness of the $i$-th problem is $a_i$. The authors have to compose the most pretty contest (in other words, the...
T = int(input()) for o in range(T): n = int(input()) a = list(map(int, input().split())) a.sort() b = [] for i in a: if len(b) == 0 or len(b) != 0 and b[-1] != i: b.append(i) a = b n = len(b) if n == 1: print(a[0]) elif n == 2: if a[1] % a[0] == 0:...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR ...
One important contest will take place on the most famous programming platform (Topforces) very soon! The authors have a pool of $n$ problems and should choose at most three of them into this contest. The prettiness of the $i$-th problem is $a_i$. The authors have to compose the most pretty contest (in other words, the...
q = int(input()) ans = [] for w in range(q): n = int(input()) a = [int(x) for x in input().split()] a.sort() a = a[::-1] a1 = 0 b1 = 0 c1 = 0 a1 = a[0] for i in range(n): if a1 % a[i] != 0: b1 = a[i] break for i in range(n): if a1 % a[i] !=...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ...
One important contest will take place on the most famous programming platform (Topforces) very soon! The authors have a pool of $n$ problems and should choose at most three of them into this contest. The prettiness of the $i$-th problem is $a_i$. The authors have to compose the most pretty contest (in other words, the...
q = int(input()) for query in range(q): n = int(input()) l = list(map(int, input().split())) l.sort() l.reverse() wy = -1000000000000 a = [l[0]] u = 1 while u < n: if l[u] != l[u - 1]: a.append(l[u]) if len(a) > 4: break u += 1 if ( ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR IF VAR VAR VAR BIN_OP VAR NUMBER E...
One important contest will take place on the most famous programming platform (Topforces) very soon! The authors have a pool of $n$ problems and should choose at most three of them into this contest. The prettiness of the $i$-th problem is $a_i$. The authors have to compose the most pretty contest (in other words, the...
from sys import stdin, stdout q = int(stdin.readline()) for it in range(q): n = int(stdin.readline()) a = set(map(int, stdin.readline().split())) M = max(a) if M % 30 == 0 and M // 2 in a and M // 3 in a and M // 5 in a: p1 = M * 31 // 30 else: p1 = 0 ans = [M] a = sorted(li...
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 VAR IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP V...
One important contest will take place on the most famous programming platform (Topforces) very soon! The authors have a pool of $n$ problems and should choose at most three of them into this contest. The prettiness of the $i$-th problem is $a_i$. The authors have to compose the most pretty contest (in other words, the...
from sys import stdin, stdout for _ in range(int(stdin.readline())): __ = int(stdin.readline()) a = sorted(set(map(int, stdin.readline().split())), reverse=True) s = a[0] n = len(a) for i in range(n): el = a[i] for j in range(i + 1, n): if el % a[j] != 0: ...
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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF ...
One important contest will take place on the most famous programming platform (Topforces) very soon! The authors have a pool of $n$ problems and should choose at most three of them into this contest. The prettiness of the $i$-th problem is $a_i$. The authors have to compose the most pretty contest (in other words, the...
for _ in range(int(input())): input() a = list(map(int, input().split())) a = sorted(list(set(a))) ans = max(a) n = len(a) for i in range(n): x, y, z = 0, 0, a[i] for j in reversed(range(i)): if not y: if z % a[j] != 0: y = a[j] ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR NUMBER NUMBER VAR VAR FO...
One important contest will take place on the most famous programming platform (Topforces) very soon! The authors have a pool of $n$ problems and should choose at most three of them into this contest. The prettiness of the $i$-th problem is $a_i$. The authors have to compose the most pretty contest (in other words, the...
import sys 3.6 def eprint(*args, **kwargs): if __debug__: print(*args, file=sys.stderr, **kwargs) def __starting_point(): q = int(input()) while q > 0: ans = 0 q -= 1 x = y = z = 0 n = int(input()) arr = list(set(map(int, input().split(" ")))) arr...
IMPORT EXPR NUMBER FUNC_DEF IF VAR EXPR FUNC_CALL VAR VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FU...
One important contest will take place on the most famous programming platform (Topforces) very soon! The authors have a pool of $n$ problems and should choose at most three of them into this contest. The prettiness of the $i$-th problem is $a_i$. The authors have to compose the most pretty contest (in other words, the...
q = int(input()) for w in range(q): n = int(input()) arr = list(map(int, input().split())) arr = list(set(arr)) arr.sort(reverse=True) n = len(arr) ans = 0 for i in range(n): ans = max(ans, arr[i]) for j in range(i + 1, n): if arr[i] % arr[j] != 0: ...
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 EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN ...
One important contest will take place on the most famous programming platform (Topforces) very soon! The authors have a pool of $n$ problems and should choose at most three of them into this contest. The prettiness of the $i$-th problem is $a_i$. The authors have to compose the most pretty contest (in other words, the...
q = int(input()) for _ in range(q): e = set() n = int(input()) a = sorted(map(int, input().split()))[::-1] for x in a: e.add(x) r = [] for k in a: for c in r: if c % k == 0: break else: r.append(k) if len(r) >= 3: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN 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 NUMBER FOR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR VAR FOR VAR VAR IF BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VA...
One important contest will take place on the most famous programming platform (Topforces) very soon! The authors have a pool of $n$ problems and should choose at most three of them into this contest. The prettiness of the $i$-th problem is $a_i$. The authors have to compose the most pretty contest (in other words, the...
from itertools import tee from sys import stdin def input(): return stdin.readline() def remove_divisors(x, xs): return [y for y in xs if y % xs != 0] q = int(input()) for _ in range(q): n = int(input()) aas = list(set(map(int, input().split()))) aas.sort(reverse=True) ulim2 = list(map(sum...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_DEF RETURN VAR VAR VAR BIN_OP VAR VAR NUMBER 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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL V...
One important contest will take place on the most famous programming platform (Topforces) very soon! The authors have a pool of $n$ problems and should choose at most three of them into this contest. The prettiness of the $i$-th problem is $a_i$. The authors have to compose the most pretty contest (in other words, the...
q = int(input()) for i in range(q): n = int(input()) a = [int(i) for i in input().split()] a.sort(reverse=True) first = a[0] second = -1 third = -1 maxa = a[0] arr = [] for i in range(n): if first % a[i] != 0: if second == -1: second = 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 VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP V...
One important contest will take place on the most famous programming platform (Topforces) very soon! The authors have a pool of $n$ problems and should choose at most three of them into this contest. The prettiness of the $i$-th problem is $a_i$. The authors have to compose the most pretty contest (in other words, the...
import sys q = int(input()) lines = sys.stdin.readlines() res = [] def getMax(numset): n = max(numset) numset = set([j for j in numset if n % j != 0]) return n, numset for i in range(q): n = int(lines[2 * i]) m = [] numset = set() for j in lines[2 * i + 1].split(): numset.add(in...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR NUMBER RETURN VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP NUMBER VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FOR VAR...
Minion Chef likes to eat bananas a lot. There are N piles of bananas in front of Chef; for each i (1 ≤ i ≤ N), the i-th pile contains Ai bananas. Chef's mother wants her to eat the bananas and be healthy. She has gone to the office right now and will come back in H hours. Chef would like to make sure that she can finis...
t = int(input()) while t > 0: t -= 1 n, h = map(int, input().split()) a = [int(x) for x in input().split()] s = sum(a) mx = max(a) low = 1 high = mx mn = 0 if n == h: print(mx) else: while low <= high: k = (low + high) // 2 s = 0 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR ...
Minion Chef likes to eat bananas a lot. There are N piles of bananas in front of Chef; for each i (1 ≤ i ≤ N), the i-th pile contains Ai bananas. Chef's mother wants her to eat the bananas and be healthy. She has gone to the office right now and will come back in H hours. Chef would like to make sure that she can finis...
def MinimumHours(n, h, a): a.sort() b = a[0] c = 0 s = 0 j = 0 m = 1 while 1: for i in a[-1 : -(n + 2) : -1]: if i % m == 0: s += i // m else: s += i // m + 1 if s > h: break if s <= h: ...
FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER FOR VAR VAR NUMBER BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR IF VAR VAR RETURN VAR VAR NUMBER ASSIGN VAR NUMBER AS...
Minion Chef likes to eat bananas a lot. There are N piles of bananas in front of Chef; for each i (1 ≤ i ≤ N), the i-th pile contains Ai bananas. Chef's mother wants her to eat the bananas and be healthy. She has gone to the office right now and will come back in H hours. Chef would like to make sure that she can finis...
def bananas(lower, upper): k = (upper + lower) // 2 if upper <= lower: return k sum = 0 for i in l: if i % k == 0: sum += i / k else: sum += i // k + 1 if sum > hours: return bananas(k + 1, upper) elif sum == hours: return bananas(l...
FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR RETURN VAR ASSIGN VAR NUMBER FOR VAR VAR IF BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR RETURN FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR RETURN FUNC_CALL VAR VAR VAR RETURN FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CAL...
Minion Chef likes to eat bananas a lot. There are N piles of bananas in front of Chef; for each i (1 ≤ i ≤ N), the i-th pile contains Ai bananas. Chef's mother wants her to eat the bananas and be healthy. She has gone to the office right now and will come back in H hours. Chef would like to make sure that she can finis...
def trace(bIP, bPH): hT = 0 for bICP in bIP: bICPAE = bICP temp = bICPAE // bPH if bICPAE % bPH != 0: temp = temp + 1 hT = hT + temp return hT nOTC = int(input()) for _ in range(0, nOTC): nOP, hG = input().split() nOP, hG = int(nOP), int(hG) bIP = li...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_...
Minion Chef likes to eat bananas a lot. There are N piles of bananas in front of Chef; for each i (1 ≤ i ≤ N), the i-th pile contains Ai bananas. Chef's mother wants her to eat the bananas and be healthy. She has gone to the office right now and will come back in H hours. Chef would like to make sure that she can finis...
def check(mid): total = 0 for i in piles: total += (i + mid - 1) // mid return total <= hours def solve(no_piles, hours, piles): lim_0 = 1 end = max(piles) ans = end while lim_0 <= end: mid = (lim_0 + end) // 2 if check(mid): ans = min(ans, mid) ...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR RETURN VAR VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN...
Minion Chef likes to eat bananas a lot. There are N piles of bananas in front of Chef; for each i (1 ≤ i ≤ N), the i-th pile contains Ai bananas. Chef's mother wants her to eat the bananas and be healthy. She has gone to the office right now and will come back in H hours. Chef would like to make sure that she can finis...
def MinimumHours(n, h, a): a.sort() j = 0 mie = 2 mio = 1 s1 = 0 s2 = 0 c1 = 0 c2 = 0 while 1: for i in a[-1 : -(n + 1) : -1]: if i % mie == 0: s1 += i // mie else: s1 += i // mie + 1 if i % mio == 0: ...
FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER FOR VAR VAR NUMBER BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER VAR BIN...
Minion Chef likes to eat bananas a lot. There are N piles of bananas in front of Chef; for each i (1 ≤ i ≤ N), the i-th pile contains Ai bananas. Chef's mother wants her to eat the bananas and be healthy. She has gone to the office right now and will come back in H hours. Chef would like to make sure that she can finis...
for z in range(int(input())): n, h = [int(x) for x in input().split()] a = [int(x) for x in input().split()] def bs(l, r, h): if l > r: return max(a) m = int((l + r) / 2) x = 0 for i in range(len(a)): x += 1 + a[i] // m if a[i] % m == 0: ...
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 FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR VAR RETURN FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR...
Minion Chef likes to eat bananas a lot. There are N piles of bananas in front of Chef; for each i (1 ≤ i ≤ N), the i-th pile contains Ai bananas. Chef's mother wants her to eat the bananas and be healthy. She has gone to the office right now and will come back in H hours. Chef would like to make sure that she can finis...
def MinimumHours(n, h, a): a.sort() j = 0 mi = a[j] s = 0 c = 0 c2 = 0 while 1: for i in a[-1 : -(n + 2) : -1]: if i % mi == 0: s += i // mi else: s += i // mi + 1 if s > h: c = 1 if c...
FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER FOR VAR VAR NUMBER BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER RETURN BIN_OP VAR NUMBER...
Minion Chef likes to eat bananas a lot. There are N piles of bananas in front of Chef; for each i (1 ≤ i ≤ N), the i-th pile contains Ai bananas. Chef's mother wants her to eat the bananas and be healthy. She has gone to the office right now and will come back in H hours. Chef would like to make sure that she can finis...
def godFunc(arr, k, h): noh = sum([(i // k + int(i % k != 0)) for i in arr]) return noh <= h for _ in range(int(input())): n, h = map(int, input().split()) arr = list(map(int, input().split())) l, r = 1, 1000000000 while l < r: mid = (l + r) // 2 if godFunc(arr, mid, h): ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER 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 FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER WH...
Minion Chef likes to eat bananas a lot. There are N piles of bananas in front of Chef; for each i (1 ≤ i ≤ N), the i-th pile contains Ai bananas. Chef's mother wants her to eat the bananas and be healthy. She has gone to the office right now and will come back in H hours. Chef would like to make sure that she can finis...
def check(m): count = 0 for el in arr: if m < el: count += (el + m - 1) // m else: count += 1 if count <= hours: return True else: return False t = int(input()) for i in range(t): length, hours = map(int, input().split()) arr = list(map(i...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR VAR NUMBER IF VAR VAR RETURN NUMBER RETURN NUMBER 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 F...
Minion Chef likes to eat bananas a lot. There are N piles of bananas in front of Chef; for each i (1 ≤ i ≤ N), the i-th pile contains Ai bananas. Chef's mother wants her to eat the bananas and be healthy. She has gone to the office right now and will come back in H hours. Chef would like to make sure that she can finis...
def check(bananas, mid_val, H): time = 0 for i in range(len(bananas)): if bananas[i] % mid_val != 0: time += bananas[i] // mid_val + 1 else: time += bananas[i] // mid_val if time <= H: return True else: return False def minEatingSpeed(piles, H): ...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR NUMBER VAR BIN_OP BIN_OP VAR VAR VAR NUMBER VAR BIN_OP VAR VAR VAR IF VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BI...
Vasya is a CEO of a big construction company. And as any other big boss he has a spacious, richly furnished office with two crystal chandeliers. To stay motivated Vasya needs the color of light at his office to change every day. That's why he ordered both chandeliers that can change its color cyclically. For example: r...
import sys readline = sys.stdin.readline def gcd(a, b): while b: a, b = b, a % b return a def lcm(a, b): return a * b // gcd(a, b) def egcd(a, b): if a == 0: return b, 0, 1 else: g, y, x = egcd(b % a, a) return g, x - b // a * y, y N, M, K = map(int, readline...
IMPORT ASSIGN VAR VAR FUNC_DEF WHILE VAR ASSIGN VAR VAR VAR BIN_OP VAR VAR RETURN VAR FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR FUNC_CALL VAR VAR VAR FUNC_DEF IF VAR NUMBER RETURN VAR NUMBER NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR RETURN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR VAR VAR ASSIGN VAR VAR VAR FUN...
Vasya is a CEO of a big construction company. And as any other big boss he has a spacious, richly furnished office with two crystal chandeliers. To stay motivated Vasya needs the color of light at his office to change every day. That's why he ordered both chandeliers that can change its color cyclically. For example: r...
def main(): n, m, k = list(map(lambda x: int(x), str(input()).split(" "))) a = list(map(lambda x: int(x), str(input()).split(" "))) b = list(map(lambda x: int(x), str(input()).split(" "))) if n < m: print(solve(m, n, k, b, a)) return print(solve(n, m, k, a, b)) def solve(n, m, k, a...
FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR STRI...
Vasya is a CEO of a big construction company. And as any other big boss he has a spacious, richly furnished office with two crystal chandeliers. To stay motivated Vasya needs the color of light at his office to change every day. That's why he ordered both chandeliers that can change its color cyclically. For example: r...
def main(): n, m, k = map(int, input().split()) aa = map(int, input().split()) bb = map(int, input().split()) if n < m: n, m, aa, bb = m, n, bb, aa x = y2 = 1 y = x2 = 0 g, a = n, m while a: q = g // a g, a, x, y, x2, y2 = a, g % a, x2, y2, x - x2 * q, y - y2 * q ...
FUNC_DEF 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 FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR VAR VAR WHILE VAR ASSIGN VAR BIN_OP...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
from sys import stdin def input(): return next(stdin) def main(): n, k = map(int, input().split()) aa = [int(a) for a in input().split()] aa.sort() valmap = {} for a in aa: add_to_map(a, 0, k, valmap) i = 0 while a > 0: i += 1 a = a // 2 ...
FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR EXPR FUNC_CALL VAR VAR NUMBER VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER EXP...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
import sys input = sys.stdin.buffer.readline def solution(): n, k = map(int, input().split()) l = list(map(int, input().split())) l.sort() val = [0] * 1000001 op = [0] * 1000001 m = 2000000000.0 for i in range(n): val[l[i]] += 1 for i in range(n): cnt = 0 x = l...
IMPORT ASSIGN VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER FOR VAR F...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
n, k = map(int, input().split()) x = list(map(int, input().split())) q = [] for i in range(200001): q.append([0, 0]) x.sort() for i in range(n): a = x[i] q[a][0] += 1 c = 0 while a: a = a // 2 c = c + 1 if q[a][0] < k: q[a][0] += 1 q[a][1] += c q.sort(...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR LIST NUMBER NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
def cal_dis(num, val): count = 0 while num > 0: if val[num] == 0: val[num] = [] val[num].append(count) num = num // 2 count += 1 return count, val n, k = (int(x) for x in input().split()) seq = [int(x) for x in input().split()] ans = 1000000000.0 val = 200009 * ...
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR LIST EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NU...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
n, k = map(int, input().split()) L = sorted(list(map(int, input().split()))) M = [[] for i in range(L[-1] + 1)] for i in range(n): ct = 0 a = L[i] while True: M[a] += [ct] ct += 1 a //= 2 if a == 0: M[0] += [ct] break ans = None for m in M: if len(...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR WHILE NUMBER VAR VAR LIST VAR VAR NUMBER VAR NUMBER IF VAR N...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
n, k = map(int, input().split()) l = list(map(int, input().split())) d = {} for liczba in l: ll = liczba while ll > 0: d[ll] = [] ll //= 2 for liczba in l: i = 0 ll = liczba while ll > 0: d[ll].append(i) ll //= 2 i += 1 wyn = 1000000000 for number in d: if...
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 DICT FOR VAR VAR ASSIGN VAR VAR WHILE VAR NUMBER ASSIGN VAR VAR LIST VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER VAR N...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
def inti_dic(d, no, opertions): if no in d: a = d[no] if a[0] < k: a[0] += 1 a[1] += op d[no] = a else: d[no] = [1, opertions] n, k = map(int, input().split()) arr = list(map(int, input().split())) d = {} arr = sorted(arr) for i in arr: no, op = ...
FUNC_DEF IF VAR VAR ASSIGN VAR VAR VAR IF VAR NUMBER VAR VAR NUMBER NUMBER VAR NUMBER VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR LIST NUMBER 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 DICT ASSIGN VAR FUNC_CALL VAR VAR FOR VAR VAR...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
ans = {} n, k = (int(s) for s in input().split()) l = [int(s) for s in input().split()] l.sort() for i in range(n): x = l[i] count = 0 while x > 0: if x in ans: if ans[x][0] < k: ans[x][0] += 1 ans[x][1] += count else: ans[x] = [1, coun...
ASSIGN VAR DICT ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR VAR IF VAR VAR NUMBER VAR VAR VAR NUMBER NUMBER VAR VAR NUMBER VAR ASSIGN VAR VA...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
n, k = map(int, input().split()) a = list(map(int, input().split())) m = max(a) val = [[] for _ in range(m + 1)] lenvals = [(0) for _ in range(m + 1)] for el in a: temp = el c = 0 val[temp].append(c) lenvals[temp] += 1 while temp > 1: temp //= 2 c += 1 val[temp].append(c) ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL V...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
n, m = map(int, input().split()) s = str(input()) a = [int(i) for i in s.split()] b = [0] * 200001 c = [0] * 200001 a.sort() for elem in a: b[elem] += 1 count = 0 while elem != 0 and b[elem // 2] < m: elem //= 2 count += 1 c[elem] += count b[elem] += 1 ans = 10000000000 for i...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER EXPR FUNC_CALL VAR FOR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER VAR BIN_OP VAR NUMBER ...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
from sys import stdin def iinput(): return int(stdin.readline()) def minput(): return map(int, stdin.readline().split()) def linput(): return list(map(int, stdin.readline().split())) n, k = minput() a = linput() mn = float("inf") d = [[] for _ in range(200001)] for i in range(n): temp = a[i] ...
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 ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR LIST VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL V...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
def find(A, K): counting = [[] for i in range(max(A) + 1)] okay = [0] * (max(A) + 1) for i in range(len(A)): count = 0 temp = A[i] while temp > 0: counting[temp] += [count] okay[temp] += 1 temp = temp // 2 count += 1 counting[te...
FUNC_DEF ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR WHILE VAR NUMBER VAR VAR LIST VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER VAR VAR LIST VAR ...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
n, k = [int(x) for x in input().split()] a = [int(x) for x in input().split()] a.sort() ind = [0] * 200001 cnt = [0] * 200001 ans = [] for key in a: ind[key] += 1 tr = False for key in a: if ind[key] >= k: ans.append(cnt[key]) cnnt = 1 while key > 1: key //= 2 ind[key] += 1 ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR LIST FOR VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VA...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
n, m = list(map(int, input().split())) a = list(map(int, input().split())) f = {} for i in a: it = 0 while i > 0: if i in f: f[i].append(it) else: f[i] = [it] i //= 2 it += 1 s = 10000000000.0 for i in f: if len(f[i]) >= m: s = min(s, sum(sorte...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR LIST VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF FU...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
n, m = map(int, input().split()) a = list(map(int, input().split())) a.sort() c = list(set(a)) b = [[] for i in range(2 * 100000 + 1)] for i in a: temp = i j = 0 b[temp].append(0) if temp != 1: while 1: temp = temp // 2 j += 1 b[temp].append(j) if ...
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 EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR V...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
n, k = map(int, input().split()) l = list(map(int, input().split())) count = [0] * (2 * 10**5 + 1) no = [0] * (2 * 10**5 + 1) ans = float("inf") l.sort() for i in l: c = 0 e = 0 while i > 0: if no[i] < k: count[i] += c no[i] += 1 c += 1 i = i // 2 ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP NUMBER BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP NUMBER BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR STRING EXPR F...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
n, k = list(map(int, input().split())) it = list(map(int, input().split())) a = [[] for i in range(n)] ss = {} for i in range(n): j = it[i] a[i] = [j] try: ss[j].append(0) except: ss[j] = [0] st = 0 while True: st += 1 j = j // 2 try: ss[j].app...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR LIST VAR EXPR FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR LIST NUMBER AS...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
def main(): n, k = list(map(int, input().split())) arr = list(map(int, input().split())) nums = [[(0) for i in range(2)] for j in range(2 * 10**5 + 1)] arr.sort() for i in arr: moves = 0 while i >= 0: if nums[i][0] == k: break nums[i][0] += 1 ...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR FOR VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMB...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
n, k = map(int, input().split()) a = list(map(int, input().split())) num = [0] * (2 * 10**5 + 1) count = [0] * (2 * 10**5 + 1) a.sort() for i in a: j = i t = 0 while j != 0: if num[j] < k: num[j] += 1 j = int(j / 2) t += 1 if num[j] < k: ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP NUMBER BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP BIN_OP NUMBER BIN_OP NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR FOR VAR VAR ASSIGN ...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
from sys import stdin n, k = [int(i) for i in stdin.readline().strip().split()] a = [int(i) for i in stdin.readline().strip().split()] p = [(19 * [0]) for _ in range(max(a) + 1)] nums = set() for m in a: for i in range(19): p[m >> i][i] += 1 nums.add(m >> i) if m >> i == 0: brea...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER LIST NUMBER VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR BIN_OP VAR VAR VAR NUMBER...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
n, k = map(int, input().split()) l = list(map(int, input().split())) l.sort() d = dict() c = 0 f = 0 a = [(0) for i in range(200001)] min1 = -1 while l[-1] != 0: for i in range(f, len(l)): if l[i] in d: d[l[i]] += 1 else: d[l[i]] = 1 a[l[i]] += c if d[l[i]] >=...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
n, k = [int(j) for j in input().split()] l = [int(j) for j in input().split()] num = int(2 * 100000.0 + 5) arr = [[] for i in range(num)] for i in range(n): cnt = 0 tmp = l[i] while tmp > 0: arr[tmp].append(cnt) tmp = tmp // 2 cnt += 1 ans = 1000000000000.0 for i in range(1, num): ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR VAR WHILE VAR NUMBER EXPR FUNC_CALL VAR VAR V...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
MAX = 2 * 10**5 def main(): n, k = list(map(int, input().split())) a = sorted(map(int, input().split())) ops = [0] * (MAX + 1) ks = [0] * (MAX + 1) for x in a: c = x j = 0 while True: if ks[c] < k: ops[c] += j ks[c] += 1 ...
ASSIGN VAR BIN_OP NUMBER BIN_OP NUMBER NUMBER FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR VAR ASSIGN VAR VAR ASSI...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
n, k = map(int, input().split()) a = list(map(int, input().split())) cnt = [[] for i in range(2 * 10**5 + 10)] for num in a: tmp_cnt = 0 while True: if num == 0: cnt[num].append(tmp_cnt) break else: cnt[num].append(tmp_cnt) num = num // 2 ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP NUMBER NUMBER NUMBER FOR VAR VAR ASSIGN VAR NUMBER WHILE NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR AS...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
n, k = list(map(int, input().split())) arr = list(map(int, input().split())) value_lists = [[] for _ in range(2 * 10**5 + 1)] for val in arr: turn = 0 while val != 1: value_lists[val].append(turn) val //= 2 turn += 1 value_lists[val].append(turn) mindist = 999999999 for turns_val in ...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP NUMBER NUMBER NUMBER FOR VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER EXP...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
n, k = tuple(map(int, input().split())) a = list(map(int, input().split())) a1 = sorted(a) a = sorted(a) l = [[(0) for i in range(n)] for j in range(20)] d = {} for j in range(n): x = 1 for i in range(20): if i == 0: l[i][j] = a[j] else: l[i][j] = a[j] // 2 a[...
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
n, k = map(int, input().split()) a = list(map(int, input().split())) a.sort() d1 = {} d2 = {} ans = 10**9 for i in range(n): num = a[i] c = 0 while num > 0: d1[num] = c if num not in d1 else d1[num] + c d2[num] = 1 if num not in d2 else d2[num] + 1 if d2[num] == k: ans = ...
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 EXPR FUNC_CALL VAR ASSIGN VAR DICT ASSIGN VAR DICT ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR VAR VAR VAR VAR BIN_OP...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
import sys input = lambda: sys.stdin.readline().strip() n, k = map(int, input().split()) ls = list(map(int, input().split())) ls.sort() arr = [] elem = {} minSteps = {} for x in range(ls[-1] + 1): elem[x] = 0 minSteps[x] = 0 for i in ls: steps = 0 while i != 0: if elem[i] != k: elem...
IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL 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 EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUM...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
n, k = [int(x) for x in input().split()] nums = sorted([int(x) for x in input().split()]) count = [(0) for _ in range(2 * 100000 + 10)] ops = [(0) for _ in range(2 * 100000 + 10)] for num in nums: op = 0 while num > 0: ops[num] += op if count[num] < k else 0 count[num] += 1 num = num // ...
ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
n, k = map(int, input().split()) a = list(map(int, input().split())) ans = [[0, 0] for i in range(200001)] a.sort() for i in range(n): ans[a[i]][0] += 1 for i in range(n): s = a[i] d = 1 while s > 0: s = s // 2 if ans[s][0] < k: ans[s][0] += 1 ans[s][1] += d ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER WHILE V...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
n, k = map(int, input().split()) a = list(map(int, input().split())) arr = [[] for _ in range(int(200000.0 + 1))] for j in a: i = 0 while j > 0: arr[j].append(i) i += 1 j //= 2 arr[j].append(i) mn = -1 for i in arr: if len(i) >= k: sk = sum(sorted(i)[:k]) if mn > ...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP NUMBER NUMBER FOR VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR ASSI...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
z = [] a = [] for i in range(200010): a.append([]) n, k = [int(e) for e in input().split()] b = [int(e) for e in input().split()] for x in b: c = x ct = 0 a[x].append(0) while c != 0: c >>= 1 ct += 1 a[c].append(ct) ans = 10000000000 for i in range(200000): if len(a[i]) <...
ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR LIST ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER WHILE VAR NUMBER VAR NUMBER VAR NUMBER EXP...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
vals = [[] for i in range(200 * 1000 + 11)] ans = 10**19 + 7 n, k = map(int, input().split()) (*a,) = map(int, input().split()) for i in range(n): x = a[i] cur = 0 while x > 0: vals[x].append(cur) x //= 2 cur += 1 for i in range(200 * 1000): new = vals[i] new.sort() if le...
ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER EXPR FUNC_CALL ...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
from sys import stdin, stdout def __starting_point(): n, k = list(map(int, stdin.readline().split())) a = list(map(int, stdin.readline().split())) num = [[] for i in range(200005)] ans = 200000 * 100 for x in a: cnt = 0 while x > 0: num[x].append(cnt) x //= ...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER EXPR...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
import sys def answer(n, k, a): mxa = max(a) costs = [[] for _ in range(mxa + 1)] for i in range(n): temp = a[i] cost = 0 while temp > 0: costs[temp].append(cost) temp //= 2 cost += 1 best = 10**7 for i in range(1, mxa + 1): if le...
IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF FUNC_CALL VA...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
import sys [n, k] = [int(i) for i in sys.stdin.readline().split()] a = [int(j) for j in sys.stdin.readline().split()] arr = [] a.sort() prev = -2 for i in range(n): if prev != a[i]: arr.append([a[i], 1]) else: arr[-1][1] += 1 prev = a[i] done = 0 for j in range(len(arr)): if arr[j][1] >...
IMPORT ASSIGN LIST VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR NUMBER VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NU...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
n, k = map(int, input().split()) arr = [int(z) for z in input().split()] moves = {} for i in range(n): l = arr[i] m = 0 while l: if not moves.get(l): moves[l] = [] moves[l].append(m) l //= 2 m += 1 res = 10**18 for i in moves: moves[i].sort() if len(moves[...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR DICT FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR IF FUNC_CALL VAR VAR ASSIGN VAR VAR LIST EXPR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP NUMBER NU...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
n, k = map(int, input().split()) x = [int(n) for n in input().split()] a = [] m = {} ans = 10000000000 if k != 1: for i in x: c = 0 t = i while t: if t not in m: m[t] = [] m[t].append(c) t //= 2 c += 1 for i in m: if...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR DICT ASSIGN VAR NUMBER IF VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR IF VAR VAR ASSIGN VAR VAR LIST EXPR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER FOR VAR...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
MOD = 10**9 + 7 I = lambda: list(map(int, input().split())) n, m = I() l = I() l.sort() ans = MOD o = [0] * 300000 d = [0] * 300000 for i in range(n): k = l[i] o[k] += 1 if o[k] == m: ans = min(ans, d[k]) i = 0 while k > 0: i += 1 k //= 2 o[k] += 1 d[k] += i ...
ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR BIN_OP LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
n, k = map(int, input().split()) x = [int(x) for x in input().split()] counter = [[] for _ in range(max(x) + 1)] for i in x: cnt = 0 divisible = True while divisible: counter[i].append(cnt) if i == 0: divisible = False i //= 2 cnt += 1 answer = pow(10, 10) for i i...
ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR EXPR FUNC_CALL VAR VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER VAR NUMBER A...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
n, k1 = map(int, input().split()) li = list(map(int, input().split())) d = {} for i in li: k = 0 while i != 0: try: d[i].append(k) except KeyError: d[i] = [k] k += 1 i = i // 2 mi = 100000000 for i in d.values(): if len(i) >= k1: i.sort() ...
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 DICT FOR VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR LIST VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VA...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
b = {} n, k = map(int, input().split()) a = list(map(int, input().split())) b[0] = [] for x in a: j = 0 while x > 0: if x in b: b[x].append(j) else: b[x] = [j] x //= 2 j += 1 b[0].append(j) ans = 10**10 for i in b: b[i].sort() if len(b[i]) >= k...
ASSIGN VAR DICT ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER LIST FOR VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR LIST VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER ...
The only difference between easy and hard versions is the number of elements in the array. You are given an array $a$ consisting of $n$ integers. In one move you can choose any $a_i$ and divide it by $2$ rounding down (in other words, in one move you can set $a_i := \lfloor\frac{a_i}{2}\rfloor$). You can perform such...
def amount_divide(): amount_dividers = [[] for _ in range(2 * 10**5 + 1)] for i in range(n): num = arr[i] j = 0 while num > 0: amount_dividers[num].append(j) num //= 2 j += 1 amount_dividers[0].append(j) ans = 10**15 for list1 in amount...
FUNC_DEF ASSIGN VAR LIST VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR NUMBER WHILE VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR VAR ...