description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
n, l, r, x = map(int, input().split(" ")) a = list(map(int, input().split(" "))) b = list() total = 0 for i in range(1, 1 << n): for j in range(0, n): if i & 1 << j != 0: b.append(a[j]) if len(b) >= 2: if sum(b) >= l and sum(b) <= r and max(b) - min(b) >= x: total = total...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR BIN_OP NUMBER VAR NUMBER EXPR FUNC_CA...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
from itertools import * n, least, highest, x = map(int, input().split()) l = [*map(int, input().split())] cnt = 0 for i in range(2, n + 1): combination = [*map(list, combinations(l, i))] for j in range(len(combination)): combination[j].sort() total = sum(combination[j]) if ( ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FU...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
def solve(): n, l, r, x = map(int, input().split(" ")) c = list(map(int, input().split(" "))) ans = 0 for bitmask in range(2**n): if bin(bitmask).count("1") > 1: res, _min, _max = 0, float("+inf"), float("-inf") for c_i, bit_i in zip(c, (1 & int(bitmask) >> i for i in ran...
FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR IF FUNC_CALL FUNC_CALL VAR VAR STRING NUMBER ASSIGN VAR VAR VAR NUMBER FUNC_CALL VAR STRING FUNC_CALL VAR S...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
res = 0 n, l, r, x = map(int, input().split()) a = list(map(int, input().split())) msk = 1 while msk <= 1 << n: mn = 1 << 31 mx = -1 sum = 0 cnt = 0 for y in range(0, n): if msk & 1 << y: cnt += 1 sum += a[y] mx = max(mx, a[y]) mn = min(mn, a[y...
ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BI...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
n, l, r, x = map(int, input().split()) cs = list(map(int, input().split())) def subsets(x): if len(x) == 0: return [[]] a = subsets(x[1:]) b = [([x[0]] + c) for c in a] return a + b sets = subsets(cs) ans = 0 for s in sets: if len(s) < 2: continue if not l <= sum(s) <= r: ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN LIST LIST ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP LIST VAR NUMBER VAR VAR VAR RETURN BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR A...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
n, l, r, x = map(int, input().split()) c = [int(i) for i in input().split()] ans = 0 for i in range(2**n): s = bin(i)[2:] s = "0" * (n - len(s)) + s cnt = 0 for j in s: if j == "1": cnt += 1 if cnt < 2: continue diff = 0 ma = -1 mi = 10**10 for j in range(...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR ST...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
print( (lambda go, n, l, r, x, a: go(go, 0, n, l, r, x, a, 0, 10**9, -1))( lambda self, i, n, l, r, x, a, s, mi, ma: ( int(l <= s <= r and ma - mi >= x) if i >= n else self(self, i + 1, n, l, r, x, a, s, mi, ma) + self(self, i + 1, n, l, r, x, a, s + a[i], min...
EXPR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR VAR VAR VAR VAR NUMBER BIN_OP NUMBER NUMBER NUMBER VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR BIN_OP VAR VAR VAR FUNC_CAL...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
c = 0 def backtracking(actuales, restantes, l, r, x): global c if sum(actuales) <= r and sum(actuales) >= l: if max(actuales) - min(actuales) >= x: c += 1 if restantes: for i in range(len(restantes)): backtracking(actuales + [restantes[i]], restantes[i + 1 :], l, r,...
ASSIGN VAR NUMBER FUNC_DEF IF FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER IF VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR LIST VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR RETURN NUMBER FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL FUNC_...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
import itertools n, l, r, x = input().split(" ") n = int(n) l = int(l) r = int(r) x = int(x) num = [int(i) for i in input().split()] count = 0 for i in range(2, n + 1): for j in itertools.combinations(num, i): if max(j) - min(j) >= x and l <= sum(j) <= r: count += 1 print(count)
IMPORT ASSIGN VAR VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
result = 0 a = list(map(int, input().split())) b = list(map(int, input().split())) b.sort() jojo = [] for i in range(2 ** len(b)): for j in range(len(b)): if bool(i & 1 << j) == bool(1): jojo.append(b[j]) if len(jojo) > 0: if ( jojo[len(jojo) - 1] - jojo[0] >= a[3] ...
ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR BIN_OP VAR BIN_OP NUMB...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
def subsets(S): sets = [] len_S = len(S) for i in range(1 << len_S): subset = [S[bit] for bit in range(len_S) if i & 1 << bit] sets.append(subset) return sets n, l, r, x = list(map(int, input().split())) problems = list(map(int, input().split())) res = 0 for m in subsets(problems): ...
FUNC_DEF ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR RETURN VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
import itertools n, l, r, x = map(int, input().split()) c = list(map(int, input().split())) cnt = 0 for i in range(2, n + 1): combinations = itertools.combinations(c, i) for comb in combinations: max_ = 0 min_ = 10**6 sum_ = 0 for co in comb: sum_ += co i...
IMPORT ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER FOR...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
import itertools n, l, x1, r = map(int, input().split()) li = [int(i) for i in input().split()] a = [] for i in range(1, n + 1): x = itertools.combinations(li, i) a += x count = 0 for j in a: if sum(list(j)) <= x1 and sum(list(j)) >= l: if max(j) - min(j) >= r: count += 1 print(count)
IMPORT ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
from itertools import * def powerset(iterable): s = list(iterable) return chain.from_iterable(combinations(s, r) for r in range(len(s) + 1)) def solve(c, l, r, x): res = 0 for ss in powerset(c): if len(ss) >= 2 and l <= sum(ss) <= r and max(ss) - min(ss) >= x: res += 1 return...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER RETURN VAR FUNC_CALL VAR...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
def find(a, b): cc = 2 for i in range(1, 1 << len(a)): sx = 0 minn = 100000000 maxn = -1 for j in range(0, len(a)): if i & 1 << j: sx += a[j] minn = min(minn, a[j]) maxn = max(maxn, a[j]) if sx >= b[1] and sx <= ...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF BIN_OP VAR BIN_OP NUMBER VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR NU...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
from itertools import combinations num, min_dif, max_dif, easy_hard_dif = map(int, input().split(" ")) arr = [int(m) for m in input().split(" ")] all_combinations = [] for x in range(2, num + 1): combs = combinations(arr, x) for abc in combs: all_combinations.append(list(abc)) possible_answers = 0 for ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF FUNC_C...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
_n, l, r, x = map(int, input("").split()) c = list(map(int, input().split())) count = 0 def backtrack(s, l, r, x, c, i, level, min, max): if s > r: return 0 if s >= l and max - min >= x: global count count += 1 for j in range(i, len(c)): new = c[j] nmax, nmin = max,...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_DEF IF VAR VAR RETURN NUMBER IF VAR VAR BIN_OP VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR VAR IF...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
n, ll, r, x = map(int, input().split(" ")) l = list(map(int, input().split(" "))) subset = [] for i in range(1, 2**n): sub = [] for j in range(n): if 1 << j & i > 0: sub.append(l[j]) subset.append(sub) c = 0 for i in subset: if len(i) > 1: su = sum(i) if (su >= ll and...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXP...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
import itertools n, l, r, x = map(int, input().split()) a = [int(i) for i in input().split()] count = 0 s = sum(a) if s >= l and s <= r and max(a) - min(a) >= x: count += 1 for i in range(2, n): b = list(itertools.combinations(a, i)) for j in range(0, len(b)): s = sum(b[j]) if s >= l and s ...
IMPORT ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
def check_bits(x, n): total = 0 for i in range(n): if x & 1 << i: total += 1 return total >= 2 def check_compex(x, data, l, r, diff): total_c = 0 min_c = None max_c = None for i in range(len(data)): if x & 1 << i: total_c += data[i] if mi...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR BIN_OP NUMBER VAR VAR NUMBER RETURN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NONE ASSIGN VAR NONE FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR BIN_OP NUMBER VAR VAR VAR VAR IF VAR NONE VAR VAR VAR ASSIGN VAR VAR VAR IF VAR NONE VAR VAR ...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
kk = lambda: map(int, input().split()) ll = lambda: list(kk()) n, l, r, d = kk() p, t = ll(), 0 for v in range(2**n): s = [] for i in range(n): if v & 2**i: s.append(p[i]) if l <= sum(s) <= r and max(s) - min(s) >= d: t += 1 print(t)
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR VAR VAR IF VAR FUNC_CA...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
def solve(n, l, r, x, L): res = 0 def inner(a): p_list = [] tl = 0 for i in range(n): if 1 << i & a == 0: p_list.append(L[i]) tl += L[i] p_list.sort() if tl >= l and tl <= r and p_list[-1] - p_list[0] >= x and len(p_list) > 1: ...
FUNC_DEF ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR IF VAR VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER RETURN NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR ...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
from itertools import combinations [n, l, r, x] = [int(x) for x in input().split()] c = [int(x) for x in input().split()] c.sort() k = 0 for i in range(n): for j in range(i + 1, n): if c[j] - c[i] >= x: if sum(c[i : j + 1]) < l: continue elif c[i] + c[j] > r: ...
ASSIGN LIST VAR VAR 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 NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP VAR VAR VAR VAR VAR IF FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR IF BI...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
from itertools import combinations as cmb n, l, r, x = map(int, input().split()) (*a,) = map(int, input().split()) b = [] a.sort() for i in range(2, n + 1): b.extend(cmb(a, i)) ans = 0 for i in b: if sum(i) >= l and sum(i) <= r: if i[-1] - i[0] >= x: ans += 1 print(ans)
ASSIGN VAR 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 LIST EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
n, l, r, x = list(map(int, input().split())) c = list(map(int, input().split())) k = 0 for i in range(3, 1 << n): a = [] for j in range(n): if i >> j & 1 == 1: a.append(c[j]) a.sort() if len(a) >= 2: if sum(a) >= l and sum(a) <= r and a[-1] - a[0] >= x: k += 1 pri...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR E...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
import sys input = [] input_index = 0 def next(type, number=None): def next(): global input, input_index while input_index == len(input): if sys.stdin: input = sys.stdin.readline().split() input_index = 0 else: raise Excepti...
IMPORT ASSIGN VAR LIST ASSIGN VAR NUMBER FUNC_DEF NONE FUNC_DEF WHILE VAR FUNC_CALL VAR VAR IF VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER RETURN VAR BIN_OP VAR NUMBER IF VAR NONE ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR RE...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
import itertools n, l, r, x = list(map(int, input().split())) C = sorted(map(int, input().split())) ans = 0 if len(C) > 1: for i in range(2, len(C) + 1): for j in itertools.combinations(C, i): if l <= sum(j) <= r and max(j) - min(j) >= x: ans += 1 print(ans)
IMPORT ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR IF VAR FUNC_CALL VAR VAR VAR B...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
n, l, r, x = map(int, input().split()) C = list(map(int, input().split())) C.sort() z = 0 for i in range(2**n): b = bin(i)[2:] while len(b) < n: b = "0" + b S = 0 D = [] for j in range(len(b)): if b[j] == "1": S = S + C[j] D.append(C[j]) if S >= l and S <=...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER WHILE FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR NUMBER ...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
def GSB(x): counter = 0 while x != 0: counter += 1 x = x >> 1 return counter problems, minimum, maximum, difference = [int(x) for x in input().split()] array = [int(x) for x in input().split()] combinations = [int(x) for x in range(2**problems)] total = 0 for i in combinations: checker...
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR VAR 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 VAR VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER FOR VAR VAR ASSI...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
from itertools import chain, combinations def powerset(iterable): s = list(iterable) return chain.from_iterable(combinations(s, r) for r in range(len(s) + 1)) N, L, R, X = map(int, input().split(" ")) C = map(int, input().split(" ")) def is_ok(c): if len(c) < 2: return False if not L <= su...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER IF VAR...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
[n, l, r, x] = list(map(int, input().strip().split())) Cs = list(sorted(map(int, input().strip().split()))) probs = 0 for i in range(1, 2**n): currsub = [Cs[j] for j in range(n) if i & 1 << j] probs += ( len(currsub) > 1 and l <= sum(currsub) <= r and currsub[-1] - currsub[0] >= x ) print(probs)
ASSIGN LIST VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP NUMBER VAR ...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
from itertools import chain, combinations def powerset(x): s = list(x) return chain.from_iterable(combinations(s, r) for r in range(len(s) + 1)) n, l, r, x = [int(s) for s in input().split(" ")] c = [int(s) for s in input().split(" ")] cnt = 0 for a in powerset(c): if a and max(a) - min(a) >= x and l <=...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VA...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
n, l, w, x = map(int, input().split()) arr = list(map(int, input().split())) n = len(arr) ans = 0 for r in range(2, n + 1): show = list(range(r)) data = [0] * r while max(show) <= n - 1: for i in range(r): data[i] = arr[show[i]] if l <= sum(data) <= w and max(data) - min(data) >=...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP LIST NUMBER VAR WHILE FUNC_CALL V...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
cnt = 0 def condition(arr, l, r, x): if not arr: return False s = sum(arr) ma = max(arr) mi = min(arr) if s <= r and s >= l and ma - mi >= x: return True return False def dp(i, n, st, arr, l, r, x): global cnt if i == n: result = [] for i in range(len(...
ASSIGN VAR NUMBER FUNC_DEF IF VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR BIN_OP VAR VAR VAR RETURN NUMBER RETURN NUMBER FUNC_DEF IF VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR VA...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
from itertools import combinations n, l, r, x = map(int, input().split()) p = [int(x) for x in input().split()] p = sorted(p) s = 0 result_list = sum([list(map(list, combinations(p, i))) for i in range(len(p) + 1)], []) for i in result_list: if l <= sum(i) <= r and max(i) - min(i) >= x: s += 1 print(s)
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER LIST FOR VAR VAR IF VA...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
def gen(n): if n == 1: yield "0" yield "1" else: for s in gen(n - 1): yield s + "0" yield s + "1" n, l, r, x = map(int, input().split()) cnt = 0 C = list(map(int, input().split())) for pos in gen(n): A = [] for i in range(n): if pos[i] == "1": ...
FUNC_DEF IF VAR NUMBER EXPR STRING EXPR STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR BIN_OP VAR STRING EXPR BIN_OP VAR STRING ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL 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 VAR ASSIGN VAR ...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
from itertools import combinations n, l, r, x = map(int, input().split()) a = list(map(int, input().split())) result = sum( [ sum([(max(j) - min(j) >= x and l <= sum(j) <= r) for j in combinations(a, i)]) for i in range(2, n + 1) ] ) print(result)
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FU...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
def calc(str, n, mn, mx, dif): end = 2**n binary = "" index = -1 mnx = 100000000 mxx = -1 sum = 0 count = 0 for i in range(end): binary = "{0:015b}".format(i)[::-1] binary = binary[:n] index = -1 sum = 0 mnx = 100000000 mxx = -1 for...
FUNC_DEF ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL STRING VAR NUMBER ASSIGN VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR NU...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
n, l, r, hard = list(map(int, input().split())) val = list(map(int, input().split())) arr = [] for i in range(0, 2**n): x = bin(i) x = x.split("b")[1] x = "0" * (n - len(x)) + x arr.append(x) ans = 0 for i in arr: if i.count("1") >= 2: cur = i temp = [] for j in range(n): ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR STRING NUMBER ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP VAR ...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
import itertools n, l, kk, x = input().split() n = int(n) l = int(l) kk = int(kk) x = int(x) arr = list(map(int, input().split())) cnt = 0 def printCombination(arr, n, r): data = [0] * r combinationUtil(arr, data, 0, n - 1, 0, r) def combinationUtil(arr, data, start, end, index, r): if index == r: ...
IMPORT ASSIGN VAR VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR EXPR FUNC_CALL VAR VAR...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
n, l, r, x = 0, 0, 0, 0 c, sumC = [], [] def solve(step, totalC, num, maxC, minC): if step == n: if totalC >= l and totalC <= r and num >= 2 and maxC - minC >= x: return 1 else: return 0 if totalC > r: return 0 if totalC + sumC[step] < l: return 0 ...
ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR VAR LIST LIST FUNC_DEF IF VAR VAR IF VAR VAR VAR VAR VAR NUMBER BIN_OP VAR VAR VAR RETURN NUMBER RETURN NUMBER IF VAR VAR RETURN NUMBER IF BIN_OP VAR VAR VAR VAR RETURN NUMBER RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR VAR FUNC_CALL VAR BIN_OP...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
n, l, r, x = list(map(int, input().split())) b = list(map(int, input().split())) if len(b) == 1: print(0) else: w = ["0", "1"] e = 0 t = len(b) while t - 1 > 0: k = [] for i in w: k.append("0" + i) for i in w: k.append("1" + i) w = k t ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR LIST STRING STRING ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR WHILE BIN_OP VAR NUMBER NUMBER ASSIGN VAR L...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
n, l, r, x = map(int, input().split()) c = list(map(int, input().split())) cnt = 0 def f(i, total, mx, mn, num): global cnt if i == n: if l <= total <= r and mx - mn >= x and num >= 2: cnt += 1 return f(i + 1, total + c[i], max(mx, c[i]), min(mn, c[i]), num + 1) f(i + 1, to...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_DEF IF VAR VAR IF VAR VAR VAR BIN_OP VAR VAR VAR VAR NUMBER VAR NUMBER RETURN EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
n, l, r, x = (int(x) for x in input().split()) seq = [int(x) for x in input().split()] seq.sort() count = 0 def get_bit(i, n): ele = bin(i)[2:] ele = [int(x) for x in ele] ele = (n - ele.__len__()) * [0] + ele return ele for i in range(1, 2**n): situ = get_bit(i, n) summing = 0 maxj = 0 ...
ASSIGN VAR VAR 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 NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR FUNC_CALL VAR LIST NUMBER VAR RETURN VA...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
n, l, r, x = map(int, input().split()) d = list(map(int, input().split())) ans = 0 for i in range(pow(2, n) - 1, -1, -1): s = bin(i)[2:] while len(s) < n: s = "0" + s diff = 0 t = [] for j in range(n): if s[j] == "1": diff += d[j] t.append(d[j]) t.sort() ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR NUMBER VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER WHILE FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP STRING VAR AS...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
def gen(k, n, p): if k == n: ans.append(p) return gen(k + 1, n, p + [1]) gen(k + 1, n, p + [0]) n, l, r, x = map(int, input().split()) m = list(map(int, input().split())) ans = [] count = 0 gen(0, n, []) for i in range(len(ans)): now = [] for j in range(len(ans[i])): if ans...
FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR VAR RETURN EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_OP VAR LIST NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR BIN_OP VAR LIST NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
def generate(made, lis): if made == n: nonlocal res s = sum(lis) if l <= s and s <= r and len(lis) >= 2 and lis[-1] - lis[0] >= x: res += 1 else: generate(made + 1, lis + [a[made]]) generate(made + 1, lis) n, l, r, x = list(map(int, input().split())) a = sor...
FUNC_DEF IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR LIST VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR AS...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
s = input().split(" ") n, l, r, d = [int(x) for x in s] arr = input().split(" ") arr = [int(x) for x in arr] arr.sort() ans = 0 for x in range(2**n + 1): m = 0 sum = 0 t = x for i in range(n): if t % 2 == 1: if m == 0: m = arr[i] sum += arr[i] ...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR FOR VAR ...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
n, l, r, x = map(int, input().split()) c = list(map(int, input().split())) c.sort() all_sub = [] for i in range(2**n): subset = [] for j in range(n): if i & 1 << j != 0: subset.append(c[j]) all_sub.append(subset) final = 0 for i in all_sub[1:]: if i[-1] - i[0] >= x and sum(i) >= l an...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR BIN_OP NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR ...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
def gray(n): if n == 1: return ["0", "1"] l1 = gray(n - 1) l2 = reversed(l1) l1 = [(a + "0") for a in l1] l2 = [(a + "1") for a in l2] return l1 + l2 n, l, r, x = list(map(int, input().split())) a = list(map(int, input().split())) ps = gray(n) ans = 0 for i in ps: ma = -1 mi = ...
FUNC_DEF IF VAR NUMBER RETURN LIST STRING STRING ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR STRING VAR VAR ASSIGN VAR BIN_OP VAR STRING VAR VAR RETURN BIN_OP VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
import itertools __author__ = "victormion" def function(): res = 0 for i in range(2, len(vet) + 1): temp = itertools.combinations(vet, i) for case in temp: sum = 0 minimum = None maximum = None for j in case: sum += int(j) ...
IMPORT ASSIGN VAR STRING FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NONE ASSIGN VAR NONE FOR VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NONE VAR VAR ASSIGN VAR VAR IF VAR NONE VA...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
def subsets(L, i): if i == len(L): yield [] else: for s in subsets(L, i + 1): yield s yield [L[i]] + s def computeValidProblemsets(problems, l, r, x): isValid = lambda ps: len(ps) > 1 and l <= sum(ps) <= r and ps[-1] - ps[0] >= x print(sum(isValid(problemset) fo...
FUNC_DEF IF VAR FUNC_CALL VAR VAR EXPR LIST FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR VAR EXPR BIN_OP LIST VAR VAR VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUM...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
I = lambda: map(int, input().split()) n, l, r, x = I() t = sorted(I()) k = [0] def f(n, q, w, e): if n < 0: k[0] += q and w - q >= x and l <= e <= r return f(n - 1, q, w, e) if w: q = t[n] else: w = t[n] f(n - 1, q, w, e + t[n]) f(n - 1, 0, 0, 0) print(k[0])
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER FUNC_DEF IF VAR NUMBER VAR NUMBER VAR BIN_OP VAR VAR VAR VAR VAR VAR RETURN EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR IF VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VA...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
from itertools import combinations n, l, r, x = map(int, input().split()) c = [*map(int, input().split())] print( sum( [ sum( [ (1 if max(j) - min(j) >= x and l <= sum(j) <= r else 0) for j in combinations(c, i) ] ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER NUMBER VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP VAR N...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
n, l, r, x = map(int, input().split()) arr = list(map(int, input().split())) count = 0 for mask in range(0, 1 << n): max_total = 0 min_total = 0 diff = 0 temp_arr = [] for i in range(n): if mask & 1 << i: temp_arr.append(arr[i]) if ( l <= sum(temp_arr) <= r an...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR BIN_OP NUMBER...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
def mlt(): return map(int, input().split()) x, l, r, df = mlt() s = sorted(list(mlt())) def f(x): global s, l, r, df tm = [] for n in range(len(s)): if x % 2: tm.append(s[n]) x //= 2 return int(sum(tm) >= l and sum(tm) <= r and max(tm) - min(tm) >= df) res = 0 for n...
FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER RETURN FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
from itertools import combinations n, l, r, x = list(map(int, input().split())) c = list(map(int, input().split())) ans = 0 for i in range(2, len(c) + 1): all = combinations(c, i) for j in all: sum = 0 mn = 10000000 mx = 0 for k in j: mn = min(mn, k) mx =...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUM...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
from itertools import combinations a, b, c, d = map(int, input().split()) l = list(map(int, input().split())) ans = 0 fl = [] for i in range(2, a + 1): tl = list(list(e) for e in combinations(l, i)) for e in tl: fl.append(e) for e in fl: n = len(e) e = sorted(e) t = 0 if max(e) - min(e)...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR FOR...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
a = [] def fn(x, n, l, r, k): sum = 0 v = [] for j in range(20): if 1 << j & x: v.append(a[j]) sum += a[j] if len(v) < 2: return 0 elif v[len(v) - 1] - v[0] >= k and sum >= l and sum <= r: return 1 else: return 0 n, l, r, k = input().sp...
ASSIGN VAR LIST FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER IF BIN_OP VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR VAR VAR VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR VAR...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
I = lambda: map(int, input().split()) n, l, r, x = I() C, k = [*I()], 0 for i in range(2**n): W = [w for w, b in zip(C, bin(i)[2:].zfill(n)) if b == "1"] if l <= sum(W) <= r and max(W) - min(W) >= x: k += 1 print(k)
ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR LIST FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR VAR STRING IF VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
import itertools n, l, r, x = input().split() n = int(n) l = int(l) r = int(r) x = int(x) numbers = [int(z) for z in input().split()] numbers = sorted(numbers) count = 0 for z in range(2, len(numbers) + 1): for subset in itertools.combinations(numbers, z): total = sum(subset) if total >= l and tota...
IMPORT ASSIGN VAR VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL ...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
import itertools s1 = input() s1 = s1.split() s2 = input() s2 = s2.split() nlrx = [int(x) for x in s1] nci = [int(x) for x in s2] result = [ seq for i in range(0, len(nci) + 1) for seq in itertools.combinations(nci, i) if sum(seq) >= nlrx[1] and sum(seq) <= nlrx[2] and max(seq) - min(seq) >= nlrx[3] ] ...
IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR NUMBER FUNC_CALL VA...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
def combinations(arr, n): if n == 0: return [[]] l = [] for i in range(len(arr)): m = arr[i] rem = arr[i + 1 :] for j in combinations(rem, n - 1): l.append([m] + j) return l def solve(arr, n, l, r, x): subset = [] for i in range(2, n + 1): fo...
FUNC_DEF IF VAR NUMBER RETURN LIST LIST ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP LIST VAR VAR RETURN VAR FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VA...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
from itertools import combinations n, l, r, x = input().split() n = int(n) l = int(l) r = int(r) x = int(x) a = list(map(int, input().strip().split()))[:n] sublist = [] for i in range(2, len(a) + 1): for j in list(combinations(a, i)): sublist.append(j) ans = 0 for i in sublist: if len(i) == 1: ...
ASSIGN VAR VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
def suma_o_resta(a, b): return a & 1 << b def diferencia(s1, d): if s1: s1.sort() if s1[-1] - s1[0] >= d: return s1 else: return diferencia(s1.remove(s1[-1]), d) return s1 def no_sets(v, n, l, r, d): s = [] cont = 0 for x in range(1 << n): ...
FUNC_DEF RETURN BIN_OP VAR BIN_OP NUMBER VAR FUNC_DEF IF VAR EXPR FUNC_CALL VAR IF BIN_OP VAR NUMBER VAR NUMBER VAR RETURN VAR RETURN FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR RETURN VAR FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VA...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
import itertools limits = [int(x) for x in input().split()] problems = [int(x) for x in input().split()] n = limits[0] l = limits[1] r = limits[2] x = limits[3] kinds = 0 problems.sort() for i in range(2, n + 1): sublists = list(itertools.combinations(problems, i)) for sublist in sublists: sublist = li...
IMPORT ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FU...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
import sys mod = 1000000007 def factorial_p(n, p): ans = 1 if n <= p // 2: for i in range(1, n + 1): ans = ans * i % p else: for i in range(1, p - n): ans = ans * i % p ans = pow(ans, p - 2, p) if n % 2 == 0: ans = p - ans return ans...
IMPORT ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER IF VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR IF BIN_OP VAR NUMBER NUMBER...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
from sys import stdin, stdout def read(): return stdin.readline().rstrip() def readint(): return int(read()) def readints(): return [int(i) for i in read().split()] _, l, r, x = readints() xs = sorted(readints()) total = 0 for i in range(1 << len(xs)): ans = [xs[moves] for moves in range(len(xs)...
FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR FUN...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
ways = 0 def solve(i, l, r, x, max1, min1, sum, flag): global ways if flag == 0: if max1 != min1 and (max1 != -99999999999999 and min1 != 99999999999999): if sum > r: return elif sum >= l and max1 - min1 >= x: ways += 1 if i < 0: retu...
ASSIGN VAR NUMBER FUNC_DEF IF VAR NUMBER IF VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR RETURN IF VAR VAR BIN_OP VAR VAR VAR VAR NUMBER IF VAR NUMBER RETURN EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VA...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
from itertools import * n, l, r, x = map(lambda x: int(x), input().split()) c = sorted(list(map(lambda x: int(x), input().split()))) variants = [] for i in range(2, n + 1): variants.extend(list(combinations(c, i))) counter = 0 for i in range(len(variants)): sum_var = sum(variants[i]) if sum_var >= l and su...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FU...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
n, l, r, x = tuple(map(int, input().split())) cs = sorted(list(map(int, input().split()))) def findSet(s, minc, maxc, depth, rest, left, n, l, r, x): if s > r or left >= n and s < l: return 0 ans = 0 if s >= l and s <= r and depth >= 2 and minc + x <= maxc: ans = 1 for i in range(left,...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR VAR VAR VAR VAR VAR RETURN NUMBER ASSIGN VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER BIN_OP VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
from itertools import chain, combinations def powerset(iterable): xs = list(iterable) return list(chain.from_iterable(combinations(xs, n) for n in range(2, len(xs) + 1))) n, l, r, x = map(int, input().split()) sett = list(map(int, input().split())) psett = powerset(sett) count = 0 for i in psett: k = so...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN ...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
import itertools criteria = input() items_weights = input() n, m, k, p = map(int, criteria.split()) _items_weights = list(map(int, items_weights.split())) if ( not 1 <= n <= 15 or not 1 <= m <= k <= 10**9 or not 1 <= p <= 10**6 or not n == len(_items_weights) ): print("ошибка ввода данных") exi...
IMPORT ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR IF NUMBER VAR NUMBER NUMBER VAR VAR BIN_OP NUMBER NUMBER NUMBER VAR BIN_OP NUMBER NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR STRING EXPR FUNC_CALL...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
n, l, r, x = map(int, input().strip().split()) c = [int(v) for v in input().strip().split()] ans = 0 for mask in range(1, 1 << n): cur = 0 mn = max(c) mx = min(c) for j in range(n): if mask & 1 << j > 0: cur += c[j] mn = min(mn, c[j]) mx = max(mx, c[j]) if...
ASSIGN VAR VAR VAR VAR FUNC_CALL 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 NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF BIN_OP V...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
def find(n, l, r, x, contests, lista): if n == 0: s = sum(lista) if s >= l and s <= r and max(lista) - min(lista) >= x: return 1 else: return 0 c = 0 for i in range(len(contests)): c += find(n - 1, l, r, x, contests[i + 1 :], lista + [contests[i]]) ...
FUNC_DEF IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR LIST VAR VAR RETURN VAR ASSIGN VAR ...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
def combine(n, k, w=1, out=[], result=[]): if k == 0: result.append(out) for i in range(w, n + 1): new_out = out[:] new_out.append(i) combine(n, k - 1, i + 1, new_out) return result def main(): n, l, r, x = [int(i) for i in input().split()] c = [int(i) for i in inpu...
FUNC_DEF NUMBER LIST LIST IF VAR NUMBER EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR RETURN VAR FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VA...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
vet = [] aux = [] cont = 0 def fa(i, f): global aux, cont if i <= f: aux.append(vet[i]) if len(aux) >= 2 and menor <= sum(aux) <= maior and max(aux) - min(aux) >= diff: cont += 1 for k in range(i, f): fa(k + 1, f) aux.pop() n, menor, maior, diff = map(...
ASSIGN VAR LIST ASSIGN VAR LIST ASSIGN VAR NUMBER FUNC_DEF IF VAR VAR EXPR FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR VAR VA...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
def GETBIT(x, bit): return x >> bit & 1 n, l, r, dif = map(int, input().split()) a = list(map(int, input().split())) rs = 0 for i in range(1, 1 << n): lst = [] for j in range(n): if GETBIT(i, j) == 1: lst.append(a[j]) if max(lst) - min(lst) >= dif: if sum(lst) >= l and sum(...
FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR NUMBER EXPR...
You have n problems. You have estimated the difficulty of the i-th one as integer c_{i}. Now you want to prepare a problemset for a contest, using some of the problems you've made. A problemset for the contest must consist of at least two problems. You think that the total difficulty of the problems of the contest mus...
n, l, r, x = [int(y) for y in input().split()] c = [int(y) for y in input().split()] c.sort() ans = [0] def solve(ans, tasklist=[], e=0): if ( sum(tasklist) <= r and sum(tasklist) >= l and len(tasklist) >= 2 and max(tasklist) - min(tasklist) >= x ): ans[0] += 1 for ...
ASSIGN VAR VAR 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 LIST NUMBER FUNC_DEF LIST NUMBER IF FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR NUMBER BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER N...
Have you ever played Hanabi? If not, then you've got to try it out! This problem deals with a simplified version of the game. Overall, the game has 25 types of cards (5 distinct colors and 5 distinct values). Borya is holding n cards. The game is somewhat complicated by the fact that everybody sees Borya's cards excep...
input() colour = {"R": 0, "G": 1, "B": 2, "Y": 3, "W": 4} cards = {(colour[c], ord(v) - ord("1")) for c, v in input().split()} def ok(cs, vs): return len( {(c if cs >> c & 1 else -1, v if vs >> v & 1 else -1) for c, v in cards} ) == len(cards) print( min( bin(cs).count("1") + bin(vs).cou...
EXPR FUNC_CALL VAR ASSIGN VAR DICT STRING STRING STRING STRING STRING NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF RETURN FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER VAR NUMBER VAR VAR ...
Have you ever played Hanabi? If not, then you've got to try it out! This problem deals with a simplified version of the game. Overall, the game has 25 types of cards (5 distinct colors and 5 distinct values). Borya is holding n cards. The game is somewhat complicated by the fact that everybody sees Borya's cards excep...
from itertools import combinations n = int(input()) colors = {"R": 0, "G": 1, "B": 2, "Y": 3, "W": 4} letters = {"1": 0, "2": 1, "3": 2, "4": 3, "5": 4} l = list(set(list(input().split()))) def checker(hint, cards): for i in cards: for j in cards: if i == j: continue ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR DICT STRING STRING STRING STRING STRING NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR DICT STRING STRING STRING STRING STRING NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF FOR VAR VAR FOR VAR VAR...
Have you ever played Hanabi? If not, then you've got to try it out! This problem deals with a simplified version of the game. Overall, the game has 25 types of cards (5 distinct colors and 5 distinct values). Borya is holding n cards. The game is somewhat complicated by the fact that everybody sees Borya's cards excep...
import itertools def read(mode=2): inputs = input().strip() if mode == 0: return inputs if mode == 1: return inputs.split() if mode == 2: return [int(x) for x in inputs.split()] def write(s="\n"): if isinstance(s, list): s = " ".join(map(str, s)) s = str(s) ...
IMPORT FUNC_DEF NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER RETURN VAR IF VAR NUMBER RETURN FUNC_CALL VAR IF VAR NUMBER RETURN FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_DEF STRING IF FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ST...
Have you ever played Hanabi? If not, then you've got to try it out! This problem deals with a simplified version of the game. Overall, the game has 25 types of cards (5 distinct colors and 5 distinct values). Borya is holding n cards. The game is somewhat complicated by the fact that everybody sees Borya's cards excep...
from itertools import * power = lambda i: chain.from_iterable(combinations(i, r) for r in range(len(i) + 1)) input() cards = set(input().split()) print( min( len(s) for s in power("RGBYW12345") if len(set(str(set(s) & set(t)) for t in cards)) == len(cards) ) )
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VA...
Have you ever played Hanabi? If not, then you've got to try it out! This problem deals with a simplified version of the game. Overall, the game has 25 types of cards (5 distinct colors and 5 distinct values). Borya is holding n cards. The game is somewhat complicated by the fact that everybody sees Borya's cards excep...
n = int(input()) colour = dict(zip("RGBYW", range(5, 10))) cards = list({(2 ** colour[c] + 2 ** (ord(v) - ord("1"))) for c, v in input().split()}) ans = 10 n = len(cards) if n > 1: for bit in range(2**10): ok = True for i in range(n - 1): for j in range(i + 1, n): if card...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING FUNC_CALL VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR VAR BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER ...
Have you ever played Hanabi? If not, then you've got to try it out! This problem deals with a simplified version of the game. Overall, the game has 25 types of cards (5 distinct colors and 5 distinct values). Borya is holding n cards. The game is somewhat complicated by the fact that everybody sees Borya's cards excep...
import itertools input() cards = tuple(set(str.split(input()))) n = len(cards) if n == 1: print(0) return symbols = "RGBYW12345" for l in range(1, 10): for comb in itertools.combinations(symbols, l): positions = [cards] * n for symbol in comb: for i in range(n): ...
IMPORT EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER RETURN ASSIGN VAR STRING FOR VAR FUNC_CALL VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP LIST VAR VAR FOR VAR VAR FOR VAR FUNC_CALL VAR VA...
Have you ever played Hanabi? If not, then you've got to try it out! This problem deals with a simplified version of the game. Overall, the game has 25 types of cards (5 distinct colors and 5 distinct values). Borya is holding n cards. The game is somewhat complicated by the fact that everybody sees Borya's cards excep...
input() p = {((1 << "RGBYW".index(c)) + (1 << int(k) + 4)) for c, k in input().split()} mn = 20 res = 90 for i in range(1024): if len(p) == len(set(i & j for j in p)): mn = min(mn, bin(i).count("1")) print(mn)
EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP BIN_OP NUMBER FUNC_CALL STRING VAR BIN_OP NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FUNC...
Have you ever played Hanabi? If not, then you've got to try it out! This problem deals with a simplified version of the game. Overall, the game has 25 types of cards (5 distinct colors and 5 distinct values). Borya is holding n cards. The game is somewhat complicated by the fact that everybody sees Borya's cards excep...
import sys n = int(sys.stdin.readline()) cards = list(set(sys.stdin.readline().split())) m = 10 def count_ones(n): cnt = 0 while n > 0: if n & 1: cnt += 1 n //= 2 return cnt def split(l, c): a, b = [], [] for card in l: if c in card: a.append(card...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER IF BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR VAR LIST LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL ...
Have you ever played Hanabi? If not, then you've got to try it out! This problem deals with a simplified version of the game. Overall, the game has 25 types of cards (5 distinct colors and 5 distinct values). Borya is holding n cards. The game is somewhat complicated by the fact that everybody sees Borya's cards excep...
def Checker(hint, card): for a in card: for b in card: if a == b: continue elif a[0] == b[0]: if a[1] not in hint and b[1] not in hint: return False elif a[1] == b[1]: if a[0] not in hint and b[0] not in ...
FUNC_DEF FOR VAR VAR FOR VAR VAR IF VAR VAR IF VAR NUMBER VAR NUMBER IF VAR NUMBER VAR VAR NUMBER VAR RETURN NUMBER IF VAR NUMBER VAR NUMBER IF VAR NUMBER VAR VAR NUMBER VAR RETURN NUMBER IF VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR AS...
Have you ever played Hanabi? If not, then you've got to try it out! This problem deals with a simplified version of the game. Overall, the game has 25 types of cards (5 distinct colors and 5 distinct values). Borya is holding n cards. The game is somewhat complicated by the fact that everybody sees Borya's cards excep...
def check(hint, Card): for i in Card: for j in Card: if i == j: continue elif i[0] == j[0]: if i[1] not in hint and j[1] not in hint: return False elif i[1] == j[1]: if i[0] not in hint and j[0] not in hi...
FUNC_DEF FOR VAR VAR FOR VAR VAR IF VAR VAR IF VAR NUMBER VAR NUMBER IF VAR NUMBER VAR VAR NUMBER VAR RETURN NUMBER IF VAR NUMBER VAR NUMBER IF VAR NUMBER VAR VAR NUMBER VAR RETURN NUMBER IF VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR STRING ASSIGN VAR FUNC_CALL VA...
Have you ever played Hanabi? If not, then you've got to try it out! This problem deals with a simplified version of the game. Overall, the game has 25 types of cards (5 distinct colors and 5 distinct values). Borya is holding n cards. The game is somewhat complicated by the fact that everybody sees Borya's cards excep...
input() colour = dict(zip("RGBYW", range(5))) cards = {(colour[c], ord(v) - ord("1")) for c, v in input().split()} print( min( bin(cs).count("1") + bin(vs).count("1") for cs in range(1 << 5) for vs in range(1 << 5) if len({(c if cs >> c & 1 else -1, v if vs >> v & 1 else -1) for c, v...
EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR STRING VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP FUNC_CALL FUNC_CALL VAR VAR STRING FUNC_CALL FUNC_CALL VAR VAR STRING VAR FUNC_CALL VAR BIN_OP NU...
Given 2 integers n and start. Your task is return any permutation p of (0,1,2.....,2^n -1) such that : p[0] = start p[i] and p[i+1] differ by only one bit in their binary representation. p[0] and p[2^n -1] must also differ by only one bit in their binary representation.   Example 1: Input: n = 2, start = 3 Output: [3...
from itertools import chain class Solution: def circularPermutation(self, n: int, start: int) -> List[int]: start_mask = start while start_mask: start_mask >>= 1 start ^= start_mask out = [(x ^ x >> 1) for x in chain(range(start, 2**n), range(start))] retur...
CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR VAR WHILE VAR VAR NUMBER VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP NUMBER VAR FUNC_CALL VAR VAR RETURN VAR VAR VAR
Given 2 integers n and start. Your task is return any permutation p of (0,1,2.....,2^n -1) such that : p[0] = start p[i] and p[i+1] differ by only one bit in their binary representation. p[0] and p[2^n -1] must also differ by only one bit in their binary representation.   Example 1: Input: n = 2, start = 3 Output: [3...
class Solution: def circularPermutation(self, n: int, start: int) -> List[int]: gc = [0] for i in range(1, 2**n): gc.append(gc[-1] ^ i & -i) l = len(gc) for i in range(l): fe = gc[0] if fe == start: break else: ...
CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR LIST NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER IF VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR NUMBER RETURN VAR VAR VAR
Given 2 integers n and start. Your task is return any permutation p of (0,1,2.....,2^n -1) such that : p[0] = start p[i] and p[i+1] differ by only one bit in their binary representation. p[0] and p[2^n -1] must also differ by only one bit in their binary representation.   Example 1: Input: n = 2, start = 3 Output: [3...
class Solution: def circularPermutation(self, n: int, start: int) -> List[int]: def extendPerm(arr): arr.extend([("1" + num) for num in arr[::-1]]) for i in range(len(arr) // 2): arr[i] = "0" + arr[i] arr = ["0", "1"] for i in range(n - 1): ...
CLASS_DEF FUNC_DEF VAR VAR FUNC_DEF EXPR FUNC_CALL VAR BIN_OP STRING VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR BIN_OP STRING VAR VAR ASSIGN VAR LIST STRING STRING FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR VAR ASSI...
Given 2 integers n and start. Your task is return any permutation p of (0,1,2.....,2^n -1) such that : p[0] = start p[i] and p[i+1] differ by only one bit in their binary representation. p[0] and p[2^n -1] must also differ by only one bit in their binary representation.   Example 1: Input: n = 2, start = 3 Output: [3...
class Solution: def circularPermutation(self, n: int, start: int) -> List[int]: def dfs(i): if len(p) == 1 << n: a = p[0] ^ p[1] return a and a & a - 1 == 0 j = 1 for _ in range(n): k = i ^ j if k not in vi...
CLASS_DEF FUNC_DEF VAR VAR FUNC_DEF IF FUNC_CALL VAR VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR RETURN NUM...
Given 2 integers n and start. Your task is return any permutation p of (0,1,2.....,2^n -1) such that : p[0] = start p[i] and p[i+1] differ by only one bit in their binary representation. p[0] and p[2^n -1] must also differ by only one bit in their binary representation.   Example 1: Input: n = 2, start = 3 Output: [3...
class Solution: def circularPermutation(self, n: int, start: int) -> List[int]: bi = str(bin(start))[2:].zfill(n) def get_perm(bi_start, l): a = bi_start[-1 * l] b = str(1 - int(a)) if l == 1: return [a, b] perms = get_perm(bi_start, ...
CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_DEF ASSIGN VAR VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR BIN_OP NUMBER FUNC_CALL VAR VAR IF VAR NUMBER RETURN LIST VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP VAR V...
Given 2 integers n and start. Your task is return any permutation p of (0,1,2.....,2^n -1) such that : p[0] = start p[i] and p[i+1] differ by only one bit in their binary representation. p[0] and p[2^n -1] must also differ by only one bit in their binary representation.   Example 1: Input: n = 2, start = 3 Output: [3...
class Solution: def circularPermutation(self, n: int, start: int) -> List[int]: ans = [] lastNumberSet = set([(start ^ 1 << i) for i in range(n)]) nMax = 2**n visited = set() visited.add(start) def helper(preNum, ni): if ni == nMax: if pr...
CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR FUNC_DEF IF VAR VAR IF VAR VAR RETURN NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR...
Given 2 integers n and start. Your task is return any permutation p of (0,1,2.....,2^n -1) such that : p[0] = start p[i] and p[i+1] differ by only one bit in their binary representation. p[0] and p[2^n -1] must also differ by only one bit in their binary representation.   Example 1: Input: n = 2, start = 3 Output: [3...
class Solution: def circularPermutation(self, n: int, start: int) -> List[int]: used = {start} two = [(2**i) for i in range(n)] res = [start] while len(res) < 2**n: i = 0 a = res[-1] ^ two[i] while a in used: i += 1 ...
CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST VAR WHILE FUNC_CALL VAR VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR VAR WHILE VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR RE...
Given 2 integers n and start. Your task is return any permutation p of (0,1,2.....,2^n -1) such that : p[0] = start p[i] and p[i+1] differ by only one bit in their binary representation. p[0] and p[2^n -1] must also differ by only one bit in their binary representation.   Example 1: Input: n = 2, start = 3 Output: [3...
class Solution: def circularPermutation(self, n: int, start: int) -> List[int]: gray_code = [1, 0] for i in range(1, n): next_gray_code = [] increase = 1 << i for num in gray_code: next_gray_code.append(num + increase) for num in rever...
CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR LIST NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR LIST ASSIGN VAR BIN_OP NUMBER VAR FOR VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR FUNC_CALL VAR VAR RETURN BIN_OP VAR VAR VAR VAR VAR VAR
Given 2 integers n and start. Your task is return any permutation p of (0,1,2.....,2^n -1) such that : p[0] = start p[i] and p[i+1] differ by only one bit in their binary representation. p[0] and p[2^n -1] must also differ by only one bit in their binary representation.   Example 1: Input: n = 2, start = 3 Output: [3...
class Solution: def circularPermutation(self, n: int, start: int) -> List[int]: original_list = [None for _ in range(1 << n)] original_list[0] = 0 original_list[1] = 1 for i in range(1, n): num_elements = 1 << i for j in range(num_elements): o...
CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR NONE VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR BIN_OP NUMBER VAR FOR VAR FUNC_CALL VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUM...
Given 2 integers n and start. Your task is return any permutation p of (0,1,2.....,2^n -1) such that : p[0] = start p[i] and p[i+1] differ by only one bit in their binary representation. p[0] and p[2^n -1] must also differ by only one bit in their binary representation.   Example 1: Input: n = 2, start = 3 Output: [3...
class Solution: def circularPermutation(self, n: int, start: int) -> List[int]: used = set() result = [None] * int(2**n) result[0] = start used.add(start) for i in range(1, len(result)): for x in range(n): bit = bool(result[i - 1] & 1 << x) ...
CLASS_DEF FUNC_DEF VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NONE FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR IF VAR ASSIGN VAR ...