description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
n = 2 * int(input()) arr = sorted(map(int, input().split())) x = arr[n - 1] for i in range(n): for j in range(i): u = arr[:j] + arr[j + 1 : i] + arr[i + 1 :] a = sum(u[h + 1] - u[h] for h in range(0, n - 3, 2)) x = min(x, a) print(x)
ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VA...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
n = int(input()) a = list(map(int, input().split(" "))) a.sort() mini = 100000000000 for i in range(len(a)): for j in range(i + 1, len(a)): lmin = 0 x = 0 y = 1 while y < len(a): if x == i or x == j: x += 1 continue if y == i or...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR FUNC_CAL...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
n = int(input()) ln = n * 2 weight = input() weight = weight.split(" ") length = len(weight) weight = list(map(int, weight)) arr = [] sum = 0 mini = 50000000000 for l in range(0, ln): for k in range(l + 1, ln): arr = [] sum = 0 for i in range(0, ln): if i != l and i != k: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR N...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
n = int(input()) weights = [int(i) for i in input().split()] weights.sort(reverse=True) possibleOutputs = set() for x in range(2 * n): for y in range(x, 2 * n): if x != y: tempList = [] for i in range(2 * n): if i != x: if i != y: ...
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 FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR VAR BIN_OP NUMBER VAR IF VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR IF VAR VAR IF VAR VAR ...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
n = int(input()) w = list(map(int, input().split())) w.sort() d = [] for i in range(0, 2 * n): for j in range(i + 1, 2 * n): if i == j: continue tw = list(w) tw.pop(i) tw.pop(j - 1) td = 0 for k in range(0, len(tw), 2): td += tw[k + 1] - tw[k] ...
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 FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_C...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
n = int(input()) L = sorted(list(map(int, input().split()))) v = lambda x: sum(x[i] - x[i - 1] for i, _ in enumerate(x) if i % 2 == 1) m = 100000 for p in range(2 * n): for q in range(p + 1, 2 * n): LL = L[:] del LL[p] del LL[q - 1] m = min(m, v(LL)) print(m)
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 ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP ...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
def main(): n = int(input()) n *= 2 a = list(map(int, input().split())) a.sort() o = 919478437678234 for i in range(0, n - 1): for j in range(i + 1, n): oo = 0 s = 0 while s < n - 1: if i == s or j == s: s += 1 ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP VAR NUMBER IF...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
n = int(input()) * 2 lst = [int(i) for i in input().split()] num = 99999999999999 for i in range(n - 1): for i2 in range(i + 1, n): sum_ = 0 nums = [] for m in range(n): if m != i2 and m != i: nums.append(lst[m]) nums = sorted(nums) for k in range(...
ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR AS...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
n = int(input()) w = list(map(int, input().split())) w.sort() ans = [] v = [] for i in range(len(w)): for j in range(i + 1, len(w)): v = w[:i] + w[i + 1 : j] + w[j + 1 :] s = 0 for c in range(0, len(v), 2): s += v[c] for g in range(1, len(v), 2): s = s - v[g] ...
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 ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR BI...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
def foo(ls): ls.sort() return sum([(ls[i + 1] - ls[i]) for i in range(0, len(ls) - 1, 2)]) n = int(input()) w = list(map(int, input().split())) ans = 1005000 for i in range(len(w) - 1): for j in range(i + 1, len(w)): ans = min(ans, foo([w[l] for l in range(len(w)) if l != i and l != j])) print(ans...
FUNC_DEF EXPR FUNC_CALL VAR RETURN FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER 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 FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
n = int(input()) t = list(map(int, input().split())) t.sort() t.append(0) a = [0] * (n + 1) b = [0] * (n + 1) for i in range(n): j = 2 * i a[i] = a[i - 1] + t[j + 1] - t[j] b[i] = b[i - 1] + t[j] - t[j - 1] s = a[n - 1] for i in range(0, n): for j in range(i, n): s = min(s, a[i - 1] + b[j] - b[i...
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 NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR VAR BIN...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
n = int(input()) l = input().split() for i in range(2 * n): l[i] = int(l[i]) l.sort() m = [] for i in range(2 * n): for j in range(i): k = l[:] k.remove(k[i]) k.remove(k[j]) a = [] for q in range(n - 1): a.append(k[2 * q + 1] - k[2 * q]) a.sort() ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
n = int(input()) w = list(map(int, input().split())) w.sort() swd = [0, 0] for i in range(n * 2 - 1): swd.append(swd[i] + (w[i + 1] - w[i])) m = swd[n * 2] for i in range(n): for j in range(0, n - i): s = ( swd[i * 2] + swd[(i + j) * 2 + 1] - swd[i * 2 + 1] ...
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 NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER FOR VAR...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
n = int(input()) arr = input().split() for i in range(2 * n): arr[i] = int(arr[i]) arr.sort() b = [0] * (n * 2) ctr = 0 best = 1000000 for i in range(2 * n): for j in range(i + 1, 2 * n): for k in range(2 * n): b[k] = arr[k] b[i] = -1 b[j] = -1 b.sort() ctr = ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR BIN_...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
n = int(input()) lst = [*map(int, input().split())] lst.sort() item = n * 2 - 2 res = 100000000000000000000000000 for i, x in enumerate(lst): for j, y in enumerate(lst): if i != j: mas = lst[:] mas.pop(i) mas.pop(j - 1) result = 0 for k in range(0,...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMB...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
def insertionSort(myList): for i in range(1, len(myList)): currentIndex = i while myList[currentIndex] < myList[currentIndex - 1]: temp = myList[currentIndex - 1] myList[currentIndex - 1] = myList[currentIndex] myList[currentIndex] = temp currentIndex ...
FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR WHILE VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
n = int(input()) arr = [int(el) for el in input().split()] arr.sort() d_rez = [] m = 99999999 l = len(arr) for i in range(0, l - 1): for j in range(i + 1, l): a = arr.pop(i) b = arr.pop(j - 1) size = l - 2 diff = [] s = 0 for h in range(0, size, 2): s = s ...
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 LIST ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL V...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
from itertools import combinations N = 2 * int(input()) W = list(map(int, input().split())) W.sort() def it(): for i, j in combinations(range(N), r=2): k = 0 cnt = 0 w = None for k in range(N): if not (k == i or k == j): if w is None: ...
ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_DEF FOR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NONE FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR IF VAR NONE ASSIGN VAR V...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
n = int(input()) a = sorted([int(f) for f in input().split()]) m = 1 << 31 for x in range(2 * n): for y in range(x + 1, 2 * n): b = a[:] b.pop(x) b.pop(y - 1) m = min(m, sum([abs(b[x] - b[x + 1]) for x in range(0, len(b), 2)])) print(m)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIG...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
def get_ints(): return [int(n) for n in input().split()] def get_floats(): return [float(n) for n in input().split()] def calc(w, rid): plus = True val = 0 for i, t in enumerate(w): if i not in rid: if plus: val += t else: val -= t ...
FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR FUNC_CALL VAR VAR IF VAR VAR IF VAR VAR VAR VAR VAR ASSIGN VAR VAR RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR ...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
n = int(input()) l = sorted(list(map(int, input().split()))) res = 10000000000000000 for i in range(2 * n): for j in range(i + 1, 2 * n): l1 = [l[k] for k in range(2 * n) if k != i and k != j] res = min(res, sum([(l1[k + 1] - l1[k]) for k in range(0, 2 * n - 2, 2)])) print(res)
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 ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR BIN_OP NUMBER VAR VAR VAR VAR VAR ASSIGN VAR FU...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
N = int(input()) N *= 2 W = [] W = input().split() for i in range(len(W)): W[i] = int(W[i]) W.sort() instab = 1000000000.0 for i in range(0, N): for j in range(i + 1, N): a = [] for z in range(N): if z != i and z != j: a.append(W[z]) total = 0 for k in...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR LIST ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
n = int(input()) a = [int(x) for x in input().split()] diffs = [] a.sort() for i in range(len(a) - 1): for j in range(i + 1, len(a)): sam = a[:i] + a[i + 1 : j] + a[j + 1 :] diffs.append(sum(sam[1::2]) - sum(sam[::2])) print(min(diffs))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUM...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
n = int(input()) ws = sorted(list(map(int, input().split(" ")))) res = 10**10 def f(vs): return sum(abs(a - b) for a, b in zip(vs[0::2], vs[1::2])) for i in range(len(ws)): for j in range(i + 1, len(ws)): test = ws[:i] + ws[i + 1 : j] + ws[j + 1 :] res = min(res, f(test)) print(res)
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 ASSIGN VAR BIN_OP NUMBER NUMBER FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR FUNC_CALL VAR VAR NUMBER NUMBER VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR ...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
n = int(input()) weights = list(map(int, input().split())) pairs = [] for i in range(2 * n): for j in range(2 * n): if i != j: pairs.append([i, j]) total_diff = 10000000000 for pair in pairs: diff = 0 new_weights = weights.copy() new_weights.pop(pair[0]) new_weights.pop(pair[1] -...
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 BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR IF VAR VAR EXPR FUNC_CALL VAR LIST VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR EX...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
n = 2 * int(input()) w = sorted(map(int, input().split())) r = 10000 for i in range(n): wi = w.pop(i) for j in range(i): wj = w.pop(j) r = min(r, sum(w[i + 1] - w[i] for i in range(0, n - 3, 2))) w.insert(j, wj) w.insert(i, wi) print(r)
ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER ...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
def main(): n = int(input()) wei = [] num = input().split(" ") for i in range(0, 2 * n): w = int(num[i]) wei.append(w) weight = sorted(wei) result = 100000000000 for i in range(0, 2 * n): for j in range(0, 2 * n): inslist = [] insum = 0 ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR FOR VAR FUNC_CALL...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
n = int(input()) people = [int(x) for x in input().split()] people.sort() ans = 9999999999 for i in range(n * 2): for j in range(n * 2 - 1): if i != j: counter = 0 temp_people = people.copy() temp_people.pop(i) temp_people.pop(j) for k in reversed(...
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 NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL V...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
n = int(input()) weights = [int(x) for x in input().split()] weights = sorted(weights, reverse=True) s = 0 def lap(weights): first = weights[0] second = weights[1] totalInstability = 0 for k in range(0, len(weights), 2): totalInstability += first - second try: first = weigh...
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 NUMBER ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR BIN_OP VAR VAR ASSIGN VAR VAR BIN_OP VAR ...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
def total_insta(www, exl1, exl2): wwe = www[:] wwe.remove(exl1) wwe.remove(exl2) result = 0 for x in range(len(wwe) // 2): result += abs(wwe[x * 2] - wwe[x * 2 + 1]) return result class CodeforcesTask863BSolution: def __init__(self): self.result = "" self.n = 0 ...
FUNC_DEF ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP VAR NUMBER NUMBER RETURN VAR CLASS_DEF FUNC_DEF ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR LIST FUNC_DEF ASSI...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
def solve(): n = int(input()) w = [int(st) for st in input().split(" ")] w.sort() ans = 2**31 ansi, ansj = None, None for i in range(0, 2 * n - 1, 2): for j in range(i + 1, 2 * n, 2): s = 0 for k in range(0, i - 1, 2): s += w[k + 1] - w[k] ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR VAR NONE NONE FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR NUMBER...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
input() l = list(map(int, input().split())) l.sort() count = 100000 for i in range(len(l)): for j in range(i + 1, len(l)): l_new = l[:] l_new.pop(j) l_new.pop(i) v = sum([abs(l_new[k] - l_new[k + 1]) for k in range(0, len(l_new), 2)]) if v < count: count = v print...
EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
import sys def main(pname): n = int(input()) l = [int(i) for i in input().split()] l.sort() m = 100000 for i in range(2 * n): for j in range(i): d = l[:j] + l[j + 1 : i] + l[i + 1 :] s = 0 for k in range(0, len(d) - 1, 2): s += d[k + 1] -...
IMPORT FUNC_DEF 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 NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER FOR VA...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
def main(): nK = int(input()) - 1 wL = list(map(int, input().split())) wL = sorted(wL) ans = findScore(wL) print(ans) def findScore(wL): scoreL = [] for i in range(len(wL) - 1): for j in range(i + 1, len(wL)): temp = wL.copy() temp.pop(temp.index(wL[i])) ...
FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR NUMBER 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 EXPR FUNC_CALL VAR VAR FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VA...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
def solve(n, ar): ar = sorted(ar) n = 2 * n cnt = 0 temp = [] ans = 999999999 for i in range(n - 1): for j in range(i + 1, n): for k in range(n): if k == i or k == j: continue temp.append(ar[k]) for z in range(0,...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VA...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
n = int(input()) w = list(map(int, input().split())) ans = 10**6 w.sort() for i in range(n * 2): for j in range(i + 1, n * 2): t = w[:i] + w[i + 1 : j] + w[j + 1 :] temp = 0 for k in range(n - 1): temp += t[k * 2 + 1] - t[k * 2] ans = min(ans, temp) print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR BI...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
import sys n = int(input()) * 2 a = sorted(map(int, input().split())) ans = 10**9 for ex1 in range(n): for ex2 in range(ex1 + 1, n): i, j = 0, 0 res = 0 while i < n: while i < n and (i == ex1 or i == ex2): i += 1 j = i + 1 while j < n and ...
IMPORT ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR WHILE VAR VAR VAR VAR VAR VAR ...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
def list_input(): return list(map(int, input().split())) def map_input(): return map(int, input().split()) def map_string(): return input().split() n = int(input()) n *= 2 a = list_input() a.sort() ans = 10000000000000 for i in range(n): for j in range(i + 1, n): b = [] for k in ra...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
n = int(input()) a = list(map(int, input().split())) a.sort() m = float("inf") for i in range(0, 2 * n - 1): for j in range(i + 1, 2 * n): k = 0 ans = 0 if j != i + 1: while k < 2 * n: if k == i or k == j: k += 1 elif k + 1 == i...
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 FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR B...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
n = int(input()) a = [int(z) for z in input().split()] n = n * 2 out = int(1000000000.0) def pos(cur, i, j): if cur != i and cur != j: return cur else: return pos(cur + 1, i, j) a.sort() for i in range(n): for j in range(i + 1, n): ans = 0 k = 0 while True: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER FUNC_DEF IF VAR VAR VAR VAR RETURN VAR RETURN FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
INF = 1061109567 n = int(input()) t = n - 1 n = n + n str = input() ls = [int(x) for x in str.split()] ls.sort() x = [] ans = INF for i in range(0, n): for j in range(i + 1, n): x = [] sum = 0 for k in range(n): if i != k and j != k: x.append(ls[k]) for k ...
ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VA...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
def solution(x): x.sort() min_ans = x[-1] - x[0] for L in range(len(x) - 1): for R in range(L + 1, len(x)): cur_ans = 0 indexes = ( list(range(L)) + list(range(L + 1, R)) + list(range(R + 1, len(x))) ) for k in range(1, len(indexes), 2)...
FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR F...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
input() w = list(map(int, input().split())) w = sorted(w) if len(w) % 2 == 0: minsum = 10**10 for a in range(len(w)): for b in range(a + 1, len(w)): sum = 0 p = w[:a] + w[a + 1 : b] + w[b + 1 :] for c in range(len(p) // 2): sum += p[2 * c + 1] - p[2 * ...
EXPR 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 FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
n = int(input()) arr = list(map(int, input().split(" "))) arr.sort() dif_list = [] for i in arr: for j in arr: k = 0 count = 0 copyarr = arr.copy() if i == j: continue copyarr.remove(i) copyarr.remove(j) while k < 2 * n - 2: count += ab...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR FOR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR WHILE VAR BIN_OP BIN_OP NUMBER...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
n = int(input()) v = [int(i) for i in input().split()] count = 0 m = float("inf") for i in range(len(v)): for j in range(i + 1, len(v)): c = [] for k in range(len(v)): if k == i or k == j: continue c.append(v[k]) c.sort() p = 0 for k in...
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 FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR E...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
n = int(input()) next_line = input() arr = next_line.split(" ") arr = [int(i) for i in arr] arr.sort() mintotal = 100001 for y in range(0, 2 * n): for z in range(0, 2 * n): if y != z: newarr = [] curtotal = 0 for x in range(0, 2 * n): if x != z and x != y:...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR IF VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUN...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
n = int(input()) weights = input().strip().split() for weight in range(len(weights)): weights[weight] = int(weights[weight]) weights.sort() reset = weights[:] totalList = [] for exclude1 in range(len(weights) - 1): for exclude2 in range(exclude1 + 1, len(weights)): reset = weights[:] total = 0 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR V...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
import sys def readinput(): data = sys.stdin.read().strip().split("\n") n = int(data[0]) p = sorted([int(i) for i in data[1].split()]) return 2 * n, p def main(): n, p = readinput() instability = set() for i in range(n): for j in range(i + 1, n): instability.add(solve...
IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER RETURN BIN_OP NUMBER VAR VAR FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP V...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
n = int(input()) * 2 w = [int(x) for x in input().split()] w.sort(reverse=True) a = [0] * n s = 10**100 for i in range(n - 1): for j in range(i + 1, n): b = [] for k in range(n): if k != i and k != j: b.append(w[k]) for k in range(0, n - 3, 2): a[k] = ...
ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL ...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
def main(): n = 2 * int(input()) a = list(map(int, input().split())) a.sort() ans = 10**9 + 7 for i in range(n): for j in range(i + 1, n): b = [] b.extend(a) b.remove(a[i]) b.remove(a[j]) cnt = 0 for l in range(1, n - 2,...
FUNC_DEF ASSIGN VAR BIN_OP NUMBER 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 BIN_OP BIN_OP NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VA...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
y = int(input()) z = list(map(int, input().split())) z.sort(reverse=True) difs = [] mini = 1000 def btsheel(lista, ind1, ind2): return lista[:ind1] + lista[ind1 + 1 : ind2] + lista[ind2 + 1 :] for i in range(2 * y - 1): for j in range(i + 1, 2 * y): new = btsheel(z, i, j) temp = 0 fo...
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 NUMBER ASSIGN VAR LIST ASSIGN VAR NUMBER FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER FOR VAR FUNC_C...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
n = int(input()) l = [int(i) for i in input().split()] l.sort() mini = 10**100 for i in range(2 * n): for j in range(0, 2 * n): inst = 0 l1 = [] for k in range(2 * n): if k == i or k == j: continue l1.append(l[k]) l1.sort() for x in ran...
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 BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR IF VAR VAR V...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
def calcdifs(nums): difs = [] for i in range(len(nums) - 1): difs.append(nums[i + 1] - nums[i]) return sum(difs[::2]) input() nums = sorted([int(x) for x in input().split()]) allvalues = [] for i, ii in enumerate(nums): for j, jj in enumerate(nums): if i != j: nums2 = nums....
FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR RETURN FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR FOR VAR VAR FUNC_...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
n = int(input()) w = list(map(int, input().split())) h = dict() for val in w: h[val] = h.get(val, 0) + 1 res = [] for key in h: res += [key] * (h[key] % 2) res.sort() s = [] for i in range(len(res)): for j in range(i + 1, len(res)): b = res[:i] + res[i + 1 : j] + res[j + 1 :] s.append(abs(su...
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 FOR VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR LIST FOR VAR VAR VAR BIN_OP LIST VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL ...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
n = int(input()) a = list(map(int, input().split())) a.sort() cap = [] res = [] for i in range(0, 2 * n - 1, 2): for j in range(i + 1, 2 * n, 2): f = 0 first = 1 cap = [] for k in range(2 * n): if k == i or k == j: continue if first: ...
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 ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR N...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
n = int(input()) a = list(map(int, input().strip().split())) a.sort() best = 100000 for i in range(0, 2 * n - 1): for j in range(i + 1, 2 * n): diff = 0 p = -1 for k in range(0, 2 * n): if k != i and k != j: diff += p * a[k] p = -p best = m...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
N = int(input()) ans = 1000000000.0 weights = sorted(map(int, input().split())) for x in range(2 * N): for y in range(x + 1, 2 * N): rest = [weights[z] for z in range(2 * N) if z != x and z != y] curr = sum(rest[z] - rest[z - 1] for z in range(1, len(rest), 2)) ans = min(ans, curr) print(ans...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR BIN_OP NUMBER VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR BI...
Vadim is really keen on travelling. Recently he heard about kayaking activity near his town and became very excited about it, so he joined a party of kayakers. Now the party is ready to start its journey, but firstly they have to choose kayaks. There are 2·n people in the group (including Vadim), and they have exactly...
n = int(input()) w = list(map(int, input().split(" "))) w.sort() min = 1000000 for i in range(2 * n - 1): for j in range(i + 1, 2 * n): sum = 0 sch = 0 h = 0 while h < 2 * n - 1 and sch != 2 * n - 2: sch += 2 if h != i and h != j: if h + 1 != i...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHIL...
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev decided to build a house of cards. For that they've already found a hefty deck of n playing cards. Let's describe the house they want to make: 1. The house consists of some non-zero number of floors. 2. Each ...
R = lambda: map(int, input().split()) def gc(h): return 2 * h + 3 * h * (h - 1) // 2 mx = 10**7 n = int(input()) cnt = 0 for f in range(1, mx): base = gc(f) if base > n: break if (n - base) % 3 == 0: cnt += 1 print(cnt)
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN BIN_OP BIN_OP NUMBER VAR BIN_OP BIN_OP BIN_OP NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR IF BIN_...
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev decided to build a house of cards. For that they've already found a hefty deck of n playing cards. Let's describe the house they want to make: 1. The house consists of some non-zero number of floors. 2. Each ...
def is_suit(n, k): return n >= k * (k + 1) // 2 def check2(n, k, j=1): if k == 0 and n == 0: return True cur = False for i in range(j, n + 1): cur |= check2(n - i, k - 1, j + 1) return cur def check(n, k): if n < k: return False r = 3 - n % 3 k = (k - 1) * 3 +...
FUNC_DEF RETURN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER FUNC_DEF NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER RETURN VAR FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR BIN_OP NUMBER B...
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev decided to build a house of cards. For that they've already found a hefty deck of n playing cards. Let's describe the house they want to make: 1. The house consists of some non-zero number of floors. 2. Each ...
cards = int(input()) result = 0 n = 0 while True: n += 1 needed = 2 * n + 3 * n * (n - 1) / 2 if cards < needed: break if (cards - needed) % 3 == 0: result += 1 print(result)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR BIN_OP BIN_OP BIN_OP NUMBER VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev decided to build a house of cards. For that they've already found a hefty deck of n playing cards. Let's describe the house they want to make: 1. The house consists of some non-zero number of floors. 2. Each ...
n = int(input()) ans = 0 layer = 0 while True: layer += 1 rem = 2 * layer % 3 if n % 3 != rem: continue least = 3 * layer * (layer + 1) // 2 - layer if n < least: break ans += 1 print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR IF VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev decided to build a house of cards. For that they've already found a hefty deck of n playing cards. Let's describe the house they want to make: 1. The house consists of some non-zero number of floors. 2. Each ...
n = int(input()) cnt = 0 ans = 0 for i in range(0, 10**7): cnt += 3 * i + 2 if cnt > n: break elif (n - cnt) % 3 == 0: ans += 1 print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER NUMBER VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev decided to build a house of cards. For that they've already found a hefty deck of n playing cards. Let's describe the house they want to make: 1. The house consists of some non-zero number of floors. 2. Each ...
n = int(input()) c = 0 i = 0 if (n - 2) % 3 == 0: b = 0 while c == 0: a = (n - 2 - 6 * b) / 3 q = 3 * b * (3 * b + 1) / 2 if a >= q: b = b + 1 else: break if (n - 4) % 3 == 0: b = 0 while c == 0: a = (n - 4 - 6 * b) / 3 q = (3 * b +...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER VAR BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER IF VAR VAR ASSIGN ...
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev decided to build a house of cards. For that they've already found a hefty deck of n playing cards. Let's describe the house they want to make: 1. The house consists of some non-zero number of floors. 2. Each ...
n = int(input()) t = 1 sum = 0 while True: sum += 2 * t + (t - 1) if sum > n: t -= 1 break t += 1 cnt = 0 for i in range(1, t + 1): if (n + i) % 3 == 0: cnt += 1 print(cnt)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER VAR BIN_OP BIN_OP NUMBER VAR BIN_OP VAR NUMBER IF VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev decided to build a house of cards. For that they've already found a hefty deck of n playing cards. Let's describe the house they want to make: 1. The house consists of some non-zero number of floors. 2. Each ...
N = int(input()) a = 0 b = 10**12 while b - a > 1: e = (b + a) // 2 if 3 * e * e + e - 2 * N <= 0: a = e else: b = e x = a if N % 3 == 0: print(x // 3) elif N % 3 == 1: inc = 0 if x % 3 == 2: inc += 1 print(x // 3 + inc) else: inc = 0 if x % 3 >= 1: in...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER WHILE BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR VAR VAR BIN_OP NUMBER VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL ...
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev decided to build a house of cards. For that they've already found a hefty deck of n playing cards. Let's describe the house they want to make: 1. The house consists of some non-zero number of floors. 2. Each ...
n = int(input()) res, k = 0, 1 while n >= 2 * k + 3 * k * (k - 1) // 2: if n % 3 == 2 * k % 3: res += 1 k += 1 print(res)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER NUMBER WHILE VAR BIN_OP BIN_OP NUMBER VAR BIN_OP BIN_OP BIN_OP NUMBER VAR BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev decided to build a house of cards. For that they've already found a hefty deck of n playing cards. Let's describe the house they want to make: 1. The house consists of some non-zero number of floors. 2. Each ...
print( ( lambda n: len( [ (1) for x in range(1, int((-1 + (24 * n + 25) ** 0.5) / 6) + 1) if not (n - 2 * x) % 3 ] ) )(int(input())) )
EXPR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER NUMBER NUMBER BIN_OP BIN_OP VAR BIN_OP NUMBER VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev decided to build a house of cards. For that they've already found a hefty deck of n playing cards. Let's describe the house they want to make: 1. The house consists of some non-zero number of floors. 2. Each ...
n, bisect = int(input()), lambda l, r: ( l if r <= l + 1 else ( bisect(l + r >> 1, r) if (3 * (l + r >> 1) - 2) * ((l + r >> 1) + 1) <= n * 2 else bisect(l, l + r >> 1) ) ) print((bisect(0, n) - (n + bisect(0, n)) % 3 + 2) // 3)
ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR BIN_OP BIN_OP BIN_OP NUMBER BIN_OP BIN_OP VAR VAR NUMBER NUMBER BIN_OP BIN_OP BIN_OP VAR VAR NUMBER NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP BIN_OP...
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev decided to build a house of cards. For that they've already found a hefty deck of n playing cards. Let's describe the house they want to make: 1. The house consists of some non-zero number of floors. 2. Each ...
import sys n = int(sys.stdin.readline()) def sum(n): return (n + 1) * n // 2 a = 1 res = 0 while 3 * sum(a - 1) + 2 * a <= n: if (n - 2 * a) % 3 == 0: res += 1 a += 1 print(res)
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP BIN_OP NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR VAR IF BIN_OP BIN_OP VAR BIN_OP NUMBER VAR NUMBER NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev decided to build a house of cards. For that they've already found a hefty deck of n playing cards. Let's describe the house they want to make: 1. The house consists of some non-zero number of floors. 2. Each ...
n = int(input()) if n % 3 == 2 and n >= 2: min = 1 elif n % 3 == 1 and n >= 7: min = 2 elif n % 3 == 0 and n >= 15: min = 3 else: print("0") quit() zac, end = 0, n + 47 while end - zac > 1: str = (end + zac) // 2 if n >= (3 * str * str + str) // 2: zac = str else: end = s...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER WHILE BIN_OP VAR VAR NUMB...
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev decided to build a house of cards. For that they've already found a hefty deck of n playing cards. Let's describe the house they want to make: 1. The house consists of some non-zero number of floors. 2. Each ...
def main(): (n,) = read() c = 0 i = 1 m = 3 - n % 3 res = 0 while c <= n: c += 3 * i - 1 i += 1 m -= 1 if m == 0 and c <= n: res += 1 m += 3 print(res) def read(mode=2): inputs = input().strip() if mode == 0: return in...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP BIN_OP NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR FUNC_DEF NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR...
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev decided to build a house of cards. For that they've already found a hefty deck of n playing cards. Let's describe the house they want to make: 1. The house consists of some non-zero number of floors. 2. Each ...
n, a, b = int(input()), 0, 0 for i in range(1, int(1000000000000.0) + 1): if i**2 > 1000000000000.0: break a += 3 * i - 1 if a > n: break if (n - a) % 3 == 0: b += 1 print(b)
ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev decided to build a house of cards. For that they've already found a hefty deck of n playing cards. Let's describe the house they want to make: 1. The house consists of some non-zero number of floors. 2. Each ...
n = int(input()) ans = 0 if n == 2: print(1) else: for i in range(1, 1000000): val = i * (3 * i + 1) / 2 if n < val: break elif (n - val) % 3 == 0: ans += 1 print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER IF VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev decided to build a house of cards. For that they've already found a hefty deck of n playing cards. Let's describe the house they want to make: 1. The house consists of some non-zero number of floors. 2. Each ...
from itertools import count def f(n): least = 0 ret = 0 for x in count(1): least += 3 * x - 1 if least > n: break if (n - least) % 3 == 0: ret += 1 return ret n = int(input()) print(f(n))
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR BIN_OP BIN_OP NUMBER VAR NUMBER IF VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev decided to build a house of cards. For that they've already found a hefty deck of n playing cards. Let's describe the house they want to make: 1. The house consists of some non-zero number of floors. 2. Each ...
num_cards = int(input()) l, r = 0, num_cards + 1 while l + 1 < r: m = l + r >> 1 if m * (3 * m + 1) <= num_cards * 2: l = m else: r = m print(len([(1) for x in range(1, l + 1) if (num_cards - 2 * x) % 3 == 0]))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER WHILE BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP VAR BIN_OP BIN_OP NUMBER VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUM...
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev decided to build a house of cards. For that they've already found a hefty deck of n playing cards. Let's describe the house they want to make: 1. The house consists of some non-zero number of floors. 2. Each ...
print( (lambda x: (x[1] - (x[0] + x[1]) % 3 + 2) // 3)( (lambda n: [n, int((-1 + (1 + 24 * n) ** 0.5) / 6)])(int(input())) ) )
EXPR FUNC_CALL VAR FUNC_CALL BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR NUMBER NUMBER NUMBER NUMBER FUNC_CALL LIST VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER BIN_OP BIN_OP NUMBER BIN_OP NUMBER VAR NUMBER NUMBER FUNC_CALL VAR FUNC_CALL VAR
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev decided to build a house of cards. For that they've already found a hefty deck of n playing cards. Let's describe the house they want to make: 1. The house consists of some non-zero number of floors. 2. Each ...
def cl(a, b): if a % b: return 1 + int(a / b) return int(a / b) n = int(input()) ans = 1 prev = 1 tot = 2 while tot + prev + 2 * (prev + 1) <= n: tot += prev + 2 * (prev + 1) prev += 1 ans += 1 rem = n - tot ans -= rem % 3 if ans <= 0: print(0) exit() print(cl(ans, 3))
FUNC_DEF IF BIN_OP VAR VAR RETURN BIN_OP NUMBER FUNC_CALL VAR BIN_OP VAR VAR RETURN FUNC_CALL VAR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP BIN_OP VAR VAR BIN_OP NUMBER BIN_OP VAR NUMBER VAR VAR BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER VAR...
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev decided to build a house of cards. For that they've already found a hefty deck of n playing cards. Let's describe the house they want to make: 1. The house consists of some non-zero number of floors. 2. Each ...
import itertools n = int(input()) count = 0 for f in itertools.count(1): min_count = f * (f + 1) * 3 // 2 - f if min_count > n: break if (n - min_count) % 3 == 0: count += 1 print(count)
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER NUMBER VAR IF VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev decided to build a house of cards. For that they've already found a hefty deck of n playing cards. Let's describe the house they want to make: 1. The house consists of some non-zero number of floors. 2. Each ...
n = int(input()) res = 0 floors = 0 maxCardForRooms = 0 while maxCardForRooms < n: maxCardForRooms += 2 + 3 * floors floors += 1 if maxCardForRooms != n: floors -= 1 for j in range(floors): if (n - 2 * (j + 1)) % 3 == 0: res += 1 print(res)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR BIN_OP NUMBER BIN_OP NUMBER VAR VAR NUMBER IF VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev decided to build a house of cards. For that they've already found a hefty deck of n playing cards. Let's describe the house they want to make: 1. The house consists of some non-zero number of floors. 2. Each ...
n = int(input()) if n in [1, 3, 4, 6]: print(0) quit() elif n == 2: print(1) quit() k = int((24 * n + 1) ** 0.5 - 1) / 6 k -= 1 while k * (3 * k + 1) / 2 <= n: k += 1 k -= 1 a = 0 k = int(k) for i in range(1, k + 1): if (3 - i) % 3 == n % 3: a += 1 print(a)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR LIST NUMBER NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP FUNC_CALL VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER NUMBER NUMBER VAR NUMBER WHILE BIN_OP BIN_OP VAR BIN...
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev decided to build a house of cards. For that they've already found a hefty deck of n playing cards. Let's describe the house they want to make: 1. The house consists of some non-zero number of floors. 2. Each ...
n = int(input()) i = 1 r = 0 while i * (i + 1) * 3 // 2 - i <= n: if (n - i * (i + 1) * 3 // 2 + i) % 3 == 0: r += 1 i += 1 print(r)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER NUMBER VAR VAR IF BIN_OP BIN_OP BIN_OP VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo of Kiev decided to build a house of cards. For that they've already found a hefty deck of n playing cards. Let's describe the house they want to make: 1. The house consists of some non-zero number of floors. 2. Each ...
n = int(input()) l = 0 r = 10**13 ans = 0 while l <= r: mid = l + (r - l) // 2 if (3 * mid**2 + mid) // 2 <= n: ans = mid l = mid + 1 else: r = mid - 1 c = 0 for i in range(1, ans + 1): if (n + i) % 3 == 0: c += 1 print(c)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER IF BIN_OP BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER VAR NUMBER VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR ...
Sehr Sus is an infinite hexagonal grid as pictured below, controlled by MennaFadali, ZerooCool and Hosssam. They love equilateral triangles and want to create $n$ equilateral triangles on the grid by adding some straight lines. The triangles must all be empty from the inside (in other words, no straight line or hexago...
def check(mid, n): x = mid // 3 y = x z = x if mid % 3 == 1: z += 1 elif mid % 3 == 2: z += 1 y += 1 if 2 * (x * y + x * z + y * z) >= n: return True return False def lbp(n): left = 1 right = int(n ** (1 / 3)) + 1 while right - left > 1: ...
FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER IF BIN_OP NUMBER BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL ...
Sehr Sus is an infinite hexagonal grid as pictured below, controlled by MennaFadali, ZerooCool and Hosssam. They love equilateral triangles and want to create $n$ equilateral triangles on the grid by adding some straight lines. The triangles must all be empty from the inside (in other words, no straight line or hexago...
import sys input = lambda: sys.stdin.readline().strip() ans = 0 for i in range(int(input())): a = int(input()) f = int((3 / 2 * a) ** 0.5) final = 0 for i in range(f, f + 2): if 2 * i**2 / 3 >= a: final = i break if a == 1 or a == 2: print(2) else: ...
IMPORT ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP NUMBER NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER IF BIN_OP BIN_OP NUMBER BIN_OP VAR NUM...
Sehr Sus is an infinite hexagonal grid as pictured below, controlled by MennaFadali, ZerooCool and Hosssam. They love equilateral triangles and want to create $n$ equilateral triangles on the grid by adding some straight lines. The triangles must all be empty from the inside (in other words, no straight line or hexago...
t = int(input()) out = "" for _ in range(t): n = int(input()) i = int((n / 6) ** 0.5) total = 6 * i**2 add = 4 * i i *= 3 while total < n: total += add i += 1 if i % 3 != 0: add += 2 out += str(i) + "\n" print(out)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR STRING FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR VAR NUMBER WHILE VAR VAR VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMB...
Sehr Sus is an infinite hexagonal grid as pictured below, controlled by MennaFadali, ZerooCool and Hosssam. They love equilateral triangles and want to create $n$ equilateral triangles on the grid by adding some straight lines. The triangles must all be empty from the inside (in other words, no straight line or hexago...
import sys DEBUG = False def check(n): k = (n / 2 / 3) ** 0.5 k = int(k) def test(a, b, c): if (a * b + a * c + b * c) * 2 >= n: print(a + b + c) return True return False if test(k, k, k): return if test(k, k, k + 1): return if test(k,...
IMPORT ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR FUNC_DEF IF BIN_OP BIN_OP BIN_OP BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP VAR VAR NUMBER VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR VAR RETURN NUMBER RETURN NUMBER IF FUNC_CALL VAR VAR VAR VAR RETURN IF...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given N integers. In each step you can choose some K of the remaining numbers and delete them, if the following condition holds: Let the K numbers you've chosen be a_{1}, a_{2}, a_{3}, ..., a_{K} in sorted order. Then, for each i ≤ ...
def fun(x): arr = [a[i] for i in range(x)] zz = x for i in range(1, k): for j in range(x): while zz < n and a[zz] < c * arr[j]: zz += 1 if zz >= n: return False arr[j] = a[zz] zz += 1 return True for _ in range(int...
FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR WHILE VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR NUMBER IF VAR VAR RETURN NUMBER ASSIGN VAR VAR VAR VAR VAR NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FU...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given N integers. In each step you can choose some K of the remaining numbers and delete them, if the following condition holds: Let the K numbers you've chosen be a_{1}, a_{2}, a_{3}, ..., a_{K} in sorted order. Then, for each i ≤ ...
def chk(arr, n, k, c, ted): ok = 0 cur = 0 if ted == ok: return True it = [-1] * ted las = [0] * ted for i in range(n): if ted == ok: return True while it[cur] >= k: cur = (cur + 1) % ted if it[cur] == -1: las[cur] = arr[i] ...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR RETURN NUMBER ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF VAR VAR RETURN NUMBER WHILE VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR IF VAR VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR NUMBER IF VAR VAR...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given N integers. In each step you can choose some K of the remaining numbers and delete them, if the following condition holds: Let the K numbers you've chosen be a_{1}, a_{2}, a_{3}, ..., a_{K} in sorted order. Then, for each i ≤ ...
def binary(l, n, m, c, k): li = [] for i in range(m): li.append(l[i]) i = m for j in range(1, k): for h in range(m): while i < n and li[h] * c > l[i]: i = i + 1 if i < n: li[h] = l[i] i = i + 1 else: ...
FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR WHILE VAR VAR BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN NUMBER RETURN NUMBER FOR VAR...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given N integers. In each step you can choose some K of the remaining numbers and delete them, if the following condition holds: Let the K numbers you've chosen be a_{1}, a_{2}, a_{3}, ..., a_{K} in sorted order. Then, for each i ≤ ...
def check(arr, noOfSteps, C, K): if noOfSteps == 0: return True steps = [] for i in range(noOfSteps): steps.append([]) done = 0 index = 0 for i in range(len(arr)): if len(steps[index]) == 0: steps[index].append(arr[i]) if len(steps[index]) == K: ...
FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR IF FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VA...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given N integers. In each step you can choose some K of the remaining numbers and delete them, if the following condition holds: Let the K numbers you've chosen be a_{1}, a_{2}, a_{3}, ..., a_{K} in sorted order. Then, for each i ≤ ...
def check(l, a, n, k, c): count = 0 b = {} new = 0 for i in range(l): b[i] = [] for i in range(n): if len(b[new]) == 0: b[new].append(a[i]) if len(b[new]) == k: count += 1 new = (new + 1) % l elif a[i] >= b[new][-1] * c: ...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR DICT ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR LIST FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR IF FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR IF VAR VAR BIN_OP VAR VAR NUMBER VAR EXPR FU...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given N integers. In each step you can choose some K of the remaining numbers and delete them, if the following condition holds: Let the K numbers you've chosen be a_{1}, a_{2}, a_{3}, ..., a_{K} in sorted order. Then, for each i ≤ ...
def check(x): v1 = [] v2 = [] for i in range(x): v1.append(a[i]) p = x for i in range(1, k): v2 = [] for j in range(len(v1)): while p < n and a[p] < v1[j] * c: p += 1 if p >= n: return False v2.append(a[p]) ...
FUNC_DEF ASSIGN VAR LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR WHILE VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR NUMBER IF VAR VAR RETURN NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN ...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given N integers. In each step you can choose some K of the remaining numbers and delete them, if the following condition holds: Let the K numbers you've chosen be a_{1}, a_{2}, a_{3}, ..., a_{K} in sorted order. Then, for each i ≤ ...
def check(m): ptr = 0 ds = [[] for i in range(m)] ele = 0 for i in range(K): for j in range(m): if len(ds[j]) == 0 and ptr < len(a): ds[j].append(a[ptr]) ele += 1 else: while ptr < len(a) and a[ptr] < ds[j][i - 1] * C: ...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR NUMBER WHILE VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER IF VA...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given N integers. In each step you can choose some K of the remaining numbers and delete them, if the following condition holds: Let the K numbers you've chosen be a_{1}, a_{2}, a_{3}, ..., a_{K} in sorted order. Then, for each i ≤ ...
def check(arr, x, k, c): vec = [[] for i in range(x)] l = 0 for i in range(n): if len(vec[l]) == k: return True elif len(vec[l]) == 0 or vec[l][-1] * c <= arr[i]: vec[l].append(arr[i]) l = (l + 1) % x for i in range(x): if len(vec[i]) != k: ...
FUNC_DEF ASSIGN VAR LIST VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR VAR RETURN NUMBER IF FUNC_CALL VAR VAR VAR NUMBER BIN_OP VAR VAR NUMBER VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VA...
Read problems statements in mandarin chinese, russian and vietnamese as well. You are given N integers. In each step you can choose some K of the remaining numbers and delete them, if the following condition holds: Let the K numbers you've chosen be a_{1}, a_{2}, a_{3}, ..., a_{K} in sorted order. Then, for each i ≤ ...
def find(N, K, C, A): start = N // K def check(X): if X == 0: return 1 AA = [[] for i in range(X)] cur = 0 for i in range(len(A)): x = A[i] if AA[cur] == []: AA[cur] += [x] cur = (cur + 1) % X elif l...
FUNC_DEF ASSIGN VAR BIN_OP VAR VAR FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR LIST VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR IF VAR VAR LIST VAR VAR LIST VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER VAR IF FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR VAR NUMBER IF VA...
Given a positive integer $m$, we say that a sequence $x_1, x_2, \dots, x_n$ of positive integers is $m$-cute if for every index $i$ such that $2 \le i \le n$ it holds that $x_i = x_{i - 1} + x_{i - 2} + \dots + x_1 + r_i$ for some positive integer $r_i$ satisfying $1 \le r_i \le m$. You will be given $q$ queries consi...
t = int(input()) def r(i, m): return 1 << i, m * (1 << i) def bis(i, e, m): if i == 0: return e mn = 1 << i - 1 e -= mn mlt = 1 << i - 1 l, r = 1, m if r * mlt <= e: return r while r - l > 1: m = (r + l) // 2 if m * mlt <= e: l = m ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN BIN_OP NUMBER VAR BIN_OP VAR BIN_OP NUMBER VAR FUNC_DEF IF VAR NUMBER RETURN VAR ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER VAR VAR ASSIGN VAR BIN_OP NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER VAR IF BIN_OP VAR VAR VAR RETURN VAR WHILE BIN_OP VAR VAR NUMBER ASS...
Given a positive integer $m$, we say that a sequence $x_1, x_2, \dots, x_n$ of positive integers is $m$-cute if for every index $i$ such that $2 \le i \le n$ it holds that $x_i = x_{i - 1} + x_{i - 2} + \dots + x_1 + r_i$ for some positive integer $r_i$ satisfying $1 \le r_i \le m$. You will be given $q$ queries consi...
N = int(input()) for _ in range(N): a, b, m = list(map(int, input().split())) m -= 1 if a == b: print("1 " + str(a)) continue c = a d = 1 f = False r = [] while b - (1 << d - 1) - c >= 0: if b - (1 << d - 1) - c <= m << d - 1: rem = b - (1 << d - 1) - ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR BIN_OP STRING FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE BIN_OP BIN_OP VAR BIN_OP NUMBER BI...
Given a positive integer $m$, we say that a sequence $x_1, x_2, \dots, x_n$ of positive integers is $m$-cute if for every index $i$ such that $2 \le i \le n$ it holds that $x_i = x_{i - 1} + x_{i - 2} + \dots + x_1 + r_i$ for some positive integer $r_i$ satisfying $1 \le r_i \le m$. You will be given $q$ queries consi...
q = int(input()) for _ in range(q): a, b, m = map(int, input().split()) if a == b: print(1, a) continue a1 = a + 1 am = a + m for i in range(49): if a1 <= b <= am: n = i + 2 s = 0 ans = [a, *([0] * (n - 1))] for j in range(1, n)...
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 IF VAR VAR EXPR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN ...
Given a positive integer $m$, we say that a sequence $x_1, x_2, \dots, x_n$ of positive integers is $m$-cute if for every index $i$ such that $2 \le i \le n$ it holds that $x_i = x_{i - 1} + x_{i - 2} + \dots + x_1 + r_i$ for some positive integer $r_i$ satisfying $1 \le r_i \le m$. You will be given $q$ queries consi...
def get_r_list(a, b, m): k = 2 two_power_k = 1 isMatch = False if a == b: return 1, [] while True: if b <= two_power_k * (a + 1): isMatch = True break if k == 50: break k += 1 two_power_k *= 2 isDone = False if isMat...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR RETURN NUMBER LIST WHILE NUMBER IF VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR B...