description
stringlengths
171
4k
code
stringlengths
94
3.98k
normalized_code
stringlengths
57
4.99k
Consider two non-negative long integers, $a$ and $\boldsymbol{b}$, where $a\leq b$. The bitwise AND of all long integers in the inclusive range between $a$ and $\boldsymbol{b}$ can be expressed as $a\ \text{&}\ (a+1)\ \text{&}\ \ldots\ \text{&}\ (b-1)\ \text{&}\ b$, where $\text{&}$ is the bitwise AND operator. Given...
T = int(input()) for _ in range(0, T): S, L = map(int, input().split()) if S == 0 or L == 0: print(0) continue S = "{0:032b}".format(S) L = "{0:032b}".format(L) S = list(S) L = list(L) S.reverse() L.reverse() s = S.pop() l = L.pop() while s != "1" and l != "1"...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR...
Consider two non-negative long integers, $a$ and $\boldsymbol{b}$, where $a\leq b$. The bitwise AND of all long integers in the inclusive range between $a$ and $\boldsymbol{b}$ can be expressed as $a\ \text{&}\ (a+1)\ \text{&}\ \ldots\ \text{&}\ (b-1)\ \text{&}\ b$, where $\text{&}$ is the bitwise AND operator. Given...
for _ in range(int(input())): A, B = map(int, input().split()) N = A.bit_length() if N == B.bit_length(): A, B = str(bin(A))[2:], str(bin(B))[2:] for i in range(N): if not A[i] == B[i]: print(int(A[:i] + "0" * (N - i), 2)) break else: p...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR IF VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL ...
Consider two non-negative long integers, $a$ and $\boldsymbol{b}$, where $a\leq b$. The bitwise AND of all long integers in the inclusive range between $a$ and $\boldsymbol{b}$ can be expressed as $a\ \text{&}\ (a+1)\ \text{&}\ \ldots\ \text{&}\ (b-1)\ \text{&}\ b$, where $\text{&}$ is the bitwise AND operator. Given...
for _ in range(int(input())): a, b = map(int, input().split()) x = 0 while a | x < b: x = x + x | 1 print(a & ~x)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR
Consider two non-negative long integers, $a$ and $\boldsymbol{b}$, where $a\leq b$. The bitwise AND of all long integers in the inclusive range between $a$ and $\boldsymbol{b}$ can be expressed as $a\ \text{&}\ (a+1)\ \text{&}\ \ldots\ \text{&}\ (b-1)\ \text{&}\ b$, where $\text{&}$ is the bitwise AND operator. Given...
import sys t = int(sys.stdin.readline().strip()) for tests in range(t): a, b = [int(x) for x in sys.stdin.readline().split()] msb_a = 0 msb_b = 0 mask = 1 << 31 a_test = True b_test = True if a == 0: msb_a = 0 a_test = False if b == 0: msb_b = 0 b_test = ...
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VA...
Consider two non-negative long integers, $a$ and $\boldsymbol{b}$, where $a\leq b$. The bitwise AND of all long integers in the inclusive range between $a$ and $\boldsymbol{b}$ can be expressed as $a\ \text{&}\ (a+1)\ \text{&}\ \ldots\ \text{&}\ (b-1)\ \text{&}\ b$, where $\text{&}$ is the bitwise AND operator. Given...
t = int(input()) while t != 0: t -= 1 l, u = map(int, input().split()) s1 = "{0:032b}".format(l) s2 = "{0:032b}".format(u) s = [0] * 32 i = 0 flag = False ans = 0 while i < 32: if s2[i] == "1" and s1[i] == "1": s[i] = 1 flag = True if flag == T...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR FUNC_CALL STRING VAR ASSIGN VAR BIN_OP LIST NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR NUMBER IF VAR VAR STRING VAR VA...
Consider two non-negative long integers, $a$ and $\boldsymbol{b}$, where $a\leq b$. The bitwise AND of all long integers in the inclusive range between $a$ and $\boldsymbol{b}$ can be expressed as $a\ \text{&}\ (a+1)\ \text{&}\ \ldots\ \text{&}\ (b-1)\ \text{&}\ b$, where $\text{&}$ is the bitwise AND operator. Given...
T = int(input().strip()) for t in range(0, T): a, b = list(map(int, input().strip().split(" "))) A, B = [bin(a)[2:], bin(b)[2:]] alen, blen = len(A), len(B) if alen < blen: print(0) else: s = "" found = False for i in range(0, alen): if found: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR VAR LIST FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR EXPR FUNC_CALL VAR...
Consider two non-negative long integers, $a$ and $\boldsymbol{b}$, where $a\leq b$. The bitwise AND of all long integers in the inclusive range between $a$ and $\boldsymbol{b}$ can be expressed as $a\ \text{&}\ (a+1)\ \text{&}\ \ldots\ \text{&}\ (b-1)\ \text{&}\ b$, where $\text{&}$ is the bitwise AND operator. Given...
for t in range(int(input())): a, b = sorted(map(int, input().split())) bits = ["0"] * (a.bit_length() + 1) for k in range(a.bit_length()): twoP = 1 << k if a & twoP and b < (a // twoP + 1) * twoP: bits[~k] = "1" ans = "".join(bits) print(int(ans, 2))
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST STRING BIN_OP FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR IF BIN_OP VAR VAR VAR BIN_OP BIN_OP BIN_OP VAR VAR NUMBER VAR ASSIGN VAR VAR...
Consider two non-negative long integers, $a$ and $\boldsymbol{b}$, where $a\leq b$. The bitwise AND of all long integers in the inclusive range between $a$ and $\boldsymbol{b}$ can be expressed as $a\ \text{&}\ (a+1)\ \text{&}\ \ldots\ \text{&}\ (b-1)\ \text{&}\ b$, where $\text{&}$ is the bitwise AND operator. Given...
import sys T = int(input().strip()) def ANDproduct(A, B): s = (B ^ A).bit_length() B = B >> s B = B << s return B for t in range(T): arr = [int(arr_temp) for arr_temp in input().strip().split(" ")] print(ANDproduct(arr[0], arr[1]))
IMPORT ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER
Consider two non-negative long integers, $a$ and $\boldsymbol{b}$, where $a\leq b$. The bitwise AND of all long integers in the inclusive range between $a$ and $\boldsymbol{b}$ can be expressed as $a\ \text{&}\ (a+1)\ \text{&}\ \ldots\ \text{&}\ (b-1)\ \text{&}\ b$, where $\text{&}$ is the bitwise AND operator. Given...
numcases = int(input()) for _ in range(numcases): min, max = [int(x) for x in input().split()] reverseDigits = [] for i in range(32): place = pow(2, i) if place > max: break if min // place == max // place and min // place % 2 == 1: reverseDigits.append("1") ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR IF BIN_OP VAR VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER NUMBER EXPR FUNC_CALL VAR STRING EXPR FU...
Consider two non-negative long integers, $a$ and $\boldsymbol{b}$, where $a\leq b$. The bitwise AND of all long integers in the inclusive range between $a$ and $\boldsymbol{b}$ can be expressed as $a\ \text{&}\ (a+1)\ \text{&}\ \ldots\ \text{&}\ (b-1)\ \text{&}\ b$, where $\text{&}$ is the bitwise AND operator. Given...
def longest_common_prefix(seq1, seq2): start = 0 while start < min(len(seq1), len(seq2)): if seq1[start] != seq2[start]: break start += 1 return seq1[:start] t = int(input()) while t: s = input().split() a, b = int(s[0]), int(s[1]) x = bin(a)[2:] y = bin(b)[2:] ...
FUNC_DEF ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR IF VAR VAR VAR VAR VAR NUMBER RETURN VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASS...
Consider two non-negative long integers, $a$ and $\boldsymbol{b}$, where $a\leq b$. The bitwise AND of all long integers in the inclusive range between $a$ and $\boldsymbol{b}$ can be expressed as $a\ \text{&}\ (a+1)\ \text{&}\ \ldots\ \text{&}\ (b-1)\ \text{&}\ b$, where $\text{&}$ is the bitwise AND operator. Given...
def next_all_ones(n): n -= 1 for k in (1, 2, 4, 8, 16, 32, 64): n |= n >> k return n for _ in range(int(input())): a, b = list(map(int, input().split())) print(a & b & ~next_all_ones(a ^ b))
FUNC_DEF VAR NUMBER FOR VAR NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER VAR BIN_OP VAR VAR RETURN VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR
Consider two non-negative long integers, $a$ and $\boldsymbol{b}$, where $a\leq b$. The bitwise AND of all long integers in the inclusive range between $a$ and $\boldsymbol{b}$ can be expressed as $a\ \text{&}\ (a+1)\ \text{&}\ \ldots\ \text{&}\ (b-1)\ \text{&}\ b$, where $\text{&}$ is the bitwise AND operator. Given...
numOfCase = int(input()) for noc in range(numOfCase): l = list(map(lambda s: int(s), input().split(" "))) m = l[0] n = l[1] res = n while res > m: res = res & res - 1 print(res)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL 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 WHILE VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR
Consider two non-negative long integers, $a$ and $\boldsymbol{b}$, where $a\leq b$. The bitwise AND of all long integers in the inclusive range between $a$ and $\boldsymbol{b}$ can be expressed as $a\ \text{&}\ (a+1)\ \text{&}\ \ldots\ \text{&}\ (b-1)\ \text{&}\ b$, where $\text{&}$ is the bitwise AND operator. Given...
def ANDprod(s): n1, n2 = s.split() n1 = int(n1) n2 = int(n2) c1 = 0 c2 = 0 x = 1 y = 1 while x <= n1: x = x << 1 | 0 c1 = c1 + 1 while y <= n2: y = y << 1 | 0 c2 = c2 + 1 if x == y: y = 0 while c1: c1 = c1 - 1 ...
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VA...
Consider two non-negative long integers, $a$ and $\boldsymbol{b}$, where $a\leq b$. The bitwise AND of all long integers in the inclusive range between $a$ and $\boldsymbol{b}$ can be expressed as $a\ \text{&}\ (a+1)\ \text{&}\ \ldots\ \text{&}\ (b-1)\ \text{&}\ b$, where $\text{&}$ is the bitwise AND operator. Given...
def hibit(n): n = n | n >> 1 n = n | n >> 2 n = n | n >> 4 n = n | n >> 8 n = n | n >> 16 return n - (n >> 1) T = int(input()) for _ in range(T): A, B = [int(i) for i in input().split()] diff = A ^ B diff = hibit(diff) diff = (diff << 1) - 1 print(A & ~diff)
FUNC_DEF ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER RETURN BIN_OP VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR...
Consider two non-negative long integers, $a$ and $\boldsymbol{b}$, where $a\leq b$. The bitwise AND of all long integers in the inclusive range between $a$ and $\boldsymbol{b}$ can be expressed as $a\ \text{&}\ (a+1)\ \text{&}\ \ldots\ \text{&}\ (b-1)\ \text{&}\ b$, where $\text{&}$ is the bitwise AND operator. Given...
def AND_A2B(A, B): if not A: return 0 last1 = A & -A a = A - last1 while a and a + (last1 << 1) <= B: last1 = a & -a a -= last1 return 0 if not A and last1 << 1 <= B else a + last1 def bt4c(A, B): ans = A for i in range(A + 1, B + 1): ans &= i return ans...
FUNC_DEF IF VAR RETURN NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR WHILE VAR BIN_OP VAR BIN_OP VAR NUMBER VAR ASSIGN VAR BIN_OP VAR VAR VAR VAR RETURN VAR BIN_OP VAR NUMBER VAR NUMBER BIN_OP VAR VAR FUNC_DEF ASSIGN VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR VAR RETURN VAR FOR V...
Consider two non-negative long integers, $a$ and $\boldsymbol{b}$, where $a\leq b$. The bitwise AND of all long integers in the inclusive range between $a$ and $\boldsymbol{b}$ can be expressed as $a\ \text{&}\ (a+1)\ \text{&}\ \ldots\ \text{&}\ (b-1)\ \text{&}\ b$, where $\text{&}$ is the bitwise AND operator. Given...
T = int(input().strip()) for _ in range(T): a, b = [int(s) for s in input().strip().split(" ")] et = a & b for i in range(et.bit_length()): bit = 1 << i if et & bit: if a <= b - bit: et -= bit print(et)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER VAR IF BIN_OP VAR VAR IF VAR BIN_OP VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR
Consider two non-negative long integers, $a$ and $\boldsymbol{b}$, where $a\leq b$. The bitwise AND of all long integers in the inclusive range between $a$ and $\boldsymbol{b}$ can be expressed as $a\ \text{&}\ (a+1)\ \text{&}\ \ldots\ \text{&}\ (b-1)\ \text{&}\ b$, where $\text{&}$ is the bitwise AND operator. Given...
def bin_repr(n): return "{:b}".format(n) def smart(low, high): return int(_smart_r(bin_repr(low), bin_repr(high)), base=2) def _smart_r(low_bin_str, high_bin_str): low_bin_str_stripped = low_bin_str.lstrip("0") high_bin_str_stripped = high_bin_str.lstrip("0") if len(low_bin_str) == 0: re...
FUNC_DEF RETURN FUNC_CALL STRING VAR FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR NUMBER RETURN STRING IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN BIN_OP STRING FUNC_CALL VAR VAR RET...
Consider two non-negative long integers, $a$ and $\boldsymbol{b}$, where $a\leq b$. The bitwise AND of all long integers in the inclusive range between $a$ and $\boldsymbol{b}$ can be expressed as $a\ \text{&}\ (a+1)\ \text{&}\ \ldots\ \text{&}\ (b-1)\ \text{&}\ b$, where $\text{&}$ is the bitwise AND operator. Given...
for t in range(int(input())): a, b = map(int, input().split()) s = a if b - a >= a: print(0) else: while a <= b: k = 1 t = a while t % 2 == 0: t //= 2 k *= 2 a += k if a <= b: s &=...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR IF BIN_OP VAR VAR VAR EXPR FUNC_CALL VAR NUMBER WHILE VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR NUMBER VAR VAR IF VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR
Consider two non-negative long integers, $a$ and $\boldsymbol{b}$, where $a\leq b$. The bitwise AND of all long integers in the inclusive range between $a$ and $\boldsymbol{b}$ can be expressed as $a\ \text{&}\ (a+1)\ \text{&}\ \ldots\ \text{&}\ (b-1)\ \text{&}\ b$, where $\text{&}$ is the bitwise AND operator. Given...
def has_zero(a, b, n): if a & 2**n == 0: return True x = a // 2**n * 2**n x += 2**n return x <= b for _ in range(int(input())): a, b = [int(s) for s in input().split()] res = 0 for i in range(32): if not has_zero(a, b, i): res += 2**i print(res)
FUNC_DEF IF BIN_OP VAR BIN_OP NUMBER VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP NUMBER VAR BIN_OP NUMBER VAR VAR BIN_OP NUMBER VAR RETURN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBE...
Consider two non-negative long integers, $a$ and $\boldsymbol{b}$, where $a\leq b$. The bitwise AND of all long integers in the inclusive range between $a$ and $\boldsymbol{b}$ can be expressed as $a\ \text{&}\ (a+1)\ \text{&}\ \ldots\ \text{&}\ (b-1)\ \text{&}\ b$, where $\text{&}$ is the bitwise AND operator. Given...
all_ones = pow(2, 33) - 1 n = int(input()) for i in range(n): s, e = [int(p) for p in input().split()] r = s twopow = 0 v = pow(2, twopow) while twopow < 33: _next = (all_ones ^ v - 1) & s + v if v > e: break if _next <= e and r & v > 0: r ^= v ...
ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR NUMBER VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP V...
Consider two non-negative long integers, $a$ and $\boldsymbol{b}$, where $a\leq b$. The bitwise AND of all long integers in the inclusive range between $a$ and $\boldsymbol{b}$ can be expressed as $a\ \text{&}\ (a+1)\ \text{&}\ \ldots\ \text{&}\ (b-1)\ \text{&}\ b$, where $\text{&}$ is the bitwise AND operator. Given...
T = int(input()) for T_i in range(T): p, r = [int(x) for x in input().split()] if len(bin(p)) != len(bin(r)): print(0) continue low = bin(p)[2:] high = bin(r)[2:] ans = 0 for c in range(len(low)): if low[c] == high[c] == "1": ans += 2 ** (len(low) - c - 1) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR IF FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUN...
Consider two non-negative long integers, $a$ and $\boldsymbol{b}$, where $a\leq b$. The bitwise AND of all long integers in the inclusive range between $a$ and $\boldsymbol{b}$ can be expressed as $a\ \text{&}\ (a+1)\ \text{&}\ \ldots\ \text{&}\ (b-1)\ \text{&}\ b$, where $\text{&}$ is the bitwise AND operator. Given...
t = int(input()) for ii in range(t): a, b = input().split() a, b = int(a), int(b) ax = str(bin(a)) bs = str(bin(b)) ca = len(ax) cb = len(bs) if ca == cb: c = ca aa = ax bb = bs elif ca > cb: c = ca aa = ax bb = "0" for i in range(1...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR ASSIGN VAR...
Consider two non-negative long integers, $a$ and $\boldsymbol{b}$, where $a\leq b$. The bitwise AND of all long integers in the inclusive range between $a$ and $\boldsymbol{b}$ can be expressed as $a\ \text{&}\ (a+1)\ \text{&}\ \ldots\ \text{&}\ (b-1)\ \text{&}\ b$, where $\text{&}$ is the bitwise AND operator. Given...
t = int(input()) while t: a, b = [int(i) for i in input().split()] ans = b k = 0 i = a while i < b: ans &= i i += 2**k k += 1 print(ans) t -= 1
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR VAR WHILE VAR VAR VAR VAR VAR BIN_OP NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR VAR VAR NUMBER
Consider two non-negative long integers, $a$ and $\boldsymbol{b}$, where $a\leq b$. The bitwise AND of all long integers in the inclusive range between $a$ and $\boldsymbol{b}$ can be expressed as $a\ \text{&}\ (a+1)\ \text{&}\ \ldots\ \text{&}\ (b-1)\ \text{&}\ b$, where $\text{&}$ is the bitwise AND operator. Given...
t = int(input()) for tt in range(t): a, b = list(map(int, input().split())) a_b = list(bin(a)[2:]) b_b = list(bin(b)[2:]) if len(a_b) > len(b_b): b_b = [0] * (len(a_b) - len(b_b)) + b_b else: a_b = [0] * (len(b_b) - len(a_b)) + a_b res = [] for i, (bit_a, bit_b) in enumerate(...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP BIN_OP LIST NUMBER BIN_OP F...
Consider two non-negative long integers, $a$ and $\boldsymbol{b}$, where $a\leq b$. The bitwise AND of all long integers in the inclusive range between $a$ and $\boldsymbol{b}$ can be expressed as $a\ \text{&}\ (a+1)\ \text{&}\ \ldots\ \text{&}\ (b-1)\ \text{&}\ b$, where $\text{&}$ is the bitwise AND operator. Given...
t = int(input()) for i in range(t): a, b = input().split(" ") a = int(a) b = int(b) r = 0 for j in range(32): if a == b and a & 1 == 1: r += 1 << j a >>= 1 b >>= 1 print(r)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR
Consider two non-negative long integers, $a$ and $\boldsymbol{b}$, where $a\leq b$. The bitwise AND of all long integers in the inclusive range between $a$ and $\boldsymbol{b}$ can be expressed as $a\ \text{&}\ (a+1)\ \text{&}\ \ldots\ \text{&}\ (b-1)\ \text{&}\ b$, where $\text{&}$ is the bitwise AND operator. Given...
for t in range(int(input())): a, b = [int(x) for x in input().split()] a = bin(a)[2:] b = bin(b)[2:] sol = 0 if len(a) != len(b): print(0) else: i = 0 while a[i] == b[i]: if a[i] == "1": sol += 2 ** (len(a) - i - 1) i += 1 ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR IF VAR VAR STR...
Consider two non-negative long integers, $a$ and $\boldsymbol{b}$, where $a\leq b$. The bitwise AND of all long integers in the inclusive range between $a$ and $\boldsymbol{b}$ can be expressed as $a\ \text{&}\ (a+1)\ \text{&}\ \ldots\ \text{&}\ (b-1)\ \text{&}\ b$, where $\text{&}$ is the bitwise AND operator. Given...
def test_case(): m, n = [int(x) for x in input().split()] k = 0 while True: if n > m: k += 1 else: return m << k m = m >> 1 n = n >> 1 def main(): T = int(input()) while T > 0: print(test_case()) T -= 1 main()
FUNC_DEF ASSIGN VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER WHILE NUMBER IF VAR VAR VAR NUMBER RETURN BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER EXPR FUN...
Consider two non-negative long integers, $a$ and $\boldsymbol{b}$, where $a\leq b$. The bitwise AND of all long integers in the inclusive range between $a$ and $\boldsymbol{b}$ can be expressed as $a\ \text{&}\ (a+1)\ \text{&}\ \ldots\ \text{&}\ (b-1)\ \text{&}\ b$, where $\text{&}$ is the bitwise AND operator. Given...
def function(start, end): blbs = bin(int(start))[2:] blbe = bin(int(end))[2:] if len(blbs) - len(blbe) == 0: k = 0 while int(start) >> k != int(end) >> k: k += 1 shift = int(start) >> k result = shift << k return result else: return 0 cases =...
FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR...
Nasir and two of his henchmen are planning to attack N shops of the Qureshi clan. The shops are conveniently lined up, and numbered from 1 to N. The i-th shop contains A_{i} kg of coal. For a given subarray of shops [A_{L}, A_{L+1}, \dots, A_{R}], the *bitwise and* of this subarray is defined to be the [bitwise AND] o...
for i in range(int(input())): n = int(input()) li = list(map(int, input().split())) print(li[0] & li[1], end=" ") for i in range(1, len(li) - 1): print(max(li[i] & li[i + 1], li[i] & li[i - 1]), end=" ") print(li[n - 1] & li[n - 2])
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER STRING FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR ...
Nasir and two of his henchmen are planning to attack N shops of the Qureshi clan. The shops are conveniently lined up, and numbered from 1 to N. The i-th shop contains A_{i} kg of coal. For a given subarray of shops [A_{L}, A_{L+1}, \dots, A_{R}], the *bitwise and* of this subarray is defined to be the [bitwise AND] o...
def solve(A, N): ans = [0] * N ans[0] = A[0] & A[1] ans[N - 1] = A[N - 1] & A[N - 2] for i in range(1, N - 1): ans[i] = max(A[i] & A[i + 1], A[i] & A[i - 1]) for i in ans: print(i, end=" ") print() T = int(input()) for _ in range(T): N = int(input()) A = list(map(int, i...
FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ...
Nasir and two of his henchmen are planning to attack N shops of the Qureshi clan. The shops are conveniently lined up, and numbered from 1 to N. The i-th shop contains A_{i} kg of coal. For a given subarray of shops [A_{L}, A_{L+1}, \dots, A_{R}], the *bitwise and* of this subarray is defined to be the [bitwise AND] o...
for q in range(int(input())): n = int(input()) li = [int(x) for x in input().split()] for i in range(n): if i == 0: print(li[i] & li[i + 1], end=" ") elif i == n - 1: print(li[i - 1] & li[i], end=" ") else: print(max(li[i] & li[i + 1], li[i - 1] & ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER STRING IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR BIN_OP VAR NUMBE...
Nasir and two of his henchmen are planning to attack N shops of the Qureshi clan. The shops are conveniently lined up, and numbered from 1 to N. The i-th shop contains A_{i} kg of coal. For a given subarray of shops [A_{L}, A_{L+1}, \dots, A_{R}], the *bitwise and* of this subarray is defined to be the [bitwise AND] o...
t = int(input()) for p in range(t): q = int(input()) b = list(map(int, input().split())) n = len(b) for i in range(n): val = 0 if i > 0: val = max(val, b[i] & b[i - 1]) if i < n - 1: val = max(val, b[i] & b[i + 1]) print(val, end=" ") print()
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR NUM...
Nasir and two of his henchmen are planning to attack N shops of the Qureshi clan. The shops are conveniently lined up, and numbered from 1 to N. The i-th shop contains A_{i} kg of coal. For a given subarray of shops [A_{L}, A_{L+1}, \dots, A_{R}], the *bitwise and* of this subarray is defined to be the [bitwise AND] o...
import sys def solve(n, values): for i in range(n): val = 0 if i > 0: val = max(val, values[i] & values[i - 1]) if i < n - 1: val = max(val, values[i] & values[i + 1]) print(val, end=" ") print() def main(): test_case = int(sys.stdin.readline()) ...
IMPORT FUNC_DEF FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR STRING EXPR FUNC_CALL VAR FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_C...
Nasir and two of his henchmen are planning to attack N shops of the Qureshi clan. The shops are conveniently lined up, and numbered from 1 to N. The i-th shop contains A_{i} kg of coal. For a given subarray of shops [A_{L}, A_{L+1}, \dots, A_{R}], the *bitwise and* of this subarray is defined to be the [bitwise AND] o...
for _ in range(int(input())): l = int(input()) arr = list(map(int, input().strip().split())) for i in range(len(arr)): ans1, ans2 = 0, 0 if i - 1 >= 0: ans1 = arr[i] & arr[i - 1] if i + 1 < len(arr): ans2 = arr[i] & arr[i + 1] print(max(ans1, ans2), en...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR ASSIGN VAR VAR NUMBER NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER IF BIN_OP...
Nasir and two of his henchmen are planning to attack N shops of the Qureshi clan. The shops are conveniently lined up, and numbered from 1 to N. The i-th shop contains A_{i} kg of coal. For a given subarray of shops [A_{L}, A_{L+1}, \dots, A_{R}], the *bitwise and* of this subarray is defined to be the [bitwise AND] o...
try: for _ in range(int(input())): n = int(input()) a = list(map(int, input().split())) res = [] res = [a[0] & a[1]] for i in range(1, n - 1, 1): ans = max(a[i] & a[i - 1], a[i] & a[i + 1]) res.append(ans) res.append(a[-1] & a[-2]) prin...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR LIST BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_O...
Nasir and two of his henchmen are planning to attack N shops of the Qureshi clan. The shops are conveniently lined up, and numbered from 1 to N. The i-th shop contains A_{i} kg of coal. For a given subarray of shops [A_{L}, A_{L+1}, \dots, A_{R}], the *bitwise and* of this subarray is defined to be the [bitwise AND] o...
t = int(input()) for _ in range(t): n = int(input()) lst = list(map(int, input().split())) for i in range(0, n): if i == 0: print(lst[i] & lst[i + 1], end=" ") continue elif i == n - 1: print(lst[i] & lst[i - 1]) continue print(max(lst[...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER STRING IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL...
Nasir and two of his henchmen are planning to attack N shops of the Qureshi clan. The shops are conveniently lined up, and numbered from 1 to N. The i-th shop contains A_{i} kg of coal. For a given subarray of shops [A_{L}, A_{L+1}, \dots, A_{R}], the *bitwise and* of this subarray is defined to be the [bitwise AND] o...
try: times = int(input()) for i in range(times): x = int(input()) arr = list(map(int, input().split(" "))) maximum = 1 n = len(arr) print(arr[0] & arr[1], end=" ") for i in range(1, n - 1): maxi = max(arr[i] & arr[i - 1], arr[i] & arr[i + 1]) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER STRING FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR ...
Nasir and two of his henchmen are planning to attack N shops of the Qureshi clan. The shops are conveniently lined up, and numbered from 1 to N. The i-th shop contains A_{i} kg of coal. For a given subarray of shops [A_{L}, A_{L+1}, \dots, A_{R}], the *bitwise and* of this subarray is defined to be the [bitwise AND] o...
def func(arr, N): ans = [(0) for i in range(N)] ans[0] = arr[0] & arr[1] for i in range(1, N - 1): ans[i] = max(arr[i] & arr[i + 1], arr[i] & arr[i - 1]) ans[-1] = arr[N - 1] & arr[N - 2] return ans T = int(input()) for i in range(T): N = int(input()) arr = list(map(int, input().sp...
FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER RETUR...
Nasir and two of his henchmen are planning to attack N shops of the Qureshi clan. The shops are conveniently lined up, and numbered from 1 to N. The i-th shop contains A_{i} kg of coal. For a given subarray of shops [A_{L}, A_{L+1}, \dots, A_{R}], the *bitwise and* of this subarray is defined to be the [bitwise AND] o...
n = int(input()) for i in range(n): k = int(input()) l = list(map(int, input().strip().split(" "))) if k == 2: print(l[0] & l[1]) continue print(l[0] & l[1], end=" ") for i in range(1, len(l) - 1): print(max(l[i] & l[i - 1], l[i] & l[i + 1]), end=" ") print(l[len(l) - 1] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER STRING FOR VAR FUNC_CA...
Nasir and two of his henchmen are planning to attack N shops of the Qureshi clan. The shops are conveniently lined up, and numbered from 1 to N. The i-th shop contains A_{i} kg of coal. For a given subarray of shops [A_{L}, A_{L+1}, \dots, A_{R}], the *bitwise and* of this subarray is defined to be the [bitwise AND] o...
t = int(input()) for p in range(t): q = int(input()) b = list(map(int, input().split())) b.insert(0, 0) b.append(0) n = len(b) a = b[1] & b[2] for i in range(1, len(b) - 1): d = a a = b[i] & b[i + 1] if d > a: print(d, end=" ") else: pr...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR...
Nasir and two of his henchmen are planning to attack N shops of the Qureshi clan. The shops are conveniently lined up, and numbered from 1 to N. The i-th shop contains A_{i} kg of coal. For a given subarray of shops [A_{L}, A_{L+1}, \dots, A_{R}], the *bitwise and* of this subarray is defined to be the [bitwise AND] o...
t = int(input()) for i in range(t): n = int(input()) a = input().split(" ") b = [] x = int(a[0]) & int(a[1]) y = int(a[n - 2]) & int(a[n - 1]) b.insert(0, x) b.insert(n - 1, y) for j in range(1, n - 1): c = int(a[j - 1]) & int(a[j]) d = int(a[j]) & int(a[j + 1]) e...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER ASSIGN VAR BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER ...
Nasir and two of his henchmen are planning to attack N shops of the Qureshi clan. The shops are conveniently lined up, and numbered from 1 to N. The i-th shop contains A_{i} kg of coal. For a given subarray of shops [A_{L}, A_{L+1}, \dots, A_{R}], the *bitwise and* of this subarray is defined to be the [bitwise AND] o...
t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, input().split())) ans = [a[0] & a[1]] for i in range(1, n - 1): ans.append(max(a[i] & a[i - 1], a[i] & a[i + 1])) ans.append(a[-1] & a[-2]) for i in ans: print(i, end=" ") print()
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_O...
Nasir and two of his henchmen are planning to attack N shops of the Qureshi clan. The shops are conveniently lined up, and numbered from 1 to N. The i-th shop contains A_{i} kg of coal. For a given subarray of shops [A_{L}, A_{L+1}, \dots, A_{R}], the *bitwise and* of this subarray is defined to be the [bitwise AND] o...
try: t = int(input()) while t != 0: n = int(input()) arr = [int(i) for i in input().split()] s = [] s.append(arr[0] & arr[1]) for i in range(1, len(arr) - 1): s.append(max(arr[i] & arr[i - 1], arr[i] & arr[i + 1])) s.append(arr[-1] & arr[-2]) p...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR...
Nasir and two of his henchmen are planning to attack N shops of the Qureshi clan. The shops are conveniently lined up, and numbered from 1 to N. The i-th shop contains A_{i} kg of coal. For a given subarray of shops [A_{L}, A_{L+1}, \dots, A_{R}], the *bitwise and* of this subarray is defined to be the [bitwise AND] o...
T = int(input()) for m in range(T): n = [int(X) for X in input().split()] arr = [int(X) for X in input().split()] left = 0 right = 0 for i in range(n[0]): if i - 1 >= 0: left = arr[i] & arr[i - 1] if i + 1 < n[0]: right = arr[i] & arr[i + 1] print(max(...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR NUM...
Nasir and two of his henchmen are planning to attack N shops of the Qureshi clan. The shops are conveniently lined up, and numbered from 1 to N. The i-th shop contains A_{i} kg of coal. For a given subarray of shops [A_{L}, A_{L+1}, \dots, A_{R}], the *bitwise and* of this subarray is defined to be the [bitwise AND] o...
for _ in range(int(input())): n = int(input()) arr = list(map(int, input().split())) ans = [] for i in range(n): l = 0 g = 0 if i > 0: l = arr[i] & arr[i - 1] if i < n - 1: g = arr[i] & arr[i + 1] ans.append(max(l, g)) print(*ans)
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER...
Nasir and two of his henchmen are planning to attack N shops of the Qureshi clan. The shops are conveniently lined up, and numbered from 1 to N. The i-th shop contains A_{i} kg of coal. For a given subarray of shops [A_{L}, A_{L+1}, \dots, A_{R}], the *bitwise and* of this subarray is defined to be the [bitwise AND] o...
def DhuaDhua(c, n): if n == 0: return c[0] & c[1] elif n == len(c) - 1: return c[n] & c[n - 1] else: return max(c[n] & c[n - 1], c[n] & c[n + 1]) for _ in range(int(input())): n = int(input()) c = list(map(int, input().split())) ans = [] for i in range(n): a...
FUNC_DEF IF VAR NUMBER RETURN BIN_OP VAR NUMBER VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER RETURN BIN_OP VAR VAR VAR BIN_OP VAR NUMBER RETURN FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CAL...
Nasir and two of his henchmen are planning to attack N shops of the Qureshi clan. The shops are conveniently lined up, and numbered from 1 to N. The i-th shop contains A_{i} kg of coal. For a given subarray of shops [A_{L}, A_{L+1}, \dots, A_{R}], the *bitwise and* of this subarray is defined to be the [bitwise AND] o...
t = int(input()) for _ in range(0, t): n = int(input()) l = list(map(int, input().split())) ans = [] for i in range(0, n): if i == 0: ans.append(l[i] & l[i + 1]) elif i == n - 1: ans.append(l[i] & l[i - 1]) else: p = 0 p = max(l[i] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBE...
Nasir and two of his henchmen are planning to attack N shops of the Qureshi clan. The shops are conveniently lined up, and numbered from 1 to N. The i-th shop contains A_{i} kg of coal. For a given subarray of shops [A_{L}, A_{L+1}, \dots, A_{R}], the *bitwise and* of this subarray is defined to be the [bitwise AND] o...
for _ in range(int(input())): n = int(input()) A = [int(i) for i in input().strip().split(" ")] ans = [] for i in range(n): if i == 0: ans.append(A[i] & A[i + 1]) elif i == n - 1: ans.append(A[i] & A[i - 1]) else: ans.append(max(A[i] & A[i + 1]...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER IF VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR B...
Nasir and two of his henchmen are planning to attack N shops of the Qureshi clan. The shops are conveniently lined up, and numbered from 1 to N. The i-th shop contains A_{i} kg of coal. For a given subarray of shops [A_{L}, A_{L+1}, \dots, A_{R}], the *bitwise and* of this subarray is defined to be the [bitwise AND] o...
t = int(input()) for i in range(t): n = int(input()) l = list(map(int, list(input().split()))) b = len(l) for i in range(b): if i == 0: print(l[i] & l[i + 1], end=" ") elif i != b - 1: v = l[i] & l[i + 1] k = l[i] & l[i - 1] if v > k: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER STRING IF ...
Nasir and two of his henchmen are planning to attack N shops of the Qureshi clan. The shops are conveniently lined up, and numbered from 1 to N. The i-th shop contains A_{i} kg of coal. For a given subarray of shops [A_{L}, A_{L+1}, \dots, A_{R}], the *bitwise and* of this subarray is defined to be the [bitwise AND] o...
for _ in range(int(input())): n = int(input()) arr = list(map(int, input().split())) arr.insert(0, 0) arr.append(0) for i in range(1, n + 1): print(max(arr[i] & arr[i - 1], arr[i] & arr[i + 1]), end=" ") print()
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP...
Nasir and two of his henchmen are planning to attack N shops of the Qureshi clan. The shops are conveniently lined up, and numbered from 1 to N. The i-th shop contains A_{i} kg of coal. For a given subarray of shops [A_{L}, A_{L+1}, \dots, A_{R}], the *bitwise and* of this subarray is defined to be the [bitwise AND] o...
for _ in range(int(input())): _, l, res, ps = int(input()), [int(x) for x in input().split()], [], 0 for x in range(_ - 1): sol, ps = res.append(max(ps, l[x] & l[x + 1])), l[x] & l[x + 1] print(*(res + [l[x] & l[x + 1]]))
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR LIST NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ...
Nasir and two of his henchmen are planning to attack N shops of the Qureshi clan. The shops are conveniently lined up, and numbered from 1 to N. The i-th shop contains A_{i} kg of coal. For a given subarray of shops [A_{L}, A_{L+1}, \dots, A_{R}], the *bitwise and* of this subarray is defined to be the [bitwise AND] o...
t = int(input()) for _ in range(t): n = int(input()) arr = list(map(int, input().split())) ans = [0] * n ans[0] = arr[0] & arr[1] ans[n - 1] = arr[n - 1] & arr[n - 2] for i in range(1, n - 1): ans[i] = max(arr[i] & arr[i + 1], arr[i] & arr[i - 1]) print(*ans)
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP...
Nasir and two of his henchmen are planning to attack N shops of the Qureshi clan. The shops are conveniently lined up, and numbered from 1 to N. The i-th shop contains A_{i} kg of coal. For a given subarray of shops [A_{L}, A_{L+1}, \dots, A_{R}], the *bitwise and* of this subarray is defined to be the [bitwise AND] o...
for _ in range(int(input())): N = int(input()) A = list(map(int, input().split())) arr = [0] * N for i in range(N - 1): v = A[i] & A[i + 1] v1 = v vi = i + 1 for j in range(i, N): v1 = arr[j] & v1 arr[j] = max(arr[j], v1) if v1 > v: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP LIST NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBE...
Nasir and two of his henchmen are planning to attack N shops of the Qureshi clan. The shops are conveniently lined up, and numbered from 1 to N. The i-th shop contains A_{i} kg of coal. For a given subarray of shops [A_{L}, A_{L+1}, \dots, A_{R}], the *bitwise and* of this subarray is defined to be the [bitwise AND] o...
case = int(input()) for r in range(case): n = int(input()) arr = [int(x) for x in input().split()] for i in range(n): res = 1 if i == 0: res = arr[0] & arr[1] print(res, end=" ") continue elif i == n - 1: res = arr[n - 1] & arr[n - 2] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR STRING IF VAR BIN_OP VAR NUMBER ASSIGN...
Nasir and two of his henchmen are planning to attack N shops of the Qureshi clan. The shops are conveniently lined up, and numbered from 1 to N. The i-th shop contains A_{i} kg of coal. For a given subarray of shops [A_{L}, A_{L+1}, \dots, A_{R}], the *bitwise and* of this subarray is defined to be the [bitwise AND] o...
for _ in range(int(input())): n = int(input()) lst = list(map(int, input().split())) ans = list() nm = 0 for i in range(n): if i == 0: nm = lst[0] & lst[1] elif i == n - 1: nm = lst[i] & lst[i - 1] else: nm = max(lst[i] & lst[i - 1], lst[i]...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_O...
Nasir and two of his henchmen are planning to attack N shops of the Qureshi clan. The shops are conveniently lined up, and numbered from 1 to N. The i-th shop contains A_{i} kg of coal. For a given subarray of shops [A_{L}, A_{L+1}, \dots, A_{R}], the *bitwise and* of this subarray is defined to be the [bitwise AND] o...
t = int(input()) for i in range(t): n = int(input()) c = [] a = list(map(int, input().split())) c.append(a[0] & a[1]) for i in range(1, n - 1): b = a[i] & a[i + 1] e = a[i] & a[i - 1] c.append(max(b, e)) c.append(a[n - 1] & a[n - 2]) print(*c, sep=" ")
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR BIN_OP V...
Nasir and two of his henchmen are planning to attack N shops of the Qureshi clan. The shops are conveniently lined up, and numbered from 1 to N. The i-th shop contains A_{i} kg of coal. For a given subarray of shops [A_{L}, A_{L+1}, \dots, A_{R}], the *bitwise and* of this subarray is defined to be the [bitwise AND] o...
t = int(input()) for _ in range(t): input() xs = [int(w) for w in input().strip().split(" ")] ans = [] for i, x in enumerate(xs): if i == 0: ans.append(x & xs[1]) elif i == len(xs) - 1: ans.append(x & xs[i - 1]) else: ans.append(max(x & xs[i - ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN...
Nasir and two of his henchmen are planning to attack N shops of the Qureshi clan. The shops are conveniently lined up, and numbered from 1 to N. The i-th shop contains A_{i} kg of coal. For a given subarray of shops [A_{L}, A_{L+1}, \dots, A_{R}], the *bitwise and* of this subarray is defined to be the [bitwise AND] o...
def ans(arr): new_arr = [] i = 0 while i < len(arr): if i == 0: new_arr.append(arr[i] & arr[i + 1]) elif i == len(arr) - 1: new_arr.append(arr[i] & arr[i - 1]) else: new_arr.append(max(arr[i] & arr[i - 1], arr[i] & arr[i + 1])) i += 1 r...
FUNC_DEF ASSIGN VAR LIST ASSIGN VAR NUMBER WHILE VAR FUNC_CALL VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER IF VAR BIN_OP FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR VAR...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
for _ in range(int(input())): a = [int(x) for x in input().split()] a.sort() b = [] for i in a: if i: b.append(i) ans = len(b) if len(b) == 2: if b[0] > 1: ans += 1 elif len(b) == 3: if b[0] > 1 and b[2] > 1: b[0] -= 1 b...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR IF VAR EXPR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER IF VAR NUMBER NUMBER VAR NUMBER IF FUNC_CALL VAR VAR NUMBER IF VAR NUMBER NUMBE...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
def count_colors(colors): zeros, ones, twos = colors.count(0), colors.count(1), colors.count(2) primary_color = 3 - zeros if zeros + ones > 1: secondary_color = 0 elif zeros + ones == 1: secondary_color = 1 elif twos == 1 or twos == 2: secondary_color = 2 elif twos == 3: ...
FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR NUMBER FUNC_CALL VAR NUMBER ASSIGN VAR BIN_OP NUMBER VAR IF BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER IF BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER RETURN BIN_OP VAR VAR...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
def find_max(r, g, b): sorted_array = [r, g, b] sorted_array.sort(reverse=True) max_colours = 0 for position in (0, 1): next_po = position + 1 if sorted_array[next_po] > 1 and sorted_array[position] > 1: max_colours += 1 sorted_array[next_po] -= 1 sort...
FUNC_DEF ASSIGN VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER VAR VAR NUMBER VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER IF VAR VAR NUMBER VAR VAR NUMBER VAR NUMBER VAR VAR NUMBER VAR VAR NUMB...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
for _ in range(int(input())): a = list(map(int, input().split())) count = 0 a.sort(reverse=True) for i in range(3): if a[i] > 0: a[i] -= 1 count += 1 for i in range(3): for j in range(i + 1, 3): if a[i] > 0 and a[j] > 0: a[i] -= 1 ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER IF VAR VAR...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
case = int(input()) for _ in range(case): arr = list(map(int, input().split(" "))) count = 0 n = 3 arr.sort() if arr[n - 1] > 1 and arr[n - 2] > 1: count += 1 arr[n - 1] -= 1 arr[n - 2] -= 1 if arr[n - 1] > 1 and arr[n - 3] > 1: count += 1 arr[n - 1] -= 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR IF VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER VAR BIN_OP VAR NUMBER NUM...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
T = int(input()) for i in range(T): a = list(map(int, input().split())) a.sort(reverse=True) ans = 0 if a[0] > 0: ans += 1 if a[1] > 0: ans += 1 if a[2] > 0: ans += 1 if a[0] > 1 and a[1] > 1: ans += 1 a[0] -= 1 a[1] -= 1 if a[0] > 1 and a[...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER NUMBER VAR NUMBER IF VAR NUMBER NUMBER VAR NUMBER IF VAR NUMBER NUMBER VAR NUMBER IF VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBE...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
for _ in range(int(input())): x, y, z = map(int, input().split()) n = 0 if x > 0: n += 1 x -= 1 if y > 0: n += 1 y -= 1 if z > 0: n += 1 z -= 1 x, y, z = sorted([x, y, z], reverse=True) if x > 0 and y > 0: n += 1 x -= 1 ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR LIST VAR VAR VAR NUMBER IF VAR NUMBER VAR NUMBER V...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
test = int(input()) while test > 0: test = test - 1 X, Y, Z = map(int, input().split()) list1 = [X, Y, Z] ans = 0 if list1[0] > 0: ans += 1 list1[0] -= 1 if list1[1] > 0: ans += 1 list1[1] -= 1 if list1[2] > 0: ans += 1 list1[2] -= 1 list1....
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER NUMBER VAR NUMBER VAR NUMBER NUMBER IF VAR NUMBER NUMBER VAR NUMBER VAR NUMBER NUMBER IF VAR NUMBER NUMBER VAR NUM...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
T = int(input()) for _ in range(T): list1 = list(map(int, input().split(" "))) list1.sort(reverse=True) X, Y, Z = list1[0], list1[1], list1[2] x = X - 1 if X > 1 else 0 y = Y - 1 if Y > 1 else 0 z = Z - 1 if Z > 1 else 0 total = min(X, 1) + min(Y, 1) + min(Z, 1) if x and y: total...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VA...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
t = int(input()) for _ in range(t): x, y, z = map(int, input().split()) if x > 2 and y > 2 and z > 2: print(6) elif ( x > 2 and y > 1 and z > 1 or y > 2 and x > 1 and z > 1 or z > 2 and x > 1 and y > 1 ): print(5) ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER IF V...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
for _ in range(int(input())): x, y, z = map(int, input().split()) temp = [x, y, z] res = 0 for col in range(3): if temp[col] >= 1: temp[col] -= 1 res += 1 temp.sort() if temp[0] >= 2: res += 3 elif temp[0] == 1: if temp[2] >= 2: res...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR LIST VAR VAR VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR IF VAR NUMBER NUMBER VAR NUMBER IF VAR NUMBER NUMBER IF VAR NUMBER NUMB...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
t = int(input()) while t: a, b, c = map(int, input().split()) s = 0 l = [] if a > 0: s += 1 a -= 1 if b > 0: s += 1 b -= 1 if c > 0: s += 1 c -= 1 x, p = a, a y, q = b, b z, r = c, c l, m, n = 0, 0, 0 if x > 0 and y > 0: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST IF VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
def check(a, b, output): if a > 0 and b > 0: return a - 1, b - 1, output + 1 return a, b, output n = int(input()) for i in range(n): colors = list(map(int, input().split())) output = len([i for i in colors if i > 0]) r, g, b = sorted([(i - 1) for i in colors], reverse=True) r, g, outpu...
FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER RETURN VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR NUMBER ASSIGN VAR VAR VAR FUNC_CA...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
for _ in range(int(input())): a = sorted(list(map(int, input().split()))) add = 0 for i in a: if i != 0: add += 1 if a[0] >= 3: print(add + 3) elif a[0] == 2: if a[2] >= 3: print(add + 2) else: print(add + 1) elif a[1] <= 1: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR NUMBER IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER NUMBER IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMB...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
t = int(input()) for i in range(t): x, y, z = map(int, input().split()) x, y, z = sorted([x, y, z]) count = 0 if x >= 1: count = count + 1 if y >= 1: count = count + 1 if z >= 1: count = count + 1 if y > 1 and z > 1: count = count + 1 if x > 1 and z > 2: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR LIST VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMB...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
for _ in range(int(input())): li = list(map(int, input().split())) zero = 0 one = 0 two = 0 for i in li: if i == 0: zero += 1 elif i == 1: one += 1 elif i == 2: two += 1 if zero == 3: res = 0 elif zero == 2: res = 1 ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR VAR IF VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR NUMBE...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
for i in range(0, int(input())): l = list(map(int, input().split())) a = 0 for j in range(0, 3): if l[j] > 0: a = a + 1 l[j] = l[j] - 1 else: continue n = 0 x = l[0] y = l[1] z = l[2] x, y, z = sorted([x, y, z], reverse=True) if x >...
FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER NUMBER IF VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUM...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
t = int(input()) for i in range(t): x, y, z = map(int, input().split(" ")) c = 0 if x > 0: c += 1 x -= 1 if y > 0: c += 1 y -= 1 if z > 0: c += 1 z -= 1 if x * y * z == 0 and (x, y, z).count(0) == 1: c += 1 elif (x, y, z).count(0) == 2:...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR STRING ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER IF BIN_OP BIN_OP VAR VAR VAR NUMBER FUNC_CALL VAR VAR VAR NUM...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
n = int(input()) d = [] for i in range(n): l = [int(x) for x in input().split()] ans = 3 - l.count(0) l.sort() if l[0] >= 3: print(6) elif l[0] == 2: if l[2] >= 3: ans = 5 else: ans = 4 print(ans) elif l[1] <= 1: print(ans) else...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR BIN_OP NUMBER FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER NUMBER IF VAR NUMBER NUMBER ASSIGN VAR NUMBER ASSIGN VAR...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
t = int(input()) for _ in range(t): a = list(map(int, input().split())) a.sort() v = 0 for i in range(3): a[i] = min(3, a[i]) v = 16 * a[0] + 4 * a[1] + a[2] if v == 0: ans = 0 elif v <= 3: ans = 1 elif v <= 0 * 16 + 1 * 4 + 3: ans = 2 elif v <= 1 * 16...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR 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 NUMBER ASSIGN VAR VAR FUNC_CALL VAR NUMBER VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER BIN_OP NUMBER VAR NUMBER VAR...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
T = int(input()) for _ in range(T): x = list(map(int, input().split())) x.sort(reverse=True) r = x[0] g = x[1] b = x[2] n = 0 if r > 1 and g > 1: r = r - 1 g = g - 1 n = n + 1 if r > 1 and b > 1: r = r - 1 b = b - 1 n = n + 1 if r > 0: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NU...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
for _ in range(int(input())): A = list(map(int, input().split())) A.sort(reverse=True) X, Y, Z = A colors = 0 if X > 1 and Y > 1: colors += 1 X -= 1 Y -= 1 if Y > 1 and Z > 1: colors += 1 Y -= 1 Z -= 1 if Z > 1 and X > 1: colors += 1 ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NU...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
t = int(input()) for i in range(t): l = list(map(int, input().split())) t = 0 for j in range(len(l)): if l[j] - 1 >= 0: l[j] = l[j] - 1 t += 1 l.sort() if l >= [2, 2, 2]: t += 3 elif l >= [1, 1, 2]: t += 2 elif l >= [0, 1, 1]: t += 1 ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR IF VAR LIST NUMBER NUMBER NUMBE...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
for i in range(int(input())): a = list(map(int, input().split())) r = a[0] g = a[1] b = a[2] if r > 1 and g > 1 and b > 1: if r > 2 and g > 2 and b > 2: print("6") elif r > 2 or g > 2 or b > 2: print("5") else: print("4") elif ( ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR STRING IF VAR NUMBER VAR NUMBER VAR NUMBER EXP...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
for i in range(int(input())): c = list(map(int, input().split())) ans = 0 for i in range(len(c)): if c[i] > 0: ans += 1 c[i] -= 1 c.sort() c.reverse() for j in [(0, 1), (1, 2), (0, 2)]: if c[j[0]] > 0 and c[j[1]] > 0: c[j[0]] -= 1 c...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR FOR VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER IF VAR V...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
def check_positions(sorted_array, first_pos, second_pos): try: if sorted_array[first_pos] > 1 and sorted_array[second_pos] > 1: sorted_array[first_pos] -= 1 sorted_array[second_pos] -= 1 return 1 except IndexError: pass return 0 def find_max(r, g, b): ...
FUNC_DEF IF VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER RETURN NUMBER VAR RETURN NUMBER FUNC_DEF ASSIGN VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR VAR...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
for _ in range(int(input())): a = list(map(int, input().split())) a.sort() if a[2] == 0: print(0) elif a[1] == 0: print(1) elif a[0] == 0: if a[1] >= 2: print(3) else: print(2) else: if a[0] >= 3: print(6) if a[0...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER IF VAR NUMBER NUMBER IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER EXPR FUNC_CALL VAR NUM...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
for i in range(0, int(input())): li = list(map(int, input().strip().split())) li.sort(reverse=True) cnt = 0 for i in range(0, len(li)): if li[i] > 0: li[i] -= 1 cnt += 1 for i in range(0, len(li)): for j in range(i + 1, len(li)): if li[i] > 0 and l...
FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF VAR VAR NUMBER VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR FOR ...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
t = int(input()) while t: colors = list(map(int, input().split())) ans = 0 for i in range(3): if colors[i] != 0: ans += 1 colors[i] -= 1 colors.sort() if colors[0] >= 2: print(ans + 3) t -= 1 continue if colors[0] == 1: if colors[2]...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER VAR NUMBER VAR VAR NUMBER EXPR FUNC_CALL VAR IF VAR NUMBER NUMBER EXPR FUNC_CALL VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR NUMBER NUMBER IF V...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
x = int(input()) g = [] for iir in range(0, x): op = str(input()) kkr = op.split(" ") uure = [] for bbv in kkr: uure.append(int(bbv)) g.append(uure) for nnx in g: if nnx[0] == 0 and nnx[1] == 0 and nnx[2] == 0: print(0) else: nnx.sort(reverse=True) a = nnx[0] ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR LIST FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR VAR IF VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER EXPR...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
for i in range(int(input())): lst = [int(a) for a in input().split()] lst.sort(reverse=True) answer = 0 if lst == [0, 0, 0]: print(0) else: x = 0 for i in range(3): if lst[i - x] == 0: lst.remove(0) x += 1 else: ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER IF VAR LIST NUMBER NUMBER NUMBER EXPR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR BIN_OP VAR VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMB...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
get_int = lambda: int(input()) get_mint = lambda: list(map(int, input().split())) for _ in range(get_int()): X, Y, Z = sorted(get_mint(), reverse=True) color = 0 if X > 0: X -= 1 color += 1 if Y > 0: color += 1 Y -= 1 if Z > 0: color += 1 Z -= 1 if...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBE...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
for _ in range(int(input())): x, y, z = [int(x) for x in input().split()] ans = 0 if x > 0: ans += 1 x -= 1 if y > 0: ans += 1 y -= 1 if z > 0: ans += 1 z -= 1 l1 = [x, y, z] l1.sort() l1.reverse() if l1[0] > 0 and l1[1] > 0: an...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR IF VAR NUMBER...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
reply = [] for _ in range(int(input())): arr = [] for i in input().split(): arr.append(int(i)) arr.sort() arr.reverse() r = arr[0] g = arr[1] b = arr[2] count = 0 if r >= 1: count += 1 r -= 1 if g >= 1: count += 1 g -= 1 if b >= 1: ...
ASSIGN VAR LIST FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMB...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
vojj = int(input()) for vishnesh in range(vojj): r, g, b = map(int, input().split()) c = 0 if r > 0: r = r - 1 c = c + 1 if g > 0: g = g - 1 c = c + 1 if b > 0: b = b - 1 c = c + 1 a = [r, g, b] a.sort() a = a[::-1] r, g, b = a if r...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER ASSIGN VAR BIN_OP ...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
for _ in range(int(input())): x, y, z = map(int, input().split()) ans = 0 for mask in range(8): nx = ny = nz = 0 if mask & 1: nx += 1 ny += 1 if mask & 2: nx += 1 nz += 1 if mask & 4: nz += 1 ny += 1 ...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER IF VAR ...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
for i in range(int(input())): c = list(map(int, input().split())) c = [x for x in c if x != 0] s = len(c) for i in range(len(c)): if c[i] >= 3: c = c[:i] + [3] + c[i + 1 :] c = [(x - 1) for x in c] c = [x for x in c if x != 0] if sum(c) == 6: s += 3 elif sum(c...
FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR VAR VAR VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR LIST NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
n = int(input()) for p in range(0, n): arr = [int(i) for i in input().split()] arr.sort() x = arr[0] y = arr[1] z = arr[2] ans = 0 for i in range(3): if arr[i] >= 1: ans += 1 if x == 2: if z >= 3: print(ans + 2) else: print(ans ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER VAR NUMBER IF VAR NUMBER IF VAR NUMBER EX...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
T = int(input()) for i in range(T): l = [] s = 0 x, y, z = map(int, input().split()) l.append(x) l.append(y) l.append(z) for i in range(3): if l[i] != 0: l[i] -= 1 s += 1 l.sort() if l[0] >= 2: print(s + 3) elif l[0] == 1: if l[2] >...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR VAR ASSIGN VAR LIST ASSIGN VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER IF VAR VAR NUMBER VAR VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
from sys import stdin input = stdin.readline for _ in range(int(input())): b, g, r = sorted(map(int, input().split())) if b == 0: print(3 if g > 1 else 2 if g > 0 else 1 if r > 0 else 0) elif b == 1: print(4 if g > 1 else 3) elif b == 2: print(5 if r > 2 else 4) else: ...
ASSIGN VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER NUMBER VAR NUMBER NUMBER VAR NUMBER NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL VAR VAR NUMBER NUMBER NUMBER IF VAR NUMBER EXPR FUNC_CALL...
For the human eye, primary colours are red, green, and blue. Combining 1 drop each of any two primary colours produces a new type of secondary colour. For example, mixing red and green gives yellow, mixing green and blue gives cyan, and, mixing red and blue gives magenta. You have X, Y, and Z drops of red, green, an...
t = int(input()) while t > 0: r, g, b = map(int, input().split()) res = 0 l = [r, g, b] l.sort() r = l[2] g = l[1] b = l[0] if r > 0: res += 1 r -= 1 if g > 0: res += 1 g -= 1 if b > 0: res += 1 b -= 1 if r > 0 and g > 0: ...
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR WHILE VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER ...
Bob is playing a game named "Walk on Matrix". In this game, player is given an n × m matrix A=(a_{i,j}), i.e. the element in the i-th row in the j-th column is a_{i,j}. Initially, player is located at position (1,1) with score a_{1,1}. To reach the goal, position (n,m), player can move right or down, i.e. move from ...
k = int(input()) y = 1 while y <= k: y <<= 1 X = k + y m = [[X, y, y], [k, y, y], [k, X, k]] print(3, 3) for arr in m: print(" ".join([str(x) for x in arr]))
ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR ASSIGN VAR NUMBER WHILE VAR VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR LIST LIST VAR VAR VAR LIST VAR VAR VAR LIST VAR VAR VAR EXPR FUNC_CALL VAR NUMBER NUMBER FOR VAR VAR EXPR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR VAR