description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
[Image] -----Input----- The input contains a single integer $a$ ($0 \le a \le 15$). -----Output----- Output a single integer. -----Example----- Input 3 Output 13
n = int(input()) a = n & 1 b = n >> 1 & 1 c = n >> 2 & 1 d = n >> 3 & 1 d = 1 - d if d: c = 1 - c if c and d: b = 1 - b if b and c and d: a = 1 - a ans = d << 3 | c << 2 | b << 1 | a print(ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP NUMBER VAR IF VAR ASSIGN VAR BIN_OP NUMBER VAR IF VAR VAR ASSIGN VAR BIN_OP NUMBER VAR IF VAR VAR VAR ASS...
[Image] -----Input----- The input contains a single integer $a$ ($0 \le a \le 15$). -----Output----- Output a single integer. -----Example----- Input 3 Output 13
def reverseBits(n): rev = 0 for i in range(4): rev = rev << 1 if n & 1 == 1: rev = rev ^ 1 n = n >> 1 return rev n = int(input()) n = reverseBits(n) n -= 1 print(reverseBits(n))
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR
[Image] -----Input----- The input contains a single integer $a$ ($0 \le a \le 15$). -----Output----- Output a single integer. -----Example----- Input 3 Output 13
def main(): a = "{0:b}".format(int(input())).rjust(4, "0") a = "".join(reversed(a)) a = int(a, 2) if a > 0: a -= 1 else: a = 15 a = "{0:b}".format(a).rjust(4, "0") a = "".join(reversed(a)) print(int(a, 2)) main()
FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL STRING FUNC_CALL VAR FUNC_CALL VAR NUMBER STRING ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL STRING VAR NUMBER STRING ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR EXPR...
[Image] -----Input----- The input contains a single integer $a$ ($0 \le a \le 15$). -----Output----- Output a single integer. -----Example----- Input 3 Output 13
def mystery(n): if n == 0: return 15 s = bin(n)[2:] diff = 4 - len(s) s = "0" * diff + s s = s[::-1] val = int(s, 2) - 1 s = bin(val)[2:] diff = 4 - len(s) s = "0" * diff + s s = s[::-1] return int(s, 2) n = int(input()) print(mystery(n))
FUNC_DEF IF VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP STRING VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR VAR ASSIGN VAR BI...
[Image] -----Input----- The input contains a single integer $a$ ($0 \le a \le 15$). -----Output----- Output a single integer. -----Example----- Input 3 Output 13
def int_to_bool(n): return [bool(n & 1 << i) for i in range(4)] a = int(input()) def apply(expected, input): output = [False] * 4 output[3] = not input[3] if input[3]: output[2] = not input[2] else: output[2] = input[2] if input[3] and input[2]: output[1] = not input[...
FUNC_DEF RETURN FUNC_CALL VAR BIN_OP VAR BIN_OP NUMBER VAR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER VAR NUM...
[Image] -----Input----- The input contains a single integer $a$ ($0 \le a \le 15$). -----Output----- Output a single integer. -----Example----- Input 3 Output 13
a = int(input()) if a == 0: print(15) elif a == 1: print(14) elif a == 4: print(8) elif a == 5: print(9) elif a == 7: print(11) elif a == 6: print(10) elif a == 8: print(0) elif a == 9: print(1) elif a == 10: print(2) elif a == 11: print(3) elif a == 12: print(4) elif a == 13...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER I...
[Image] -----Input----- The input contains a single integer $a$ ($0 \le a \le 15$). -----Output----- Output a single integer. -----Example----- Input 3 Output 13
n = int(input()) b = list(bin(n).split("b")[1]) l1 = list(["0"] * (4 - len(b)) + b) x = int("".join(reversed(l1)), 2) - 1 if x < 0: x = 15 y = list(bin(x).split("b")[1]) l2 = list(["0"] * (4 - len(y)) + y) print(int("".join(reversed(l2)), 2))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR VAR STRING NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP LIST STRING BIN_OP NUMBER FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR NUMBER NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUN...
[Image] -----Input----- The input contains a single integer $a$ ($0 \le a \le 15$). -----Output----- Output a single integer. -----Example----- Input 3 Output 13
n = int(input()) a = n // 8 b = n % 8 // 4 c = n % 4 // 2 d = n % 2 a = not a b = not b if a else b c = not c if a and b else c d = not d if a and b and c else d print(1 * d + 2 * c + 4 * b + 8 * a)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP BIN_OP B...
[Image] -----Input----- The input contains a single integer $a$ ($0 \le a \le 15$). -----Output----- Output a single integer. -----Example----- Input 3 Output 13
n = int(input()) a = [0] * 4 i = 0 for i in range(4): a[i] = n % 2 n = n // 2 a[3] = a[3] ^ 1 a[2] = a[3] ^ a[2] a[1] = (a[3] and a[2]) ^ a[1] a[0] = (a[3] and a[2] and a[1]) ^ a[0] sum_ = 0 for i in range(4): sum_ += a[i] * 2**i print(sum_)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR NUMBER VAR NUMBE...
[Image] -----Input----- The input contains a single integer $a$ ($0 \le a \le 15$). -----Output----- Output a single integer. -----Example----- Input 3 Output 13
def solve(n): digits_4 = bin(n)[2:].rjust(4, "0") reversed_digits = "".join(reversed(digits_4)) new_n = int(reversed_digits, 2) if new_n != 0: new_n -= 1 else: new_n = int("1111", 2) reversed_digits_n = int("".join(reversed(bin(new_n)[2:].rjust(4, "0"))), 2) return reversed_d...
FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER NUMBER STRING ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER NUMBER STRING ...
[Image] -----Input----- The input contains a single integer $a$ ($0 \le a \le 15$). -----Output----- Output a single integer. -----Example----- Input 3 Output 13
S = [int(d) for d in "{:04b}".format(int(input()))] S[0] = 1 - S[0] if S[0]: S[1] = 1 - S[1] if S[0] and S[1]: S[2] = 1 - S[2] if S[0] and S[1] and S[2]: S[3] = 1 - S[3] print(sum(2 ** (3 - i) * s for i, s in enumerate(S)))
ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL STRING FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER BIN_OP NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER BIN_OP NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER BIN_OP NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER BIN_OP NUMBER VAR NU...
[Image] -----Input----- The input contains a single integer $a$ ($0 \le a \le 15$). -----Output----- Output a single integer. -----Example----- Input 3 Output 13
val = int("{:04b}".format(int(input()))[::-1], 2) - 1 if val < 0: val = 16 + val print(int("{:04b}".format(val)[::-1], 2))
ASSIGN VAR BIN_OP FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR FUNC_CALL VAR NUMBER NUMBER NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL STRING VAR NUMBER NUMBER
[Image] -----Input----- The input contains a single integer $a$ ($0 \le a \le 15$). -----Output----- Output a single integer. -----Example----- Input 3 Output 13
n = int(input()) arr = [15, 14, 12, 13, 8, 9, 10, 11, 0, 1, 2, 3, 4, 5, 6, 7] print(arr[n]) exit(0) if n == 0: print(15) exit(0) if n == 1: print(14) exit(0) if n == 2: print(12) exit(0) if n == 3: print(13) exit(0) if n == 4: print(8) exit(0) if n == 5: print(9) exit(0) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR N...
[Image] -----Input----- The input contains a single integer $a$ ($0 \le a \le 15$). -----Output----- Output a single integer. -----Example----- Input 3 Output 13
f = lambda a: (a + 1) % 2 n = int(input()) a = list(map(int, bin(n)[2:].zfill(4)[::-1])) a[3] = f(a[3]) if a[3]: a[2] = f(a[2]) if a[3] and a[2]: a[1] = f(a[1]) if a[3] and a[2] and a[1]: a[0] = f(a[0]) print(int("".join(map(str, a))[::-1], 2))
ASSIGN VAR BIN_OP BIN_OP 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 VAR NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FUN...
[Image] -----Input----- The input contains a single integer $a$ ($0 \le a \le 15$). -----Output----- Output a single integer. -----Example----- Input 3 Output 13
N = int(input()) def calc(n): if n == 0: return 15 if n == 1: return 14 if n == 2: return 12 if n == 3: return 13 if n == 4: return 8 if n == 5: return 9 if n == 6: return 10 if n == 7: return 11 if n == 8: ret...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN...
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())) k = 0 for i in range(2**N): P = [] for j in range(N): if i & 1 << j != 0: P.append(A[j]) if len(P) > 1: if L <= sum(P) <= R and max(P) - min(P) >= X: k += 1 print(k)
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 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 IF FUNC_CALL VAR 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...
def isValid(arr, l, r, x): return l <= sum(arr) <= r and max(arr) - min(arr) >= x n, l, r, x = map(int, input().strip().split()) arr = list(map(int, input().strip().split())) valid = 0 for mask in range(1, 1 << n): temp = [] for i in range(n): if mask & 1 << i: temp.append(arr[i]) ...
FUNC_DEF RETURN VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR LIS...
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, c): Num_ways = 0 for k in range(2**n): Sum = 0 k = list(bin(k).replace("0b", "")) while len(k) < n: k.insert(0, "0") Prob = [] for i in range(n): if k[i] == "1": Prob.append(c[i]) if len(Prob) > 0: ...
FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR VAR STRING STRING WHILE FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR NUMBER STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR VAR IF 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...
def rec(a, b, cur_sum): res = 0 if cur_sum > r: return 0 if cur_sum >= l: res += 1 for el in C[a + 1 : b]: if r >= cur_sum + el >= l: res += 1 for i in range(a + 1, b): for j in range(i + 1, b): res += rec(i, j, cur_sum + C[i] + C[j]) retur...
FUNC_DEF ASSIGN VAR NUMBER IF VAR VAR RETURN NUMBER IF VAR VAR VAR NUMBER FOR VAR VAR BIN_OP VAR NUMBER VAR IF VAR BIN_OP VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP VAR VAR VAR VAR VAR RETURN VAR ASSIGN VAR VAR 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...
n, l, r, x = map(int, input().split()) a = list(map(int, input().split())) ans = 0 for i in range(1, 2**n + 1): j = bin(i) j = j[2:] if len(j) < n: j = "0" * (n - len(j)) + j c = 0 temp = [] for k in j: if k == "1": temp.append(a[c]) c += 1 s = sum(temp) ...
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 BIN_OP NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER IF FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP STRING 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 = input().split() for i in range(n): c[i] = int(c[i]) ans = 0 for i in range(1, 2**n): s = bin(i) s = s[2:] s = "0" * (n - len(s)) + s if s.count("1") >= 2: total = 0 maxi = 0 mini = 10**6 + 1 for j in range(n): if ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP 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()) arr = list(map(int, input().split())) answer = 0 for i in range(1, n + 1): for j in combinations(arr, i): if len(j) >= 2 and l <= sum(j) <= r and max(j) - min(j) >= x: answer += 1 print(answer)
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 FOR VAR 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 ...
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() p = 1 << n cnt = 0 for j in range(p): list1 = [] if j > 0 and j & j - 1 != 0: for k in range(n): if j & 1 << k: list1.append(c[k]) if sum(list1) >= l and sum(list1) <= r and list1[-1] ...
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 BIN_OP NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST IF VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF 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...
import itertools n, l, r, x = map(int, input().split()) a = [int(y) for y in input().split()] ans = 0 for i in range(2, n + 1): combs = itertools.combinations(a, i) for comb in combs: sum = 0 for j in comb: sum += j dif = max(comb) - min(comb) if sum >= l and sum <= ...
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 FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FOR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR 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 I(): return list(map(int, input().split())) n, l, r, x = I() c = I() l1 = list(range(2**n)) ans = 0 for j in l1: s = 0 num = 0 ma = 0 mi = 100000000 for i in range(n): if j & 1 << i: num += 1 s += c[i] ma = max(c[i], ma) mi = min(c[i]...
FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR I...
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()) m = list(map(int, input().split())) res = 0 for i in range(3, int(1 << n)): if str(bin(i)).count("1") > 1: s = bin(i)[2:].zfill(n) mi = 1000000000.0 + 1 ma = 0 su = 0 for j, e in enumerate(s): if e == "1": su ...
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 FUNC_CALL VAR BIN_OP NUMBER VAR IF FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR VAR STRING NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR 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...
n, l, r, x = [int(x) for x in input().split()] a = [int(x) for x in input().split()] a.sort() mask = (1 << n) - 1 ans = 0 for sub in range(mask + 1): s, num = 0, 0 hard, easy = float("-inf"), float("inf") for i in range(n): if sub & 1 << i > 0: s += a[i] num += 1 ...
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 BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR FUNC_CALL VAR STRING 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 s(): [n, l, r, x] = list(map(int, input().split(" "))) l -= 1 r += 1 a = list(map(int, input().split(" "))) def f(i=0, s=0, mi=10**6, ma=1): if i == n: return ma - mi >= x and l < s < r return f(i + 1, s + a[i], min(mi, a[i]), max(ma, a[i])) + f(i + 1, s, mi, ma) ...
FUNC_DEF ASSIGN LIST VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING FUNC_DEF NUMBER NUMBER BIN_OP NUMBER NUMBER NUMBER IF VAR VAR RETURN BIN_OP VAR VAR VAR VAR VAR VAR RETURN 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...
from itertools import combinations n, l, r, x = input().split() n = int(n) l = int(l) r = int(r) x = int(x) c = [] cc = input().split() for i in range(n): cc[i] = int(cc[i]) c.append(cc[i]) c2 = [] for i in range(len(c) + 1): c2.append([x for x in combinations(c, i)]) k = 0 for i in range(len(c2)): for...
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 LIST ASSIGN VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR LIST ...
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 n, l, r, x = map(int, sys.stdin.readline().split()) c = list(map(int, sys.stdin.readline().split())) ans = 0 for i in range(1 << n): td = 0 min = 1000001 max = 0 for j in range(n): if i & 1 << j > 0: td += c[j] if c[j] > max: max = c[j] ...
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 BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR BIN_OP NUMBER VAR 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...
def main(): n, l, r, x = map(int, input().split()) cc, res = sorted(map(int, input().split())), 0 for i in range(1, 2**n): tmp, idx = [], 0 while i: if i & 1: tmp.append(cc[idx]) idx += 1 i >>= 1 if tmp[-1] - tmp[0] >= x and l <= su...
FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR VAR LIST NUMBER WHILE VAR IF BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER IF 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...
vals = input().split() n = int(vals[0]) l = int(vals[1]) r = int(vals[2]) x = int(vals[3]) plist = input().split() pbs = [] for i in range(n): pbs.append(int(plist[i])) if n == 1: print(0) elif n == 2: if pbs[0] + pbs[1] >= l and pbs[0] + pbs[1] <= r and abs(pbs[0] - pbs[1]) >= x: print(1) else:...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR IF VAR NUMBER EXPR 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...
def f(k, n, ma, mi, sum): if k: if sum + k[0] <= r and sum + k[0] >= l and max(k[0], ma) - min(k[0], mi) >= x: n += 1 if sum <= r: n = f(k[1:], n, ma, mi, sum) n = f(k[1:], n, max(k[0], ma), min(k[0], mi), sum + k[0]) return n n, l, r, x = [int(i) for i in i...
FUNC_DEF IF VAR IF BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR NUMBER VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR VAR NUMBER VAR 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 read(): return map(int, input().split()) n, l, r, x = read() c = list(read()) ans = 0 for i in range(2**n): cfg = bin(i)[2:].zfill(n) if cfg.count("1") > 1: nums = [d for j, d in enumerate(c) if cfg[j] == "1"] if max(nums) - min(nums) >= x and l <= sum(nums) <= r: ans += 1 ...
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 ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR IF FUNC_CALL VAR STRING NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL 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 b_f(l_v, c_v, c_i, l, h, l_p, h_p, x): if c_i == len(l_v): return 0 else: n_l = l_v[c_i] if not l_p else min(l_v[c_i], l_p) n_h = l_v[c_i] if not l_p else max(l_v[c_i], h_p) return ( 1 if c_v + l_v[c_i] >= l and c_v + l_v[c_i] <= h and n_h - n_l >= x else 0 ...
FUNC_DEF IF VAR FUNC_CALL VAR VAR RETURN NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR RETURN BIN_OP BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR VAR NUMBER NUMBER BIN_OP FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR 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 def is_valid(diffs): if sum(diffs) > r or sum(diffs) < l or diffs[-1] - diffs[0] < x: return False return True n, l, r, x = (int(i) for i in input().split()) d = sorted([int(i) for i in input().split()]) ind = {i for i in range(n)} nvalid = 0 for numel in range(n +...
FUNC_DEF IF FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER VAR RETURN NUMBER RETURN NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER 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, least, most, x = map(int, input().split()) c = list(map(int, input().split())) ans = 0 _max = lambda x, y: x if x > y else y _min = lambda x, y: x if x < y else y for mask in range(1 << n): mx = float("-inf") mn = float("inf") count = 0 Sum = 0 for i in range(n): if mask & 1 << i: ...
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 VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN 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()) difficulties = list(map(int, input().split())) total = 0 mask = 0 while mask < 1 << n: difficulty_sum = 0 turns = 0 easy = 0 hard = 0 for i in range(n): if mask & 1 << i: difficulty_sum += difficulties[i] turns += 1 i...
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 NUMBER WHILE VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR BIN_OP NUMBE...
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...
R = lambda: list(map(int, input().split())) n, l, r, x = R() c = R() ans = 0 for mask in range(1 << n): sum, mini, maxi, cnt = 0, 1000000000.0, -1000000000.0, 0 for i in range(n): if mask & 1 << i: sum += c[i] mini = min(mini, c[i]) maxi = max(maxi, c[i]) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR BIN_OP NUMBER VAR VAR VAR VAR ASSIGN VAR F...
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())) ans = 0 for mask in range(2**n): cnt, csum = 0, 0 mn, mx = 10**18, -(10**18) for i in range(n): if mask & 1 << i != 0: cnt += 1 csum += c[i] mn = min(mn, c[i]) mx = max(mx, c[i]...
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 NUMBER VAR ASSIGN VAR VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP NUMBER NUMBER BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR BIN_...
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 = sorted(list(map(int, input().split()))) ANS = 0 for i in range(2**n): s = bin(i)[2:] s = "0" * (n - len(s)) + s L = [] for j in range(n): if s[j] == "1": L.append(C[j]) if len(L) < 2 or not l <= sum(L) <= r or L[-1] - L[0] < x: c...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR 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 LIST...
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()) arr = list(map(int, input().split())) count = 0 lst = [] for i in range(2, n + 1): lst.append(list(itertools.combinations(arr, i))) for i in lst: for j in i: if sum(list(j)) >= l and sum(list(j)) <= r and max(list(j)) - min(list(j)) >= x: ...
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 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 FOR VAR VAR FOR VAR VAR IF 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...
def recursion(index, sub_problem): if index == len(list_value): return [sub_problem] else: all_sub_problem = [] choosing_index = recursion(index + 1, sub_problem + [list_value[index]]) not_choosing_index = recursion(index + 1, sub_problem) for element in choosing_index: ...
FUNC_DEF IF VAR FUNC_CALL VAR VAR RETURN LIST VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR LIST VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FOR VAR VAR IF VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR VAR IF 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...
import itertools def classify(subset, l, r, x): li = [] for i in subset: li.append(i) f1 = False f2 = False f3 = False s = 0 for i in li: s += i if s >= l: f1 = True if s <= r: f2 = True li.sort() t = li[len(li) - 1] - li[0] if t >= x: ...
IMPORT FUNC_DEF ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR VAR VAR IF VAR VAR ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN 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...
n, l, r, x = map(int, input().split()) nums = sorted(list(map(int, input().split()))) ans = 0 def recurse(i, sum, dif, cnt): global ans if i == n: if not cnt: return if sum >= l and sum <= r and abs(cnt[-1] - cnt[0]) >= x: ans += 1 return recurse(i + 1, sum,...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FUNC_DEF IF VAR VAR IF VAR RETURN IF VAR VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER VAR VAR NUMBER RETURN EXPR FUNC_CALL VAR BIN_OP VAR NUMBER 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...
import itertools n, l, r, x = map(int, input().split()) C = list(map(int, input().split())) ans = 0 combi = [] for i in range(1, n + 1): tmp = [list(x) for x in itertools.combinations(C, i)] combi.extend(tmp) for tmp in combi: s = sum(tmp) if s >= l and s <= r and max(tmp) - min(tmp) >= x: ans ...
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 ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR EXPR FUNC_CALL VAR VAR FOR 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...
n, l, r, x = map(int, input().split()) c = [int(x) for x in input().split()] ans = 0 i = 0 maxval = 0 minval = 0 sum = 0 while i < 1 << n: maxval = -1 minval = 1000000 sum = 0 for j in range(n): if i & 1 << j: sum += c[j] maxval = max(maxval, c[j]) minval = mi...
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 NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER 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...
n, left, right, diff = map(int, input().split()) a = list(map(int, input().split())) ret = 0 for mask in range(1 << n): if bin(mask).count("1") < 2: continue take = [a[i] for i in range(n) if mask >> i & 1] s = sum(take) d = max(take) - min(take) ret += left <= s <= right and d >= diff print...
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 NUMBER VAR IF FUNC_CALL FUNC_CALL VAR VAR STRING NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN 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...
ans = 0 n, l, w, x = map(int, input().split()) 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: if l <= sum(data) <= w and max(data) - min(data) >= x: global ans ...
ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR EXPR FUNC_CALL VAR VAR VAR NUMBER BIN_OP VAR NUMBER NUMBER VAR FUNC_DEF IF VAR VAR IF VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER RETURN ASSIGN VAR VAR WH...
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 = [int(x) for x in input().split()] c = [int(x) for x in input().split()] counter = 0 for i, val in enumerate(["".join(seq) for seq in itertools.product("01", repeat=n)]): if val.count("1") < 2: continue dif = 0 mx = float("-inf") mn = float("inf") for i, bit in ...
IMPORT 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 NUMBER FOR VAR VAR FUNC_CALL VAR FUNC_CALL STRING VAR VAR FUNC_CALL VAR STRING VAR IF FUNC_CALL VAR STRING NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR F...
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 def subsets(M): L = list(M) n = len(L) for i in range(1 << n): mask = [(i >> k & 1) for k in range(n)] yield list(itertools.compress(L, mask)) return n, l, r, x = [int(x) for x in input().split()] def check(subset): if len(subset) < 2: return False ...
IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR VAR RETURN ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF FUNC_CALL VAR 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...
import itertools def read_data(): n, l, r, x = map(int, input().split()) cs = list(map(int, input().split())) return n, l, r, x, cs def solve(n, l, r, x, cs): cs.sort() count = 0 for m in range(2, n + 1): for sets in itertools.combinations(cs, m): diff = sets[-1] - sets[0...
IMPORT FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR RETURN VAR VAR VAR VAR VAR FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR 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...
def main(): mode = "fil" if mode == "file": f = open("test.txt", "r") get = lambda: [ int(x) for x in (f.readline() if mode == "file" else input()).split() ] [n, l, r, x] = get() c = get() if n == 1: print("0") return c.sort() if c[-1] - c[0] < x: ...
FUNC_DEF ASSIGN VAR STRING IF VAR STRING ASSIGN VAR FUNC_CALL VAR STRING STRING ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR FUNC_CALL VAR ASSIGN LIST VAR VAR VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR STRING RETURN EXPR FUNC_CALL VAR IF BIN_OP VAR 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...
def rec(c, at, mark, l, r, x, _max, _min, _sum): if _sum > r: return 0 res = 0 if _max - _min >= x and _sum >= l and _sum <= r: res += 1 for i in range(at, len(c)): if mark[i]: continue res += rec( c, i + 1, mark, l, r, x, max(_max, c[i]), min(_min...
FUNC_DEF IF VAR VAR RETURN NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR VAR VAR RETURN 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...
import time def test(a, b, C, s, n, l, r, x, p): if C == []: if s >= l and s <= r and b - a >= x: return 1 return 0 if s >= l and s <= r and b - a >= x: acc = 1 else: acc = 0 for i in range(len(C)): if s + C[i] <= r: acc += test( ...
IMPORT FUNC_DEF IF VAR LIST IF VAR VAR VAR VAR BIN_OP VAR VAR VAR RETURN NUMBER RETURN NUMBER IF VAR VAR VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR 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...
from itertools import combinations def combos(lst): for i in range(0, len(lst)): for combo in combinations(lst, i + 1): yield combo inp = list(map(int, input().split())) n = inp[0] l = inp[1] r = inp[2] k = inp[3] probs = sorted(list(map(int, input().split()))) count = 0 for sublist in combo...
FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER EXPR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL 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 FUNC_CALL 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...
IL = lambda: list(map(int, input().split())) IS = lambda: input().split() I = lambda: int(input()) S = lambda: input() n, l, r, x = IL() cArr = sorted(IL()) ans = 0 for i in range(1, 2**n): csub = [cArr[j] for j in range(n) if i & 2**j] if l <= sum(csub) <= r and csub[-1] - csub[0] >= x: ans += 1 print(...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR 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 NUMBER BIN_OP NUMBER VAR ASSIGN 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...
n, l, r, x = map(int, input().split()) a = input().split() ran = 2**n answer = 0 for i in range(n): a[i] = int(a[i]) for i in range(ran): m = i mask = "" while m != 0: if m % 2 == 0: mask += "0" else: mask += "1" m = m // 2 while len(mask) < n: ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR ASSIGN VAR STRING WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER 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...
n, l, r, x = list(map(int, input().split())) s = list(map(int, input().split())) olmps = [] c = [] v = 0 for i in range(1 << n): olmps.append([]) for j in range(n): if i & 1 << j: olmps[-1].append(s[j]) for o in olmps: if l <= sum(o) <= r: c.append(o) for z in c: if max(z) - ...
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 ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR EXPR FUNC_CALL VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR BIN_OP NUMBER VAR EX...
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, d = [int(i) for i in input().split()] op = [int(i) for i in input().split()] c = 0 for i in range(2, 2**n): s = 0 k = 0 maxx = 0 minn = 1000001 x = bin(i)[2:] x = "0" * (n - len(x)) + x for j in range(n): if x[j] == "1": s += op[j] k += 1 ...
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 NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP BIN...
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()] a = [int(x) for x in input().split()] a.sort() k = 1 << n res = 0 lst = 0 for i in range(k): num = 0 cnt = 0 fst = -1 for j in range(n): if 1 << j & i != 0: num += a[j] cnt += 1 if fst == -1: fst =...
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 BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF 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 = (int(x) for x in input().split()) c = [int(x) for x in input().split()] c.sort() ans = 0 for i in range(1, 2**n): cur = [] for j in range(n): if i & 1 << j: cur.append(c[j]) if cur[-1] - cur[0] < x: continue if l <= sum(cur) <= r: ans += 1 print(ans)
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 FOR VAR FUNC_CALL VAR NUMBER 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 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...
a = list(map(int, input().split(" "))) b = list(map(int, input().split(" "))) n = a[0] l = a[1] r = a[2] x = a[3] ans = 0 puis = 1 << n for m in range(puis): mn = 1000000 mx = 1 cnt = 0 sum = 0 for i in range(n): if m & 1 << i != 0: cnt += 1 sum += b[i] mn...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER 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 chain, combinations def powerset(iterable): s = list(iterable) return chain.from_iterable(combinations(s, r) for r in range(1, len(s) + 1)) n, l, r, x = map(int, input().split()) cantidad_de_formas = 0 difficulties = powerset(map(int, input().split())) for combinacion in difficulties: ...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR RETURN 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 NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR VAR IF 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...
def dfs(now, num, l, r, dx, c): if now < 0 or num >= r: return 0 temp = dfs(now - 1, num, l, r, dx, c) num += c[now] if num >= l and num <= r and c[now] <= dx: temp += 1 return temp + dfs(now - 1, num, l, r, dx, c) c = input().split() n = int(c[0]) l = int(c[1]) r = int(c[2]) x = i...
FUNC_DEF IF VAR NUMBER VAR VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR VAR VAR VAR IF VAR VAR VAR VAR VAR VAR VAR VAR NUMBER RETURN BIN_OP VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR 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 = [int(i) for i in input().split()] c = [int(i) for i in input().split()] ans = 0 for i in range(1, 1 << n): a = [] s = 0 for j in range(0, n): if i >> j & 1 > 0: a.append(c[j]) s += c[j] a.sort() if s >= l and s <= r and a[len(a) - 1] - a[0] >= x: ...
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 NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER 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...
def getSub(l, i): j = -1 r = [] while i > 0: if i % 2 == 1: r.append(l[j]) i //= 2 j -= 1 return r n, l, r, x = map(int, input().split()) cs = list(map(int, input().split())) count = 0 cs.sort() for subI in range(1, 2**n): sub = getSub(cs, subI) if len(sub) ...
FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR NUMBER IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER VAR NUMBER RETURN VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER EXPR FUNC_CALL 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...
from itertools import * def inp(): return map(int, input().split()) def arr_inp(): return [int(x) for x in input().split()] n, l, r, x = inp() c, out = arr_inp(), 0 for i in range(2, n + 1): for j in list(combinations(c, i)): s, mi, ma = sum(j), min(j), max(j) if s >= l and s <= r and ...
FUNC_DEF RETURN FUNC_CALL VAR VAR FUNC_CALL 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 VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR 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...
n, l, r, x = list(map(int, input().split())) a = list(map(int, input().split())) subsets = [] for i in range(1, 2**n): temp = [] for j in range(n): if 1 << j & i: temp.append(a[j]) subsets.append(temp) count = 0 for i in range(len(subsets)): cur = subsets[i] mi = min(cur) ma ...
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 LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP NUMBER VAR VAR EXPR FUNC_CALL VAR VAR VAR EXPR 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 = map(int, input().split()) c = list(map(int, input().split())) count = 0 for i in range(2**n): b = bin(i)[2:] b = "0" * (n - len(b)) + b minn, maxx = 10**18, 0 s = 0 for j in range(n): if b[j] == "1": minn = min(minn, c[j]) maxx = max(maxx, c[j]) ...
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 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 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 main(): n, l, r, x = list(map(int, input().split())) C = list(map(int, input().split())) ans = 0 for i in range(1 << n): use = [] for j in range(n): if i >> j & 1: use.append(C[j]) if use == []: continue if max(use) - min(use) >...
FUNC_DEF 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 BIN_OP NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR 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...
import itertools def judge(_list: int, _min: int, _max: int, _dif: int) -> int: count = 0 for i in range(len(_list)): a = itertools.combinations(_list, i + 1) for j in a: if _min <= sum(j) <= _max and max(j) - min(j) >= _dif: count += 1 return count number, mi...
IMPORT FUNC_DEF VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FOR VAR VAR IF VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER RETURN VAR VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL 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...
n, l, r, x = [int(i) for i in input().split()] a = [int(i) for i in input().split()] res = 0 for i in range(2, 1 << len(a)): cmin = 10**9 + 1 cmax = 0 ctotal = 0 for j in range(len(a)): if i & 1 << j: cmin = min(a[j], cmin) cmax = max(a[j], cmax) ctotal += a[j...
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 NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR 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...
def check_combos(diff, n, size, start, picked, total, l, r, x, combination=[]): if picked == size: if max(combination) - min(combination) >= x and l <= sum(combination) <= r: total += 1 else: for i in range(start, n - (size - picked - 1)): combination.append(diff[i]) ...
FUNC_DEF LIST IF VAR VAR IF BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR VAR VAR VAR NUMBER 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...
l = [int(x) for x in input().split()] l2 = [int(x) for x in input().split()] l2 = sorted(l2) ans = 0 for i in range(1 << l[0]): first = -1 last = -1 t = 0 for j in range(l[0]): if 1 << j & i > 0: if first == -1: first = j last = j t += l2[j] ...
ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER IF BIN_OP BIN_OP NUMBER 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...
n, l, r, x = list(map(int, input().split(" "))) c = sorted(list(map(int, input().split(" ")))) ways = 0 for i in range(0, 2**n): temp = 0 m = 10**9 + 1 M = -1 for j in range(0, n): if i & 1 << j: temp += c[j] m = min(m, c[j]) M = max(M, c[j]) if temp >= l ...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER NUMBER 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...
nlrx = list(map(int, input().split())) n, l, r, x = nlrx problems = list(map(int, input().split())) valid_sets = [] numSets = pow(2, n) for i in range(1, numSets): currSet = [] for j in range(n): if i & 1 << j > 0: currSet.append(problems[j]) if sum(currSet) < l or sum(currSet) > r: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF 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...
import sys def set(mask, pos): return mask | 1 << pos def isOn(mask, pos): return mask & 1 << pos > 0 n, l, r, x = map(int, input().split(" ")) dif = list(map(int, input().split(" "))) count, mask = 0, 0 while mask <= 2**n: summ, bit = [], 0 while bit < n: if isOn(mask, bit): s...
IMPORT FUNC_DEF RETURN BIN_OP VAR BIN_OP NUMBER VAR FUNC_DEF RETURN BIN_OP VAR BIN_OP NUMBER VAR NUMBER 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 VAR NUMBER NUMBER WHILE VAR BIN_OP NUMBER VAR ASSIGN 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 calcular_problemas(n, l, r, x, problemas): num_elementos = n conj_act = 0 num_formas = 0 while conj_act < 1 << num_elementos: suma_de_problemas = 0 pos_max_enc = 0 pos_min_dif = 0 pos_max_dif = 0 contar_elementos = 0 for elemento in range(num_elementos...
FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR BIN_OP NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER 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...
import sys def main(): import sys n, l, r, x, *c = [int(i) for i in sys.stdin.read().split()] result = 0 for mask in range(1 << n): number = 0 minimal = float("inf") maximal = -float("inf") s = 0 for i in range(n): if mask & 1 << i: ...
IMPORT FUNC_DEF IMPORT ASSIGN VAR VAR VAR VAR 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 NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR BIN_OP NUMBER VAR 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 = [] def judge(n, cjx): inf, sup = float("inf"), -float("inf") total = 0 for i in range(n): if cjx[i]: total += c[i] inf = min(inf, c[i]) sup = max(sup, c[i]) return sup - inf >= x and l <= total and total <= r def dfs(s, n, cjx):...
ASSIGN VAR VAR VAR VAR NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR STRING FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR RETURN BIN_OP VAR VAR VAR 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...
def generate(i, real, a): if i == n: if real >= 2: min_a = a[0] max_a = a[real - 1] sum_a = sum(a) if sum_a >= l and sum_a <= r and max_a - min_a >= x: count[0] += 1 else: generate(i + 1, real + 1, a + [c[i]]) generate(i + 1...
FUNC_DEF IF VAR VAR IF VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR BIN_OP VAR VAR VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR LIST VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR VAR 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 combinations def subsetSums(arr): c = [] for i in range(1, len(arr) + 1): c += list(combinations(arr, i)) return c n, l, r, x = map(int, input().split()) a = list(map(int, input().split())) a = sorted(a) ways = 0 a = subsetSums(a) for i in range(len(a)): a[i] = list(a[i...
FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR RETURN VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER 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 combinations def check(j): if sum(j) >= l and sum(j) <= r and max(j) - min(j) >= x: return 1 return 0 n, l, r, x = list(map(int, input().split())) c = list(map(int, input().rstrip().split())) count = 0 for i in range(2, n + 1): a = list(combinations(c, i)) for j in a: ...
FUNC_DEF IF FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR RETURN NUMBER RETURN NUMBER 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 FUNC_CALL VAR ASSIGN VAR NUMBER FOR 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 s(): [n, l, r, x] = list(map(int, input().split(" "))) l -= 1 r += 1 a = list(map(int, input().split(" "))) s = 0 for i in range(1, 1 << n): ind = 0 k = [] while i: if i & 1: k.append(a[ind]) ind += 1 i >>= 1 ...
FUNC_DEF ASSIGN LIST VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR LIST WHILE VAR IF 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...
aa = 0 a, b, c, d = list(map(int, input().split(" "))) l = list(map(int, input().split(" "))) for i in range(2**a): k = bin(i)[2:] t = 0 k = "0" * (a - len(k)) + k x = [] for j in range(a): if k[j] == "1": x.append(l[j]) t += 1 if t >= 2: if b <= sum(x) <=...
ASSIGN VAR NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP STRING BIN_OP 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 as it n, l, r, x = map(int, input().split()) arr = list(map(int, input().split())) poss = [] for i in range(2, len(arr) + 1): p = list(it.combinations(arr, i)) for j in p: poss.append(j) ans = 0 for a in poss: a = sorted(a) if l <= sum(a) <= r and a[-1] - a[0] >= x: ans...
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 LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FOR VAR VAR EXPR FUNC_CALL VAR VAR 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...
n, l, r, x = map(int, input().split()) c = list(map(int, input().split())) c.sort() qtd = 0 for b in range(int("1" * n, base=2) + 1): binary = bin(b)[2:] binary = "{:0>{n}}".format(int(binary), n=n) vetor = [] for i, d in enumerate(binary): if d == "1": vetor.append(c[i]) vetor.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 FUNC_CALL VAR BIN_OP STRING VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL STRING 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...
values = input() values = values.split() n = int(values[0]) l = int(values[1]) r = int(values[2]) x = int(values[3]) ci = input() ci = ci.split() for i in range(len(ci)): ci[i] = int(ci[i]) count = 0 def sub_lists(l): base = [] lists = [base] for i in range(len(l)): orig = lists[:] new...
ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR 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 = map(int, input().split()) tasks = list(map(int, input().split())) mask = 3 ans = 0 while mask < 1 << n: sum_dif = 0 min_diff = float("inf") max_diff = -float("inf") if mask & mask - 1: for i in range(n): if mask & 1 << i: sum_dif += tasks[i] ...
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 NUMBER WHILE VAR BIN_OP NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF BIN_OP VAR BIN_OP 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 = map(int, input().split()) arr = list(map(int, input().split())) def solve(): count = 0 for i in range(1 << n): minv = float("inf") maxv = 0 total = 0 for j in range(n): if i & 1 << j: total += arr[j] minv = min(minv, arr[...
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 ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER 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...
import sys def answer(n, l, r, x, c): num_ways = 0 ctr = 1 while ctr < 2**n: s = bin(ctr)[2:].zfill(n) t_ary = [] summ = 0 mx = 0 mn = 10**7 for i in range(n): if s[i] == "1": t_ary.append(c[i]) summ += c[i] ...
IMPORT FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR BIN_OP NUMBER VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR STRING EXPR FUNC_CALL VAR VAR VAR VAR VAR 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...
def isValidSet( problemSet: list, minTotalDif: int, maxTotalDif: int, minDelta: int ) -> bool: if len(problemSet) >= 2: total = sum(problemSet) myDelta = max(problemSet) - min(problemSet) if minTotalDif <= total <= maxTotalDif and myDelta >= minDelta: return True return F...
FUNC_DEF VAR VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR RETURN NUMBER RETURN NUMBER VAR FUNC_DEF VAR VAR VAR VAR FUNC_DEF VAR VAR VAR IF FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR F...
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())) def check(a): s = sum(a) global l, r, x return max(a) - min(a) >= x and s >= l and s <= r res = 0 for t in range(1, 2**n): a = [c[i] for i in range(n) if t >> i & 1 == 1] if check(a): res += 1 print(res)
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 ASSIGN VAR FUNC_CALL VAR VAR RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER VAR 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...
from itertools import combinations def main(): n, l, r, x = [int(t) for t in input().split()] c = [int(t) for t in input().split()] def is_valid(candidate): mx = max(candidate) mn = min(candidate) sm = sum(candidate) return l <= sm <= r and mx - mn >= x way = 0 fo...
FUNC_DEF 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 FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR RETURN VAR VAR VAR BIN_OP VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_...
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())) c = [] for i in range(2, n + 1): c += list(combinations(a, i)) cnt = 0 for t in c: m = min(t) M = max(t) s = sum(t) if M - m >= x and (s >= l and s <= r): cnt += 1 print(cnt)
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 LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR 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...
from sys import stdin inp = lambda: stdin.readline().strip() def int2bin(integer, digits): if integer >= 0: return bin(integer)[2:].zfill(digits) else: return bin(2**digits + integer)[2:] n, l, r, x = [int(x) for x in inp().split()] a = [int(x) for x in inp().split()] ans = 0 for i in range...
ASSIGN VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF IF VAR NUMBER RETURN FUNC_CALL FUNC_CALL VAR VAR NUMBER VAR RETURN FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR VAR NUMBER 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 NUMBER FOR 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...
n, l, r, x = map(int, input().split()) li = list(map(int, input().split())) t = (1 << n) - 1 ans = 0 while t != 0: s, mi, mx = 0, 1000001, 0 for i in range(len(li)): if t & 1 << i: s += li[i] mi = min(mi, li[i]) mx = max(mx, li[i]) if mx - mi >= x and (s >= l and ...
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 BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR VAR VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR BIN_OP 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...
ans = 0 n, l, r, x = map(int, input().split()) z = list(map(int, input().split())) for i in range(3, 1 << len(z)): lst = [] for j in range(25): if i & 1 << j: lst.append(z[j]) lst.sort() if len(lst) > 1 and l <= sum(lst) <= r and lst[-1] - lst[0] >= x: ans += 1 print(ans)
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 FOR VAR FUNC_CALL VAR NUMBER BIN_OP NUMBER FUNC_CALL VAR VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER IF BIN_OP VAR BIN_OP NUMBER VAR 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...
from itertools import combinations from sys import stdin n, l, r, x = map(int, stdin.readline().rstrip().split(" ")) li = list(map(int, stdin.readline().rstrip().split(" "))) z = [] ans = 0 for i in range(2, n + 1): z += list(combinations(li, i)) for i in z: a = sorted(i) if a[-1] - a[0] >= x and r >= sum(...
ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FOR VAR VAR ASSIGN VAR FUNC_CALL ...